Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix: unify cross-platform path contracts
sunsunsunb0b62c0ec5ec
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex a138b321..78c776a7 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -192,15 +192,87 @@ jobs:- name: Install test dependenciesrun: npm ci --ignore-scriptsworking-directory: archify- - name: Verify Windows-sensitive regression fixtures- run: >-- node --test- --test-name-pattern="Git checkout preserves|clean staging preserves index modes|workflow migration cleanup failure|preview runs from an installed skill|canonical watch target|Windows 8.3 short path"- archify/test/checkout-line-endings.test.mjs- archify/test/clean-skill-staging.test.mjs- archify/test/workflow-migration.test.mjs- archify/test/cli.test.mjs- archify/test/preview.test.mjs+ - name: Provision controlled Windows path fixtures+ shell: pwsh+ run: |+ $ErrorActionPreference = 'Stop'+ $shareName = "archify-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT-node${{ matrix.node-version }}"+ $fixtureRoot = Join-Path $env:RUNNER_TEMP $shareName+ $shareRoot = Join-Path $fixtureRoot 'share'+ $caseRoot = Join-Path $fixtureRoot 'case-sensitive'+ $eightDotThreeRoot = Join-Path $fixtureRoot 'controlled-eight-dot-three-root'+ $eightDotThreeShortRoot = Join-Path $fixtureRoot 'ARCH8D~1'+ Get-SmbShare -Name $shareName -ErrorAction SilentlyContinue |+ Remove-SmbShare -Force -Confirm:$false -ErrorAction SilentlyContinue+ if (Test-Path -LiteralPath $fixtureRoot) {+ Remove-Item -LiteralPath $fixtureRoot -Recurse -Force+ }+ New-Item -ItemType Directory -Path $shareRoot, $caseRoot, $eightDotThreeRoot | Out-Null++ & fsutil.exe file setshortname $eightDotThreeRoot 'ARCH8D~1'+ if ($LASTEXITCODE -ne 0) {+ throw "Could not assign the controlled 8.3 alias at $eightDotThreeRoot"+ }+ $eightDotThreeProbe = Join-Path $eightDotThreeRoot 'short-name-probe.txt'+ $eightDotThreeAliasProbe = Join-Path $eightDotThreeShortRoot 'short-name-probe.txt'+ [IO.File]::WriteAllText($eightDotThreeProbe, 'controlled-8dot3')+ if (-not [IO.Directory]::Exists($eightDotThreeShortRoot) -or+ [IO.File]::ReadAllText($eightDotThreeAliasProbe) -ne 'controlled-8dot3') {+ throw 'The explicit 8.3 alias did not resolve to the controlled NTFS directory.'+ }+ [IO.File]::Delete($eightDotThreeProbe)++ & fsutil.exe file setCaseSensitiveInfo $caseRoot enable+ if ($LASTEXITCODE -ne 0) {+ throw "Could not enable per-directory case sensitivity at $caseRoot"+ }+ $upperProbe = Join-Path $caseRoot 'ArchifyCaseProbe.txt'+ $lowerProbe = Join-Path $caseRoot 'archifycaseprobe.txt'+ [IO.File]::WriteAllText($upperProbe, 'upper')+ [IO.File]::WriteAllText($lowerProbe, 'lower')+ if ([IO.File]::ReadAllText($upperProbe) -ne 'upper' -or+ [IO.File]::ReadAllText($lowerProbe) -ne 'lower') {+ throw 'The controlled NTFS directory did not preserve case-distinct files.'+ }+ [IO.File]::Delete($upperProbe)+ [IO.File]::Delete($lowerProbe)++ $identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name+ New-SmbShare -Name $shareName -Path $shareRoot -Temporary -ChangeAccess $identity | Out-Null+ $uncRoot = "\\localhost\$shareName"+ $extendedUncRoot = "\\?\UNC\localhost\$shareName"+ $uncProbe = [IO.Path]::Combine($uncRoot, 'ordinary-unc-probe.txt')+ $extendedProbe = [IO.Path]::Combine($extendedUncRoot, 'extended-unc-probe.txt')+ [IO.File]::WriteAllText($uncProbe, 'ordinary')+ [IO.File]::WriteAllText($extendedProbe, 'extended')+ if ([IO.File]::ReadAllText($uncProbe) -ne 'ordinary' -or+ [IO.File]::ReadAllText($extendedProbe) -ne 'extended') {+ throw 'The controlled SMB share did not support ordinary and extended UNC access.'+ }+ [IO.File]::Delete($uncProbe)+ [IO.File]::Delete($extendedProbe)++ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_CASE_SENSITIVE_ROOT=$caseRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_UNC_ROOT=$uncRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_EXTENDED_UNC_ROOT=$extendedUncRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_8DOT3_ROOT=$eightDotThreeRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT=$eightDotThreeShortRoot"+ - name: Verify maintained Windows path contracts+ run: node scripts/run-windows-path-tests.mjs+ env:+ ARCHIFY_REQUIRE_WINDOWS_8DOT3: ${{ matrix.node-version == 22 && '1' || '0' }}+ ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS: '1'+ - name: Clean up controlled Windows path fixtures+ if: ${{ always() }}+ shell: pwsh+ run: |+ $shareName = "archify-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT-node${{ matrix.node-version }}"+ Get-SmbShare -Name $shareName -ErrorAction SilentlyContinue |+ Remove-SmbShare -Force -Confirm:$false -ErrorAction SilentlyContinue+ $fixtureRoot = Join-Path $env:RUNNER_TEMP $shareName+ if (Test-Path -LiteralPath $fixtureRoot) {+ Remove-Item -LiteralPath $fixtureRoot -Recurse -Force+ }deploy-pages:if: github.event_name == 'push' && github.ref == 'refs/heads/main'diff --git a/.github/workflows/dsh.yml b/.github/workflows/dsh.ymlindex bbd12d03..e0b53fe6 100644--- a/.github/workflows/dsh.yml+++ b/.github/workflows/dsh.yml@@ -5,6 +5,9 @@ on:paths:- 'integrations/deepseek-harness/**'- '.github/workflows/dsh.yml'+ - 'archify/renderers/shared/atomic-output.mjs'+ - 'archify/renderers/shared/path-semantics.mjs'+ - 'archify/renderers/shared/portable-path.mjs'- 'scripts/stage-clean-skill.mjs'- 'scripts/third-party-notices-contract.mjs'push:@@ -12,6 +15,9 @@ on:paths:- 'integrations/deepseek-harness/**'- '.github/workflows/dsh.yml'+ - 'archify/renderers/shared/atomic-output.mjs'+ - 'archify/renderers/shared/path-semantics.mjs'+ - 'archify/renderers/shared/portable-path.mjs'- 'scripts/stage-clean-skill.mjs'- 'scripts/third-party-notices-contract.mjs'tags:diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 377d2c9f..1fed2b5b 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -8,7 +8,105 @@ permissions:contents: writejobs:+ windows-test-portability:+ name: Windows path contracts (Node ${{ matrix.node-version }})+ strategy:+ fail-fast: false+ matrix:+ node-version: [22, 24]+ runs-on: windows-latest+ steps:+ - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0+ - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0+ with:+ node-version: ${{ matrix.node-version }}+ - name: Install test dependencies+ run: npm ci --ignore-scripts+ working-directory: archify+ - name: Provision controlled Windows path fixtures+ shell: pwsh+ run: |+ $ErrorActionPreference = 'Stop'+ $shareName = "archify-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT-node${{ matrix.node-version }}"+ $fixtureRoot = Join-Path $env:RUNNER_TEMP $shareName+ $shareRoot = Join-Path $fixtureRoot 'share'+ $caseRoot = Join-Path $fixtureRoot 'case-sensitive'+ $eightDotThreeRoot = Join-Path $fixtureRoot 'controlled-eight-dot-three-root'+ $eightDotThreeShortRoot = Join-Path $fixtureRoot 'ARCH8D~1'+ Get-SmbShare -Name $shareName -ErrorAction SilentlyContinue |+ Remove-SmbShare -Force -Confirm:$false -ErrorAction SilentlyContinue+ if (Test-Path -LiteralPath $fixtureRoot) {+ Remove-Item -LiteralPath $fixtureRoot -Recurse -Force+ }+ New-Item -ItemType Directory -Path $shareRoot, $caseRoot, $eightDotThreeRoot | Out-Null++ & fsutil.exe file setshortname $eightDotThreeRoot 'ARCH8D~1'+ if ($LASTEXITCODE -ne 0) {+ throw "Could not assign the controlled 8.3 alias at $eightDotThreeRoot"+ }+ $eightDotThreeProbe = Join-Path $eightDotThreeRoot 'short-name-probe.txt'+ $eightDotThreeAliasProbe = Join-Path $eightDotThreeShortRoot 'short-name-probe.txt'+ [IO.File]::WriteAllText($eightDotThreeProbe, 'controlled-8dot3')+ if (-not [IO.Directory]::Exists($eightDotThreeShortRoot) -or+ [IO.File]::ReadAllText($eightDotThreeAliasProbe) -ne 'controlled-8dot3') {+ throw 'The explicit 8.3 alias did not resolve to the controlled NTFS directory.'+ }+ [IO.File]::Delete($eightDotThreeProbe)++ & fsutil.exe file setCaseSensitiveInfo $caseRoot enable+ if ($LASTEXITCODE -ne 0) {+ throw "Could not enable per-directory case sensitivity at $caseRoot"+ }+ $upperProbe = Join-Path $caseRoot 'ArchifyCaseProbe.txt'+ $lowerProbe = Join-Path $caseRoot 'archifycaseprobe.txt'+ [IO.File]::WriteAllText($upperProbe, 'upper')+ [IO.File]::WriteAllText($lowerProbe, 'lower')+ if ([IO.File]::ReadAllText($upperProbe) -ne 'upper' -or+ [IO.File]::ReadAllText($lowerProbe) -ne 'lower') {+ throw 'The controlled NTFS directory did not preserve case-distinct files.'+ }+ [IO.File]::Delete($upperProbe)+ [IO.File]::Delete($lowerProbe)++ $identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name+ New-SmbShare -Name $shareName -Path $shareRoot -Temporary -ChangeAccess $identity | Out-Null+ $uncRoot = "\\localhost\$shareName"+ $extendedUncRoot = "\\?\UNC\localhost\$shareName"+ $uncProbe = [IO.Path]::Combine($uncRoot, 'ordinary-unc-probe.txt')+ $extendedProbe = [IO.Path]::Combine($extendedUncRoot, 'extended-unc-probe.txt')+ [IO.File]::WriteAllText($uncProbe, 'ordinary')+ [IO.File]::WriteAllText($extendedProbe, 'extended')+ if ([IO.File]::ReadAllText($uncProbe) -ne 'ordinary' -or+ [IO.File]::ReadAllText($extendedProbe) -ne 'extended') {+ throw 'The controlled SMB share did not support ordinary and extended UNC access.'+ }+ [IO.File]::Delete($uncProbe)+ [IO.File]::Delete($extendedProbe)++ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_CASE_SENSITIVE_ROOT=$caseRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_UNC_ROOT=$uncRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_EXTENDED_UNC_ROOT=$extendedUncRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_8DOT3_ROOT=$eightDotThreeRoot"+ Add-Content -LiteralPath $env:GITHUB_ENV -Value "ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT=$eightDotThreeShortRoot"+ - name: Verify maintained Windows path contracts+ run: node scripts/run-windows-path-tests.mjs+ env:+ ARCHIFY_REQUIRE_WINDOWS_8DOT3: ${{ matrix.node-version == 22 && '1' || '0' }}+ ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS: '1'+ - name: Clean up controlled Windows path fixtures+ if: ${{ always() }}+ shell: pwsh+ run: |+ $shareName = "archify-$env:GITHUB_RUN_ID-$env:GITHUB_RUN_ATTEMPT-node${{ matrix.node-version }}"+ Get-SmbShare -Name $shareName -ErrorAction SilentlyContinue |+ Remove-SmbShare -Force -Confirm:$false -ErrorAction SilentlyContinue+ $fixtureRoot = Join-Path $env:RUNNER_TEMP $shareName+ if (Test-Path -LiteralPath $fixtureRoot) {+ Remove-Item -LiteralPath $fixtureRoot -Recurse -Force+ }+release:+ needs: windows-test-portabilityruns-on: ubuntu-lateststeps:- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0diff --git a/archify.zip b/archify.zipindex 585b79a8..e1c2e97e 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/bin/archify.mjs b/archify/bin/archify.mjsindex 78451fe0..ce484b26 100755--- a/archify/bin/archify.mjs+++ b/archify/bin/archify.mjs@@ -11,18 +11,211 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));const skillRoot = path.resolve(__dirname, '..');const TYPES = new Set(['architecture', 'workflow', 'sequence', 'dataflow', 'lifecycle']);+const DELIVERY_SIDECAR_SUFFIXES = Object.freeze([+ '.delivery.json',+ '.delivery-pending.json',+ '.delivery-lock.json',+]);+const COMPARE_SIDECAR_SUFFIXES = Object.freeze(['.receipt.json']);+const DELIVERY_DIRECTORY_LOCK = '.archify-delivery-lock.json';+const SIDECAR_STEM_NAMESPACE = /\.~archify-[0-9a-f]{64}$/iu;+let sidecarNamespaceComponentKeyRuntime;++function sidecarStemNeedsBounding(stem, suffixes) {+ const fits = (value) => value.length <= 255 && Buffer.byteLength(value, 'utf8') <= 255;+ return !suffixes.every((suffix) => fits(`${stem}${suffix}`));+}++function boundedSidecarStem(stem, suffixes, { force = false, hashDomain } = {}) {+ if (!force && !sidecarStemNeedsBounding(stem, suffixes)+ && !SIDECAR_STEM_NAMESPACE.test(stem)) return stem;+ const hashInput = hashDomain ? `${hashDomain}\0${stem}` : stem;+ const marker = `.~archify-${createHash('sha256').update(hashInput).digest('hex')}`;+ const codePoints = [...stem];+ while (codePoints.length && sidecarStemNeedsBounding(`${codePoints.join('')}${marker}`, suffixes)) {+ codePoints.pop();+ }+ return `${codePoints.join('')}${marker}`;+}++function sidecarStemFromComponent(component) {+ if (component.endsWith('.html')) {+ return {+ stem: component.slice(0, -'.html'.length),+ options: undefined,+ };+ }+ return {+ stem: component,+ options: { force: true, hashDomain: 'full-component' },+ };+}++function deliverySidecarNamespace(artifactPath) {+ let artifact = path.resolve(artifactPath);+ try {+ artifact = fs.realpathSync.native(artifact);+ } catch (error) {+ if (error?.code !== 'ENOENT' && error?.code !== 'ENOTDIR') throw error;+ }+ if (typeof sidecarNamespaceComponentKeyRuntime !== 'function') {+ throw new Error('The sidecar namespace runtime is unavailable.');+ }+ const namespace = sidecarNamespaceComponentKeyRuntime(+ path.dirname(artifact),+ path.basename(artifact),+ );+ if (namespace.status !== 'resolved') {+ const error = new Error(+ `Could not establish a stable sidecar namespace (${namespace.reason?.code || 'unknown'}).`,+ );+ error.code = 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE';+ error.sidecarNamespaceReason = namespace.reason;+ throw error;+ }+ return { directory: namespace.directoryPath, ...sidecarStemFromComponent(namespace.componentKey) };+}++function deliverySidecarPath(artifactPath, suffix) {+ const { directory, stem, options } = deliverySidecarNamespace(artifactPath);+ return path.join(+ directory,+ `${boundedSidecarStem(stem, DELIVERY_SIDECAR_SUFFIXES, options)}${suffix}`,+ );+}function deliveryProvenancePath(artifactPath) {- const artifact = path.resolve(artifactPath);- return `${artifact.replace(/\.html?$/i, '')}.delivery.json`;+ return deliverySidecarPath(artifactPath, '.delivery.json');}function deliveryPendingPath(artifactPath) {- return deliveryProvenancePath(artifactPath).replace(/\.json$/, '-pending.json');+ return deliverySidecarPath(artifactPath, '.delivery-pending.json');+}++function rawHeadDeliverySidecarPath(artifactPath, suffix) {+ const { directory, stem, options } = deliverySidecarNamespace(artifactPath);+ if (options?.force) return undefined;+ if (sidecarStemNeedsBounding(stem, DELIVERY_SIDECAR_SUFFIXES)+ || !SIDECAR_STEM_NAMESPACE.test(stem)) return undefined;+ return path.join(directory, `${stem}${suffix}`);+}++function rawHeadDeliveryProvenancePath(artifactPath) {+ return rawHeadDeliverySidecarPath(artifactPath, '.delivery.json');+}++function rawHeadDeliveryPendingPath(artifactPath) {+ return rawHeadDeliverySidecarPath(artifactPath, '.delivery-pending.json');+}++function canonicalExistingDeliveryOutput(outputPath) {+ const output = path.resolve(outputPath);+ try {+ return fs.realpathSync.native(output);+ } catch (error) {+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return output;+ throw error;+ }+}++function legacyDeliveryLockPath(artifactPath) {+ const artifact = path.resolve(artifactPath);+ return `${artifact.replace(/\.html?$/i, '')}.delivery-lock.json`;+}++function legacyDeliveryLockPaths(artifactPaths) {+ const paths = [];+ for (const artifactPath of artifactPaths) {+ const lockPath = legacyDeliveryLockPath(artifactPath);+ const name = path.basename(lockPath);+ const canExist = process.platform === 'win32'+ ? name.length <= 255+ : Buffer.byteLength(name, 'utf8') <= 255;+ if (canExist && !paths.includes(lockPath)) paths.push(lockPath);+ }+ return paths;}function deliveryLockPath(artifactPath) {- return deliveryProvenancePath(artifactPath).replace(/\.json$/, '-lock.json');+ // A directory-wide mutex is deliberately conservative. Future 8.3, case,+ // and Unicode aliases cannot be assigned a sound canonical filename before+ // the artifact exists, so a per-artifact lock can split one delivery into+ // multiple owners. Provenance and pending journals remain artifact-specific.+ const artifact = path.resolve(artifactPath);+ let directory;+ try {+ directory = path.dirname(fs.realpathSync.native(artifact));+ } catch (error) {+ if (error?.code !== 'ENOENT' && error?.code !== 'ENOTDIR') throw error;+ const authoredDirectory = path.dirname(artifact);+ try {+ directory = fs.realpathSync.native(authoredDirectory);+ } catch (directoryError) {+ if (directoryError?.code !== 'ENOENT' && directoryError?.code !== 'ENOTDIR') throw directoryError;+ directory = authoredDirectory;+ }+ }+ return path.join(directory, DELIVERY_DIRECTORY_LOCK);+}++function deliveryLockInvalid(lockPath) {+ return Object.assign(new Error(`Unrecognized delivery lock at "${lockPath}"; inspect the existing entry before retrying.`), {+ deliveryLockCode: 'delivery/lock-invalid',+ deliveryLockPath: lockPath,+ });+}++function regularDeliveryLockExists(lockPath) {+ try {+ if (!fs.lstatSync(lockPath).isFile()) throw deliveryLockInvalid(lockPath);+ return true;+ } catch (error) {+ if (error.deliveryLockCode) throw error;+ if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return false;+ throw deliveryLockInvalid(lockPath);+ }+}++function rejectExistingDeliveryLock(lockPath, output, fileBindingRuntime) {+ const {+ captureRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};+ let lock;+ let captured;+ try {+ if (typeof captureRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ captured = captureRegularFileBinding(lockPath, {+ subject: 'delivery-lock',+ expectedLinks: 1,+ includeContent: true,+ });+ if (captured.status !== 'captured') throw new Error('Not a stable regular lock file.');+ lock = JSON.parse(captured.content.buffer.toString('utf8'));+ if (lock?.schemaVersion !== 1 || !Number.isSafeInteger(lock.pid) || lock.pid <= 0+ || typeof lock.receiptId !== 'string'+ || !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(lock.receiptId)) {+ throw new Error('Unrecognized delivery lock.');+ }+ } catch {+ throw deliveryLockInvalid(lockPath);+ } finally {+ if (captured?.binding) releaseRegularFileBinding(captured.binding);+ }+ if (processIsRunning(lock.pid)) {+ throw Object.assign(new Error(`Another delivery attempt owns "${output}" through lock "${lockPath}".`), {+ deliveryLockCode: 'delivery/concurrent-attempt',+ deliveryLockPath: lockPath,+ });+ }+ throw Object.assign(new Error(`A stale delivery lock remains at "${lockPath}"; recover it serially before retrying.`), {+ deliveryLockCode: 'delivery/lock-stale',+ deliveryLockPath: lockPath,+ deliveryLockOwner: { pid: lock.pid, receiptId: lock.receiptId },+ });}function processIsRunning(pid) {@@ -61,90 +254,249 @@ function deliveryOwnershipState(ownership, operation) {}function sameFileIdentity(actual, expected) {- const hasIdentity = (entry) => entry.ino !== 0 && entry.ino !== 0n;+ const hasIdentity = (entry) => entry?.ino !== undefined && entry.ino !== 0 && entry.ino !== 0n;return hasIdentity(actual)&& hasIdentity(expected)&& actual.dev === expected.dev&& actual.ino === expected.ino;}-function assertDeliveryOwnership(ownership, operation, { allowInitializing = false, pending = 'ignore' } = {}) {- const state = deliveryOwnershipState(ownership, operation);- let lockEntry;+function assertOwnedDeliveryLock(state, ownedLock, operation, { verifyReceipt = true } = {}) {+ const {+ captureRegularFileBinding,+ releaseRegularFileBinding,+ } = state?.fileBindingRuntime || {};+ let captured;try {- lockEntry = fs.lstatSync(state.lockPath);+ if (typeof captureRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ captured = captureRegularFileBinding(ownedLock.path, {+ subject: 'owned-delivery-lock',+ ...(ownedLock.content ? {+ expectedSha256: ownedLock.content.sha256,+ expectedBytes: ownedLock.content.bytes,+ } : {}),+ expectedMode: Number(ownedLock.identity.mode & 0o777n),+ expectedLinks: 1,+ includeContent: verifyReceipt,+ });} catch (error) {- throw deliveryOwnershipFailure(state, operation, 'the owned lock entry can no longer be inspected', {+ throw deliveryOwnershipFailure(state, operation, 'an owned lock entry can no longer be inspected', {+ lock: ownedLock.path,...(error?.code ? { systemCode: error.code } : {}),});}- if (!lockEntry.isFile() || !sameFileIdentity(lockEntry, state.lockIdentity)) {- throw deliveryOwnershipFailure(state, operation, 'the lock path no longer names the entry created by this attempt');+ if (captured.status !== 'captured'+ || captured.identity.device !== ownedLock.identity.dev+ || captured.identity.inode !== ownedLock.identity.ino) {+ if (captured?.binding) releaseRegularFileBinding(captured.binding);+ throw deliveryOwnershipFailure(state, operation, 'an owned lock path no longer names the entry created by this attempt', {+ lock: ownedLock.path,+ ...(captured?.reason ? { lockState: captured.reason } : {}),+ });}- if (state.phase !== 'initializing' || !allowInitializing) {+ try {+ if (!verifyReceipt) return;let lock;try {- lock = JSON.parse(fs.readFileSync(state.lockPath, 'utf8'));+ lock = JSON.parse(captured.content.buffer.toString('utf8'));} catch (error) {- throw deliveryOwnershipFailure(state, operation, 'the owned lock receipt can no longer be verified', {+ throw deliveryOwnershipFailure(state, operation, 'an owned lock receipt can no longer be verified', {+ lock: ownedLock.path,...(error?.code ? { systemCode: error.code } : {}),});}if (lock?.schemaVersion !== 1 || lock.receiptId !== state.receiptId || lock.pid !== state.pid) {- throw deliveryOwnershipFailure(state, operation, 'the lock receipt no longer matches this attempt', {+ throw deliveryOwnershipFailure(state, operation, 'an owned lock receipt no longer matches this attempt', {+ lock: ownedLock.path,...(typeof lock?.receiptId === 'string' ? { observedReceiptId: lock.receiptId } : {}),});}+ } catch (error) {+ throw error;+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+}++function assertDeliveryOwnership(ownership, operation, { allowInitializing = false, pending = 'ignore' } = {}) {+ const state = deliveryOwnershipState(ownership, operation);+ const verifyReceipt = !allowInitializing || !['acquiring', 'initializing'].includes(state.phase);+ for (const ownedLock of state.ownedLocks) {+ assertOwnedDeliveryLock(state, ownedLock, operation, { verifyReceipt });}if (pending !== 'ignore') {- const pendingPath = deliveryPendingPath(state.output);- let pendingEntry;+ const pendingPath = state.pendingPath;+ if (pending === 'absent') {+ try {+ fs.lstatSync(pendingPath);+ } catch (error) {+ if (error.code === 'ENOENT') return state;+ throw deliveryOwnershipFailure(state, operation, 'the finalized delivery journal can no longer be inspected', {+ journal: pendingPath,+ ...(error?.code ? { systemCode: error.code } : {}),+ });+ }+ throw deliveryOwnershipFailure(state, operation, 'the finalized delivery journal was recreated', { journal: pendingPath });+ }+ const {+ captureRegularFileBinding,+ releaseRegularFileBinding,+ } = state.fileBindingRuntime || {};+ let captured;try {- pendingEntry = fs.lstatSync(pendingPath);+ if (typeof captureRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ captured = captureRegularFileBinding(pendingPath, {+ subject: 'owned-delivery-journal',+ expectedSha256: state.pendingContent?.sha256,+ expectedBytes: state.pendingContent?.bytes,+ expectedMode: state.pendingIdentity?.mode,+ expectedLinks: 1,+ includeContent: pending === 'owned',+ });} catch (error) {- if (pending === 'absent' && error.code === 'ENOENT') return state;throw deliveryOwnershipFailure(state, operation, 'the owned delivery journal can no longer be inspected', {journal: pendingPath,...(error?.code ? { systemCode: error.code } : {}),});}- if (pending === 'absent') {- throw deliveryOwnershipFailure(state, operation, 'the finalized delivery journal was recreated', { journal: pendingPath });- }- if (!state.pendingIdentity || !pendingEntry.isFile() || !sameFileIdentity(pendingEntry, state.pendingIdentity)) {+ if (captured.status !== 'captured'+ || !state.pendingIdentity+ || captured.identity.device !== state.pendingIdentity.dev+ || captured.identity.inode !== state.pendingIdentity.ino) {+ if (captured?.binding) releaseRegularFileBinding(captured.binding);throw deliveryOwnershipFailure(state, operation, 'the delivery journal no longer names the entry created by this attempt', {journal: pendingPath,+ ...(captured?.reason ? { journalState: captured.reason } : {}),});}- if (pending === 'owned' || pending === 'identity') {- let journalSource;- try {- journalSource = fs.readFileSync(pendingPath, 'utf8');- } catch (error) {- // An unreadable journal is a commit/finalization failure. The unchanged- // lock and journal identities still permit a guarded rollback.- if (pending === 'owned') throw error;- return state;- }- let journal;- try {- journal = JSON.parse(journalSource);- } catch {- throw deliveryOwnershipFailure(state, operation, 'the delivery journal receipt is malformed', {- journal: pendingPath,- });- }- if (journal?.receiptId !== state.receiptId) {- throw deliveryOwnershipFailure(state, operation, 'the delivery journal receipt belongs to another attempt', {- journal: pendingPath,- ...(typeof journal?.receiptId === 'string' ? { observedReceiptId: journal.receiptId } : {}),- });+ try {+ if (pending === 'owned') {+ let journal;+ try {+ journal = JSON.parse(captured.content.buffer.toString('utf8'));+ } catch {+ throw deliveryOwnershipFailure(state, operation, 'the delivery journal receipt is malformed', {+ journal: pendingPath,+ });+ }+ if (journal?.receiptId !== state.receiptId) {+ throw deliveryOwnershipFailure(state, operation, 'the delivery journal receipt belongs to another attempt', {+ journal: pendingPath,+ ...(typeof journal?.receiptId === 'string' ? { observedReceiptId: journal.receiptId } : {}),+ });+ }}+ } finally {+ releaseRegularFileBinding(captured.binding);}}return state;}+function quarantineRemoveOwnedDeliveryEntry(state, {+ filePath,+ identity,+ content,+ subject,+ operation,+ evidenceKey,+}) {+ const {+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ releaseRegularFileBinding,+ } = state?.fileBindingRuntime || {};+ let captured;+ try {+ if (typeof captureRegularFileBinding !== 'function'+ || typeof quarantineRemoveRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ captured = captureRegularFileBinding(filePath, {+ subject,+ ...(content ? {+ expectedSha256: content.sha256,+ expectedBytes: content.bytes,+ } : {}),+ expectedMode: typeof identity?.mode === 'bigint'+ ? Number(identity.mode & 0o777n)+ : identity?.mode,+ expectedIdentity: {+ device: identity?.dev,+ inode: identity?.ino,+ },+ expectedLinks: 1,+ });+ } catch (error) {+ throw deliveryOwnershipFailure(state, operation, `the owned ${subject} can no longer be captured for removal`, {+ [evidenceKey]: filePath,+ ...(error?.code ? { systemCode: error.code } : {}),+ });+ }+ if (captured.status !== 'captured') {+ throw deliveryOwnershipFailure(state, operation, `the owned ${subject} changed before removal`, {+ [evidenceKey]: filePath,+ entryState: captured.reason,+ });+ }+ try {+ const removed = quarantineRemoveRegularFileBinding(captured.binding, filePath, {+ subject,+ expectedLinks: 1,+ });+ if (removed.status === 'removed') return;+ const removalCode = removed.reason?.code;+ if (removed.status === 'unknown'+ && ['removal-quarantine-create-failed', `${subject}-quarantine-move-failed`]+ .includes(removalCode)) {+ const detail = removed.reason?.message ? `: ${removed.reason.message}` : '';+ const error = new Error(`The owned ${subject} could not be moved into its private removal quarantine (${removalCode})${detail}.`);+ if (removed.reason?.systemCode) error.code = removed.reason.systemCode;+ if (subject === 'delivery-lock') {+ error.deliveryOwnershipCode = 'delivery/lock-release';+ error.deliveryOwnershipDetails = {+ operation,+ lock: filePath,+ reason: error.message,+ entryState: removed.reason,+ };+ } else {+ error.deliveryJournalRemovalState = removed;+ }+ throw error;+ }+ throw deliveryOwnershipFailure(+ state,+ operation,+ removed.status === 'recovery-required'+ ? `a replacement ${subject} could not be restored from quarantine`+ : `the public ${subject} changed during removal and was preserved`,+ {+ [evidenceKey]: filePath,+ entryState: removed.reason,+ ...(removed.status === 'recovery-required' ? {+ recoveryRequired: true,+ recoveryDirectory: removed.recoveryDirectory,+ recoveryFiles: [{+ label: `preserved replacement ${subject}`,+ path: removed.recoveryFile,+ target: filePath,+ }],+ } : {}),+ },+ );+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+}+function releaseDeliveryOwnership(ownership, { allowInitializing = false } = {}) {const current = deliveryOwnershipState(ownership, 'release the delivery lock');const pending = current.phase === 'finalized'@@ -153,82 +505,183 @@ function releaseDeliveryOwnership(ownership, { allowInitializing = false } = {})? 'identity': 'ignore';const state = assertDeliveryOwnership(ownership, 'release the delivery lock', { allowInitializing, pending });- try {- fs.unlinkSync(state.lockPath);- } catch (cause) {- if (cause.code === 'ENOENT') {- throw deliveryOwnershipFailure(state, 'release the delivery lock', 'the owned lock disappeared before it could be removed', {- systemCode: cause.code,- });- }- const error = new Error(`Could not release delivery lock "${state.lockPath}": ${cause.message}`);- error.code = cause.code;- error.deliveryOwnershipCode = 'delivery/lock-release';- error.deliveryOwnershipDetails = {+ const verifyReceipt = !allowInitializing || !['acquiring', 'initializing'].includes(state.phase);+ for (const ownedLock of state.ownedLocks) {+ assertOwnedDeliveryLock(state, ownedLock, 'release the delivery lock', { verifyReceipt });+ quarantineRemoveOwnedDeliveryEntry(state, {+ filePath: ownedLock.path,+ identity: ownedLock.identity,+ content: ownedLock.content,+ subject: 'delivery-lock',operation: 'release the delivery lock',- lock: state.lockPath,- expectedReceiptId: state.receiptId,- reason: cause.message,- };- throw error;+ evidenceKey: 'lock',+ });}state.phase = 'released';}-function acquireDeliveryLock(output, receiptId, inputPath, pathsAlias, recordInitializationFailure) {- const lockPath = deliveryLockPath(output);- try {- const existingLock = fs.lstatSync(lockPath);- if (!existingLock.isFile()) {- throw Object.assign(new Error(`Unrecognized delivery lock at "${lockPath}"; inspect the existing entry before retrying.`), {- deliveryLockCode: 'delivery/lock-invalid',- });+function acquireDeliveryLock(+ output,+ receiptId,+ inputPath,+ pathsAlias,+ recordInitializationFailure,+ legacyOutputPaths = [],+ fileBindingRuntime,+) {+ const stableOutput = canonicalExistingDeliveryOutput(output);+ const lockPath = deliveryLockPath(stableOutput);+ const comparableLockPath = (candidate) => {+ const absolute = path.resolve(candidate);+ try {+ return path.join(fs.realpathSync.native(path.dirname(absolute)), path.basename(absolute));+ } catch (error) {+ if (error?.code !== 'ENOENT' && error?.code !== 'ENOTDIR') throw error;+ return absolute;}- } catch (error) {- if (error.deliveryLockCode) throw error;- if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') {- throw Object.assign(new Error(`Unrecognized delivery lock at "${lockPath}"; inspect the existing entry before retrying.`), {- deliveryLockCode: 'delivery/lock-invalid',- });+ };+ const lockPathsAlias = (left, right) => {+ const comparableLeft = comparableLockPath(left);+ const comparableRight = comparableLockPath(right);+ if (!pathsAlias(path.dirname(comparableLeft), path.dirname(comparableRight))) return false;+ return pathsAlias(comparableLeft, comparableRight);+ };+ const legacyFencePathsAlias = (left, right) => {+ const comparableLeft = comparableLockPath(left);+ const comparableRight = comparableLockPath(right);+ if (comparableLeft === comparableRight) return true;+ try {+ return lockPathsAlias(comparableLeft, comparableRight);+ } catch {+ // An indeterminate future-name relation is not evidence of aliasing.+ // Keep both candidates; an EEXIST below is accepted only when dev/ino+ // proves that it names a lock already created by this attempt.+ return false;+ }+ };+ const legacyLockPaths = [];+ for (const candidate of legacyDeliveryLockPaths([+ ...legacyOutputPaths.filter(Boolean),+ output,+ stableOutput,+ ])) {+ if (!legacyLockPaths.some((existing) => legacyFencePathsAlias(candidate, existing))) {+ legacyLockPaths.push(candidate);}}- if (pathsAlias(lockPath, inputPath)) {+ const pendingPath = deliveryPendingPath(stableOutput);+ const provenancePath = deliveryProvenancePath(stableOutput);+ const rawHeadPendingPath = rawHeadDeliveryPendingPath(stableOutput);+ const existingLegacyLocks = legacyLockPaths.filter((candidate) => regularDeliveryLockExists(candidate));+ regularDeliveryLockExists(lockPath);+ const conflictingLockPath = [lockPath, ...legacyLockPaths]+ .find((candidate) => lockPathsAlias(candidate, inputPath));+ if (conflictingLockPath) {throw Object.assign(new Error('Delivery lock path aliases the input specification; choose another output path.'), {deliveryLockCode: 'delivery/lock-path-conflict',+ deliveryLockPath: conflictingLockPath,});}- let descriptor;+ if (existingLegacyLocks.length) {+ rejectExistingDeliveryLock(existingLegacyLocks[0], output, fileBindingRuntime);+ }+ const openedLocks = [];let ownership;+ let collisionPath;try {- descriptor = fs.openSync(lockPath, 'wx', 0o600);- const lockIdentity = fs.fstatSync(descriptor);+ const openOwnedLock = (ownedLockPath, { allowOwnedAlias = false } = {}) => {+ let descriptor;+ try {+ descriptor = fs.openSync(ownedLockPath, 'wx', 0o600);+ } catch (error) {+ if (error.code === 'EEXIST' && allowOwnedAlias) {+ try {+ const existingEntry = fs.lstatSync(ownedLockPath, { bigint: true });+ if (existingEntry.isFile()+ && openedLocks.some((ownedLock) => sameFileIdentity(existingEntry, ownedLock.identity))) {+ return undefined;+ }+ } catch {+ // Preserve the original EEXIST classification below.+ }+ }+ if (error.code === 'EEXIST') collisionPath = ownedLockPath;+ throw error;+ }+ const ownedLock = {+ path: ownedLockPath,+ identity: fs.fstatSync(descriptor, { bigint: true }),+ descriptor,+ };+ openedLocks.push(ownedLock);+ return ownedLock;+ };++ openOwnedLock(lockPath);ownership = Object.freeze({});deliveryOwnershipStates.set(ownership, {- output: path.resolve(output),+ output: stableOutput,lockPath,+ pendingPath,+ provenancePath,receiptId,pid: process.pid,- lockIdentity,- phase: 'initializing',+ ownedLocks: openedLocks,+ fileBindingRuntime,+ phase: 'acquiring',});- fs.writeFileSync(descriptor, `${JSON.stringify({ schemaVersion: 1, receiptId, pid: process.pid })}\n`);- deliveryOwnershipStates.get(ownership).phase = 'owned';- fs.closeSync(descriptor);- descriptor = undefined;+ for (const legacyLockPath of legacyLockPaths) {+ openOwnedLock(legacyLockPath, { allowOwnedAlias: true });+ }+ const state = deliveryOwnershipStates.get(ownership);+ if (rawHeadPendingPath && pathEntryExists(rawHeadPendingPath)) {+ throw Object.assign(new Error(`A pre-namespace delivery journal remains at "${rawHeadPendingPath}"; recover it before retrying.`), {+ deliveryLockCode: 'delivery/legacy-pending',+ deliveryLockPath: rawHeadPendingPath,+ });+ }+ state.phase = 'initializing';+ const lockReceipt = `${JSON.stringify({ schemaVersion: 1, receiptId, pid: process.pid })}\n`;+ const lockContent = artifactIdentity(Buffer.from(lockReceipt));+ for (const ownedLock of openedLocks) {+ fs.writeFileSync(ownedLock.descriptor, lockReceipt);+ ownedLock.content = lockContent;+ }+ for (const ownedLock of openedLocks) {+ fs.closeSync(ownedLock.descriptor);+ ownedLock.descriptor = undefined;+ }+ state.phase = 'owned';return ownership;} catch (error) {- if (descriptor !== undefined) {+ for (const ownedLock of openedLocks) {+ if (ownedLock.descriptor === undefined) continue;try {- fs.closeSync(descriptor);+ fs.closeSync(ownedLock.descriptor);+ ownedLock.descriptor = undefined;} catch (closeError) {error.lockCleanupError = closeError.message;}}if (ownership) {+ const state = deliveryOwnershipStates.get(ownership);+ let preserveOwnership = false;try {- assertDeliveryOwnership(ownership, 'record a lock initialization failure', { allowInitializing: true });- error.deliveryFailureRecord = recordInitializationFailure?.(error, ownership);- releaseDeliveryOwnership(ownership, { allowInitializing: true });+ if (state.phase === 'initializing') {+ assertDeliveryOwnership(ownership, 'record a lock initialization failure', { allowInitializing: true });+ error.deliveryFailureRecord = recordInitializationFailure?.(error, ownership);+ if (error.deliveryFailureRecord?.journalRecovery) {+ error.deliveryJournalRecovery = error.deliveryFailureRecord.journalRecovery.deliveryJournalRecovery;+ preserveOwnership = true;+ }+ if (error.deliveryFailureRecord?.provenanceRecovery) {+ error.deliveryProvenanceRecovery = error.deliveryFailureRecord.provenanceRecovery.deliveryProvenanceRecovery;+ preserveOwnership = true;+ }+ }+ if (!preserveOwnership) {+ releaseDeliveryOwnership(ownership, { allowInitializing: true });+ }} catch (cleanupError) {if (cleanupError.deliveryOwnershipCode) {cleanupError.deliveryOwnershipDetails = {@@ -243,32 +696,11 @@ function acquireDeliveryLock(output, receiptId, inputPath, pathsAlias, recordIni}error.lockCleanupError = cleanupError.message;}+ if (collisionPath) rejectExistingDeliveryLock(collisionPath, output, fileBindingRuntime);throw error;}- if (error.code !== 'EEXIST') throw error;- let lock;- try {- if (!fs.lstatSync(lockPath).isFile()) throw new Error('Not a regular lock file.');- lock = JSON.parse(fs.readFileSync(lockPath, 'utf8'));- if (lock?.schemaVersion !== 1 || !Number.isSafeInteger(lock.pid) || lock.pid <= 0- || typeof lock.receiptId !== 'string'- || !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(lock.receiptId)) {- throw new Error('Unrecognized delivery lock.');- }- } catch {- throw Object.assign(new Error(`Unrecognized delivery lock at "${lockPath}"; inspect the existing entry before retrying.`), {- deliveryLockCode: 'delivery/lock-invalid',- });- }- if (processIsRunning(lock.pid)) {- throw Object.assign(new Error(`Another delivery attempt owns "${output}" through lock "${lockPath}".`), {- deliveryLockCode: 'delivery/concurrent-attempt',- });- }- throw Object.assign(new Error(`A stale delivery lock remains at "${lockPath}"; recover it serially before retrying.`), {- deliveryLockCode: 'delivery/lock-stale',- deliveryLockOwner: { pid: lock.pid, receiptId: lock.receiptId },- });+ if (collisionPath) rejectExistingDeliveryLock(collisionPath, output, fileBindingRuntime);+ throw error;}}@@ -286,64 +718,557 @@ function artifactIdentity(artifact) {return { sha256: createHash('sha256').update(artifact).digest('hex'), bytes: artifact.byteLength };}-function beginDeliveryAttempt({ ownership, input, pathsAlias }) {+function beginDeliveryAttempt({ ownership, input, pathsAlias, fileBindingRuntime }) {const state = assertDeliveryOwnership(ownership, 'begin the delivery journal', { allowInitializing: true });- const { output, receiptId } = state;- const journal = deliveryPendingPath(output);- for (const protectedPath of [input, output, deliveryProvenancePath(output)].filter(Boolean)) {+ const {+ output, pendingPath: journal, provenancePath, receiptId,+ } = state;+ for (const protectedPath of [input, output, provenancePath].filter(Boolean)) {if (pathsAlias(journal, protectedPath)) throw new Error('Delivery journal aliases an input or output.');}- writeDeliveryProvenance(journal, {+ const published = writeDeliveryProvenance(journal, {schemaVersion: 1, command: 'deliver', status: 'pending', receiptId,input, output: path.resolve(output),}, {beforeReplace: () => assertDeliveryOwnership(ownership, 'create the delivery journal', { allowInitializing: true }),+ fileBindingRuntime,});+ state.pendingIdentity = {+ dev: published.identity.device,+ ino: published.identity.inode,+ mode: published.identity.mode,+ };+ state.pendingContent = published.content;assertDeliveryOwnership(ownership, 'finish creating the delivery journal', { allowInitializing: true });- let pendingIdentity;- try {- pendingIdentity = fs.lstatSync(journal);- } catch (error) {- throw deliveryOwnershipFailure(state, 'finish creating the delivery journal', 'the new journal identity cannot be captured', {- journal,- ...(error?.code ? { systemCode: error.code } : {}),- });+}++function writeDeliveryProvenance(file, value, { beforeReplace, fileBindingRuntime } = {}) {+ const {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};+ if (typeof captureRegularFileBinding !== 'function'+ || typeof backupPublicRegularFileBinding !== 'function'+ || typeof quarantineRemoveRegularFileBinding !== 'function'+ || typeof verifyRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ const error = new Error('The regular-file binding runtime is unavailable.');+ error.deliveryJournalState = {+ status: 'unknown',+ reason: { code: 'atomic-output-runtime-unavailable' },+ };+ throw error;}- let pending;+ const stagingDirectory = fs.mkdtempSync(path.join(path.dirname(file), '.archify-provenance-'));+ const temporary = path.join(stagingDirectory, path.basename(file));+ const backup = path.join(stagingDirectory, '.previous-journal');+ const serialized = Buffer.from(`${JSON.stringify(value, null, 2)}\n`);+ const expectedContent = artifactIdentity(serialized);+ let candidateCapture;+ let previousCapture;+ let candidatePresent = false;+ let backupPresent = false;+ let backupVerified = false;+ let published = false;+ let retainStaging = false;+ const bindingError = (result, action) => {+ const error = new Error(`Could not ${action} delivery journal "${file}" safely (${result.reason?.code || 'unknown target state'}).`);+ error.deliveryJournalState = result;+ return error;+ };try {- pending = JSON.parse(fs.readFileSync(journal, 'utf8'));- } catch (error) {- throw deliveryOwnershipFailure(state, 'finish creating the delivery journal', 'the new journal cannot be verified', {- journal,- ...(error?.code ? { systemCode: error.code } : {}),+ fs.writeFileSync(temporary, serialized, { flag: 'wx' });+ candidatePresent = true;+ candidateCapture = captureRegularFileBinding(temporary, {+ subject: 'delivery-journal-candidate',+ expectedSha256: expectedContent.sha256,+ expectedBytes: expectedContent.bytes,+ expectedLinks: 1,});- }- if (!pendingIdentity.isFile() || pending.receiptId !== receiptId) {- throw deliveryOwnershipFailure(state, 'finish creating the delivery journal', 'the new journal belongs to another attempt', {- journal,- ...(typeof pending?.receiptId === 'string' ? { observedReceiptId: pending.receiptId } : {}),+ if (candidateCapture.status !== 'captured') throw bindingError(candidateCapture, 'prepare the');++ let existing = false;+ try {+ fs.lstatSync(file);+ existing = true;+ } catch (error) {+ if (error?.code !== 'ENOENT' && error?.code !== 'ENOTDIR') throw error;+ }+ if (existing) {+ previousCapture = captureRegularFileBinding(file, {+ subject: 'previous-delivery-journal',+ expectedLinks: 1,+ });+ if (previousCapture.status !== 'captured') {+ throw bindingError(previousCapture, 'snapshot the existing');+ }+ }+ beforeReplace?.();+ if (previousCapture) {+ const moved = backupPublicRegularFileBinding(previousCapture.binding, file, backup, {+ subject: 'previous-delivery-journal',+ });+ backupPresent = moved.backupCreated === true;+ backupVerified = moved.backupVerified === true;+ if (moved.status !== 'backed-up') throw bindingError(moved, 'back up the existing');+ }++ const ready = verifyRegularFileBinding(candidateCapture.binding, {+ filePath: temporary,+ expectedLinks: 1,+ });+ if (ready.status !== 'match') throw bindingError(ready, 'verify the staged');+ try {+ fs.linkSync(temporary, file);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw bindingError({+ status: 'different',+ reason: { code: 'target-claimed-during-publish', phase: 'journal-publish' },+ }, 'publish the');+ }+ throw error;+ }+ published = true;+ for (const target of [temporary, file]) {+ const linked = verifyRegularFileBinding(candidateCapture.binding, {+ filePath: target,+ expectedLinks: 2,+ });+ if (linked.status !== 'match') throw bindingError(linked, 'verify the published');+ }+ fs.unlinkSync(temporary);+ candidatePresent = false;+ const finalized = verifyRegularFileBinding(candidateCapture.binding, {+ filePath: file,+ expectedLinks: 1,});+ if (finalized.status !== 'match') throw bindingError(finalized, 'finalize the');+ if (backupPresent) {+ const previous = verifyRegularFileBinding(previousCapture.binding, {+ filePath: backup,+ expectedLinks: 1,+ });+ if (previous.status !== 'match') throw bindingError(previous, 'verify the previous');+ fs.unlinkSync(backup);+ backupPresent = false;+ }+ return {+ identity: candidateCapture.identity,+ content: candidateCapture.content,+ };+ } catch (cause) {+ const rollbackErrors = [];+ const publicRecoveryFiles = [];+ if (cause.deliveryJournalState?.status === 'recovery-required'+ && cause.deliveryJournalState.recoveryFile) {+ publicRecoveryFiles.push({+ label: 'preserved journal replacement',+ path: cause.deliveryJournalState.recoveryFile,+ target: file,+ });+ }+ if (published) {+ try {+ const removed = quarantineRemoveRegularFileBinding(candidateCapture.binding, file, {+ subject: 'published-delivery-journal',+ expectedLinks: candidatePresent ? 2 : 1,+ });+ if (removed.status === 'removed') {+ published = false;+ } else {+ rollbackErrors.push(`the published journal could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ if (removed.status === 'recovery-required') {+ publicRecoveryFiles.push({+ label: 'preserved journal replacement',+ path: removed.recoveryFile,+ target: file,+ });+ }+ }+ } catch (error) {+ if (error?.code !== 'ENOENT') rollbackErrors.push(`published journal cleanup failed (${error.message})`);+ }+ }+ if (candidatePresent) {+ try {+ const current = verifyRegularFileBinding(candidateCapture.binding, {+ filePath: temporary,+ expectedLinks: published ? 2 : 1,+ });+ if (current.status === 'match') {+ fs.unlinkSync(temporary);+ candidatePresent = false;+ } else {+ rollbackErrors.push('the staged journal candidate was replaced before cleanup');+ retainStaging = true;+ }+ } catch (error) {+ if (error?.code !== 'ENOENT') rollbackErrors.push(`staged journal cleanup failed (${error.message})`);+ }+ }+ if (backupPresent) {+ try {+ if (!backupVerified) {+ throw new Error('the backup entry was never verified as the previous journal');+ }+ if (pathEntryExists(file)) throw new Error('a new journal claimant prevents restoring the previous journal');+ const previous = verifyRegularFileBinding(previousCapture.binding, {+ filePath: backup,+ expectedLinks: 1,+ });+ if (previous.status !== 'match') {+ backupVerified = false;+ throw bindingError(previous, 'verify the previous');+ }+ try {+ fs.linkSync(backup, file);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw new Error('a new journal claimant prevents restoring the previous journal');+ }+ throw error;+ }+ for (const target of [backup, file]) {+ const restored = verifyRegularFileBinding(previousCapture.binding, {+ filePath: target,+ expectedLinks: 2,+ });+ if (restored.status !== 'match') throw bindingError(restored, 'verify the restored');+ }+ fs.unlinkSync(backup);+ backupPresent = false;+ const restored = verifyRegularFileBinding(previousCapture.binding, {+ filePath: file,+ expectedLinks: 1,+ });+ if (restored.status !== 'match') throw bindingError(restored, 'finalize the restored');+ } catch (error) {+ rollbackErrors.push(`previous journal restore failed (${error.message})`);+ retainStaging = backupPresent || candidatePresent;+ }+ }+ const claimantConflict = cause.deliveryJournalState?.reason?.code === 'target-claimed-during-publish';+ if (rollbackErrors.length || claimantConflict) {+ cause.deliveryJournalRecovery = {+ recoveryRequired: true,+ journal: file,+ ...(claimantConflict ? { claimantConflict: true } : {}),+ rollbackErrors,+ ...(retainStaging ? {+ recoveryDirectory: stagingDirectory,+ } : publicRecoveryFiles.length ? {+ recoveryDirectory: path.dirname(publicRecoveryFiles[0].path),+ } : {}),+ ...(backupPresent || (candidatePresent && retainStaging) || publicRecoveryFiles.length ? {+ recoveryFiles: [+ ...(backupPresent ? [{+ label: backupVerified+ ? 'previous delivery journal'+ : 'unverified preserved journal backup entry',+ path: backup,+ target: file,+ verifiedPrevious: backupVerified,+ }] : []),+ ...(candidatePresent && retainStaging ? [{ label: 'preserved staged journal entry', path: temporary }] : []),+ ...publicRecoveryFiles,+ ],+ } : {}),+ };+ }+ throw cause;+ } finally {+ if (candidateCapture?.binding) releaseRegularFileBinding(candidateCapture.binding);+ if (previousCapture?.binding) releaseRegularFileBinding(previousCapture.binding);+ if (!retainStaging) fs.rmSync(stagingDirectory, { recursive: true, force: true });}- assertDeliveryOwnership(ownership, 'finish creating the delivery journal', { allowInitializing: true });- state.pendingIdentity = pendingIdentity;}-function writeDeliveryProvenance(file, value, { beforeReplace } = {}) {+function writeCapturedDeliveryProvenance(file, value, {+ beforeCommit,+ capture,+ verifyAtomicOutput,+ fileBindingRuntime,+} = {}) {+ const {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};+ if (!capture+ || typeof verifyAtomicOutput !== 'function'+ || typeof backupPublicRegularFileBinding !== 'function'+ || typeof captureRegularFileBinding !== 'function'+ || typeof quarantineRemoveRegularFileBinding !== 'function'+ || typeof verifyRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw deliveryTargetStateError(file, 'delivery provenance', {+ status: 'unknown',+ reason: { code: 'atomic-output-runtime-unavailable' },+ });+ }const stagingDirectory = fs.mkdtempSync(path.join(path.dirname(file), '.archify-provenance-'));- const temporary = path.join(stagingDirectory, path.basename(file));+ const candidate = path.join(stagingDirectory, path.basename(file));+ const backup = path.join(stagingDirectory, '.previous-provenance');+ let candidateIdentity;+ let candidateBinding;+ let previousBinding;+ let candidatePresent = false;+ let backupPresent = false;+ let backupVerified = false;+ let published = false;+ let retainStaging = false;try {- fs.writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`, { flag: 'wx' });- beforeReplace?.();- fs.renameSync(temporary, file);+ const serialized = Buffer.from(`${JSON.stringify(value, null, 2)}\n`);+ const expectedContent = artifactIdentity(serialized);+ fs.writeFileSync(candidate, serialized, { flag: 'wx' });+ candidatePresent = true;+ if (capture.mode !== null) fs.chmodSync(candidate, capture.mode);+ const candidateCapture = captureRegularFileBinding(candidate, {+ subject: 'delivery-provenance-candidate',+ expectedSha256: expectedContent.sha256,+ expectedBytes: expectedContent.bytes,+ ...(capture.mode === null ? {} : { expectedMode: capture.mode }),+ expectedLinks: 1,+ });+ if (candidateCapture.status !== 'captured') {+ throw deliveryTargetStateError(file, 'delivery provenance', candidateCapture);+ }+ candidateBinding = candidateCapture.binding;+ candidateIdentity = {+ dev: candidateCapture.identity.device,+ ino: candidateCapture.identity.inode,+ };+ beforeCommit?.();+ const verification = verifyAtomicOutput(capture.snapshot);+ if (verification.status !== 'match') {+ throw deliveryTargetStateError(file, 'delivery provenance', verification);+ }+ if (capture.snapshot.target.kind === 'file') {+ const expected = capture.snapshot.target;+ const previous = captureRegularFileBinding(capture.commitPath, {+ subject: 'previous-delivery-provenance',+ expectedIdentity: { device: expected.device, inode: expected.inode },+ expectedMode: expected.mode,+ expectedLinks: 1,+ });+ if (previous.status !== 'captured') {+ throw deliveryTargetStateError(file, 'delivery provenance', previous);+ }+ previousBinding = previous.binding;+ const moved = backupPublicRegularFileBinding(+ previousBinding,+ capture.commitPath,+ backup,+ { subject: 'previous-delivery-provenance' },+ );+ backupPresent = moved.backupCreated === true;+ backupVerified = moved.backupVerified === true;+ if (moved.status !== 'backed-up') {+ throw deliveryTargetStateError(file, 'delivery provenance', moved);+ }+ }+ const currentCandidate = verifyRegularFileBinding(candidateBinding, {+ filePath: candidate,+ expectedLinks: 1,+ });+ if (currentCandidate.status !== 'match') {+ throw deliveryTargetStateError(file, 'delivery provenance', currentCandidate);+ }+ try {+ fs.linkSync(candidate, capture.commitPath);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw deliveryTargetStateError(file, 'delivery provenance', {+ status: 'different',+ reason: { code: 'target-claimed-during-publish' },+ });+ }+ throw error;+ }+ published = true;+ for (const target of [candidate, capture.commitPath]) {+ const linked = verifyRegularFileBinding(candidateBinding, {+ filePath: target,+ expectedLinks: 2,+ });+ if (linked.status !== 'match') {+ throw deliveryTargetStateError(file, 'delivery provenance', linked);+ }+ }+ fs.unlinkSync(candidate);+ candidatePresent = false;+ const finalized = verifyRegularFileBinding(candidateBinding, {+ filePath: capture.commitPath,+ expectedLinks: 1,+ });+ if (finalized.status !== 'match') {+ throw deliveryTargetStateError(file, 'delivery provenance', finalized);+ }+ if (backupPresent) {+ const currentBackup = verifyRegularFileBinding(previousBinding, {+ filePath: backup,+ expectedLinks: 1,+ });+ if (currentBackup.status !== 'match') {+ backupVerified = false;+ throw deliveryTargetStateError(file, 'delivery provenance', {+ status: 'different',+ reason: { code: 'backup-identity-changed-before-finalize' },+ });+ }+ fs.unlinkSync(backup);+ backupPresent = false;+ }+ } catch (cause) {+ const rollbackErrors = [];+ const publicRecoveryFiles = [];+ if (cause.deliveryTargetState?.status === 'recovery-required'+ && cause.deliveryTargetState.recoveryFile) {+ publicRecoveryFiles.push({+ label: 'preserved provenance replacement',+ path: cause.deliveryTargetState.recoveryFile,+ target: capture.commitPath,+ });+ }+ if (published) {+ try {+ const removed = quarantineRemoveRegularFileBinding(candidateBinding, capture.commitPath, {+ subject: 'published-delivery-provenance',+ expectedLinks: candidatePresent ? 2 : 1,+ });+ if (removed.status === 'removed') {+ published = false;+ } else {+ rollbackErrors.push(`the published provenance could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ if (removed.status === 'recovery-required') {+ publicRecoveryFiles.push({+ label: 'preserved provenance replacement',+ path: removed.recoveryFile,+ target: capture.commitPath,+ });+ }+ }+ } catch (error) {+ if (error?.code !== 'ENOENT') rollbackErrors.push(`published provenance cleanup failed (${error.message})`);+ }+ }+ if (candidatePresent) {+ try {+ const current = verifyRegularFileBinding(candidateBinding, {+ filePath: candidate,+ expectedLinks: published ? 2 : 1,+ });+ if (current.status === 'match') {+ fs.unlinkSync(candidate);+ candidatePresent = false;+ } else {+ rollbackErrors.push('the staged provenance candidate was replaced before cleanup');+ retainStaging = true;+ }+ } catch (error) {+ if (error?.code !== 'ENOENT') {+ rollbackErrors.push(`staged provenance cleanup failed (${error.message})`);+ retainStaging = true;+ }+ }+ }+ if (backupPresent) {+ try {+ if (!backupVerified) {+ throw new Error('the backup entry was never verified as the previous provenance');+ }+ if (pathEntryExists(capture.commitPath)) {+ throw new Error('a new target claimant prevents restoring the previous provenance');+ }+ const currentBackup = verifyRegularFileBinding(previousBinding, {+ filePath: backup,+ expectedLinks: 1,+ });+ if (currentBackup.status !== 'match') {+ backupVerified = false;+ throw new Error('the previous provenance backup identity changed');+ }+ fs.linkSync(backup, capture.commitPath);+ for (const target of [backup, capture.commitPath]) {+ const restored = verifyRegularFileBinding(previousBinding, {+ filePath: target,+ expectedLinks: 2,+ });+ if (restored.status !== 'match') {+ throw new Error('the restored provenance identity could not be verified');+ }+ }+ fs.unlinkSync(backup);+ backupPresent = false;+ const restoredFinal = verifyRegularFileBinding(previousBinding, {+ filePath: capture.commitPath,+ expectedLinks: 1,+ });+ if (restoredFinal.status !== 'match') {+ throw new Error('the restored provenance link count could not be verified');+ }+ } catch (error) {+ rollbackErrors.push(`previous provenance restore failed (${error.message})`);+ retainStaging = true;+ }+ }+ const recoveryFiles = [+ ...(backupPresent ? [{+ label: backupVerified+ ? 'preserved delivery provenance backup entry'+ : 'unverified preserved delivery provenance backup entry',+ path: backup,+ target: capture.commitPath,+ verifiedPrevious: backupVerified,+ }] : []),+ ...(candidatePresent && retainStaging ? [{ label: 'preserved staged provenance entry', path: candidate }] : []),+ ...publicRecoveryFiles,+ ];+ if (rollbackErrors.length) {+ cause.deliveryProvenanceRecovery = {+ recoveryRequired: true,+ rollbackErrors,+ ...(recoveryFiles.length ? {+ recoveryDirectory: retainStaging+ ? stagingDirectory+ : path.dirname(recoveryFiles[0].path),+ recoveryFiles,+ } : {}),+ };+ }+ if (rollbackErrors.length && cause?.archifyDiagnostics?.[0]) {+ const [issue] = cause.archifyDiagnostics;+ issue.evidence = {+ ...(issue.evidence || {}),+ rollbackErrors,+ ...(recoveryFiles.length ? {+ recoveryDirectory: retainStaging+ ? stagingDirectory+ : path.dirname(recoveryFiles[0].path),+ recoveryFile: recoveryFiles[0].path,+ recoveryFiles,+ } : {}),+ };+ }+ throw cause;} finally {- fs.rmSync(stagingDirectory, { recursive: true, force: true });+ if (candidateBinding) releaseRegularFileBinding(candidateBinding);+ if (previousBinding) releaseRegularFileBinding(previousBinding);+ if (!retainStaging) fs.rmSync(stagingDirectory, { recursive: true, force: true });}}function recordDeliveryFailure(options) {const {output, stage, input, error, receiptId, pathsAlias, ownership: suppliedOwnership,- releaseOwnership: shouldReleaseSuppliedOwnership = false,+ releaseOwnership: shouldReleaseSuppliedOwnership = false, legacyOutputPaths = [],+ captureAtomicOutput, verifyAtomicOutput, fileBindingRuntime,} = options;if (!output || !/\.html?$/i.test(output)) return { ok: true, status: 'not-applicable' };let ownership = suppliedOwnership;@@ -361,46 +1286,100 @@ function recordDeliveryFailure(options) {ownership: initializingOwnership,releaseOwnership: false,}),+ legacyOutputPaths,+ fileBindingRuntime,);acquiredHere = true;} catch (lockError) {+ const reportedLockError = lockError?.code === 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE'+ && lockError.sidecarNamespaceReason?.code === 'sidecar-directory-missing'+ ? Object.assign(+ new Error(`Delivery lock parent directory does not exist for "${output}".`),+ { code: 'ENOENT', cause: lockError },+ )+ : lockError;return {...(lockError.deliveryFailureRecord || { ok: false, status: 'unrecorded' }),- lockError,+ lockError: reportedLockError,};}}const state = deliveryOwnershipStates.get(ownership);let recorded;+ if (!state?.deliveryTargets) {+ try {+ captureDeliveryTargetState({+ state,+ requestedOutput: legacyOutputPaths[0] || output,+ pathsAlias,+ captureAtomicOutput,+ verifyAtomicOutput,+ });+ } catch (captureError) {+ recorded = {+ ok: false,+ status: 'unrecorded',+ diagnostic: captureError.archifyDiagnostics?.[0] || diagnostic({+ code: 'output/target-indeterminate',+ message: captureError.message,+ subject: { output },+ evidence: { ...(captureError?.code ? { systemCode: captureError.code } : {}) },+ supportedFixes: ['use ordinary absent or regular-file delivery targets, then retry'],+ }),+ };+ }+ }+ const stableOutput = state?.output || canonicalExistingDeliveryOutput(output);// Keep independent evidence even when the artifact is unreadable or the// provenance target is locked, aliases the input, or cannot be replaced.let journalError;- if (!state?.pendingIdentity) {+ if (!recorded && !state?.pendingIdentity) {try {- beginDeliveryAttempt({ ownership, input, pathsAlias });+ beginDeliveryAttempt({ ownership, input, pathsAlias, fileBindingRuntime });} catch (cause) {if (cause.deliveryOwnershipCode === 'delivery/ownership-lost') {recorded = { ok: false, status: 'unrecorded', ownershipError: cause };+ } else if (cause.deliveryJournalRecovery?.recoveryRequired) {+ recorded = {+ ok: false,+ status: 'unrecorded',+ journalRecovery: cause,+ diagnostic: deliveryJournalRecoveryDiagnostic(stableOutput, cause),+ };}journalError = cause;}}if (!recorded) {let artifact;+ let artifactBinding;+ const {+ captureRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};try {- artifact = fs.readFileSync(output);- } catch (readError) {- if (readError.code === 'ENOENT' || readError.code === 'ENOTDIR') {- recorded = { ok: true, status: 'absent' };+ if (typeof captureRegularFileBinding === 'function') {+ const artifactCapture = captureRegularFileBinding(stableOutput, {+ subject: 'failed-delivery-artifact',+ expectedLinks: 1,+ includeContent: true,+ });+ if (artifactCapture.status === 'captured') {+ artifact = artifactCapture.content.buffer;+ artifactBinding = artifactCapture.binding;+ } else if (['ENOENT', 'ENOTDIR'].includes(artifactCapture.reason?.systemCode)) {+ recorded = { ok: true, status: 'absent' };+ }+ // A failed marker does not need an artifact hash to invalidate old+ // evidence. Non-regular or changing paths are never followed.}- // A failed marker does not need an artifact hash to invalidate old evidence.- }- if (!recorded) {- const provenancePath = deliveryProvenancePath(output);+ if (!recorded) {+ const provenancePath = state?.provenancePath || deliveryProvenancePath(stableOutput);let aliasesProtectedPath;try {aliasesProtectedPath = (input && pathsAlias(provenancePath, input))- || pathsAlias(provenancePath, output);+ || pathsAlias(provenancePath, stableOutput);} catch (aliasError) {recorded = {ok: false,@@ -408,7 +1387,7 @@ function recordDeliveryFailure(options) {diagnostic: diagnostic({code: 'delivery/provenance-path-resolution',message: 'Delivery failure provenance could not resolve its target safely.',- subject: { output: path.resolve(output), provenance: provenancePath },+ subject: { output: stableOutput, provenance: provenancePath },evidence: {reason: aliasError.message,...(aliasError?.code ? { systemCode: aliasError.code } : {}),@@ -424,7 +1403,7 @@ function recordDeliveryFailure(options) {diagnostic: diagnostic({code: 'delivery/provenance-target-alias',message: 'Delivery failure provenance could not be recorded without replacing an input or the artifact.',- subject: { output: path.resolve(output), provenance: provenancePath },+ subject: { output: stableOutput, provenance: provenancePath },evidence: { ...(input ? { input: path.resolve(input) } : {}) },supportedFixes: ['choose an output whose .delivery.json sidecar is distinct from every input and the HTML artifact'],}),@@ -432,26 +1411,70 @@ function recordDeliveryFailure(options) {}if (!recorded) {try {- writeDeliveryProvenance(provenancePath, {+ writeCapturedDeliveryProvenance(provenancePath, {schemaVersion: 1,receiptId,status: 'failed',command: 'deliver',stage,input,- output: path.resolve(output),+ output: stableOutput,...(artifact ? { artifact: artifactIdentity(artifact) } : {}),error,}, {- beforeReplace: () => assertDeliveryOwnership(ownership, 'record failed delivery provenance', {- allowInitializing: true,- pending: state?.pendingIdentity ? 'owned' : 'ignore',- }),+ beforeCommit: () => {+ assertDeliveryOwnership(ownership, 'record failed delivery provenance', {+ allowInitializing: true,+ pending: state?.pendingIdentity ? 'owned' : 'ignore',+ });+ if (artifactBinding) {+ const verification = verifyRegularFileBinding(artifactBinding, {+ filePath: stableOutput,+ expectedLinks: 1,+ });+ if (verification.status !== 'match') {+ throw deliveryTargetStateError(+ stableOutput,+ 'failed delivery artifact',+ verification,+ );+ }+ }+ },+ capture: state?.deliveryTargets?.provenance,+ verifyAtomicOutput,+ fileBindingRuntime,});recorded = { ok: true, status: 'failed' };} catch (writeError) {if (writeError.deliveryOwnershipCode === 'delivery/ownership-lost') {recorded = { ok: false, status: 'unrecorded', ownershipError: writeError };+ } else if (writeError.deliveryProvenanceRecovery?.recoveryRequired) {+ const recovery = writeError.deliveryProvenanceRecovery;+ recorded = {+ ok: false,+ status: 'unrecorded',+ provenanceRecovery: writeError,+ diagnostic: diagnostic({+ code: 'delivery/provenance-recovery-required',+ message: 'Failed-delivery provenance could not be rolled back safely.',+ subject: { output: stableOutput, provenance: provenancePath },+ evidence: {+ reason: writeError.message,+ recoveryRequired: true,+ ...(recovery.recoveryDirectory ? { recoveryDirectory: recovery.recoveryDirectory } : {}),+ ...(recovery.recoveryFiles?.length ? { recoveryFiles: recovery.recoveryFiles } : {}),+ ...(recovery.rollbackErrors?.length ? { rollbackErrors: recovery.rollbackErrors } : {}),+ },+ supportedFixes: ['leave the delivery lock and journal untouched, inspect the retained recovery files, then recover serially'],+ }),+ };+ } else if (writeError.deliveryTargetState) {+ recorded = {+ ok: false,+ status: 'unrecorded',+ diagnostic: writeError.archifyDiagnostics?.[0],+ };} else {recorded = {ok: false,@@ -459,7 +1482,7 @@ function recordDeliveryFailure(options) {diagnostic: diagnostic({code: 'delivery/provenance-write',message: 'The failed delivery could not persist its stale-artifact marker.',- subject: { output: path.resolve(output), provenance: provenancePath },+ subject: { output: stableOutput, provenance: provenancePath },evidence: {reason: writeError.message,...(writeError?.code ? { systemCode: writeError.code } : {}),@@ -472,8 +1495,14 @@ function recordDeliveryFailure(options) {}}}+ }+ } finally {+ if (artifactBinding && typeof releaseRegularFileBinding === 'function') {+ releaseRegularFileBinding(artifactBinding);+ }}}+ if (recorded?.journalRecovery || recorded?.provenanceRecovery) return recorded;if (acquiredHere || shouldReleaseSuppliedOwnership) {try {releaseDeliveryOwnership(ownership, { allowInitializing: true });@@ -516,41 +1545,61 @@ function deliverySuccessProvenance(receipt) {};}-function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance = false } = {}) {- const sidecar = deliveryProvenancePath(artifactPath);+function inspectDeliveryProvenance(artifactPath, artifact, {+ requireProvenance = false,+ pathIdentityRuntime,+ expectedSidecar,+ inspection,+} = {}) {+ let sidecar = deliveryProvenancePath(artifactPath);+ const rawHeadSidecar = rawHeadDeliveryProvenancePath(artifactPath);const pending = deliveryPendingPath(artifactPath);- const lock = deliveryLockPath(artifactPath);+ const rawHeadPending = rawHeadDeliveryPendingPath(artifactPath);+ const stableOutput = canonicalExistingDeliveryOutput(artifactPath);+ const locks = [+ deliveryLockPath(stableOutput),+ ...legacyDeliveryLockPaths([artifactPath, stableOutput]),+ ];+ let foundPending;try {- if (pathEntryExists(pending)) {+ for (const candidate of [pending, rawHeadPending].filter(Boolean)) {+ if (pathEntryExists(candidate)) {+ foundPending = candidate;+ break;+ }+ }+ if (foundPending) {return {ok: false, status: 'failed',diagnostics: [diagnostic({code: 'delivery/provenance-failed',message: 'A delivery attempt is unfinished or failed; complete a successful deliver before trusting this artifact.',subject: { artifact: path.resolve(artifactPath), provenance: sidecar },- evidence: { pendingJournal: pending, found: true },+ evidence: { pendingJournal: foundPending, found: true },supportedFixes: ['finish any active delivery, then rerun deliver successfully; retain the pending journal until recovery succeeds'],})],};}} catch (error) {- return invalidProvenance(artifactPath, pending, error.message);+ return invalidProvenance(artifactPath, foundPending || pending, error.message);}- try {- if (pathEntryExists(lock)) {- return {- ok: false, status: 'locked',- diagnostics: [diagnostic({- code: 'delivery/provenance-locked',- message: 'Delivery ownership is unresolved while the output lock remains; complete or recover delivery before trusting this artifact.',- subject: { artifact: path.resolve(artifactPath), lock },- evidence: { deliveryLock: lock, found: true },- supportedFixes: ['finish the active delivery or inspect and recover the preserved lock, then rerun deliver successfully'],- })],- };+ for (const lock of locks) {+ try {+ if (pathEntryExists(lock)) {+ return {+ ok: false, status: 'locked',+ diagnostics: [diagnostic({+ code: 'delivery/provenance-locked',+ message: 'Delivery ownership is unresolved while the output lock remains; complete or recover delivery before trusting this artifact.',+ subject: { artifact: path.resolve(artifactPath), lock },+ evidence: { deliveryLock: lock, found: true },+ supportedFixes: ['finish the active delivery or inspect and recover the preserved lock, then rerun deliver successfully'],+ })],+ };+ }+ } catch (error) {+ return invalidProvenance(artifactPath, lock, error.message);}- } catch (error) {- return invalidProvenance(artifactPath, lock, error.message);}let found;try {@@ -558,6 +1607,14 @@ function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance =} catch (error) {return invalidProvenance(artifactPath, sidecar, error.message);}+ if (!found && rawHeadSidecar) {+ try {+ found = pathEntryExists(rawHeadSidecar);+ if (found) sidecar = rawHeadSidecar;+ } catch (error) {+ return invalidProvenance(artifactPath, rawHeadSidecar, error.message);+ }+ }if (!found) {if (!requireProvenance) return { ok: true, status: 'unknown' };const message = 'Delivery provenance is required, but the artifact has no .delivery.json sidecar.';@@ -574,16 +1631,51 @@ function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance =};}let receipt;+ let sidecarCapture;try {- if (!fs.lstatSync(sidecar).isFile()) throw new Error('Delivery provenance must be a regular file, not a symbolic link or directory.');- receipt = JSON.parse(fs.readFileSync(sidecar, 'utf8'));+ const {+ captureRegularFileBinding,+ releaseRegularFileBinding,+ } = pathIdentityRuntime || {};+ if (typeof captureRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ sidecarCapture = captureRegularFileBinding(sidecar, {+ subject: 'delivery-provenance',+ ...(expectedSidecar ? {+ expectedIdentity: expectedSidecar.identity,+ expectedSha256: expectedSidecar.content.sha256,+ expectedBytes: expectedSidecar.content.bytes,+ expectedMode: expectedSidecar.mode,+ } : {}),+ expectedLinks: 1,+ includeContent: true,+ });+ if (sidecarCapture.status !== 'captured') {+ if (sidecarCapture.reason?.code === 'delivery-provenance-hardlinked') {+ return {+ ok: false,+ status: 'unsupported',+ diagnostics: [diagnostic({+ code: 'delivery/provenance-hardlink-unsupported',+ message: 'Delivery provenance is hard-linked and cannot prove that every linked name was updated atomically.',+ subject: { artifact: path.resolve(artifactPath), provenance: sidecar },+ evidence: { links: sidecarCapture.reason.links },+ supportedFixes: ['remove extra hard links to the provenance sidecar, then rerun deliver'],+ })],+ };+ }+ throw new Error(`Delivery provenance is not a stable regular file (${sidecarCapture.reason?.code || 'unknown target state'}).`);+ }+ receipt = JSON.parse(sidecarCapture.content.buffer.toString('utf8'));const identityValid = (value) => value && typeof value.sha256 === 'string' && /^[0-9a-f]{64}$/.test(value.sha256)&& Number.isSafeInteger(value.bytes) && value.bytes >= 0;if (!receipt || typeof receipt !== 'object' || Array.isArray(receipt)|| receipt.schemaVersion !== 1 || receipt.command !== 'deliver'|| typeof receipt.receiptId !== 'string'|| !/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(receipt.receiptId)- || typeof receipt.output !== 'string' || !path.isAbsolute(receipt.output) || path.resolve(receipt.output) !== path.resolve(artifactPath)+ || typeof receipt.output !== 'string' || !path.isAbsolute(receipt.output)|| typeof receipt.input !== 'string' || !path.isAbsolute(receipt.input)|| !['current', 'failed'].includes(receipt.status)|| (receipt.status === 'current' && (!TYPES.has(receipt.type)@@ -591,6 +1683,20 @@ function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance =|| (receipt.status === 'failed' && typeof receipt.stage !== 'string')) {throw new Error('Delivery provenance does not conform to the supported receipt schema.');}+ if (inspection) {+ inspection.sidecar = {+ path: sidecar,+ identity: {+ device: sidecarCapture.identity.device,+ inode: sidecarCapture.identity.inode,+ },+ content: {+ sha256: sidecarCapture.content.sha256,+ bytes: sidecarCapture.content.bytes,+ },+ mode: sidecarCapture.mode,+ };+ }} catch (error) {const message = `Could not read delivery provenance: ${error.message}`;return {@@ -604,6 +1710,58 @@ function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance =supportedFixes: ['rerun deliver to replace the invalid provenance sidecar'],})],};+ } finally {+ if (sidecarCapture?.binding) {+ pathIdentityRuntime.releaseRegularFileBinding(sidecarCapture.binding);+ }+ }+ let outputIdentity;+ if (typeof pathIdentityRuntime?.sameEntry !== 'function') {+ const error = pathIdentityRuntime?.error;+ outputIdentity = {+ status: 'unknown',+ reason: {+ code: 'path-semantics-runtime-unavailable',+ ...(typeof error?.code === 'string' ? { systemCode: error.code } : {}),+ },+ };+ } else {+ try {+ outputIdentity = pathIdentityRuntime.sameEntry(receipt.output, artifactPath);+ } catch (error) {+ outputIdentity = {+ status: 'unknown',+ reason: {+ code: 'path-identity-check-failed',+ ...(typeof error?.code === 'string' ? { systemCode: error.code } : {}),+ },+ };+ }+ }+ if (outputIdentity.status === 'unknown') {+ return {+ ok: false,+ status: 'invalid',+ diagnostics: [diagnostic({+ code: 'delivery/provenance-output-indeterminate',+ message: 'Delivery provenance could not determine whether its recorded output identifies the inspected artifact.',+ subject: {+ artifact: path.resolve(artifactPath),+ provenance: sidecar,+ recordedOutput: receipt.output,+ },+ evidence: { pathIdentity: outputIdentity.reason },+ supportedFixes: ['restore access to both the artifact and its recorded output path, then rerun deliver successfully'],+ })],+ };+ }+ if (outputIdentity.status !== 'match') {+ return invalidProvenance(+ artifactPath,+ sidecar,+ 'The recorded delivery output does not identify this artifact.',+ { recordedOutput: receipt.output, pathIdentity: outputIdentity.reason },+ );}const actualSha256 = createHash('sha256').update(artifact).digest('hex');if (receipt.status === 'failed') {@@ -644,12 +1802,12 @@ function inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance =return { ok: true, status: 'current', receiptId: receipt.receiptId, artifact: receipt.artifact };}-function invalidProvenance(artifactPath, sidecar, reason) {+function invalidProvenance(artifactPath, sidecar, reason, evidence = {}) {return {ok: false, status: 'invalid',diagnostics: [diagnostic({code: 'delivery/provenance-invalid', message: 'Delivery provenance could not be verified.',- subject: { artifact: artifactPath, provenance: sidecar }, evidence: { reason },+ subject: { artifact: artifactPath, provenance: sidecar }, evidence: { reason, ...evidence },supportedFixes: ['restore access to the delivery records, then rerun deliver successfully'],})],};@@ -799,7 +1957,7 @@ function extractOutDirArgs(args) {}rest.push(arg);}- return { rest, outDir: outDir ? path.resolve(outDir) : undefined };+ return { rest, outDir };}function rendererEnv(quality, repoRoot, diagnosticJson = false) {@@ -823,6 +1981,18 @@ function diagnostic({ code, message, subject = {}, evidence = {}, supportedFixesfunction deliveryLockFailureDiagnostic(output, error) {const code = error.deliveryOwnershipCode || error.deliveryLockCode || 'delivery/lock-acquire';+ if (code === 'delivery/legacy-pending') {+ return diagnostic({+ code,+ message: `A pre-namespace delivery journal blocks delivery for "${output}".`,+ subject: { output, journal: error.deliveryLockPath },+ evidence: { pendingJournal: error.deliveryLockPath, found: true },+ supportedFixes: ['recover the unfinished delivery and remove only its journal after recovery succeeds'],+ });+ }+ const lock = error.deliveryOwnershipDetails?.lock+ || error.deliveryLockPath+ || deliveryLockPath(output);return diagnostic({code,message: code === 'delivery/lock-release'@@ -830,7 +2000,7 @@ function deliveryLockFailureDiagnostic(output, error) {: code === 'delivery/ownership-lost'? `Delivery ownership was lost for "${output}": ${error.message}`: `Could not start delivery for "${output}": ${error.message}`,- subject: { output, lock: deliveryLockPath(output) },+ subject: { output, lock },evidence: {reason: error.message,...(error.code ? { systemCode: error.code } : {}),@@ -844,7 +2014,7 @@ function deliveryLockFailureDiagnostic(output, error) {: code === 'delivery/lock-stale'? ['confirm no delivery attempt is active for this output',- `remove only the preserved lock "${deliveryLockPath(output)}", then rerun deliver successfully`,+ `remove only the preserved lock "${lock}", then rerun deliver successfully`,]: code === 'delivery/lock-path-conflict'? ['choose an output whose lock path is distinct from the input specification']@@ -858,6 +2028,156 @@ function deliveryLockFailureDiagnostic(output, error) {});}+function deliveryJournalRecoveryDiagnostic(output, error) {+ const recovery = error.deliveryJournalRecovery || {};+ const location = recovery.recoveryDirectory+ ? ` Recovery material was retained at "${recovery.recoveryDirectory}".`+ : '';+ return diagnostic({+ code: 'delivery/journal-recovery-required',+ message: `Delivery journal publication could not be rolled back safely.${location}`,+ subject: { output, journal: recovery.journal || deliveryPendingPath(output) },+ evidence: {+ reason: error.message,+ recoveryRequired: true,+ ...(recovery.recoveryDirectory ? { recoveryDirectory: recovery.recoveryDirectory } : {}),+ ...(recovery.recoveryFiles?.length ? { recoveryFiles: recovery.recoveryFiles } : {}),+ ...(recovery.rollbackErrors?.length ? { rollbackErrors: recovery.rollbackErrors } : {}),+ },+ supportedFixes: recovery.recoveryDirectory+ ? [+ 'leave the delivery lock and current journal claimant untouched',+ `inspect every recovery file in ${JSON.stringify(recovery.recoveryDirectory)} and restore the previous journal only after the claimant is resolved`,+ ]+ : ['leave the delivery lock and journal untouched, inspect their current owners, then recover serially'],+ });+}++function deliveryCommitRecoveryDiagnostic(output, error) {+ const recovery = error.deliveryCommitDetails || {};+ return diagnostic({+ code: 'delivery/commit-recovery-required',+ message: `Delivery rollback could not safely restore the previous output pair for "${output}".`,+ subject: { output },+ evidence: {+ reason: recovery.reason || error.message,+ recoveryRequired: true,+ ...(recovery.recoveryDirectory ? { recoveryDirectory: recovery.recoveryDirectory } : {}),+ ...(recovery.recoverableBackups?.length+ ? { recoverableBackups: recovery.recoverableBackups }+ : {}),+ ...(recovery.rollbackErrors?.length ? { rollbackErrors: recovery.rollbackErrors } : {}),+ },+ supportedFixes: [+ 'leave the delivery lock, journal, current claimants, and retained backups untouched',+ 'inspect the reported files and restore the previous pair only after resolving every claimant',+ ],+ });+}++function deliveryTargetStateDiagnostic(output, role, result) {+ const reason = result?.reason || { code: 'target-state-unavailable' };+ const hardlinked = typeof reason.code === 'string' && reason.code.endsWith('-hardlinked');+ const provenanceTarget = /provenance/iu.test(role);+ const code = hardlinked+ ? provenanceTarget ? 'delivery/provenance-hardlink-unsupported' : 'output/target-hardlinked'+ : ['target-not-regular-file', 'requested-entry-symbolic-link', 'requested-entry-not-regular-file'].includes(reason.code)+ ? 'output/target-not-regular-file'+ : result?.status === 'different'+ ? 'output/target-changed'+ : 'output/target-indeterminate';+ const message = hardlinked+ ? `The ${role} target is hard-linked and cannot be replaced atomically.`+ : code === 'output/target-not-regular-file'+ ? `The ${role} target is not a regular file.`+ : code === 'output/target-changed'+ ? `The ${role} target changed while the verified delivery pair was being prepared.`+ : `The ${role} target identity could not be determined safely.`;+ return diagnostic({+ code,+ message,+ subject: { output: path.resolve(output), role },+ evidence: { targetState: reason },+ supportedFixes: hardlinked+ ? ['remove extra hard links or choose a new output path, then rerun deliver']+ : code === 'output/target-not-regular-file'+ ? ['choose an absent or regular-file target, then rerun deliver']+ : code === 'output/target-changed'+ ? ['retry only after other processes stop creating, replacing, retargeting, or changing the output pair']+ : ['use an ordinary local filesystem path with stable file identity, then retry'],+ });+}++function deliveryTargetStateError(output, role, result) {+ const issue = deliveryTargetStateDiagnostic(output, role, result);+ const error = new Error(issue.message);+ error.archifyDiagnostics = [issue];+ error.deliveryTargetState = result;+ return error;+}++function captureDeliveryTargetState({+ state,+ requestedOutput,+ pathsAlias,+ captureAtomicOutput,+ verifyAtomicOutput,+ preparedTargets,+}) {+ if (typeof captureAtomicOutput !== 'function' || typeof verifyAtomicOutput !== 'function') {+ throw deliveryTargetStateError(requestedOutput, 'delivery pair', {+ status: 'unknown',+ reason: { code: 'atomic-output-runtime-unavailable' },+ });+ }+ const artifactTarget = preparedTargets?.artifact || {+ requestedPath: requestedOutput,+ ...captureAtomicOutput(requestedOutput),+ };+ if (artifactTarget.status !== 'captured') {+ throw deliveryTargetStateError(requestedOutput, 'HTML artifact', artifactTarget);+ }+ if (!pathsAlias(artifactTarget.commitPath, state.output)) {+ throw deliveryTargetStateError(requestedOutput, 'HTML artifact', {+ status: 'different',+ reason: {+ code: 'write-slot-changed-before-snapshot',+ plannedCommitPath: state.output,+ currentCommitPath: artifactTarget.commitPath,+ },+ });+ }+ const requestedProvenancePath = preparedTargets?.provenance?.requestedPath+ || deliveryProvenancePath(artifactTarget.commitPath);+ const provenanceTarget = preparedTargets?.provenance || {+ requestedPath: requestedProvenancePath,+ ...captureAtomicOutput(requestedProvenancePath, {+ requestedEntryPolicy: 'regular-or-absent',+ }),+ };+ if (provenanceTarget.status !== 'captured') {+ throw deliveryTargetStateError(requestedProvenancePath, 'delivery provenance', provenanceTarget);+ }+ for (const [role, target] of [+ ['HTML artifact', artifactTarget],+ ['delivery provenance', provenanceTarget],+ ]) {+ const verification = verifyAtomicOutput(target.snapshot);+ if (verification.status !== 'match') {+ throw deliveryTargetStateError(target.requestedPath, role, verification);+ }+ }+ state.output = artifactTarget.commitPath;+ state.provenancePath = provenanceTarget.commitPath;+ state.pendingPath = deliveryPendingPath(artifactTarget.commitPath);+ state.verifyAtomicOutput = verifyAtomicOutput;+ state.deliveryTargets = {+ artifact: artifactTarget,+ provenance: provenanceTarget,+ };+ return state.deliveryTargets;+}+function inputDiagnostic(error, inputPath) {const isSyntax = error instanceof SyntaxError;return diagnostic({@@ -1033,8 +2353,11 @@ function extractCompareOptions(args) {}function compareReceiptPath(outputPath) {- const extension = path.extname(outputPath);- return extension ? `${outputPath.slice(0, -extension.length)}.receipt.json` : `${outputPath}.receipt.json`;+ const { directory, stem, options } = deliverySidecarNamespace(outputPath);+ return path.join(+ directory,+ `${boundedSidecarStem(stem, COMPARE_SIDECAR_SUFFIXES, options)}.receipt.json`,+ );}function compareCommitError(message, code, details = {}) {@@ -1045,135 +2368,555 @@ function compareCommitError(message, code, details = {}) {return error;}-function commitComparePair({ htmlCandidate, receiptCandidate, outputPath, receiptPath, stagingDirectory }) {+function compareAtomicOutputFailure(result, label, requestedPath, stage) {+ const reason = result.reason || { code: 'atomic-output-unknown' };+ let code = 'output/target-indeterminate';+ let message = `The compare ${label} target identity could not be verified safely.`;+ let supportedFixes = ['use an ordinary local filesystem path with stable file identity, then retry'];+ if (typeof reason.code === 'string' && reason.code.endsWith('-hardlinked')) {+ code = 'output/target-hardlinked';+ message = `The compare ${label} target has multiple hard links and cannot be replaced atomically.`;+ supportedFixes = [`choose a ${label} path that is absent or names a regular file with one link`];+ } else if (reason.code === 'target-not-regular-file') {+ code = 'output/target-not-regular-file';+ message = `The compare ${label} target is not a regular file.`;+ supportedFixes = [`choose an absent or regular-file path for the ${label}`];+ } else if (result.status === 'different') {+ code = 'output/target-changed';+ message = `The compare ${label} target changed while the artifact pair was being prepared.`;+ supportedFixes = ['retry after other processes stop creating, replacing, or redirecting compare outputs'];+ }+ return {+ stage,+ code,+ message,+ details: {+ side: label,+ path: requestedPath,+ atomicOutput: reason,+ supportedFixes,+ },+ };+}++function commitComparePair({+ htmlCandidate,+ htmlContent,+ receiptCandidate,+ receiptContent,+ outputCapture,+ receiptCapture,+ stagingDirectory,+ verifyAtomicOutput,+ fileBindingRuntime,+}) {+ const {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};const targets = [- { label: 'HTML artifact', target: outputPath, candidate: htmlCandidate, backup: path.join(stagingDirectory, '.previous-output') },- { label: 'receipt', target: receiptPath, candidate: receiptCandidate, backup: path.join(stagingDirectory, '.previous-receipt') },+ {+ label: 'HTML artifact', capture: outputCapture, candidate: htmlCandidate, content: htmlContent, backup: path.join(stagingDirectory, '.previous-output'),+ },+ {+ label: 'receipt', capture: receiptCapture, candidate: receiptCandidate, content: receiptContent, backup: path.join(stagingDirectory, '.previous-receipt'),+ },];-- // Preflight the whole pair before moving either trusted target. This avoids- // replacing the HTML and only then discovering that its receipt destination- // cannot be committed (for example, because it is a directory).- for (const item of targets) {- if (!fs.existsSync(item.target)) continue;- const existing = fs.lstatSync(item.target);- if (!existing.isFile()) {- throw compareCommitError(- `Could not commit Architecture Delta: existing ${item.label} target is not a regular file.`,- 'delta/commit-target',- {- target: path.basename(item.target),- targetType: existing.isDirectory() ? 'directory' : 'non-file',- supportedFixes: [`choose a regular-file path for the ${item.label}`],- },- );- }- }+ const targetChanged = (item, result) => {+ const normalized = typeof result === 'string'+ ? { status: 'different', reason: { code: result } }+ : result;+ const failure = compareAtomicOutputFailure(+ normalized,+ item.label,+ item.capture.snapshot.requestedPath,+ 'commit',+ );+ const error = compareCommitError(failure.message, failure.code, failure.details);+ error.compareFailure = failure;+ return error;+ };const backedUp = [];const committed = [];try {+ if (typeof backupPublicRegularFileBinding !== 'function'+ || typeof captureRegularFileBinding !== 'function'+ || typeof quarantineRemoveRegularFileBinding !== 'function'+ || typeof verifyRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw targetChanged(targets[0], {+ status: 'unknown',+ reason: { code: 'atomic-output-runtime-unavailable' },+ });+ }+ // Re-resolve and bind both requested write slots and candidate inodes+ // before moving either target. The held handles keep bytes, mode and+ // identity authoritative across every publish/finalize transition.+ for (const item of targets) {+ const verification = verifyAtomicOutput(item.capture.snapshot);+ if (verification.status !== 'match') throw targetChanged(item, verification);+ if (item.capture.mode !== null) fs.chmodSync(item.candidate, item.capture.mode);+ const candidate = captureRegularFileBinding(item.candidate, {+ subject: 'compare-candidate',+ expectedSha256: item.content.sha256,+ expectedBytes: item.content.bytes,+ ...(item.capture.mode === null ? {} : { expectedMode: item.capture.mode }),+ expectedLinks: 1,+ });+ if (candidate.status !== 'captured') throw targetChanged(item, candidate);+ item.candidateBinding = candidate.binding;+ item.candidatePresent = true;+ item.candidateIdentity = {+ dev: candidate.identity.device,+ ino: candidate.identity.inode,+ };+ item.candidateMode = candidate.mode;+ if (item.capture.snapshot.target.kind === 'file') {+ const expected = item.capture.snapshot.target;+ const previous = captureRegularFileBinding(item.capture.commitPath, {+ subject: 'previous-compare-target',+ expectedIdentity: { device: expected.device, inode: expected.inode },+ expectedMode: expected.mode,+ expectedLinks: 1,+ });+ if (previous.status !== 'captured') throw targetChanged(item, previous);+ item.previousBinding = previous.binding;+ }+ }for (const item of targets) {- if (!fs.existsSync(item.target)) continue;- fs.renameSync(item.target, item.backup);- backedUp.push(item);+ if (item.capture.snapshot.target.kind !== 'file') continue;+ const moved = backupPublicRegularFileBinding(+ item.previousBinding,+ item.capture.commitPath,+ item.backup,+ { subject: 'previous-compare-target' },+ );+ item.backupPresent = moved.backupCreated === true;+ item.backupVerified = moved.backupVerified === true;+ if (item.backupPresent) backedUp.push(item);+ if (moved.status === 'recovery-required' && moved.recoveryFile) {+ item.backupRecovery = moved.recoveryFile;+ }+ if (moved.status !== 'backed-up') throw targetChanged(item, moved);}for (const item of targets) {- fs.renameSync(item.candidate, item.target);+ const candidate = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.candidate,+ expectedLinks: 1,+ });+ if (candidate.status !== 'match') throw targetChanged(item, candidate);+ try {+ // linkSync is the no-clobber publish primitive: unlike renameSync, it+ // fails with EEXIST if another writer claims an absent slot after the+ // final snapshot verification.+ fs.linkSync(item.candidate, item.capture.commitPath);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw targetChanged(+ item,+ 'target-claimed-during-publish',+ );+ }+ throw error;+ }+ item.committedIdentity = item.candidateIdentity;committed.push(item);+ const linked = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.capture.commitPath,+ expectedLinks: 2,+ });+ if (linked.status !== 'match') throw targetChanged(item, linked);+ }+ for (const item of committed) {+ const current = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.capture.commitPath,+ expectedLinks: 2,+ });+ if (current.status !== 'match') throw targetChanged(item, current);+ }+ // The target remains the durable link. Removing the staging links inside+ // the transaction keeps successful outputs at nlink=1 even if the outer+ // best-effort staging-directory cleanup later fails.+ for (const item of committed) {+ const staged = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.candidate,+ expectedLinks: 2,+ });+ if (staged.status !== 'match') throw targetChanged(item, staged);+ fs.unlinkSync(item.candidate);+ item.candidatePresent = false;+ }+ for (const item of committed) {+ const finalized = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.capture.commitPath,+ expectedLinks: 1,+ });+ if (finalized.status !== 'match') throw targetChanged(item, finalized);}} catch (cause) {const rollbackErrors = [];- const recoveryFiles = [];+ const recoveryFiles = targets+ .filter((item) => item.backupRecovery)+ .map((item) => ({+ backup: item.backupRecovery,+ target: item.capture.commitPath,+ verifiedPrevious: false,+ }));for (const item of [...committed].reverse()) {try {- fs.rmSync(item.target, { force: true });+ const removed = quarantineRemoveRegularFileBinding(+ item.candidateBinding,+ item.capture.commitPath,+ {+ subject: 'published-compare-target',+ expectedLinks: item.candidatePresent ? 2 : 1,+ },+ );+ if (removed.status !== 'removed') {+ if (removed.status === 'recovery-required') {+ recoveryFiles.push({+ backup: removed.recoveryFile,+ target: item.capture.commitPath,+ });+ }+ throw new Error(`the committed target could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ }} catch (error) {rollbackErrors.push(`${item.label}: remove failed (${error.message})`);}}for (const item of [...backedUp].reverse()) {try {- if (fs.existsSync(item.target)) fs.rmSync(item.target, { force: true });- fs.renameSync(item.backup, item.target);+ if (pathEntryExists(item.capture.commitPath)) {+ const current = item.candidateBinding+ ? verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.capture.commitPath,+ expectedLinks: item.candidatePresent ? 2 : 1,+ })+ : { status: 'different' };+ if (current.status !== 'match') {+ throw new Error(`a changed target claimant prevents restoring the previous file (${current.reason?.code || 'unknown target state'})`);+ }+ const removed = quarantineRemoveRegularFileBinding(+ item.candidateBinding,+ item.capture.commitPath,+ {+ subject: 'published-compare-target',+ expectedLinks: item.candidatePresent ? 2 : 1,+ },+ );+ if (removed.status !== 'removed') {+ if (removed.status === 'recovery-required') {+ recoveryFiles.push({+ backup: removed.recoveryFile,+ target: item.capture.commitPath,+ });+ }+ throw new Error(`the committed target could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ }+ }+ if (item.backupVerified !== true) {+ throw new Error('the backup entry was never verified as the previous file');+ }+ const currentBackup = verifyRegularFileBinding(item.previousBinding, {+ filePath: item.backup,+ expectedLinks: 1,+ });+ if (currentBackup.status !== 'match') {+ item.backupVerified = false;+ throw new Error('the recoverable backup was replaced before rollback');+ }+ // Publish the previous file without clobbering a claimant that appears+ // after the absence check. The backup remains the recovery source until+ // the restored hard link has been identity-verified.+ fs.linkSync(item.backup, item.capture.commitPath);+ for (const restoredPath of [item.capture.commitPath, item.backup]) {+ const restored = verifyRegularFileBinding(item.previousBinding, {+ filePath: restoredPath,+ expectedLinks: 2,+ });+ if (restored.status !== 'match') {+ throw new Error('the restored target identity could not be verified');+ }+ }+ fs.unlinkSync(item.backup);+ item.backupPresent = false;+ const finalized = verifyRegularFileBinding(item.previousBinding, {+ filePath: item.capture.commitPath,+ expectedLinks: 1,+ });+ if (finalized.status !== 'match') {+ throw new Error('the restored target changed before rollback finalized');+ }} catch (error) {rollbackErrors.push(`${item.label}: restore failed (${error.message})`);// Track failed restoration rather than probing existence: a permission// error must not make cleanup discard a potentially recoverable backup.- recoveryFiles.push({ backup: item.backup, target: item.target });+ if (item.backupPresent !== false) {+ recoveryFiles.push({+ backup: item.backup,+ target: item.capture.commitPath,+ verifiedPrevious: item.backupVerified === true,+ });+ }}}+ if (!rollbackErrors.length && cause.compareFailure) {+ throw compareCommitError(+ cause.message,+ cause.compareFailure.code,+ {+ ...cause.compareFailure.details,+ reason: cause.message,+ },+ );+ }throw compareCommitError((rollbackErrors.length? 'Architecture Delta pair commit failed and its previous files could not be fully restored.': 'Architecture Delta pair commit failed; the previous files were restored.')- + (recoveryFiles.length ? ` Recovery directory retained at ${stagingDirectory}.` : ''),+ + (recoveryFiles.length+ ? ` Recovery directory retained at ${path.dirname(recoveryFiles[0].backup)}.`+ : ''),rollbackErrors.length ? 'delta/commit-rollback-failed' : 'delta/commit-failed',{reason: cause.message,...(rollbackErrors.length ? { rollbackErrors } : {}),- ...(recoveryFiles.length ? { recoveryDirectory: stagingDirectory, recoveryFiles } : {}),+ ...(recoveryFiles.length ? {+ recoveryDirectory: path.dirname(recoveryFiles[0].backup),+ recoveryDirectories: [...new Set(recoveryFiles.map(({ backup }) => path.dirname(backup)))],+ recoveryFiles,+ } : {}),supportedFixes: recoveryFiles.length? [- ...recoveryFiles.map(({ backup, target }) => `resolve the filesystem error, inspect the current target, then restore ${JSON.stringify(backup)} to ${JSON.stringify(target)} before retrying`),+ ...recoveryFiles.map(({ backup, target, verifiedPrevious }) => verifiedPrevious+ ? `resolve the filesystem error, inspect the current target, then restore ${JSON.stringify(backup)} to ${JSON.stringify(target)} before retrying`+ : `preserve and inspect the unverified entry at ${JSON.stringify(backup)}; do not treat it as the previous file for ${JSON.stringify(target)}`),'remove the recovery directory only after the previous files have been recovered and verified',]: ['check that both output paths are writable regular files, then retry'],},);+ } finally {+ for (const item of targets) {+ if (item.candidateBinding) releaseRegularFileBinding(item.candidateBinding);+ if (item.previousBinding) releaseRegularFileBinding(item.previousBinding);+ }}}-function commitDeliveryPair({ htmlCandidate, provenanceCandidate, outputPath, provenancePath, stagingDirectory, ownership }) {+function commitDeliveryPair({+ htmlCandidate,+ htmlContent,+ provenanceCandidate,+ provenanceContent,+ stagingDirectory,+ ownership,+ verifyAtomicOutput,+ fileBindingRuntime,+}) {+ const {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = fileBindingRuntime || {};+ const state = assertDeliveryOwnership(ownership, 'start the delivery pair commit', { pending: 'owned' });+ const snapshots = state.deliveryTargets;+ if (!snapshots?.artifact || !snapshots?.provenance) {+ throw deliveryTargetStateError(state.output, 'delivery pair', {+ status: 'unknown',+ reason: { code: 'target-snapshot-missing' },+ });+ }const targets = [- { label: 'HTML artifact', target: outputPath, candidate: htmlCandidate, backup: path.join(stagingDirectory, '.previous-output') },- { label: 'delivery provenance', target: provenancePath, candidate: provenanceCandidate, backup: path.join(stagingDirectory, '.previous-provenance') },+ {+ label: 'HTML artifact',+ target: snapshots.artifact.commitPath,+ candidate: htmlCandidate,+ content: htmlContent,+ backup: path.join(stagingDirectory, '.previous-output'),+ capture: snapshots.artifact,+ },+ {+ label: 'delivery provenance',+ target: snapshots.provenance.commitPath,+ candidate: provenanceCandidate,+ content: provenanceContent,+ backup: path.join(stagingDirectory, '.previous-provenance'),+ capture: snapshots.provenance,+ },];- assertDeliveryOwnership(ownership, 'start the delivery pair commit', { pending: 'owned' });- for (const item of targets) {- if (!fs.existsSync(item.target)) continue;- const existing = fs.lstatSync(item.target);- if (!existing.isFile()) {- const error = new Error(`Existing ${item.label} target is not a regular file.`);- error.deliveryCommitDetails = {- target: item.target,- targetType: existing.isDirectory() ? 'directory' : 'non-file',- };- throw error;- }- }-const backedUp = [];const retainedBackups = new Set();+ const publicRecoveryBackups = [];const committed = [];try {+ if (typeof backupPublicRegularFileBinding !== 'function'+ || typeof captureRegularFileBinding !== 'function'+ || typeof quarantineRemoveRegularFileBinding !== 'function'+ || typeof verifyRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw deliveryTargetStateError(state.output, 'delivery pair', {+ status: 'unknown',+ reason: { code: 'atomic-output-runtime-unavailable' },+ });+ }+ for (const item of targets) {+ const verification = verifyAtomicOutput(item.capture.snapshot);+ if (verification.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, verification);+ }+ if (item.capture.mode !== null) fs.chmodSync(item.candidate, item.capture.mode);+ const candidate = captureRegularFileBinding(item.candidate, {+ subject: 'delivery-candidate',+ expectedSha256: item.content.sha256,+ expectedBytes: item.content.bytes,+ ...(item.capture.mode === null ? {} : { expectedMode: item.capture.mode }),+ expectedLinks: 1,+ });+ if (candidate.status !== 'captured') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, candidate);+ }+ item.candidateBinding = candidate.binding;+ item.candidatePresent = true;+ item.candidateIdentity = {+ dev: candidate.identity.device,+ ino: candidate.identity.inode,+ };+ item.candidateMode = candidate.mode;+ if (item.capture.snapshot.target.kind === 'file') {+ const expected = item.capture.snapshot.target;+ const previous = captureRegularFileBinding(item.target, {+ subject: 'previous-delivery-target',+ expectedIdentity: { device: expected.device, inode: expected.inode },+ expectedMode: expected.mode,+ expectedLinks: 1,+ });+ if (previous.status !== 'captured') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, previous);+ }+ item.previousBinding = previous.binding;+ }+ }for (const item of targets) {- if (!fs.existsSync(item.target)) continue;+ if (item.capture.snapshot.target.kind !== 'file') continue;assertDeliveryOwnership(ownership, `back up the ${item.label}`, { pending: 'owned' });- fs.renameSync(item.target, item.backup);- backedUp.push(item);+ const moved = backupPublicRegularFileBinding(+ item.previousBinding,+ item.target,+ item.backup,+ { subject: 'previous-delivery-target' },+ );+ item.backupPresent = moved.backupCreated === true;+ item.backupVerified = moved.backupVerified === true;+ if (item.backupPresent) backedUp.push(item);+ if (moved.status === 'recovery-required' && moved.recoveryFile) {+ publicRecoveryBackups.push({+ label: `preserved replacement for ${item.label}`,+ path: moved.recoveryFile,+ target: item.target,+ });+ }+ if (moved.status !== 'backed-up') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, moved);+ }retainedBackups.add(item);}for (const item of targets) {assertDeliveryOwnership(ownership, `commit the ${item.label}`, { pending: 'owned' });- fs.renameSync(item.candidate, item.target);+ const candidate = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.candidate,+ expectedLinks: 1,+ });+ if (candidate.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, candidate);+ }+ try {+ fs.linkSync(item.candidate, item.target);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, {+ status: 'different',+ reason: { code: 'target-claimed-during-publish' },+ });+ }+ throw error;+ }+ item.committedIdentity = item.candidateIdentity;committed.push(item);+ const linked = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.target,+ expectedLinks: 2,+ });+ if (linked.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, linked);+ }+ }+ for (const item of committed) {+ assertDeliveryOwnership(ownership, `verify the committed ${item.label}`, { pending: 'owned' });+ const current = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.target,+ expectedLinks: 2,+ });+ if (current.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, current);+ }+ }+ for (const item of committed) {+ const staged = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.candidate,+ expectedLinks: 2,+ });+ if (staged.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, staged);+ }+ fs.unlinkSync(item.candidate);+ item.candidatePresent = false;+ }+ for (const item of committed) {+ const finalized = verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.target,+ expectedLinks: 1,+ });+ if (finalized.status !== 'match') {+ throw deliveryTargetStateError(item.capture.requestedPath, item.label, finalized);+ }}// Finalization is part of the commit: keep the old files recoverable until// the journal has been removed and checkers can accept the new artifact.- const state = assertDeliveryOwnership(ownership, 'finalize the delivery journal', { pending: 'owned' });- fs.unlinkSync(deliveryPendingPath(outputPath));+ assertDeliveryOwnership(ownership, 'finalize the delivery journal', { pending: 'owned' });+ quarantineRemoveOwnedDeliveryEntry(state, {+ filePath: state.pendingPath,+ identity: state.pendingIdentity,+ content: state.pendingContent,+ subject: 'delivery-journal',+ operation: 'finalize the delivery journal',+ evidenceKey: 'journal',+ });assertDeliveryOwnership(ownership, 'finish finalizing the delivery journal', { pending: 'absent' });state.pendingIdentity = undefined;+ state.pendingContent = undefined;state.phase = 'finalized';return {- recoverableBackups: [...retainedBackups].map((item) => ({ label: item.label, path: item.backup })),+ recoverableBackups: [+ ...[...retainedBackups].map((item) => ({ label: item.label, path: item.backup })),+ ...publicRecoveryBackups,+ ],};} catch (cause) {const recoveryDetails = () => ({recoveryRequired: true,recoveryDirectory: stagingDirectory,- recoverableBackups: [...retainedBackups].map((item) => ({ label: item.label, path: item.backup })),+ recoverableBackups: [+ ...[...retainedBackups].map((item) => ({ label: item.label, path: item.backup })),+ ...publicRecoveryBackups,+ ],});if (cause.deliveryOwnershipCode === 'delivery/ownership-lost') {cause.deliveryCommitDetails = { ...(cause.deliveryCommitDetails || {}), ...recoveryDetails() };@@ -1185,7 +2928,20 @@ function commitDeliveryPair({ htmlCandidate, provenanceCandidate, outputPath, prfor (const item of [...committed].reverse()) {try {assertDeliveryOwnership(ownership, `roll back the ${item.label}`, { pending: 'identity' });- fs.rmSync(item.target, { force: true });+ const removed = quarantineRemoveRegularFileBinding(item.candidateBinding, item.target, {+ subject: 'published-delivery-target',+ expectedLinks: item.candidatePresent ? 2 : 1,+ });+ if (removed.status !== 'removed') {+ if (removed.status === 'recovery-required') {+ publicRecoveryBackups.push({+ label: `preserved replacement for ${item.label}`,+ path: removed.recoveryFile,+ target: item.target,+ });+ }+ throw new Error(`the committed target could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ }} catch (error) {if (error.deliveryOwnershipCode === 'delivery/ownership-lost') throw error;rollbackErrors.push(`${item.label}: remove failed (${error.message})`);@@ -1194,16 +2950,86 @@ function commitDeliveryPair({ htmlCandidate, provenanceCandidate, outputPath, prfor (const item of [...backedUp].reverse()) {try {assertDeliveryOwnership(ownership, `restore the previous ${item.label}`, { pending: 'identity' });- if (fs.existsSync(item.target)) fs.rmSync(item.target, { force: true });+ if (pathEntryExists(item.target)) {+ const current = item.candidateBinding+ ? verifyRegularFileBinding(item.candidateBinding, {+ filePath: item.target,+ expectedLinks: item.candidatePresent ? 2 : 1,+ })+ : { status: 'different' };+ if (current.status !== 'match') {+ throw new Error(`a changed target claimant prevents restoring the previous file (${current.reason?.code || 'unknown target state'})`);+ }+ const removed = quarantineRemoveRegularFileBinding(item.candidateBinding, item.target, {+ subject: 'published-delivery-target',+ expectedLinks: item.candidatePresent ? 2 : 1,+ });+ if (removed.status !== 'removed') {+ if (removed.status === 'recovery-required') {+ publicRecoveryBackups.push({+ label: `preserved replacement for ${item.label}`,+ path: removed.recoveryFile,+ target: item.target,+ });+ }+ throw new Error(`the committed target could not be removed safely (${removed.reason?.code || 'unknown target state'})`);+ }+ }assertDeliveryOwnership(ownership, `restore the previous ${item.label}`, { pending: 'identity' });- fs.renameSync(item.backup, item.target);+ if (item.backupVerified !== true) {+ throw new Error('the backup entry was never verified as the previous delivery file');+ }+ const currentBackup = verifyRegularFileBinding(item.previousBinding, {+ filePath: item.backup,+ expectedLinks: 1,+ });+ if (currentBackup.status !== 'match') {+ item.backupVerified = false;+ retainedBackups.delete(item);+ throw new Error('the previous delivery backup identity changed');+ }+ try {+ fs.linkSync(item.backup, item.target);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ throw new Error('a new target claimant prevents restoring the previous file');+ }+ throw error;+ }+ for (const restoredPath of [item.target, item.backup]) {+ const restored = verifyRegularFileBinding(item.previousBinding, {+ filePath: restoredPath,+ expectedLinks: 2,+ });+ if (restored.status !== 'match') {+ throw new Error('the restored delivery target identity could not be verified');+ }+ }+ fs.unlinkSync(item.backup);+ item.backupPresent = false;+ const restoredFinal = verifyRegularFileBinding(item.previousBinding, {+ filePath: item.target,+ expectedLinks: 1,+ });+ if (restoredFinal.status !== 'match') {+ throw new Error('the restored delivery target link count could not be verified');+ }retainedBackups.delete(item);} catch (error) {if (error.deliveryOwnershipCode === 'delivery/ownership-lost') throw error;rollbackErrors.push(`${item.label}: restore failed (${error.message})`);// A failed restoration leaves this exact backup at its source path.// Record it without probing the failing recovery path again.- recoverableBackups.push({ label: item.label, path: item.backup });+ if (item.backupPresent !== false) {+ recoverableBackups.push({+ label: item.backupVerified === true+ ? item.label+ : `unverified preserved backup entry for ${item.label}`,+ path: item.backup,+ target: item.target,+ verifiedPrevious: item.backupVerified === true,+ });+ }}}assertDeliveryOwnership(ownership, 'finish the delivery rollback', { pending: 'identity' });@@ -1230,10 +3056,19 @@ function commitDeliveryPair({ htmlCandidate, provenanceCandidate, outputPath, prrollbackErrors,recoveryRequired: true,recoveryDirectory: stagingDirectory,- recoverableBackups,+ recoverableBackups: [...recoverableBackups, ...publicRecoveryBackups],} : {}),};+ if (cause.deliveryTargetState) {+ error.deliveryTargetState = cause.deliveryTargetState;+ error.archifyDiagnostics = cause.archifyDiagnostics;+ }throw error;+ } finally {+ for (const item of targets) {+ if (item.candidateBinding) releaseRegularFileBinding(item.candidateBinding);+ if (item.previousBinding) releaseRegularFileBinding(item.previousBinding);+ }}}@@ -1273,7 +3108,28 @@ function renderValidatedArchitecture(inputPath, outputPath, quality, repoRoot) {}async function commandCompare(args) {- const { resolveOutputPath } = await import('../renderers/shared/output-path.mjs');+ const { canonicalFuturePath, resolveOutputPath } = await import('../renderers/shared/output-path.mjs');+ const {+ captureAtomicOutput,+ verifyAtomicOutput,+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = await import('../renderers/shared/atomic-output.mjs');+ const fileBindingRuntime = {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ };+ const {+ sameParent,+ sidecarNamespaceComponentKey,+ } = await import('../renderers/shared/path-semantics.mjs');+ sidecarNamespaceComponentKeyRuntime = sidecarNamespaceComponentKey;const qualityArgs = extractQualityArgs(args);const repoArgs = extractRepoRootArgs(qualityArgs.rest);const options = extractCompareOptions(repoArgs.rest);@@ -1301,14 +3157,27 @@ async function commandCompare(args) {const basePath = path.resolve(baseInput);const headPath = path.resolve(headInput);- const receiptTarget = options.receipt || compareReceiptPath(path.resolve(requestedOutput || 'architecture-delta.html'));+ const explicitReceiptTarget = options.receipt ? path.resolve(options.receipt) : undefined;+ const rawOutputTarget = requestedOutput || 'architecture-delta.html';+ const rawOutputExtension = path.extname(rawOutputTarget);+ // Preserve the established alias-first diagnostic for an already-invalid+ // CLI extension without letting this legacy spelling select the real+ // sidecar namespace for any valid compare output.+ const invalidOutputAliasPreflight = !explicitReceiptTarget+ && rawOutputExtension.toLowerCase() !== '.html'+ ? path.resolve(rawOutputExtension+ ? `${rawOutputTarget.slice(0, -rawOutputExtension.length)}.receipt.json`+ : `${rawOutputTarget}.receipt.json`)+ : undefined;let outputPath;try {({ outputPath } = resolveOutputPath({requestedOutput,defaultOutput: 'architecture-delta.html',inputPaths: [basePath, headPath],- otherOutputPaths: [path.resolve(receiptTarget)],+ otherOutputPaths: explicitReceiptTarget+ ? [explicitReceiptTarget]+ : (invalidOutputAliasPreflight ? [invalidOutputAliasPreflight] : []),}));} catch (error) {const outputDiagnostic = error.archifyDiagnostics?.[0];@@ -1325,15 +3194,38 @@ async function commandCompare(args) {});return;}+ const requestedOutputPath = outputPath;let receiptPath;+ let requestedReceiptPath;+ if (explicitReceiptTarget) {+ try {+ ({ outputPath: receiptPath } = resolveOutputPath({+ requestedOutput: options.receipt,+ defaultOutput: options.receipt,+ requiredExtension: '.json',+ inputPaths: [basePath, headPath],+ otherOutputPaths: [outputPath],+ }));+ requestedReceiptPath = receiptPath;+ } catch (error) {+ const outputDiagnostic = error.archifyDiagnostics?.[0];+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: error.message,+ code: outputDiagnostic?.code || 'output/path-resolution',+ details: {+ ...(outputDiagnostic?.subject || {}),+ ...(outputDiagnostic?.evidence || {}),+ supportedFixes: outputDiagnostic?.supportedFixes || ['choose a safe receipt path and retry'],+ },+ });+ return;+ }+ }try {- ({ outputPath: receiptPath } = resolveOutputPath({- requestedOutput: options.receipt || compareReceiptPath(outputPath),- defaultOutput: compareReceiptPath(outputPath),- requiredExtension: '.json',- inputPaths: [basePath, headPath],- otherOutputPaths: [outputPath],- }));+ outputPath = canonicalFuturePath(requestedOutputPath);+ if (requestedReceiptPath) receiptPath = canonicalFuturePath(requestedReceiptPath);} catch (error) {const outputDiagnostic = error.archifyDiagnostics?.[0];reportCompareFailure({@@ -1344,7 +3236,7 @@ async function commandCompare(args) {details: {...(outputDiagnostic?.subject || {}),...(outputDiagnostic?.evidence || {}),- supportedFixes: outputDiagnostic?.supportedFixes || ['choose a safe receipt path and retry'],+ supportedFixes: outputDiagnostic?.supportedFixes || ['choose safe compare output paths and retry'],},});return;@@ -1368,17 +3260,150 @@ async function commandCompare(args) {return;}- const outputDirectory = path.dirname(outputPath);- if (path.dirname(receiptPath) !== outputDirectory) {- reportCompareFailure({ json: options.json, stage: 'prepare', error: 'The compare receipt must be written beside the HTML artifact.', code: 'delta/receipt-directory', details: { supportedFixes: ['choose a --receipt path in the same directory as output.html'] } });+ let outputDirectory = path.dirname(outputPath);+ if (receiptPath) {+ const explicitReceiptDirectoryIdentity = sameParent(outputPath, receiptPath);+ if (explicitReceiptDirectoryIdentity.status === 'unknown') {+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: 'The compare receipt directory identity could not be verified.',+ code: 'delta/receipt-directory-identity-indeterminate',+ details: {+ artifactDirectory: outputDirectory,+ receiptDirectory: path.dirname(receiptPath),+ pathIdentity: explicitReceiptDirectoryIdentity.reason,+ supportedFixes: ['restore access to both output directories or choose paths in one verifiable directory'],+ },+ });+ return;+ }+ if (explicitReceiptDirectoryIdentity.status !== 'match') {+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: 'The compare receipt must be written beside the HTML artifact.',+ code: 'delta/receipt-directory',+ details: {+ artifactDirectory: outputDirectory,+ receiptDirectory: path.dirname(receiptPath),+ pathIdentity: explicitReceiptDirectoryIdentity.reason,+ supportedFixes: ['choose a --receipt path in the same directory as output.html'],+ },+ });+ return;+ }+ }+ try {+ fs.mkdirSync(outputDirectory, { recursive: true });+ } catch (error) {+ reportCompareFailure({ json: options.json, stage: 'prepare', error: `Could not create compare output directory: ${error.message}`, code: 'delta/output-directory', details: { reason: error.message } });+ return;+ }++ if (!receiptPath) {+ try {+ const defaultReceiptPath = compareReceiptPath(outputPath);+ ({ outputPath: receiptPath } = resolveOutputPath({+ requestedOutput: defaultReceiptPath,+ defaultOutput: defaultReceiptPath,+ requiredExtension: '.json',+ inputPaths: [basePath, headPath],+ otherOutputPaths: [outputPath],+ }));+ requestedReceiptPath = receiptPath;+ receiptPath = canonicalFuturePath(requestedReceiptPath);+ } catch (error) {+ const outputDiagnostic = error.archifyDiagnostics?.[0];+ const namespaceIndeterminate = error?.code === 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE';+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: error.message,+ code: namespaceIndeterminate+ ? 'delta/receipt-namespace-indeterminate'+ : outputDiagnostic?.code || 'output/path-resolution',+ details: {+ ...(outputDiagnostic?.subject || {}),+ ...(outputDiagnostic?.evidence || {}),+ ...(namespaceIndeterminate ? { pathIdentity: error.sidecarNamespaceReason } : {}),+ supportedFixes: outputDiagnostic?.supportedFixes+ || ['choose a safe receipt path beside the compare artifact and retry'],+ },+ });+ return;+ }+ }++ const receiptDirectoryIdentity = sameParent(outputPath, receiptPath);+ if (receiptDirectoryIdentity.status === 'unknown') {+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: 'The compare receipt directory identity could not be verified.',+ code: 'delta/receipt-directory-identity-indeterminate',+ details: {+ artifactDirectory: outputDirectory,+ receiptDirectory: path.dirname(receiptPath),+ pathIdentity: receiptDirectoryIdentity.reason,+ supportedFixes: ['restore access to both output directories or choose paths in one verifiable directory'],+ },+ });+ return;+ }+ if (receiptDirectoryIdentity.status !== 'match') {+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: 'The compare receipt must be written beside the HTML artifact.',+ code: 'delta/receipt-directory',+ details: {+ artifactDirectory: outputDirectory,+ receiptDirectory: path.dirname(receiptPath),+ pathIdentity: receiptDirectoryIdentity.reason,+ supportedFixes: ['choose a --receipt path in the same directory as output.html'],+ },+ });+ return;+ }++ const outputCapture = captureAtomicOutput(requestedOutputPath);+ const receiptCapture = captureAtomicOutput(requestedReceiptPath);+ for (const [capture, label, requestedPath] of [+ [outputCapture, 'HTML artifact', requestedOutputPath],+ [receiptCapture, 'receipt', requestedReceiptPath],+ ]) {+ if (capture.status === 'captured') continue;+ const failure = compareAtomicOutputFailure(capture, label, requestedPath, 'prepare');+ reportCompareFailure({+ json: options.json,+ stage: failure.stage,+ error: failure.message,+ code: failure.code,+ details: failure.details,+ });return;}- try {- fs.mkdirSync(outputDirectory, { recursive: true });- } catch (error) {- reportCompareFailure({ json: options.json, stage: 'prepare', error: `Could not create compare output directory: ${error.message}`, code: 'delta/output-directory', details: { reason: error.message } });+ const outputParent = outputCapture.snapshot.slot;+ const receiptParent = receiptCapture.snapshot.slot;+ if (outputParent.parentDevice !== receiptParent.parentDevice+ || outputParent.parentInode !== receiptParent.parentInode) {+ reportCompareFailure({+ json: options.json,+ stage: 'prepare',+ error: 'The compare receipt must be written beside the HTML artifact.',+ code: 'delta/receipt-directory',+ details: {+ artifactDirectory: outputParent.parentPath,+ receiptDirectory: receiptParent.parentPath,+ supportedFixes: ['choose a --receipt path in the same physical directory as output.html'],+ },+ });return;}+ outputPath = outputCapture.commitPath;+ receiptPath = receiptCapture.commitPath;+ outputDirectory = path.dirname(outputPath);let stagingDirectory;try {@@ -1511,7 +3536,7 @@ async function commandCompare(args) {const headChecks = headResult.checks.checks.filter((check) => check.ok).length;const finalReceipt = {...compareIr,- artifact: { sha256: createHash('sha256').update(artifact).digest('hex'), bytes: artifact.byteLength },+ artifact: artifactIdentity(artifact),validation: {checksPassed: baseChecks + headChecks + deltaValidation.checksPassed,checkCount: baseResult.checks.checks.length + headResult.checks.checks.length + deltaValidation.checkCount,@@ -1519,14 +3544,15 @@ async function commandCompare(args) {headComposition: headResult.checks.composition.status,},};- fs.writeFileSync(receiptCandidate, `${JSON.stringify(finalReceipt, null, 2)}\n`);+ const receiptBytes = Buffer.from(`${JSON.stringify(finalReceipt, null, 2)}\n`);+ fs.writeFileSync(receiptCandidate, receiptBytes);try {const currentOutput = resolveOutputPath({requestedOutput,defaultOutput: 'architecture-delta.html',inputPaths: [basePath, headPath],- otherOutputPaths: [receiptPath],+ otherOutputPaths: [requestedReceiptPath],}).outputPath;resolveOutputPath({requestedOutput: options.receipt || compareReceiptPath(currentOutput),@@ -1551,12 +3577,22 @@ async function commandCompare(args) {return;}- commitComparePair({ htmlCandidate, receiptCandidate, outputPath, receiptPath, stagingDirectory });+ commitComparePair({+ htmlCandidate,+ htmlContent: finalReceipt.artifact,+ receiptCandidate,+ receiptContent: artifactIdentity(receiptBytes),+ outputCapture,+ receiptCapture,+ stagingDirectory,+ verifyAtomicOutput,+ fileBindingRuntime,+ });if (options.json) console.log(JSON.stringify(finalReceipt, null, 2));else {- console.log(`compared architecture ${outputPath}`);+ console.log(`compared architecture ${requestedOutputPath}`);console.log(`${finalReceipt.validation.checksPassed}/${finalReceipt.validation.checkCount} checks; completeness ${finalReceipt.completeness}; ${finalReceipt.proofLevel}; sha256 ${finalReceipt.artifact.sha256.slice(0, 12)}`);- console.log(`receipt ${receiptPath}`);+ console.log(`receipt ${requestedReceiptPath}`);}} catch (error) {if (error instanceof ArchitectureDeltaError) {@@ -1653,10 +3689,16 @@ function writeDeliveryFailureReceipt(options) {});return recorded;}- const diagnostics = [- ...(options.diagnostics || []),- ...(recorded.diagnostic ? [recorded.diagnostic] : []),- ];+ const recoveryDiagnosticFirst = Boolean(recorded.journalRecovery || recorded.provenanceRecovery);+ const diagnostics = recoveryDiagnosticFirst+ ? [+ ...(recorded.diagnostic ? [recorded.diagnostic] : []),+ ...(options.diagnostics || []),+ ]+ : [+ ...(options.diagnostics || []),+ ...(recorded.diagnostic ? [recorded.diagnostic] : []),+ ];reportArtifactFailure({...options,command: 'deliver',@@ -1724,11 +3766,34 @@ async function commandDeliver(args) {supportedFixes: ['use: archify deliver <type> <input.json> [output.html] [options]'],});const renderer = rendererPath(type);- const { pathsAlias, resolveOutputPath } = await import('../renderers/shared/output-path.mjs');+ const {+ canonicalFuturePath,+ pathsAlias,+ resolveOutputPath,+ } = await import('../renderers/shared/output-path.mjs');+ const {+ captureAtomicOutput,+ verifyAtomicOutput,+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = await import('../renderers/shared/atomic-output.mjs');+ ({ sidecarNamespaceComponentKey: sidecarNamespaceComponentKeyRuntime }+ = await import('../renderers/shared/path-semantics.mjs'));+ const fileBindingRuntime = {+ backupPublicRegularFileBinding,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ };const receiptId = randomUUID();let deliveryOwnership;let recoveryRequired = false;let stagingDirectory;+ let deliveryAliasOutput;const reportDeliveryFailure = (options) => {const ownership = deliveryOwnership;deliveryOwnership = undefined;@@ -1739,6 +3804,10 @@ async function commandDeliver(args) {ownership,releaseOwnership: Boolean(ownership),recoveryDirectory: stagingDirectory,+ legacyOutputPaths: deliveryAliasOutput ? [deliveryAliasOutput] : [],+ captureAtomicOutput,+ verifyAtomicOutput,+ fileBindingRuntime,});if (ownership && (recorded?.ownershipError || recorded?.lockError)?.deliveryOwnershipCode === 'delivery/ownership-lost') {recoveryRequired = true;@@ -1764,11 +3833,12 @@ async function commandDeliver(args) {return;}- const authoredOutput = typeof diagram?.meta?.output === 'string' && diagram.meta.output+ const authoredOutput = typeof diagram?.meta?.output === 'string'? diagram.meta.output: undefined;let outputPath;let provenancePath;+ let preparedDeliveryTargets;try {({ outputPath } = resolveOutputPath({requestedOutput,@@ -1776,14 +3846,11 @@ async function commandDeliver(args) {defaultOutput: `${type}.html`,inputPaths: [inputPath],}));- ({ outputPath: provenancePath } = resolveOutputPath({- requestedOutput: deliveryProvenancePath(outputPath),- defaultOutput: deliveryProvenancePath(outputPath),- requiredExtension: '.json',- inputPaths: [inputPath],- inputDescription: 'the delivery input',- otherOutputPaths: [outputPath],- }));+ deliveryAliasOutput = outputPath;+ // Redelivery through a case, normalization, 8.3, or file-symlink alias+ // must replace the existing physical artifact without changing its stored+ // spelling. That keeps its realpath-derived sidecars discoverable.+ outputPath = canonicalFuturePath(outputPath);} catch (error) {const attemptedOutput = path.resolve(requestedOutput || authoredOutput || `${type}.html`);const failure = {@@ -1808,7 +3875,7 @@ async function commandDeliver(args) {}return;}- const outputDirectory = path.dirname(outputPath);+ let outputDirectory = path.dirname(outputPath);try {fs.mkdirSync(outputDirectory, { recursive: true });} catch (error) {@@ -1831,6 +3898,96 @@ async function commandDeliver(args) {return;}+ // Name semantics such as NTFS per-directory case sensitivity cannot be+ // projected through an unmaterialized directory. Creating the requested+ // physical parent is directory preparation, not artifact/sidecar+ // publication; all input, portable-path and native-resolution contracts+ // above have already passed. Only now may sidecar naming probe the actual+ // directory. A later target snapshot still rejects any authored alias that+ // was retargeted across this boundary.+ try {+ const defaultProvenancePath = deliveryProvenancePath(outputPath);+ ({ outputPath: provenancePath } = resolveOutputPath({+ requestedOutput: defaultProvenancePath,+ defaultOutput: defaultProvenancePath,+ requiredExtension: '.json',+ inputPaths: [inputPath],+ inputDescription: 'the delivery input',+ otherOutputPaths: [outputPath],+ }));+ } catch (error) {+ const attemptedOutput = path.resolve(requestedOutput || authoredOutput || `${type}.html`);+ const failure = {+ json,+ stage: 'prepare',+ type,+ input: inputPath,+ output: attemptedOutput,+ error: error.message,+ diagnostics: error.archifyDiagnostics || [diagnostic({+ code: 'output/path-resolution',+ message: error.message,+ subject: { output: attemptedOutput },+ evidence: { ...(error?.code ? { systemCode: error.code } : {}) },+ supportedFixes: ['choose a safe output path and retry'],+ })],+ };+ if (error?.code === 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE') {+ reportArtifactFailure({ ...failure, command: 'deliver', receiptId });+ } else {+ reportDeliveryFailure(failure);+ }+ return;+ }++ try {+ const plannedOutputPath = outputPath;+ const artifactCapture = {+ requestedPath: deliveryAliasOutput || outputPath,+ ...captureAtomicOutput(deliveryAliasOutput || outputPath),+ };+ if (artifactCapture.status !== 'captured') {+ throw deliveryTargetStateError(artifactCapture.requestedPath, 'HTML artifact', artifactCapture);+ }+ if (!pathsAlias(artifactCapture.commitPath, plannedOutputPath)) {+ throw deliveryTargetStateError(artifactCapture.requestedPath, 'HTML artifact', {+ status: 'different',+ reason: {+ code: 'write-slot-changed-before-snapshot',+ plannedCommitPath: plannedOutputPath,+ currentCommitPath: artifactCapture.commitPath,+ },+ });+ }+ const requestedProvenancePath = deliveryProvenancePath(artifactCapture.commitPath);+ const provenanceCapture = {+ requestedPath: requestedProvenancePath,+ ...captureAtomicOutput(requestedProvenancePath, {+ requestedEntryPolicy: 'regular-or-absent',+ }),+ };+ if (provenanceCapture.status !== 'captured') {+ throw deliveryTargetStateError(requestedProvenancePath, 'delivery provenance', provenanceCapture);+ }+ preparedDeliveryTargets = { artifact: artifactCapture, provenance: provenanceCapture };+ outputPath = artifactCapture.commitPath;+ provenancePath = provenanceCapture.commitPath;+ outputDirectory = path.dirname(outputPath);+ } catch (error) {+ reportArtifactFailure({+ command: 'deliver', json, stage: 'prepare', type, input: inputPath, output: outputPath, receiptId,+ error: error.message,+ diagnostics: error.archifyDiagnostics || [diagnostic({+ code: 'output/target-indeterminate',+ message: error.message,+ subject: { output: outputPath },+ evidence: { ...(error?.code ? { systemCode: error.code } : {}) },+ supportedFixes: ['retry only after the output path and its parent directories stop changing'],+ })],+ });+ return;+ }+// Keep the candidate beside the target so the final rename is one// same-filesystem commit. A render or artifact-check failure never touches// an existing trusted output.@@ -1875,7 +4032,12 @@ async function commandDeliver(args) {receiptId,pathsAlias,ownership: initializingOwnership,+ captureAtomicOutput,+ verifyAtomicOutput,+ fileBindingRuntime,}),+ deliveryAliasOutput ? [deliveryAliasOutput] : [],+ fileBindingRuntime,);} catch (error) {const message = `Could not start delivery for "${outputPath}": ${error.message}`;@@ -1884,17 +4046,76 @@ async function commandDeliver(args) {command: 'deliver', json, stage: 'prepare', type, input: inputPath, output: outputPath, receiptId,error: message,...(recorded ? { provenance: recorded.status } : {}),+ diagnostics: error.deliveryJournalRecovery?.recoveryRequired+ ? [deliveryJournalRecoveryDiagnostic(outputPath, error)]+ : error.deliveryProvenanceRecovery?.recoveryRequired+ ? [+ ...(recorded?.diagnostic ? [recorded.diagnostic] : []),+ deliveryLockFailureDiagnostic(outputPath, error),+ ]+ : [+ deliveryLockFailureDiagnostic(outputPath, error),+ ...(recorded?.diagnostic ? [recorded.diagnostic] : []),+ ],+ });+ return;+ }++ try {+ const state = deliveryOwnershipStates.get(deliveryOwnership);+ const targets = captureDeliveryTargetState({+ state,+ requestedOutput: deliveryAliasOutput || outputPath,+ pathsAlias,+ captureAtomicOutput,+ verifyAtomicOutput,+ preparedTargets: preparedDeliveryTargets,+ });+ outputPath = targets.artifact.commitPath;+ provenancePath = targets.provenance.commitPath;+ } catch (error) {+ let releaseError;+ try {+ releaseDeliveryOwnership(deliveryOwnership);+ } catch (cause) {+ releaseError = cause;+ }+ deliveryOwnership = undefined;+ reportArtifactFailure({+ command: 'deliver', json, stage: 'prepare', type, input: inputPath, output: outputPath, receiptId,+ error: error.message,diagnostics: [- deliveryLockFailureDiagnostic(outputPath, error),- ...(recorded?.diagnostic ? [recorded.diagnostic] : []),+ ...(releaseError ? [deliveryLockFailureDiagnostic(outputPath, releaseError)] : []),+ ...(error.archifyDiagnostics || [diagnostic({+ code: 'output/target-indeterminate',+ message: error.message,+ subject: { output: outputPath },+ evidence: { ...(error?.code ? { systemCode: error.code } : {}) },+ })]),],});return;}try {- beginDeliveryAttempt({ ownership: deliveryOwnership, input: inputPath, pathsAlias });+ beginDeliveryAttempt({+ ownership: deliveryOwnership,+ input: inputPath,+ pathsAlias,+ fileBindingRuntime,+ });} catch (error) {+ if (error.deliveryJournalRecovery?.recoveryRequired) {+ // The lock is the remaining fail-closed barrier. Do not write failure+ // provenance or release it after journal rollback itself became unsafe.+ deliveryOwnership = undefined;+ reportArtifactFailure({+ command: 'deliver', json, stage: 'prepare', type, input: inputPath, output: outputPath, receiptId,+ error: `Could not persist the delivery attempt before rendering: ${error.message}`,+ diagnostics: [deliveryJournalRecoveryDiagnostic(outputPath, error)],+ });+ return;+ }if (error.deliveryOwnershipCode === 'delivery/ownership-lost') {deliveryOwnership = undefined;recoveryRequired = true;@@ -1915,7 +4136,11 @@ async function commandDeliver(args) {error: 'Could not persist the delivery attempt before rendering.',diagnostics: [diagnostic({code: 'delivery/journal-write', message: 'Could not persist the delivery attempt before rendering.',- subject: { output: outputPath, journal: deliveryPendingPath(outputPath) },+ subject: {+ output: outputPath,+ journal: deliveryOwnershipStates.get(deliveryOwnership)?.pendingPath+ || deliveryPendingPath(outputPath),+ },evidence: { reason: error.message },supportedFixes: ['choose a writable output directory with a journal path distinct from the input'],})],@@ -2090,12 +4315,9 @@ async function commandDeliver(args) {} : {}),};+ const provenanceBytes = Buffer.from(`${JSON.stringify(deliverySuccessProvenance(receipt), null, 2)}\n`);try {- fs.writeFileSync(- provenanceCandidatePath,- `${JSON.stringify(deliverySuccessProvenance(receipt), null, 2)}\n`,- { flag: 'wx' },- );+ fs.writeFileSync(provenanceCandidatePath, provenanceBytes, { flag: 'wx' });} catch (error) {reportDeliveryFailure({json,@@ -2116,13 +4338,13 @@ async function commandDeliver(args) {}try {- const currentOutputPath = resolveOutputPath({+ const currentOutputPath = canonicalFuturePath(resolveOutputPath({requestedOutput,authoredOutput,defaultOutput: `${type}.html`,inputPaths: [inputPath],otherOutputPaths: [provenancePath],- }).outputPath;+ }).outputPath);resolveOutputPath({requestedOutput: deliveryProvenancePath(currentOutputPath),defaultOutput: deliveryProvenancePath(currentOutputPath),@@ -2153,11 +4375,13 @@ async function commandDeliver(args) {try {const committed = commitDeliveryPair({htmlCandidate: candidatePath,+ htmlContent: receipt.artifact,provenanceCandidate: provenanceCandidatePath,- outputPath,- provenancePath,+ provenanceContent: artifactIdentity(provenanceBytes),stagingDirectory,ownership: deliveryOwnership,+ verifyAtomicOutput,+ fileBindingRuntime,});commitRecoveryBackups = committed.recoverableBackups;} catch (error) {@@ -2170,6 +4394,42 @@ async function commandDeliver(args) {}recoveryRequired = error.deliveryCommitDetails?.recoveryRequired === true;const message = `Could not commit verified delivery "${outputPath}": ${error.message}`;+ if (recoveryRequired) {+ // The owned lock and pending journal are the remaining fail-closed+ // barrier around retained backups and any claimant we did not create.+ // Do not write failure provenance or release ownership here.+ deliveryOwnership = undefined;+ reportArtifactFailure({+ command: 'deliver', json, stage: 'commit', type, input: inputPath, output: outputPath, receiptId,+ error: message,+ diagnostics: [+ ...(error.deliveryOwnershipCode === 'delivery/ownership-lost'+ ? [deliveryLockFailureDiagnostic(outputPath, error)]+ : []),+ ...(error.archifyDiagnostics || []),+ deliveryCommitRecoveryDiagnostic(outputPath, error),+ ],+ });+ return;+ }+ if (error.deliveryTargetState) {+ let releaseError;+ try {+ releaseDeliveryOwnership(deliveryOwnership);+ } catch (cause) {+ releaseError = cause;+ }+ deliveryOwnership = undefined;+ reportArtifactFailure({+ command: 'deliver', json, stage: 'commit', type, input: inputPath, output: outputPath, receiptId,+ error: message,+ diagnostics: [+ ...(releaseError ? [deliveryLockFailureDiagnostic(outputPath, releaseError)] : []),+ ...(error.archifyDiagnostics || []),+ ],+ });+ return;+ }if (error.deliveryOwnershipCode === 'delivery/ownership-lost') {deliveryOwnership = undefined;reportArtifactFailure({@@ -2186,7 +4446,7 @@ async function commandDeliver(args) {input: inputPath,output: outputPath,error: message,- diagnostics: [diagnostic({+ diagnostics: error.archifyDiagnostics || [diagnostic({code: 'delivery/commit',message,subject: { output: outputPath },@@ -2315,10 +4575,76 @@ async function commandPreview(args) {}}-function inspectArtifactDeliveryProvenance(artifactPath, requireProvenance) {- let artifact;+async function loadPathIdentityRuntime() {+ try {+ const {+ sameEntry,+ sidecarNamespaceComponentKey,+ } = await import('../renderers/shared/path-semantics.mjs');+ sidecarNamespaceComponentKeyRuntime = sidecarNamespaceComponentKey;+ const {+ captureRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = await import('../renderers/shared/atomic-output.mjs');+ return {+ sameEntry,+ captureRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ };+ } catch (error) {+ return { error };+ }+}++function inspectArtifactDeliveryProvenance(+ artifactPath,+ requireProvenance,+ pathIdentityRuntime,+ expectedBindings,+) {+ const {+ captureRegularFileBinding,+ verifyRegularFileBinding,+ releaseRegularFileBinding,+ } = pathIdentityRuntime || {};+ const stableArtifactPath = canonicalExistingDeliveryOutput(artifactPath);+ let artifactCapture;try {- artifact = fs.readFileSync(artifactPath);+ if (typeof captureRegularFileBinding !== 'function'+ || typeof verifyRegularFileBinding !== 'function'+ || typeof releaseRegularFileBinding !== 'function') {+ throw new Error('The regular-file binding runtime is unavailable.');+ }+ artifactCapture = captureRegularFileBinding(stableArtifactPath, {+ subject: 'delivery-artifact',+ ...(expectedBindings?.artifact ? {+ expectedIdentity: expectedBindings.artifact.identity,+ expectedSha256: expectedBindings.artifact.content.sha256,+ expectedBytes: expectedBindings.artifact.content.bytes,+ expectedMode: expectedBindings.artifact.mode,+ } : {}),+ expectedLinks: 1,+ includeContent: true,+ });+ if (artifactCapture.status !== 'captured') {+ if (artifactCapture.reason?.code === 'delivery-artifact-hardlinked') {+ const message = 'Delivery provenance is unsupported for a hard-linked artifact because one receipt cannot prove every linked name was updated atomically.';+ return {+ ok: false,+ status: 'unsupported',+ diagnostics: [diagnostic({+ code: 'output/target-hardlinked',+ message,+ subject: { artifact: path.resolve(artifactPath) },+ evidence: { links: artifactCapture.reason.links },+ supportedFixes: ['remove the extra hard links, then rerun deliver and strict check on the remaining artifact path'],+ })],+ };+ }+ throw new Error(`The artifact is not a stable regular file (${artifactCapture.reason?.code || 'unknown target state'}).`);+ }} catch (error) {return {ok: false, status: 'unknown',@@ -2330,11 +4656,72 @@ function inspectArtifactDeliveryProvenance(artifactPath, requireProvenance) {})],};}- return { ...inspectDeliveryProvenance(artifactPath, artifact, { requireProvenance }), artifact: artifactIdentity(artifact) };+ try {+ const inspection = {};+ const provenance = inspectDeliveryProvenance(+ artifactPath,+ artifactCapture.content.buffer,+ {+ requireProvenance,+ pathIdentityRuntime,+ expectedSidecar: expectedBindings?.sidecar,+ inspection,+ },+ );+ const verification = verifyRegularFileBinding(artifactCapture.binding, {+ filePath: stableArtifactPath,+ expectedLinks: 1,+ });+ if (verification.status !== 'match') {+ return {+ ok: false,+ status: 'mismatch',+ diagnostics: [diagnostic({+ code: 'delivery/provenance-mismatch',+ message: 'The artifact changed while delivery provenance was being inspected.',+ subject: { artifact: artifactPath },+ evidence: { artifactState: verification.reason },+ supportedFixes: ['finish delivery and other writes before rerunning the checker'],+ })],+ };+ }+ const result = {+ ...provenance,+ artifact: {+ sha256: artifactCapture.content.sha256,+ bytes: artifactCapture.content.bytes,+ },+ };+ Object.defineProperty(result, 'fileBindings', {+ enumerable: false,+ value: {+ artifact: {+ identity: {+ device: artifactCapture.identity.device,+ inode: artifactCapture.identity.inode,+ },+ content: {+ sha256: artifactCapture.content.sha256,+ bytes: artifactCapture.content.bytes,+ },+ mode: artifactCapture.mode,+ },+ ...(inspection.sidecar ? { sidecar: inspection.sidecar } : {}),+ },+ });+ return result;+ } finally {+ releaseRegularFileBinding(artifactCapture.binding);+ }}-function verifyDeliveryUnchanged(artifactPath, expected, checkedArtifact) {- const current = inspectArtifactDeliveryProvenance(artifactPath, false);+function verifyDeliveryUnchanged(artifactPath, expected, checkedArtifact, pathIdentityRuntime) {+ const current = inspectArtifactDeliveryProvenance(+ artifactPath,+ false,+ pathIdentityRuntime,+ expected?.fileBindings,+ );if (current && !current.ok) return current;if (!current || !expected || current.status !== expected.status || current.receiptId !== expected.receiptId|| current.artifact.sha256 !== expected.artifact.sha256 || current.artifact.bytes !== expected.artifact.bytes@@ -2372,7 +4759,7 @@ function provenanceFailureReceipt({ command, artifactPath, provenance }) {};}-function commandCheck(args) {+async function commandCheck(args) {const knownOptions = new Set(['--require-provenance']);const unknown = args.find((arg) => arg.startsWith('--') && !knownOptions.has(arg));if (unknown) fail(`Unknown check option "${unknown}".`);@@ -2381,7 +4768,12 @@ function commandCheck(args) {const [html] = positional;if (!html || positional.length !== 1) fail(usage());const artifactPath = path.resolve(html);- const provenance = inspectArtifactDeliveryProvenance(artifactPath, requireProvenance);+ const pathIdentityRuntime = await loadPathIdentityRuntime();+ const provenance = inspectArtifactDeliveryProvenance(+ artifactPath,+ requireProvenance,+ pathIdentityRuntime,+ );if (provenance && !provenance.ok) {console.log(JSON.stringify(provenanceFailureReceipt({ command: 'check', artifactPath, provenance }), null, 2));process.exitCode = 1;@@ -2394,10 +4786,20 @@ function commandCheck(args) {return;}if (result.stdout) {+ let receipt;try {- const receipt = JSON.parse(result.stdout);+ receipt = JSON.parse(result.stdout);+ } catch {+ process.stdout.write(result.stdout);+ }+ if (receipt) {if (provenance) {- const verified = verifyDeliveryUnchanged(artifactPath, provenance, receipt.artifact || {});+ const verified = verifyDeliveryUnchanged(+ artifactPath,+ provenance,+ receipt.artifact || {},+ pathIdentityRuntime,+ );if (!verified.ok) {console.log(JSON.stringify(provenanceFailureReceipt({ command: 'check', artifactPath, provenance: verified }), null, 2));process.exitCode = 1;@@ -2407,8 +4809,6 @@ function commandCheck(args) {if (provenance.receiptId) receipt.deliveryReceiptId = provenance.receiptId;}console.log(JSON.stringify(receipt, null, 2));- } catch {- process.stdout.write(result.stdout);}}if (result.stderr) process.stderr.write(result.stderr);@@ -2416,7 +4816,7 @@ function commandCheck(args) {}async function commandVisualCheck(rawArgs) {- const { rest: args, outDir } = extractOutDirArgs(rawArgs);+ const { rest: args, outDir: rawOutDir } = extractOutDirArgs(rawArgs);const json = args.includes('--json');const requireProvenance = args.includes('--require-provenance');const knownOptions = new Set(['--json', '--require-provenance']);@@ -2426,7 +4826,45 @@ async function commandVisualCheck(rawArgs) {if (positional.length !== 1) fail(usage(), 1);const artifactPath = path.resolve(positional[0]);- const provenance = inspectArtifactDeliveryProvenance(artifactPath, requireProvenance);+ let outDir;+ if (rawOutDir !== undefined) {+ const { resolveNativeOutputDirectory } = await import('../renderers/shared/output-path.mjs');+ try {+ outDir = resolveNativeOutputDirectory(rawOutDir);+ } catch (error) {+ const outputDiagnostic = error.archifyDiagnostics?.[0] || diagnostic({+ code: 'output/native-path-syntax',+ message: error.message,+ subject: { output: rawOutDir },+ evidence: { ...(error?.code ? { systemCode: error.code } : {}) },+ supportedFixes: ['choose an ordinary native filesystem directory and retry'],+ });+ const failure = {+ schemaVersion: 1,+ ok: false,+ command: 'visual-check',+ evidenceKind: 'automated-browser',+ status: 'fail',+ visualReview: 'pending',+ artifact: { path: artifactPath },+ error: error.message,+ diagnostics: [outputDiagnostic],+ };+ if (json) console.log(JSON.stringify(failure, null, 2));+ else {+ console.error(formatDiagnostics(`automated browser evidence failed: ${failure.error}`, failure.diagnostics));+ console.error('perceptual visual review pending');+ }+ process.exitCode = 1;+ return;+ }+ }+ const pathIdentityRuntime = await loadPathIdentityRuntime();+ const provenance = inspectArtifactDeliveryProvenance(+ artifactPath,+ requireProvenance,+ pathIdentityRuntime,+ );let runVisualCheck;let persistVisualCheckFailure;try {@@ -2454,7 +4892,12 @@ async function commandVisualCheck(rawArgs) {outDir,...(provenance ? { deliveryProvenance: provenance } : {}),verifyArtifact: (bytes) => {- const verified = verifyDeliveryUnchanged(artifactPath, provenance, artifactIdentity(bytes));+ const verified = verifyDeliveryUnchanged(+ artifactPath,+ provenance,+ artifactIdentity(bytes),+ pathIdentityRuntime,+ );if (!verified.ok) {const error = new Error(verified.diagnostics[0].message);error.deliveryProvenance = verified;@@ -2566,6 +5009,27 @@ async function commandDoctor(args) {missing: fs.existsSync(outputPathRuntime) ? 0 : 1,});+ const atomicOutputRuntime = path.join(skillRoot, 'renderers/shared/atomic-output.mjs');+ checks.push({+ label: 'Atomic output safety runtime',+ ok: fs.existsSync(atomicOutputRuntime),+ missing: fs.existsSync(atomicOutputRuntime) ? 0 : 1,+ });++ const pathSemanticsRuntime = path.join(skillRoot, 'renderers/shared/path-semantics.mjs');+ checks.push({+ label: 'Physical path semantics runtime',+ ok: fs.existsSync(pathSemanticsRuntime),+ missing: fs.existsSync(pathSemanticsRuntime) ? 0 : 1,+ });++ const portablePathRuntime = path.join(skillRoot, 'renderers/shared/portable-path.mjs');+ checks.push({+ label: 'Portable path contract runtime',+ ok: fs.existsSync(portablePathRuntime),+ missing: fs.existsSync(portablePathRuntime) ? 0 : 1,+ });+const scenarioGuide = path.join(skillRoot, 'recipes/scenarios.mjs');checks.push({label: 'Scenario recipe guide',@@ -2937,12 +5401,29 @@ async function commandMigrate(args) {});return;}+ const { pathsAlias, validateAuthoredOutputPath } = await import('../renderers/shared/output-path.mjs');+ const {+ captureAtomicOutput,+ captureRegularFileBinding,+ releaseRegularFileBinding,+ verifyAtomicOutput,+ verifyRegularFileBinding,+ } = await import('../renderers/shared/atomic-output.mjs');+ if (typeof sourceDocument?.meta?.output === 'string') {+ try {+ validateAuthoredOutputPath(sourceDocument.meta.output);+ } catch (error) {+ reportMigrationFailure({+ preExistingDiagnostics: migrationPathDiagnostics(error, sourcePath, destinationPath),+ });+ return;+ }+ }// Unlike render/validate, migrate has no --quality override. Pin every stage// to the document's durable policy and scrub any ambient profile from the// staged renderer by passing this value explicitly.const activeQualityProfile = sourceDocument?.meta?.quality_profile || 'standard';- const { pathsAlias } = await import('../renderers/shared/output-path.mjs');let sourceDestinationAlias;try {sourceDestinationAlias = pathsAlias(sourcePath, destinationPath);@@ -2985,23 +5466,27 @@ async function commandMigrate(args) {return;}- if (fs.existsSync(destinationPath) && !fs.lstatSync(destinationPath).isFile()) {- reportMigrationFailure({- ...migration,- migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({- code: 'migration/destination-type',- message: 'Workflow migration destination must be a regular file path.',- subject: { destination: destinationPath },- supportedFixes: ['choose a destination path that is absent or names a regular file'],- })],- });- return;- }-const destinationDirectory = path.dirname(destinationPath);let stagingDirectory;+ let destinationCapture;try {fs.mkdirSync(destinationDirectory, { recursive: true });+ destinationCapture = captureAtomicOutput(destinationPath, {+ requestedEntryPolicy: 'regular-or-absent',+ });+ if (destinationCapture.status !== 'captured') {+ reportMigrationFailure({+ ...migration,+ migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({+ code: 'migration/destination-type',+ message: 'Workflow migration destination must be an absent or stable regular file path.',+ subject: { destination: destinationPath },+ evidence: { targetState: destinationCapture.reason },+ supportedFixes: ['choose a destination path that is absent or names one non-hardlinked regular file'],+ })],+ });+ return;+ }stagingDirectory = fs.mkdtempSync(path.join(destinationDirectory, '.archify-migration-'));} catch (error) {reportMigrationFailure({@@ -3020,6 +5505,7 @@ async function commandMigrate(args) {const candidatePath = path.join(stagingDirectory, 'candidate.workflow.json');const artifactPath = path.join(stagingDirectory, 'migration-check.html');const destinationBytes = Buffer.from(serializeMigratedWorkflow(migration.document));+ let candidateBinding = null;try {fs.writeFileSync(candidatePath, destinationBytes, { flag: 'wx' });const render = runNode([rendererPath('workflow'), candidatePath, artifactPath], {@@ -3083,7 +5569,74 @@ async function commandMigrate(args) {return;}- fs.renameSync(candidatePath, destinationPath);+ if (destinationCapture.mode !== null) fs.chmodSync(candidatePath, destinationCapture.mode);+ const expectedCandidate = artifactIdentity(destinationBytes);+ const candidateCapture = captureRegularFileBinding(candidatePath, {+ subject: 'migration-candidate',+ expectedSha256: expectedCandidate.sha256,+ expectedBytes: expectedCandidate.bytes,+ ...(destinationCapture.mode === null ? {} : { expectedMode: destinationCapture.mode }),+ expectedLinks: 1,+ });+ if (candidateCapture.status !== 'captured') {+ reportMigrationFailure({+ ...migration,+ migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({+ code: 'migration/candidate-changed',+ message: 'Workflow migration candidate changed before the destination commit.',+ subject: { destination: destinationPath },+ evidence: { candidateState: candidateCapture.reason },+ supportedFixes: ['retry the migration from a stable workflow source and destination'],+ })],+ });+ return;+ }+ candidateBinding = candidateCapture.binding;+ const candidateVerification = verifyRegularFileBinding(candidateBinding, { expectedLinks: 1 });+ if (candidateVerification.status !== 'match') {+ reportMigrationFailure({+ ...migration,+ migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({+ code: 'migration/candidate-changed',+ message: 'Workflow migration candidate changed before the destination commit.',+ subject: { destination: destinationPath },+ evidence: { candidateState: candidateVerification.reason },+ supportedFixes: ['retry the migration from a stable workflow source and destination'],+ })],+ });+ return;+ }+ const candidateRelease = releaseRegularFileBinding(candidateBinding);+ candidateBinding = null;+ if (candidateRelease.status !== 'released') {+ reportMigrationFailure({+ ...migration,+ migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({+ code: 'migration/candidate-changed',+ message: 'Workflow migration candidate could not be finalized before the destination commit.',+ subject: { destination: destinationPath },+ evidence: { candidateState: candidateRelease.reason },+ supportedFixes: ['retry the migration after resolving the candidate filesystem error'],+ })],+ });+ return;+ }++ const destinationVerification = verifyAtomicOutput(destinationCapture.snapshot);+ if (destinationVerification.status !== 'match') {+ reportMigrationFailure({+ ...migration,+ migrationDiagnostics: [...migration.migrationDiagnostics, diagnostic({+ code: 'migration/destination-changed',+ message: 'Workflow migration destination changed while the candidate was being verified.',+ subject: { destination: destinationPath },+ evidence: { targetState: destinationVerification.reason },+ supportedFixes: ['retry only after other processes stop creating, replacing, or redirecting the destination'],+ })],+ });+ return;+ }+ fs.renameSync(candidatePath, destinationCapture.commitPath);const report = migrationReport({...migration,sourcePath,@@ -3113,6 +5666,7 @@ async function commandMigrate(args) {migrationDiagnostics: [...migration.migrationDiagnostics, ...migrationDiagnostics],});} finally {+ if (candidateBinding) releaseRegularFileBinding(candidateBinding);try {fs.rmSync(stagingDirectory, { recursive: true, force: true });} catch (error) {@@ -3293,7 +5847,7 @@ try {commandValidate([...args, '--layout-json']);break;case 'check':- commandCheck(args);+ await commandCheck(args);break;case 'visual-check':await commandVisualCheck(args);diff --git a/archify/bin/preview.mjs b/archify/bin/preview.mjsindex 30932bc8..a058edb1 100644--- a/archify/bin/preview.mjs+++ b/archify/bin/preview.mjs@@ -7,6 +7,15 @@ import { fileURLToPath } from 'node:url';import { openLoopbackUrl } from './open-artifact.mjs';import { resolveOutputPath } from '../renderers/shared/output-path.mjs';+import { sameLocation } from '../renderers/shared/path-semantics.mjs';+import {+ captureAtomicOutput,+ captureRegularFileBinding,+ releaseRegularFileBinding,+ removeOwnedRegularFile,+ verifyAtomicOutput,+ verifyRegularFileBinding,+} from '../renderers/shared/atomic-output.mjs';const here = path.dirname(fileURLToPath(import.meta.url));const cliPath = path.join(here, 'archify.mjs');@@ -16,6 +25,7 @@ const defaultPollMs = 800;const defaultStopGraceMs = 3000;const defaultStopKillMs = 750;const diagramTypes = new Set(['architecture', 'workflow', 'sequence', 'dataflow', 'lifecycle']);+let previewCommitSequence = 0;function sha256(value) {return createHash('sha256').update(value).digest('hex');@@ -33,7 +43,7 @@ function sourceDigest(inputPath) {function initialAuthoredOutput(inputPath) {try {const source = JSON.parse(fs.readFileSync(inputPath, 'utf8'));- if (typeof source?.meta?.output === 'string' && source.meta.output) {+ if (typeof source?.meta?.output === 'string') {return source.meta.output;}} catch {@@ -178,6 +188,112 @@ function parseReceipt(stdout) {}}+function atomicOutputFailure(result) {+ const code = result?.reason?.code || 'unclassified';+ let diagnosticCode = 'output/target-indeterminate';+ let message;+ if (code === 'target-hardlinked' || code === 'candidate-hardlinked') {+ diagnosticCode = 'output/target-hardlinked';+ message = code === 'candidate-hardlinked'+ ? 'Preview commit candidate has multiple hard-link names and cannot be published safely.'+ : 'Preview output has multiple hard-link names; atomic publication cannot update every name.';+ } else if (code === 'target-not-regular-file' || code === 'candidate-not-regular-file') {+ diagnosticCode = 'output/target-not-regular-file';+ message = code === 'candidate-not-regular-file'+ ? 'Preview commit candidate is no longer a regular file.'+ : 'Preview output already exists and is not a regular file.';+ } else if (result?.status === 'different') {+ diagnosticCode = 'output/target-changed';+ message = `Preview output changed while the verified candidate was being prepared (${code}).`;+ } else {+ message = `Preview output stability could not be determined safely (${code}).`;+ }+ return {+ code: diagnosticCode,+ message,+ evidence: { relation: result?.reason || { code } },+ };+}++function atomicOutputError(result) {+ const failure = atomicOutputFailure(result);+ return Object.assign(new Error(failure.message), { previewFailure: failure });+}++function stagePreviewCommit(commitPath, artifact, mode) {+ for (let attempt = 0; attempt < 100; attempt += 1) {+ previewCommitSequence += 1;+ const candidatePath = path.join(+ path.dirname(commitPath),+ `.archify-preview-commit-${process.pid}-${Date.now().toString(36)}-${previewCommitSequence}.tmp`,+ );+ let descriptor;+ let identity;+ try {+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ descriptor = fs.openSync(+ candidatePath,+ fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | noFollow,+ mode ?? 0o666,+ );+ const metadata = fs.fstatSync(descriptor, { bigint: true });+ if (!metadata.isFile() || metadata.ino === 0n) {+ throw new Error('Preview commit candidate identity could not be verified safely.');+ }+ identity = { device: metadata.dev, inode: metadata.ino };+ fs.writeFileSync(descriptor, artifact);+ if (mode !== null) fs.fchmodSync(descriptor, mode);+ fs.closeSync(descriptor);+ descriptor = undefined;+ return { candidatePath, identity };+ } catch (error) {+ if (descriptor !== undefined) {+ try { fs.closeSync(descriptor); } catch {}+ }+ if (error.code === 'EEXIST') continue;+ if (identity) removeOwnedRegularFile(candidatePath, identity);+ throw error;+ }+ }+ throw Object.assign(new Error('Could not reserve a preview commit candidate beside the output.'), {+ code: 'EEXIST',+ errno: -17,+ syscall: 'open',+ });+}++function cleanupIdentity(filePath, subject = 'candidate') {+ const captured = captureRegularFileBinding(filePath, { subject });+ if (captured.status !== 'captured') return null;+ const released = releaseRegularFileBinding(captured.binding);+ return released.status === 'released' ? captured.identity : null;+}++function captureOwnedDirectory(directoryPath) {+ const metadata = fs.lstatSync(directoryPath, { bigint: true });+ if (!metadata.isDirectory() || metadata.ino === 0n) {+ throw new Error('Preview staging directory identity could not be verified safely.');+ }+ return { device: metadata.dev, inode: metadata.ino };+}++function cleanupOwnedDirectory(directoryPath, identity) {+ let current;+ try {+ current = fs.lstatSync(directoryPath, { bigint: true });+ } catch (error) {+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return;+ throw error;+ }+ // Preserve a replacement rather than recursively deleting a directory that+ // this preview instance did not create.+ if (!current.isDirectory()+ || current.ino === 0n+ || current.dev !== identity.device+ || current.ino !== identity.inode) return;+ fs.rmSync(directoryPath, { recursive: true, force: false });+}+export async function startPreview(options) {const type = options.type;if (!diagramTypes.has(type)) throw new Error(`Unknown diagram type "${type}".`);@@ -202,7 +318,18 @@ export async function startPreview(options) {const shouldOpen = options.open !== false;fs.mkdirSync(outputDirectory, { recursive: true });- const stagingDirectory = fs.mkdtempSync(path.join(outputDirectory, '.archify-preview-'));+ // Keep cleanup bound to the physical directory selected at startup. A+ // symlink or junction in the requested output parent may be redirected while+ // preview is running and must not redirect recursive cleanup to a claimant.+ const physicalOutputDirectory = fs.realpathSync.native(outputDirectory);+ const stagingDirectory = fs.mkdtempSync(path.join(physicalOutputDirectory, '.archify-preview-'));+ let stagingIdentity;+ try {+ stagingIdentity = captureOwnedDirectory(stagingDirectory);+ } catch (error) {+ try { fs.rmdirSync(stagingDirectory); } catch {}+ throw error;+ }let port = 0;let watcher;@@ -325,7 +452,7 @@ export async function startPreview(options) {});} catch (error) {try { server.close(); } catch {}- fs.rmSync(stagingDirectory, { recursive: true, force: true });+ cleanupOwnedDirectory(stagingDirectory, stagingIdentity);throw error;}@@ -339,7 +466,7 @@ export async function startPreview(options) {clearTimeout(stopGraceTimer);clearTimeout(stopKillTimer);try {- fs.rmSync(stagingDirectory, { recursive: true, force: true });+ cleanupOwnedDirectory(stagingDirectory, stagingIdentity);} finally {resolveClosed();}@@ -422,6 +549,8 @@ export async function startPreview(options) {state.status = 'needs-fix';state.failure = {stage: receipt?.stage || 'render',+ ...(receipt?.code ? { code: receipt.code } : {}),+ ...(receipt?.evidence ? { evidence: receipt.evidence } : {}),message: redactDiagnostic(diagnostic,[@@ -439,25 +568,63 @@ export async function startPreview(options) {broadcast();}- function commitCandidate(candidatePath, receipt, generationHash) {+ function commitCandidate(candidatePath, receipt, generationHash, outputCapture) {let candidate;+ let sourceCandidateBinding;+ let sourceCandidateIdentity;+ let commitCandidatePath;+ let commitCandidateIdentity;+ let commitCandidateBinding;try {- candidate = fs.readFileSync(candidatePath);- const digest = sha256(candidate);- if (digest !== receipt?.artifact?.sha256) {- throw new Error('Verified candidate bytes do not match the delivery receipt.');- }+ const sourceCapture = captureRegularFileBinding(candidatePath, {+ subject: 'candidate',+ expectedSha256: receipt?.artifact?.sha256,+ expectedBytes: receipt?.artifact?.bytes,+ includeContent: true,+ });+ if (sourceCapture.status !== 'captured') throw atomicOutputError(sourceCapture);+ sourceCandidateBinding = sourceCapture.binding;+ sourceCandidateIdentity = sourceCapture.identity;+ candidate = sourceCapture.content.buffer;+ const digest = sourceCapture.content.sha256;+ const releasedSource = releaseRegularFileBinding(sourceCandidateBinding);+ sourceCandidateBinding = undefined;+ if (releasedSource.status !== 'released') throw atomicOutputError(releasedSource);resolveOutputPath(outputRequest);const sameArtifact = state.lastVerified?.sha256 === digest;- let outputMatches = false;- if (sameArtifact) {- try { outputMatches = sha256(fs.readFileSync(outputPath)) === digest; } catch {}- }const currentSource = sourceDigest(inputPath);if (currentSource.hash !== generationHash) {- return { committed: false, supersededBy: currentSource };+ return {+ committed: false,+ supersededBy: currentSource,+ candidateIdentity: sourceCandidateIdentity,+ };}- if (!sameArtifact || !outputMatches) fs.renameSync(candidatePath, outputPath);+ const beforeStage = verifyAtomicOutput(outputCapture.snapshot);+ if (beforeStage.status !== 'match') throw atomicOutputError(beforeStage);+ ({+ candidatePath: commitCandidatePath,+ identity: commitCandidateIdentity,+ } = stagePreviewCommit(outputCapture.commitPath, candidate, outputCapture.mode));+ const candidateCapture = captureRegularFileBinding(commitCandidatePath, {+ subject: 'candidate',+ expectedSha256: digest,+ expectedBytes: candidate.byteLength,+ expectedIdentity: commitCandidateIdentity,+ ...(outputCapture.mode === null ? {} : { expectedMode: outputCapture.mode }),+ });+ if (candidateCapture.status !== 'captured') throw atomicOutputError(candidateCapture);+ commitCandidateBinding = candidateCapture.binding;+ const beforeCommit = verifyAtomicOutput(outputCapture.snapshot);+ if (beforeCommit.status !== 'match') throw atomicOutputError(beforeCommit);+ const verifiedCandidate = verifyRegularFileBinding(commitCandidateBinding);+ if (verifiedCandidate.status !== 'match') throw atomicOutputError(verifiedCandidate);+ const releasedCandidate = releaseRegularFileBinding(commitCandidateBinding);+ commitCandidateBinding = undefined;+ if (releasedCandidate.status !== 'released') throw atomicOutputError(releasedCandidate);+ fs.renameSync(commitCandidatePath, outputCapture.commitPath);+ commitCandidatePath = undefined;+ commitCandidateIdentity = undefined;artifactBuffer = candidate;lastGoodSourceHash = generationHash;state.status = 'verified';@@ -474,10 +641,20 @@ export async function startPreview(options) {}state.failure = null;broadcast();- return { committed: true, supersededBy: null };+ return { committed: true, supersededBy: null, candidateIdentity: sourceCandidateIdentity };} catch (error) {- publishFailure({ stage: 'commit', error: `Could not publish the verified preview: ${error.message}` }, '', '', candidatePath);- return { committed: false, supersededBy: null };+ publishFailure({+ stage: 'commit',+ error: `Could not publish the verified preview: ${error.message}`,+ ...(error.previewFailure || {}),+ }, '', '', candidatePath);+ return { committed: false, supersededBy: null, candidateIdentity: sourceCandidateIdentity };+ } finally {+ if (sourceCandidateBinding) releaseRegularFileBinding(sourceCandidateBinding);+ if (commitCandidateBinding) releaseRegularFileBinding(commitCandidateBinding);+ if (commitCandidatePath && commitCandidateIdentity) {+ removeOwnedRegularFile(commitCandidatePath, commitCandidateIdentity);+ }}}@@ -492,9 +669,38 @@ export async function startPreview(options) {const candidatePath = path.join(stagingDirectory, `generation-${state.generation}.html`);const snapshotPath = path.join(stagingDirectory, `generation-${state.generation}.json`);+ let snapshotIdentity;+ const outputCapture = captureAtomicOutput(outputPath);+ if (outputCapture.status !== 'captured') {+ const failure = atomicOutputFailure(outputCapture);+ publishFailure(+ { stage: 'prepare', error: failure.message, ...failure },+ '',+ '',+ candidatePath,+ snapshotPath,+ );+ return;+ }+ const beforeBuild = verifyAtomicOutput(outputCapture.snapshot);+ if (beforeBuild.status !== 'match') {+ const failure = atomicOutputFailure(beforeBuild);+ publishFailure(+ { stage: 'prepare', error: failure.message, ...failure },+ '',+ '',+ candidatePath,+ snapshotPath,+ );+ return;+ }if (digest.bytes !== null) {try {fs.writeFileSync(snapshotPath, digest.bytes, { flag: 'wx', mode: 0o600 });+ const metadata = fs.lstatSync(snapshotPath, { bigint: true });+ if (metadata.isFile() && metadata.ino !== 0n) {+ snapshotIdentity = { device: metadata.dev, inode: metadata.ino };+ }} catch (error) {publishFailure({ stage: 'prepare', error: `Could not snapshot the observed input: ${error.message}` },@@ -528,18 +734,25 @@ export async function startPreview(options) {const generationHash = activeHash;const stale = generationEpoch !== sourceEpoch;let supersededBy = null;+ let candidateIdentity;child = null;clearTimeout(stopGraceTimer);clearTimeout(stopKillTimer);stopGraceTimer = undefined;stopKillTimer = undefined;if (!stopping && !stale && code === 0 && receipt?.ok) {- ({ supersededBy } = commitCandidate(candidatePath, receipt, generationHash));+ ({ supersededBy, candidateIdentity } = commitCandidate(+ candidatePath,+ receipt,+ generationHash,+ outputCapture,+ ));} else if (!stopping && !stale) {publishFailure(receipt, stdout, stderr, candidatePath, snapshotPath);}- try { fs.rmSync(candidatePath, { force: true }); } catch {}- try { fs.rmSync(snapshotPath, { force: true }); } catch {}+ candidateIdentity ||= cleanupIdentity(candidatePath);+ if (candidateIdentity) removeOwnedRegularFile(candidatePath, candidateIdentity);+ if (snapshotIdentity) removeOwnedRegularFile(snapshotPath, snapshotIdentity, { subject: 'snapshot' });if (stopping) {finishStop();@@ -592,12 +805,16 @@ export async function startPreview(options) {// and junctions before libuv opens the directory so its callback path has// the same prefix as the watched path.const watchedDirectory = fs.realpathSync.native(path.dirname(inputPath));- const inputBasename = path.basename(inputPath);watcher = fs.watch(watchedDirectory, (event, filename) => {// On Windows the watcher hands us just the basename; on POSIX it can be- // null. Accept either empty signals or a basename match so editors that- // swap a file atomically (write to temp + rename) still trigger us.- if (!filename || filename.toString() === inputBasename) observeSource();+ // null. Resolve named events against the directory libuv actually opened+ // so file-level case, 8.3, and hard-link aliases still identify the input.+ if (+ !filename+ || sameLocation(path.join(watchedDirectory, filename.toString()), inputPath).status === 'match'+ ) {+ observeSource();+ }});watcher.on('error', () => {const failedWatcher = watcher;diff --git a/archify/bin/visual-check.mjs b/archify/bin/visual-check.mjsindex cffde512..e949209a 100644--- a/archify/bin/visual-check.mjs+++ b/archify/bin/visual-check.mjs@@ -8,6 +8,21 @@ import {DESKTOP_READABILITY_VIEWPORT,MIN_PROJECTED_NODE_TEXT_PX,} from '../renderers/shared/desktop-readability.mjs';+import {+ backupPublicRegularFileBinding,+ captureAtomicOutput,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ releaseRegularFileBinding,+ verifyAtomicOutput,+ verifyRegularFileBinding,+} from '../renderers/shared/atomic-output.mjs';+import {+ sameEntry,+ sameLocation,+ sameParent,+ sidecarNamespaceComponentKey,+} from '../renderers/shared/path-semantics.mjs';export const VISUAL_CHECK_VIEWPORTS = Object.freeze([DESKTOP_READABILITY_VIEWPORT,@@ -23,6 +38,15 @@ const CAPTURE_VIEWPORTS = Object.freeze([const THEMES = Object.freeze(['light', 'dark']);const EXIT = Object.freeze({ pass: 0, fail: 1, skipped: 2 });export const CHROME_NO_SANDBOX_ENV = 'ARCHIFY_CHROME_NO_SANDBOX';+const VISUAL_SIDECAR_SUFFIXES = Object.freeze([+ '.visual-check.json',+ '.visual-check.html',+ ...CAPTURE_VIEWPORTS.flatMap(({ width, height }) => THEMES.map(+ (theme) => `.visual-check.${width}x${height}.${theme}.png`,+ )),+]);+const SIDECAR_STEM_NAMESPACE = /\.~archify-[0-9a-f]{64}$/iu;+const visualEvidenceOwnerships = new WeakSet();function sha256(buffer) {return createHash('sha256').update(buffer).digest('hex');@@ -34,31 +58,146 @@ function htmlEscape(value) {})[char]);}-function safeUnlink(file) {+function pathEntry(file) {try {- fs.rmSync(file, { force: true });- } catch {- // A stale optional sidecar must never make the delivered HTML mutable.+ return { exists: true, stat: fs.lstatSync(file) };+ } catch (error) {+ if (error?.code === 'ENOENT') return { exists: false };+ return { exists: null, error };}}-function writeAtomic(file, contents) {- const temporary = `${file}.tmp-${process.pid}`;- try {- fs.writeFileSync(temporary, contents, { flag: 'w' });- fs.renameSync(temporary, file);- } finally {- safeUnlink(temporary);+function visualEvidencePaths(outputs) {+ return [outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)];+}++function regularFileEvidence(file, { expectedLinks = 1 } = {}) {+ const captured = captureRegularFileBinding(file, {+ subject: 'evidence-file',+ expectedLinks,+ });+ if (captured.status !== 'captured') {+ const systemCode = captured.reason?.systemCode;+ return {+ ok: false,+ reason: systemCode === 'ENOENT'+ ? { code: 'missing-evidence-file' }+ : captured.reason?.code === 'evidence-file-not-regular-file'+ ? { code: 'evidence-path-not-regular-file' }+ : {+ code: 'evidence-file-unreadable',+ ...(systemCode ? { systemCode } : {}),+ ...(captured.reason?.code ? { bindingCode: captured.reason.code } : {}),+ },+ };+ }+ const released = releaseRegularFileBinding(captured.binding);+ if (released.status !== 'released') {+ return {+ ok: false,+ reason: {+ code: 'evidence-file-unreadable',+ ...(released.reason?.systemCode ? { systemCode: released.reason.systemCode } : {}),+ ...(released.reason?.code ? { bindingCode: released.reason.code } : {}),+ },+ };}+ return {+ ok: true,+ evidence: {+ file: path.basename(file),+ sha256: captured.content.sha256,+ bytes: captured.content.bytes,+ },+ identity: captured.identity,+ };+}++function readRegularFileContents(file, { subject = 'file' } = {}) {+ const captured = captureRegularFileBinding(file, {+ subject,+ expectedLinks: 1,+ includeContent: true,+ });+ if (captured.status !== 'captured') return { ok: false, reason: captured.reason };+ const released = releaseRegularFileBinding(captured.binding);+ if (released.status !== 'released') return { ok: false, reason: released.reason };+ return {+ ok: true,+ bytes: captured.content.buffer,+ evidence: {+ sha256: captured.content.sha256,+ bytes: captured.content.bytes,+ },+ identity: captured.identity,+ };+}++function regularFileCaptureError(label, captured) {+ const reason = captured?.reason || { code: 'regular-file-capture-failed' };+ const error = new Error(`${label} could not be read safely (${reason.code}).`);+ if (reason.systemCode) error.code = reason.systemCode;+ error.evidenceReason = reason;+ return error;}function screenshotKey(width, height, theme) {return `${width}x${height}:${theme}`;}+function boundedSidecarStem(stem, { force = false, hashDomain } = {}) {+ const fits = (value) => value.length <= 255 && Buffer.byteLength(value, 'utf8') <= 255;+ const needsBounding = (value) => !VISUAL_SIDECAR_SUFFIXES.every(+ (suffix) => fits(`${value}${suffix}`),+ );+ if (!force && !needsBounding(stem) && !SIDECAR_STEM_NAMESPACE.test(stem)) return stem;+ const hashInput = hashDomain ? `${hashDomain}\0${stem}` : stem;+ const marker = `.~archify-${sha256(Buffer.from(hashInput, 'utf8'))}`;+ const codePoints = [...stem];+ while (codePoints.length && needsBounding(`${codePoints.join('')}${marker}`)) {+ codePoints.pop();+ }+ return `${codePoints.join('')}${marker}`;+}++function resolvedSidecarNamespace(artifact, component) {+ const namespace = sidecarNamespaceComponentKey(path.dirname(artifact), component);+ if (namespace.status === 'resolved') return namespace;+ const error = new Error(+ `Could not establish a stable sidecar namespace (${namespace.reason?.code || 'unknown'}).`,+ );+ error.code = 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE';+ error.sidecarNamespaceReason = namespace.reason;+ throw error;+}++function sidecarStemFromComponent(component) {+ if (component.endsWith('.html')) {+ return {+ stem: component.slice(0, -'.html'.length),+ options: undefined,+ };+ }+ return {+ stem: component,+ options: { force: true, hashDomain: 'full-component' },+ };+}+export function sidecarPaths(artifactPath, { outDir } = {}) {- const artifact = path.resolve(artifactPath);- const stem = path.basename(artifact).replace(/\.html?$/i, '');+ let artifact = path.resolve(artifactPath);+ try {+ // Existing aliases, including Windows 8.3 spellings, must share the+ // physical artifact's evidence namespace even when the stem is short.+ artifact = fs.realpathSync.native(artifact);+ } catch (error) {+ if (!['ENOENT', 'ENOTDIR', 'ENAMETOOLONG'].includes(error?.code)) throw error;+ // Missing artifacts still need deterministic failure sidecar paths.+ }+ const namespace = resolvedSidecarNamespace(artifact, path.basename(artifact));+ artifact = path.join(namespace.directoryPath, path.basename(artifact));+ const namespaceStem = sidecarStemFromComponent(namespace.componentKey);+ const stem = boundedSidecarStem(namespaceStem.stem, namespaceStem.options);const directory = outDir ? path.resolve(outDir) : path.dirname(artifact);const base = path.join(directory, `${stem}.visual-check`);const screenshots = CAPTURE_VIEWPORTS.flatMap(({ width, height }) => THEMES.map((theme) => ({@@ -75,9 +214,1009 @@ export function sidecarPaths(artifactPath, { outDir } = {}) {};}-function cleanupCaptureSidecars(paths) {- safeUnlink(paths.contactSheet);- for (const screenshot of paths.screenshots) safeUnlink(screenshot.path);+function evidencePathConflict(artifactPath, outputs, file, reason) {+ const target = file || outputs.receipt;+ const error = `visual-check will not replace the existing unowned evidence path "${target}".`;+ return {+ ok: false,+ error,+ diagnostic: failureDiagnostic({+ code: 'viewer/evidence-path-conflict',+ message: error,+ subject: { artifact: path.resolve(artifactPath), evidencePath: target },+ evidence: { reason },+ supportedFixes: [+ 'move the conflicting file aside, or choose a separate --out-dir, then rerun visual-check',+ ],+ }),+ };+}++function visualEvidenceOwnershipMatches(ownership, artifactPath, outputs) {+ return visualEvidenceOwnerships.has(ownership)+ && ownership.active+ && sameEntry(ownership.artifact, artifactPath).status === 'match'+ && sameLocation(ownership.receipt, outputs.receipt).status === 'match';+}++function visualEvidenceTargets(outputs) {+ return [+ { kind: 'receipt', path: outputs.receipt },+ { kind: 'contact-sheet', path: outputs.contactSheet },+ ...outputs.screenshots.map((entry, index) => ({+ kind: 'screenshot',+ index,+ path: entry.path,+ })),+ ];+}++function evidenceWriteFailure(artifactPath, message, errors) {+ return {+ ok: false,+ error: message,+ diagnostic: failureDiagnostic({+ code: 'viewer/evidence-write',+ message,+ subject: { artifact: path.resolve(artifactPath) },+ evidence: { errors },+ supportedFixes: ['restore write access to the evidence directory and rerun visual-check'],+ }),+ };+}++function fileIdentity(stat) {+ return {+ device: stat.dev,+ inode: stat.ino,+ mode: Number(stat.mode & 0o777n),+ links: stat.nlink,+ };+}++function identityMatches(stat, identity, { directory = false } = {}) {+ return stat.dev === identity.device+ && stat.ino === identity.inode+ && Number(stat.mode & 0o777n) === identity.mode+ && (directory ? stat.isDirectory() : stat.isFile())+ && !stat.isSymbolicLink();+}++function evidenceIdentityMatches(actual, expected, expectedLinks = expected?.links ?? 1) {+ return actual?.device === expected?.device+ && actual?.inode === expected?.inode+ && actual?.mode === expected?.mode+ && BigInt(actual?.links ?? 0) === BigInt(expectedLinks);+}++function stagedOutputs(outputs, stagingDirectory) {+ return {+ receipt: path.join(stagingDirectory, 'receipt.json'),+ contactSheet: path.join(stagingDirectory, 'contact-sheet.html'),+ screenshots: outputs.screenshots.map((entry, index) => ({+ ...entry,+ path: path.join(stagingDirectory, `capture-${index}.png`),+ })),+ };+}++function stagedPathFor(ownership, finalPath) {+ return ownership.stagingPaths.get(finalPath);+}++function registerStagedEvidence(ownership, finalPath) {+ const stagedPath = stagedPathFor(ownership, finalPath);+ let stat;+ try {+ stat = fs.lstatSync(stagedPath, { bigint: true });+ } catch (error) {+ throw new Error(`visual-check could not inspect staged evidence "${stagedPath}": ${error.message}`);+ }+ if (!stat.isFile() || stat.isSymbolicLink() || stat.ino === 0n) {+ throw new Error(`visual-check staged evidence is not a uniquely owned regular file: "${stagedPath}".`);+ }+ if (stat.nlink !== 1n) {+ ownership.stagedEntries.set(finalPath, {+ path: stagedPath,+ identity: fileIdentity(stat),+ });+ throw new Error(`visual-check staged evidence has an external hard link: "${stagedPath}".`);+ }+ const targetMode = ownership.targets.get(finalPath)?.mode;+ if (targetMode !== null && targetMode !== undefined+ && Number(stat.mode & 0o777n) !== targetMode) {+ fs.chmodSync(stagedPath, targetMode);+ const adjusted = fs.lstatSync(stagedPath, { bigint: true });+ if (adjusted.dev !== stat.dev || adjusted.ino !== stat.ino || !adjusted.isFile()) {+ throw new Error(`visual-check staged evidence changed while preserving its mode: "${stagedPath}".`);+ }+ stat = adjusted;+ }+ const entry = {+ path: stagedPath,+ identity: fileIdentity(stat),+ };+ ownership.stagedEntries.set(finalPath, entry);+ const evidence = regularFileEvidence(stagedPath);+ if (!evidence.ok || !evidenceIdentityMatches(evidence.identity, entry.identity)) {+ throw new Error(`visual-check could not bind staged evidence "${stagedPath}" to its contents.`);+ }+ entry.evidence = {+ sha256: evidence.evidence.sha256,+ bytes: evidence.evidence.bytes,+ };+}++function writeStagedEvidence(ownership, finalPath, contents) {+ const stagedPath = stagedPathFor(ownership, finalPath);+ const target = ownership.targets.get(finalPath);+ const mode = target?.mode ?? 0o666;+ let descriptor;+ try {+ descriptor = fs.openSync(stagedPath, 'wx', mode);+ let stat = fs.fstatSync(descriptor, { bigint: true });+ if (!stat.isFile() || stat.ino === 0n) {+ throw new Error('the newly created staging entry has no unique regular-file identity');+ }+ if (target?.mode !== null && target?.mode !== undefined+ && Number(stat.mode & 0o777n) !== target.mode) {+ fs.fchmodSync(descriptor, target.mode);+ const adjusted = fs.fstatSync(descriptor, { bigint: true });+ if (adjusted.dev !== stat.dev || adjusted.ino !== stat.ino || !adjusted.isFile()+ || Number(adjusted.mode & 0o777n) !== target.mode) {+ throw new Error('the staged evidence mode could not be preserved');+ }+ stat = adjusted;+ }+ const entry = {+ path: stagedPath,+ identity: fileIdentity(stat),+ };+ ownership.stagedEntries.set(finalPath, entry);+ if (stat.nlink !== 1n) {+ throw new Error('the newly created staging entry has an external hard link');+ }+ fs.writeFileSync(descriptor, contents);+ const bytes = Buffer.isBuffer(contents) ? contents : Buffer.from(contents);+ entry.evidence = { sha256: sha256(bytes), bytes: bytes.byteLength };+ } finally {+ if (descriptor !== undefined) fs.closeSync(descriptor);+ }+}++function unlinkOwnedEntry(file, identity, {+ evidence,+ expectedLinks,+} = {}) {+ let stat;+ try {+ stat = fs.lstatSync(file, { bigint: true });+ } catch (error) {+ return error?.code === 'ENOENT'+ ? { status: 'absent' }+ : { status: 'unknown', error };+ }+ if (!identityMatches(stat, identity)+ || (expectedLinks !== undefined && stat.nlink !== BigInt(expectedLinks))) {+ return { status: 'different', reason: 'identity' };+ }+ const verifiedLinks = expectedLinks ?? stat.nlink;+ if (evidence && !currentEvidenceMatches(+ file,+ identity,+ evidence,+ { expectedLinks: verifiedLinks },+ )) {+ return { status: 'different', reason: 'content' };+ }+ try {+ stat = fs.lstatSync(file, { bigint: true });+ } catch (error) {+ return error?.code === 'ENOENT'+ ? { status: 'absent' }+ : { status: 'unknown', error };+ }+ if (!identityMatches(stat, identity) || stat.nlink !== BigInt(verifiedLinks)) {+ return { status: 'different', reason: 'identity' };+ }+ try {+ fs.unlinkSync(file);+ return { status: 'removed' };+ } catch (error) {+ return { status: 'unknown', error };+ }+}++function quarantineOwnedPublishedEntry(file, identity, evidence, expectedLinks) {+ const captured = captureRegularFileBinding(file, {+ subject: 'published-evidence',+ expectedIdentity: identity,+ expectedMode: identity.mode,+ expectedSha256: evidence.sha256,+ expectedBytes: evidence.bytes,+ expectedLinks,+ });+ if (captured.status !== 'captured') {+ return captured.reason?.systemCode === 'ENOENT'+ ? { status: 'absent', reason: captured.reason }+ : captured;+ }+ let removal;+ let released;+ try {+ removal = quarantineRemoveRegularFileBinding(captured.binding, file, {+ subject: 'published-evidence',+ expectedLinks,+ });+ } finally {+ released = releaseRegularFileBinding(captured.binding);+ }+ if (released.status !== 'released') {+ return {+ status: 'unknown',+ reason: released.reason,+ removalStatus: removal?.status,+ ...(removal?.recoveryDirectory+ ? {+ recoveryDirectory: removal.recoveryDirectory,+ recoveryFile: removal.recoveryFile,+ target: removal.target,+ }+ : {}),+ };+ }+ return removal;+}++function backupOwnedPublishedEntry(file, backupPath, identity, evidence) {+ const captured = captureRegularFileBinding(file, {+ subject: 'previous-evidence',+ expectedIdentity: identity,+ expectedMode: identity.mode,+ expectedSha256: evidence.sha256,+ expectedBytes: evidence.bytes,+ expectedLinks: 1,+ });+ if (captured.status !== 'captured') {+ return { ...captured, backupCreated: false, backupVerified: false };+ }+ let backup;+ let released;+ try {+ backup = backupPublicRegularFileBinding(captured.binding, file, backupPath, {+ subject: 'previous-evidence',+ });+ } finally {+ released = releaseRegularFileBinding(captured.binding);+ }+ if (released.status !== 'released') {+ return {+ status: 'recovery-required',+ reason: {+ code: 'previous-evidence-binding-release-failed',+ bindingState: released.reason,+ },+ recoveryDirectory: backup?.recoveryDirectory || path.dirname(backupPath),+ recoveryFile: backup?.recoveryFile || (backup?.backupCreated ? backupPath : undefined),+ target: backup?.target || file,+ backupCreated: backup?.backupCreated === true,+ backupVerified: backup?.backupVerified === true,+ };+ }+ return backup;+}++function publishedRemovalError(file, result) {+ const code = result.reason?.code;+ let reason;+ if (result.status === 'preserved') {+ reason = 'published entry changed during retirement; its successor was restored and preserved';+ } else if (result.status === 'recovery-required') {+ reason = 'published entry changed during retirement; recovery material was preserved';+ } else if (code?.includes('content-changed')) {+ reason = 'published entry content changed; it was preserved';+ } else if (code?.includes('mode-changed')) {+ reason = 'published entry mode changed; it was preserved';+ } else if (result.status === 'different' || result.status === 'unsupported') {+ reason = 'published entry identity changed; it was preserved';+ } else {+ reason = code || 'published entry could not be safely retired; it was preserved';+ }+ return {+ file,+ reason,+ ...(code ? { code } : {}),+ ...(result.recoveryDirectory ? { recoveryDirectory: result.recoveryDirectory } : {}),+ ...(result.recoveryFile ? { recoveryFile: result.recoveryFile } : {}),+ ...(result.target ? { target: result.target } : {}),+ };+}++function cleanupStagedEvidence(ownership, { removeDirectory = false } = {}) {+ const errors = [];+ for (const [finalPath, entry] of [...ownership.stagedEntries]) {+ const result = unlinkOwnedEntry(entry.path, entry.identity);+ if (result.status === 'removed' || result.status === 'absent') {+ ownership.stagedEntries.delete(finalPath);+ } else {+ errors.push({+ file: entry.path,+ reason: result.status === 'different' && result.reason === 'content'+ ? 'staging entry content changed; it was preserved'+ : result.status === 'different'+ ? 'staging entry identity changed; it was preserved'+ : result.error?.message,+ });+ }+ }+ if (removeDirectory) {+ try {+ const stat = fs.lstatSync(ownership.stagingDirectory, { bigint: true });+ if (!identityMatches(stat, ownership.stagingIdentity, { directory: true })) {+ errors.push({+ file: ownership.stagingDirectory,+ reason: 'staging directory identity changed; it was preserved',+ });+ } else {+ fs.rmdirSync(ownership.stagingDirectory);+ }+ } catch (error) {+ if (error?.code !== 'ENOENT') {+ errors.push({ file: ownership.stagingDirectory, reason: error.message });+ }+ }+ }+ return errors;+}++function verifyVisualEvidenceTargets(artifactPath, outputs, ownership) {+ for (const target of visualEvidenceTargets(outputs)) {+ const captured = ownership.targets.get(target.path);+ const verification = captured ? verifyAtomicOutput(captured.snapshot) : {+ status: 'unknown',+ reason: { code: 'evidence-snapshot-missing' },+ };+ if (verification.status !== 'match') {+ return evidencePathConflict(artifactPath, outputs, target.path, verification.reason);+ }+ }+ return { ok: true };+}++function beginVisualEvidenceWrite(artifactPath, artifactBytes, outputs) {+ const targets = visualEvidenceTargets(outputs);+ const candidates = targets.map((target) => target.path);+ const previousEvidence = new Map();+ try {+ fs.mkdirSync(path.dirname(outputs.receipt), { recursive: true });+ } catch (error) {+ return evidenceWriteFailure(+ artifactPath,+ 'visual-check could not create its evidence directory.',+ [{ file: path.dirname(outputs.receipt), reason: error.message }],+ );+ }++ const capturedTargets = new Map();+ for (const target of targets) {+ const captured = captureAtomicOutput(target.path, {+ requestedEntryPolicy: 'regular-or-absent',+ });+ if (captured.status !== 'captured') {+ return evidencePathConflict(artifactPath, outputs, target.path, captured.reason);+ }+ capturedTargets.set(target.path, captured);+ }++ const parent = capturedTargets.get(outputs.receipt).snapshot.slot;+ for (const target of targets.slice(1)) {+ const slot = capturedTargets.get(target.path).snapshot.slot;+ if (slot.parentDevice !== parent.parentDevice || slot.parentInode !== parent.parentInode) {+ return evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'evidence-parent-mismatch',+ });+ }+ }++ const existing = candidates.filter((file) => (+ capturedTargets.get(file).snapshot.requestedEntry.kind === 'existing'+ ));+ if (existing.length) {+ const receiptEntry = capturedTargets.get(outputs.receipt).snapshot.requestedEntry;+ if (receiptEntry.kind !== 'existing') {+ return evidencePathConflict(artifactPath, outputs, existing[0], {+ code: 'ownership-receipt-missing',+ });+ }++ const previousReceipt = readRegularFileContents(outputs.receipt, {+ subject: 'ownership-receipt',+ });+ const capturedReceipt = capturedTargets.get(outputs.receipt).snapshot.target;+ if (!previousReceipt.ok || !evidenceIdentityMatches(previousReceipt.identity, {+ device: capturedReceipt.device,+ inode: capturedReceipt.inode,+ mode: capturedReceipt.mode,+ links: 1,+ })) {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-receipt-invalid',+ ...(previousReceipt.reason?.code ? { bindingCode: previousReceipt.reason.code } : {}),+ ...(previousReceipt.reason?.systemCode+ ? { systemCode: previousReceipt.reason.systemCode } : {}),+ });+ }+ const previousBytes = previousReceipt.bytes;+ let previous;+ try {+ previous = JSON.parse(previousBytes.toString('utf8'));+ } catch (error) {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-receipt-invalid',+ ...(error?.code ? { systemCode: error.code } : {}),+ });+ }+ previousEvidence.set(outputs.receipt, {+ ...previousReceipt.evidence,+ });++ if (previous?.schemaVersion !== 1 || previous?.command !== 'visual-check') {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-receipt-schema-mismatch',+ });+ }+ const recordedReceiptName = previous?.sidecars?.receipt;+ const recordedContactName = previous?.sidecars?.contactSheet;+ const recordedDirectory = previous?.sidecars?.directory || path.dirname(previous?.artifact?.path || '');+ const receiptNameSafe = typeof recordedReceiptName === 'string'+ // path-contract-allow: portable-logical-path -- receipt filenames are serialized logical basenames.+ && path.basename(recordedReceiptName) === recordedReceiptName;+ const contactNameSafe = typeof recordedContactName === 'string'+ // path-contract-allow: portable-logical-path -- contact-sheet filenames are serialized logical basenames.+ && path.basename(recordedContactName) === recordedContactName;+ if (!path.isAbsolute(recordedDirectory) || !receiptNameSafe || !contactNameSafe+ || sameLocation(path.join(recordedDirectory, recordedReceiptName), outputs.receipt).status !== 'match'+ || sameLocation(path.join(recordedDirectory, recordedContactName), outputs.contactSheet).status !== 'match') {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-sidecar-path-mismatch',+ });+ }+ if (typeof previous?.artifact?.path !== 'string'+ || !path.isAbsolute(previous.artifact.path)+ || sameEntry(previous.artifact.path, artifactPath).status !== 'match'+ || previous.artifact.sha256 !== sha256(artifactBytes)+ || previous.artifact.bytes !== artifactBytes.byteLength) {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-artifact-mismatch',+ });+ }++ const existingEvidence = visualEvidencePaths(outputs).filter((file) => (+ capturedTargets.get(file).snapshot.requestedEntry.kind === 'existing'+ ));+ const recordedEvidence = previous?.sidecars?.files;+ if (existingEvidence.length && !Array.isArray(recordedEvidence)) {+ return evidencePathConflict(artifactPath, outputs, existingEvidence[0], {+ code: 'ownership-evidence-digests-missing',+ });+ }+ if (Array.isArray(recordedEvidence)) {+ const allowed = new Map(visualEvidencePaths(outputs).map((file) => [path.basename(file), file]));+ const recorded = new Map();+ for (const item of recordedEvidence) {+ if (!item || typeof item.file !== 'string' || recorded.has(item.file) || !allowed.has(item.file)) {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-evidence-list-invalid',+ });+ }+ recorded.set(item.file, item);+ }+ if (recorded.size !== existingEvidence.length+ || existingEvidence.some((file) => !recorded.has(path.basename(file)))) {+ return evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'ownership-evidence-list-mismatch',+ });+ }+ for (const file of existingEvidence) {+ const actual = regularFileEvidence(file);+ const expected = recorded.get(path.basename(file));+ if (!actual.ok+ || actual.evidence.sha256 !== expected.sha256+ || actual.evidence.bytes !== expected.bytes) {+ return evidencePathConflict(artifactPath, outputs, file, {+ code: actual.ok ? 'ownership-evidence-digest-mismatch' : actual.reason.code,+ ...(!actual.ok && actual.reason.systemCode+ ? { systemCode: actual.reason.systemCode } : {}),+ });+ }+ previousEvidence.set(file, {+ sha256: actual.evidence.sha256,+ bytes: actual.evidence.bytes,+ });+ }+ }++ }++ for (const target of targets) {+ const verification = verifyAtomicOutput(capturedTargets.get(target.path).snapshot);+ if (verification.status !== 'match') {+ return evidencePathConflict(artifactPath, outputs, target.path, verification.reason);+ }+ }++ let stagingDirectory;+ let stagingStat;+ try {+ stagingDirectory = fs.mkdtempSync(path.join(parent.parentPath, '.archify-visual-check-'));+ stagingStat = fs.lstatSync(stagingDirectory, { bigint: true });+ if (!stagingStat.isDirectory() || stagingStat.isSymbolicLink() || stagingStat.ino === 0n) {+ throw new Error('the newly created staging directory has no stable directory identity');+ }+ } catch (error) {+ return evidenceWriteFailure(+ artifactPath,+ 'visual-check could not create a private evidence staging directory.',+ [{ file: parent.parentPath, reason: error.message }],+ );+ }++ const staged = stagedOutputs(outputs, stagingDirectory);+ const ownership = {+ active: true,+ artifact: path.resolve(artifactPath),+ receipt: outputs.receipt,+ targets: capturedTargets,+ stagingDirectory,+ stagingIdentity: fileIdentity(stagingStat),+ stagedOutputs: staged,+ stagingPaths: new Map([+ [outputs.receipt, staged.receipt],+ [outputs.contactSheet, staged.contactSheet],+ ...outputs.screenshots.map((entry, index) => [entry.path, staged.screenshots[index].path]),+ ]),+ stagedEntries: new Map(),+ previousEvidence,+ };+ visualEvidenceOwnerships.add(ownership);+ return { ok: true, ownership };+}++function recordVisualEvidenceFiles(receipt, outputs, ownership) {+ const files = [];+ for (const file of visualEvidencePaths(outputs)) {+ const staged = ownership.stagedEntries.get(file);+ if (!staged || !currentEvidenceMatches(staged.path, staged.identity, staged.evidence)) {+ const error = new Error(`visual-check could not bind evidence file "${file}" to its receipt.`);+ error.evidenceReason = { code: 'staged-evidence-content-mismatch' };+ throw error;+ }+ files.push({ ...staged.evidence, file: path.basename(file) });+ }+ receipt.sidecars.files = files;+}++function currentUniqueEntryMatches(file, identity) {+ try {+ const stat = fs.lstatSync(file, { bigint: true });+ return stat.nlink === 1n && identityMatches(stat, identity);+ } catch {+ return false;+ }+}++function currentEvidenceMatches(file, identity, evidence, {+ expectedLinks = identity.links ?? 1,+} = {}) {+ if (!evidence) return false;+ const current = regularFileEvidence(file, { expectedLinks: Number(expectedLinks) });+ return current.ok+ && evidenceIdentityMatches(current.identity, identity, expectedLinks)+ && current.evidence.sha256 === evidence.sha256+ && current.evidence.bytes === evidence.bytes;+}++function linkedEntriesMatch(stagedPath, finalPath, identity) {+ try {+ const staged = fs.lstatSync(stagedPath, { bigint: true });+ const published = fs.lstatSync(finalPath, { bigint: true });+ return staged.nlink === 2n+ && published.nlink === 2n+ && identityMatches(staged, identity)+ && identityMatches(published, identity);+ } catch {+ return false;+ }+}++function restoreOwnedBackup(backup, errors) {+ const expectedLinks = backup.identity.links ?? 1n;+ const expectedLinkCount = Number(expectedLinks);+ let backupStat;+ try {+ backupStat = fs.lstatSync(backup.path, { bigint: true });+ } catch {+ errors.push({ file: backup.path, reason: 'backup identity changed; it was preserved' });+ return;+ }+ if (!identityMatches(backupStat, backup.identity) || backupStat.nlink !== expectedLinks) {+ errors.push({ file: backup.path, reason: 'backup identity changed; it was preserved' });+ return;+ }+ let captured = backup.evidence && Number.isSafeInteger(expectedLinkCount)+ ? captureRegularFileBinding(backup.path, {+ subject: 'restore-backup',+ expectedIdentity: backup.identity,+ expectedMode: backup.identity.mode,+ expectedSha256: backup.evidence.sha256,+ expectedBytes: backup.evidence.bytes,+ expectedLinks: expectedLinkCount,+ })+ : { status: 'unknown', reason: { code: 'restore-backup-evidence-unavailable' } };+ let contentChanged = false;+ if (captured.status !== 'captured'+ && captured.reason?.code === 'restore-backup-content-changed') {+ captured = captureRegularFileBinding(backup.path, {+ subject: 'restore-backup-claimant',+ expectedIdentity: backup.identity,+ expectedMode: backup.identity.mode,+ expectedLinks: expectedLinkCount,+ });+ contentChanged = captured.status === 'captured';+ }+ if (captured.status !== 'captured') {+ errors.push({+ file: backup.path,+ reason: 'backup bytes, mode, or identity changed; it was preserved',+ ...(captured.reason?.code ? { code: captured.reason.code } : {}),+ });+ return;+ }+ let released;+ try {+ const finalEntry = pathEntry(backup.finalPath);+ if (finalEntry.exists === true) {+ errors.push({+ file: backup.path,+ reason: 'final path is occupied; the owned backup was preserved',+ });+ return;+ }+ if (finalEntry.exists === null) {+ errors.push({ file: backup.finalPath, reason: finalEntry.error?.message });+ return;+ }+ try {+ fs.linkSync(backup.path, backup.finalPath);+ const linkedCount = expectedLinkCount + 1;+ const staged = verifyRegularFileBinding(captured.binding, {+ filePath: backup.path,+ expectedLinks: linkedCount,+ });+ const published = verifyRegularFileBinding(captured.binding, {+ filePath: backup.finalPath,+ expectedLinks: linkedCount,+ });+ if (staged.status !== 'match' || published.status !== 'match') {+ const removed = quarantineRemoveRegularFileBinding(+ captured.binding,+ backup.finalPath,+ { subject: 'restored-evidence', expectedLinks: linkedCount },+ );+ errors.push({+ file: backup.path,+ reason: removed.status === 'removed'+ ? 'restored entry identity could not be verified; the owned backup was preserved'+ : removed.status === 'preserved'+ ? 'restored entry changed during cleanup; its successor and the owned backup were preserved'+ : 'restored entry changed before rollback; both entries were preserved',+ ...(removed.reason?.code ? { code: removed.reason.code } : {}),+ ...(removed.recoveryDirectory ? { recoveryDirectory: removed.recoveryDirectory } : {}),+ ...(removed.recoveryFile ? { recoveryFile: removed.recoveryFile } : {}),+ });+ return;+ }+ const removed = unlinkOwnedEntry(backup.path, backup.identity);+ const finalMatches = verifyRegularFileBinding(captured.binding, {+ filePath: backup.finalPath,+ expectedLinks: expectedLinkCount,+ }).status === 'match';+ if (removed.status !== 'removed' || !finalMatches) {+ errors.push({ file: backup.path, reason: 'restored entry link count could not be finalized' });+ } else if (contentChanged) {+ errors.push({+ file: backup.finalPath,+ reason: 'the backup content changed externally; its current bytes were restored and preserved',+ });+ }+ } catch (error) {+ errors.push({+ file: backup.path,+ reason: error?.code === 'EEXIST'+ ? 'final path was claimed during restore; the owned backup was preserved'+ : error.message,+ });+ }+ } finally {+ released = releaseRegularFileBinding(captured.binding);+ if (released.status !== 'released') {+ errors.push({+ file: backup.path,+ reason: 'restored backup binding could not be released cleanly',+ ...(released.reason?.code ? { code: released.reason.code } : {}),+ });+ }+ }+}++function commitVisualEvidence(artifactPath, outputs, ownership, desiredPaths) {+ const verification = verifyVisualEvidenceTargets(artifactPath, outputs, ownership);+ if (!verification.ok) {+ cleanupStagedEvidence(ownership, { removeDirectory: true });+ ownership.active = false;+ return verification;+ }++ const desired = new Set(desiredPaths);+ for (const finalPath of desired) {+ const staged = ownership.stagedEntries.get(finalPath);+ if (!staged || !currentEvidenceMatches(staged.path, staged.identity, staged.evidence)) {+ const failure = evidenceWriteFailure(+ artifactPath,+ 'visual-check could not verify its staged evidence before publication.',+ [{ file: staged?.path || stagedPathFor(ownership, finalPath), reason: 'staged entry missing or changed' }],+ );+ cleanupStagedEvidence(ownership, { removeDirectory: true });+ ownership.active = false;+ return failure;+ }+ }++ const backups = [];+ const published = [];+ let conflict = null;+ try {+ for (const [index, target] of visualEvidenceTargets(outputs).entries()) {+ const captured = ownership.targets.get(target.path);+ if (captured.snapshot.target.kind !== 'file') continue;+ const backupPath = path.join(ownership.stagingDirectory, `previous-${index}`);+ const identity = {+ device: captured.snapshot.target.device,+ inode: captured.snapshot.target.inode,+ mode: captured.snapshot.target.mode,+ links: 1n,+ };+ const evidence = ownership.previousEvidence.get(target.path);+ if (!evidence) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'target-evidence-missing-during-commit',+ });+ throw new Error(conflict.error);+ }+ const backup = {+ targetPath: target.path,+ finalPath: captured.commitPath,+ path: backupPath,+ identity,+ evidence,+ };+ const backupResult = backupOwnedPublishedEntry(+ captured.commitPath,+ backupPath,+ identity,+ evidence,+ );+ if (backupResult.backupCreated) backups.push(backup);+ if (backupResult.status !== 'backed-up'+ || !backupResult.backupCreated+ || !backupResult.backupVerified) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: backupResult.reason?.code || 'target-backup-failed-during-commit',+ backupCreated: backupResult.backupCreated === true,+ backupVerified: backupResult.backupVerified === true,+ ...(backupResult.recoveryDirectory+ ? { recoveryDirectory: backupResult.recoveryDirectory } : {}),+ ...(backupResult.recoveryFile ? { recoveryFile: backupResult.recoveryFile } : {}),+ ...(backupResult.target ? { target: backupResult.target } : {}),+ ...(backupResult.reason ? { bindingState: backupResult.reason } : {}),+ });+ throw new Error(conflict.error);+ }+ }++ const publicationOrder = visualEvidenceTargets(outputs)+ .filter((target) => desired.has(target.path))+ .sort((left, right) => Number(left.kind === 'receipt') - Number(right.kind === 'receipt'));+ for (const target of publicationOrder) {+ const captured = ownership.targets.get(target.path);+ const staged = ownership.stagedEntries.get(target.path);+ if (!currentEvidenceMatches(staged.path, staged.identity, staged.evidence)) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'staged-evidence-content-mismatch',+ });+ throw new Error(conflict.error);+ }+ try {+ fs.linkSync(staged.path, captured.commitPath);+ } catch (error) {+ if (error?.code === 'EEXIST') {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'target-created-during-commit',+ });+ }+ throw error;+ }+ published.push({+ finalPath: captured.commitPath,+ stagedPath: staged.path,+ identity: staged.identity,+ evidence: staged.evidence,+ });+ if (!linkedEntriesMatch(staged.path, captured.commitPath, staged.identity)) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'published-entry-identity-mismatch',+ });+ throw new Error(conflict.error);+ }+ if (!currentEvidenceMatches(+ staged.path,+ staged.identity,+ staged.evidence,+ { expectedLinks: 2 },+ )) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'published-entry-content-mismatch',+ });+ throw new Error(conflict.error);+ }+ const removed = unlinkOwnedEntry(staged.path, staged.identity, {+ evidence: staged.evidence,+ expectedLinks: 2,+ });+ if (removed.status !== 'removed') {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: removed.reason === 'content'+ ? 'published-entry-content-mismatch'+ : 'published-entry-identity-mismatch',+ });+ throw new Error(`visual-check could not retire staged evidence "${staged.path}".`);+ }+ ownership.stagedEntries.delete(target.path);+ if (!currentUniqueEntryMatches(captured.commitPath, staged.identity)) {+ conflict = evidencePathConflict(artifactPath, outputs, target.path, {+ code: 'published-entry-link-count-mismatch',+ });+ throw new Error(conflict.error);+ }+ }++ // Receipt publication is the linearization point for the evidence set.+ // Recheck every earlier member afterwards so a writer that replaces a PNG+ // or the contact sheet while later members publish cannot yield success.+ for (const entry of published) {+ if (!currentUniqueEntryMatches(entry.finalPath, entry.identity)) {+ conflict = evidencePathConflict(artifactPath, outputs, entry.finalPath, {+ code: 'published-set-identity-mismatch',+ });+ throw new Error(conflict.error);+ }+ if (!currentEvidenceMatches(entry.finalPath, entry.identity, entry.evidence)) {+ conflict = evidencePathConflict(artifactPath, outputs, entry.finalPath, {+ code: 'published-set-content-mismatch',+ });+ throw new Error(conflict.error);+ }+ }++ for (const backup of backups) {+ if (!currentEvidenceMatches(+ backup.path,+ backup.identity,+ ownership.previousEvidence.get(backup.targetPath),+ )) {+ conflict = evidencePathConflict(artifactPath, outputs, backup.targetPath, {+ code: 'backup-content-changed-before-cleanup',+ });+ throw new Error(conflict.error);+ }+ }++ const cleanupErrors = [];+ for (const backup of backups) {+ const removed = unlinkOwnedEntry(backup.path, backup.identity, {+ evidence: backup.evidence,+ });+ if (removed.status !== 'removed' && removed.status !== 'absent') {+ cleanupErrors.push({+ file: backup.path,+ reason: removed.status === 'different' && removed.reason === 'content'+ ? 'backup content changed; it was preserved'+ : removed.status === 'different'+ ? 'backup identity changed; it was preserved'+ : removed.error?.message,+ });+ }+ }+ cleanupErrors.push(...cleanupStagedEvidence(ownership, { removeDirectory: true }));+ ownership.active = false;+ let recoveryDirectory;+ if (cleanupErrors.length) {+ try {+ const retained = fs.lstatSync(ownership.stagingDirectory, { bigint: true });+ if (identityMatches(retained, ownership.stagingIdentity, { directory: true })) {+ recoveryDirectory = ownership.stagingDirectory;+ }+ } catch {}+ }+ return {+ ok: true,+ status: cleanupErrors.length ? 'committed-with-warning' : 'committed',+ cleanupErrors,+ ...(recoveryDirectory ? { recoveryDirectory } : {}),+ committedReceipt: outputs.receipt,+ };+ } catch (error) {+ const rollbackErrors = [];+ const conflictReason = conflict?.diagnostic?.evidence?.reason?.code;+ for (const entry of [...published].reverse()) {+ let stagingLinkRemains = false;+ try {+ const staged = fs.lstatSync(entry.stagedPath, { bigint: true });+ stagingLinkRemains = identityMatches(staged, entry.identity);+ } catch {}+ const mayRetireHardlinkedPublication = stagingLinkRemains+ && conflictReason === 'published-entry-identity-mismatch';+ let expectedLinks = stagingLinkRemains ? 2 : 1;+ let removed;+ if (mayRetireHardlinkedPublication) {+ try {+ const current = fs.lstatSync(entry.finalPath, { bigint: true });+ const currentLinks = Number(current.nlink);+ if (!identityMatches(current, entry.identity)+ || !Number.isSafeInteger(currentLinks)+ || currentLinks < 1) {+ removed = {+ status: 'different',+ reason: { code: 'published-evidence-identity-changed' },+ };+ } else {+ expectedLinks = currentLinks;+ }+ } catch (inspectionError) {+ removed = inspectionError?.code === 'ENOENT'+ ? { status: 'absent' }+ : {+ status: 'unknown',+ reason: {+ code: 'published-evidence-inspection-failed',+ ...(inspectionError?.code ? { systemCode: inspectionError.code } : {}),+ },+ };+ }+ }+ removed ||= quarantineOwnedPublishedEntry(+ entry.finalPath,+ entry.identity,+ entry.evidence,+ expectedLinks,+ );+ if (removed.status !== 'removed' && removed.status !== 'absent') {+ rollbackErrors.push(publishedRemovalError(entry.finalPath, removed));+ }+ }+ for (const backup of [...backups].reverse()) restoreOwnedBackup(backup, rollbackErrors);+ rollbackErrors.push(...cleanupStagedEvidence(ownership, { removeDirectory: true }));+ ownership.active = false;+ if (conflict) {+ if (rollbackErrors.length) conflict.diagnostic.evidence.rollbackErrors = rollbackErrors;+ return conflict;+ }+ return evidenceWriteFailure(+ artifactPath,+ 'visual-check could not atomically publish its evidence set.',+ [{ reason: error.message }, ...rollbackErrors],+ );+ }}function executable(file, platform = process.platform) {@@ -90,24 +1229,29 @@ function executable(file, platform = process.platform) {}}-function findOnPath(command, env, platform) {- const directories = String(env.PATH || '').split(path.delimiter).filter(Boolean);+function findOnPath(command, env, platform, resolveExecutable) {+ const pathApi = platform === 'win32' ? path.win32 : path;+ const directories = String(env.PATH || '').split(pathApi.delimiter).filter(Boolean);const extensions = platform === 'win32'? String(env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';').filter(Boolean): [''];for (const directory of directories) {for (const extension of extensions) {- const candidate = path.join(directory, `${command}${extension}`);- const resolved = executable(candidate, platform);+ const candidate = pathApi.join(directory, `${command}${extension}`);+ const resolved = resolveExecutable(candidate, platform);if (resolved) return resolved;}}return null;}-export function findChrome({ env = process.env, platform = process.platform } = {}) {+export function findChrome({+ env = process.env,+ platform = process.platform,+ resolveExecutable = executable,+} = {}) {if (Object.prototype.hasOwnProperty.call(env, 'ARCHIFY_CHROME')) {- return executable(env.ARCHIFY_CHROME, platform);+ return resolveExecutable(env.ARCHIFY_CHROME, platform);}const fixed = [];@@ -118,22 +1262,24 @@ export function findChrome({ env = process.env, platform = process.platform } ='/Applications/Chromium.app/Contents/MacOS/Chromium',);} else if (platform === 'win32') {+ const pathApi = path.win32;for (const root of [env.PROGRAMFILES, env['PROGRAMFILES(X86)'], env.LOCALAPPDATA].filter(Boolean)) {fixed.push(- path.join(root, 'Google', 'Chrome', 'Application', 'chrome.exe'),- path.join(root, 'Chromium', 'Application', 'chrome.exe'),+ pathApi.join(root, 'Google', 'Chrome', 'Application', 'chrome.exe'),+ pathApi.join(root, 'Chromium', 'Application', 'chrome.exe'),);}+ commands.push('chrome', 'google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser');} else {commands.push('google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser');}for (const candidate of fixed) {- const resolved = executable(candidate, platform);+ const resolved = resolveExecutable(candidate, platform);if (resolved) return resolved;}for (const command of commands) {- const resolved = findOnPath(command, env, platform);+ const resolved = findOnPath(command, env, platform, resolveExecutable);if (resolved) return resolved;}return null;@@ -492,7 +1638,7 @@ export class ChromeVisualBrowser {captureBeyondViewport: false,}, sessionId, 20000);if (!capture.data) throw new Error('Chrome returned an empty screenshot.');- fs.writeFileSync(screenshotPath, Buffer.from(capture.data, 'base64'));+ fs.writeFileSync(screenshotPath, Buffer.from(capture.data, 'base64'), { flag: 'wx' });}return metrics;}@@ -615,6 +1761,39 @@ function failureDiagnostic({ code, message, subject, evidence, supportedFixes, sreturn { code, severity, message, subject, evidence, supportedFixes };}+function resolveSidecarDirectory(artifactPath, outputs, compareParents) {+ const artifact = path.resolve(artifactPath);+ const artifactDirectory = path.dirname(artifact);+ const sidecarDirectory = path.dirname(outputs.receipt);+ const comparison = compareParents(outputs.receipt, artifact);++ const sidecars = {+ ...(comparison?.status === 'different' ? { directory: sidecarDirectory } : {}),+ receipt: path.basename(outputs.receipt),+ contactSheet: path.basename(outputs.contactSheet),+ };+ if (comparison?.status === 'match' || comparison?.status === 'different') {+ return { ok: true, sidecars };+ }++ const reason = comparison?.reason || { code: 'invalid-path-identity-result' };+ const error = `visual-check could not determine the physical identity of its evidence directory "${sidecarDirectory}" relative to the artifact directory "${artifactDirectory}".`;+ return {+ ok: false,+ sidecars,+ error,+ diagnostic: failureDiagnostic({+ code: 'viewer/sidecar-directory-identity',+ message: error,+ subject: { artifact, sidecarDirectory },+ evidence: { comparison: reason },+ supportedFixes: [+ 'use existing, accessible artifact and evidence directories, then rerun visual-check',+ ],+ }),+ };+}+function observationDiagnostics({ artifact, allObservations, readabilityObservations }) {const diagnostics = [];for (const entry of allObservations) {@@ -694,7 +1873,7 @@ function observationDiagnostics({ artifact, allObservations, readabilityObservatreturn diagnostics;}-function baseReceipt({ artifactPath, artifact, outputs, chrome, deliveryProvenance }) {+function baseReceipt({ artifactPath, artifact, sidecars, chrome, deliveryProvenance }) {return {schemaVersion: 1,ok: false,@@ -718,54 +1897,134 @@ function baseReceipt({ artifactPath, artifact, outputs, chrome, deliveryProvenanreadability: { status: 'fail', minimumProjectedNodeTextPx: MIN_PROJECTED_NODE_TEXT_PX, viewports: [] },viewerChrome: { status: 'fail', viewports: [] },captures: { status: 'fail', screenshots: [], contactSheet: null },- sidecars: {- ...(path.dirname(outputs.receipt) !== path.dirname(artifactPath)- ? { directory: path.dirname(outputs.receipt) } : {}),- receipt: path.basename(outputs.receipt),- contactSheet: path.basename(outputs.contactSheet),- },+ sidecars: { ...sidecars, files: [] },};}-function persistReceipt(outputs, receipt) {- writeAtomic(outputs.receipt, `${JSON.stringify(receipt, null, 2)}\n`);+function appendEvidencePublicationFailure(receipt, failure) {+ if (!failure?.ok) {+ if (!receipt.error) receipt.error = failure.error;+ receipt.diagnostics = [...(receipt.diagnostics || []), failure.diagnostic];+ }+}++function appendEvidenceCleanupWarning(receipt, publication) {+ if (publication?.status !== 'committed-with-warning') return false;+ const committedStatus = receipt.status;+ const cleanupErrors = publication.cleanupErrors || [];+ const cleanupMessage = publication.recoveryDirectory+ ? `The evidence set was committed, but cleanup is incomplete. Recovery directory: "${publication.recoveryDirectory}".`+ : 'The evidence set was committed, but cleanup is incomplete.';+ receipt.ok = false;+ receipt.status = 'fail';+ receipt.error = receipt.error ? `${receipt.error} ${cleanupMessage}` : cleanupMessage;+ receipt.publication = {+ status: publication.status,+ committedReceipt: publication.committedReceipt,+ ...(publication.recoveryDirectory+ ? { recoveryDirectory: publication.recoveryDirectory } : {}),+ cleanupErrors,+ committedStatus,+ };+ receipt.diagnostics = [...(receipt.diagnostics || []), failureDiagnostic({+ code: 'viewer/evidence-cleanup-incomplete',+ severity: 'warning',+ message: cleanupMessage,+ subject: {+ artifact: receipt.artifact?.path,+ receipt: publication.committedReceipt,+ },+ evidence: {+ publicationStatus: publication.status,+ ...(publication.recoveryDirectory+ ? { recoveryDirectory: publication.recoveryDirectory } : {}),+ cleanupErrors,+ },+ supportedFixes: publication.recoveryDirectory+ ? [`inspect and safely retire the retained files under "${publication.recoveryDirectory}"`]+ : ['resolve the reported filesystem cleanup failure before rerunning visual-check'],+ })];+ return true;}-export function persistVisualCheckFailure(artifactPath, failure, { outDir } = {}) {+function publishReceiptOnly(artifactPath, outputs, receipt, ownership) {+ const cleanupErrors = cleanupStagedEvidence(ownership);+ if (cleanupErrors.length) {+ const failure = evidenceWriteFailure(+ artifactPath,+ 'visual-check could not safely retire this run\'s incomplete staged evidence.',+ cleanupErrors,+ );+ cleanupStagedEvidence(ownership, { removeDirectory: true });+ ownership.active = false;+ return failure;+ }+ try {+ writeStagedEvidence(ownership, outputs.receipt, `${JSON.stringify(receipt, null, 2)}\n`);+ } catch (error) {+ const failure = evidenceWriteFailure(+ artifactPath,+ 'visual-check could not stage its evidence receipt.',+ [{ file: stagedPathFor(ownership, outputs.receipt), reason: error.message }],+ );+ cleanupStagedEvidence(ownership, { removeDirectory: true });+ ownership.active = false;+ return failure;+ }+ return commitVisualEvidence(artifactPath, outputs, ownership, [outputs.receipt]);+}++export function persistVisualCheckFailure(+ artifactPath,+ failure,+ { outDir, compareSidecarParents = sameParent, ownership } = {},+) {const outputs = sidecarPaths(artifactPath, { outDir });+ const directory = resolveSidecarDirectory(artifactPath, outputs, compareSidecarParents);+ const capturedArtifact = readRegularFileContents(artifactPath, {+ subject: 'failure-artifact',+ });+ const artifactBytes = capturedArtifact.ok ? capturedArtifact.bytes : null;const receipt = {...failure,ok: false, status: 'fail',+ ...(artifactBytes ? {+ artifact: {+ path: path.resolve(artifactPath),+ sha256: sha256(artifactBytes),+ bytes: artifactBytes.byteLength,+ },+ } : {}),containment: { status: 'fail', viewports: [] },captures: { status: 'fail', screenshots: [], contactSheet: null },- sidecars: {- ...(path.dirname(outputs.receipt) !== path.dirname(path.resolve(artifactPath))- ? { directory: path.dirname(outputs.receipt) } : {}),- receipt: path.basename(outputs.receipt),- contactSheet: path.basename(outputs.contactSheet),- },+ sidecars: { ...directory.sidecars, files: [] },};- const errors = [];- try { fs.mkdirSync(path.dirname(outputs.receipt), { recursive: true }); } catch (error) {- errors.push({ file: path.dirname(outputs.receipt), reason: error.message });- }- for (const file of [outputs.receipt, outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)]) {- try { fs.rmSync(file, { force: true }); } catch (error) { errors.push({ file, reason: error.message }); }+ if (!directory.ok) {+ receipt.error = directory.error;+ receipt.diagnostics = [...(failure.diagnostics || []), directory.diagnostic];+ return receipt;}- const reportErrors = () => {- receipt.diagnostics = [...(failure.diagnostics || []), failureDiagnostic({- code: 'viewer/evidence-write', message: 'Previous visual evidence could not be fully invalidated or replaced.',- subject: { artifact: path.resolve(artifactPath) }, evidence: { errors },- supportedFixes: ['restore write access to the evidence files and rerun visual-check'],- })];- };- if (errors.length) reportErrors();- try {- persistReceipt(outputs, receipt);- } catch (error) {- errors.push({ file: outputs.receipt, reason: error.message });- reportErrors();+ let activeOwnership = ownership;+ if (!visualEvidenceOwnershipMatches(activeOwnership, artifactPath, outputs)) {+ if (!artifactBytes) {+ const conflict = evidencePathConflict(artifactPath, outputs, outputs.receipt, {+ code: 'artifact-unreadable',+ });+ receipt.error = conflict.error;+ receipt.diagnostics = [...(failure.diagnostics || []), conflict.diagnostic];+ return receipt;+ }+ const preflight = beginVisualEvidenceWrite(artifactPath, artifactBytes, outputs);+ if (!preflight.ok) {+ receipt.error = preflight.error;+ receipt.diagnostics = [...(failure.diagnostics || []), preflight.diagnostic];+ return receipt;+ }+ activeOwnership = preflight.ownership;}+ const publication = publishReceiptOnly(artifactPath, outputs, receipt, activeOwnership);+ appendEvidencePublicationFailure(receipt, publication);+ appendEvidenceCleanupWarning(receipt, publication);return receipt;}@@ -777,13 +2036,42 @@ export async function runVisualCheck({browserFactory = async (resolvedChrome) => new ChromeVisualBrowser(resolvedChrome),deliveryProvenance,verifyArtifact,+ compareSidecarParents = sameParent,} = {}) {if (!artifactPath) throw new Error('visual-check requires one delivered HTML artifact.');const artifact = path.resolve(artifactPath);if (!/\.html?$/i.test(artifact)) throw new Error('visual-check requires an .html artifact.');- const artifactBytes = fs.readFileSync(artifact);+ const capturedArtifact = captureRegularFileBinding(artifact, {+ subject: 'visual-check-artifact',+ expectedLinks: 1,+ includeContent: true,+ });+ if (capturedArtifact.status !== 'captured') {+ throw regularFileCaptureError('The visual-check artifact', capturedArtifact);+ }+ const artifactBytes = capturedArtifact.content.buffer;+ try {const outputs = sidecarPaths(artifact, { outDir });- fs.mkdirSync(path.dirname(outputs.receipt), { recursive: true });+ const directory = resolveSidecarDirectory(artifact, outputs, compareSidecarParents);+ const receipt = baseReceipt({+ artifactPath: artifact,+ artifact: artifactBytes,+ sidecars: directory.sidecars,+ chrome: { status: 'not-checked', executable: null },+ deliveryProvenance,+ });+ if (!directory.ok) {+ receipt.error = directory.error;+ receipt.diagnostics = [directory.diagnostic];+ return { exitCode: EXIT.fail, receipt };+ }+ const preflight = beginVisualEvidenceWrite(artifact, artifactBytes, outputs);+ if (!preflight.ok) {+ receipt.error = preflight.error;+ receipt.diagnostics = [preflight.diagnostic];+ return { exitCode: EXIT.fail, receipt };+ }+ const ownership = preflight.ownership;try {verifyArtifact?.(artifactBytes);} catch (error) {@@ -792,21 +2080,13 @@ export async function runVisualCheck({artifact: { path: artifact, sha256: sha256(artifactBytes), bytes: artifactBytes.byteLength },provenance: error.deliveryProvenance?.status, error: error.message,diagnostics: error.archifyDiagnostics || [],- }, { outDir }) };+ }, { outDir, compareSidecarParents, ownership }) };}- cleanupCaptureSidecars(outputs);- safeUnlink(outputs.receipt);const resolvedChrome = chromePath || resolveChrome();- const receipt = baseReceipt({- artifactPath: artifact,- artifact: artifactBytes,- outputs,- chrome: resolvedChrome- ? { status: 'available', executable: resolvedChrome }- : { status: 'unavailable', executable: null },- deliveryProvenance,- });+ receipt.chrome = resolvedChrome+ ? { status: 'available', executable: resolvedChrome }+ : { status: 'unavailable', executable: null };if (!resolvedChrome) {receipt.status = 'skipped';@@ -823,7 +2103,14 @@ export async function runVisualCheck({evidence: { executable: null },supportedFixes: ['set ARCHIFY_CHROME to a Chrome or Chromium executable and rerun visual-check'],})];- persistReceipt(outputs, receipt);+ const publication = publishReceiptOnly(artifact, outputs, receipt, ownership);+ if (!publication.ok) {+ appendEvidencePublicationFailure(receipt, publication);+ return { exitCode: EXIT.fail, receipt };+ }+ if (appendEvidenceCleanupWarning(receipt, publication)) {+ return { exitCode: EXIT.fail, receipt };+ }return { exitCode: EXIT.skipped, receipt };}@@ -831,9 +2118,9 @@ export async function runVisualCheck({try {browser = await browserFactory(resolvedChrome);const observations = new Map();- const screenshotsByKey = new Map(outputs.screenshots.map((entry) => [+ const screenshotsByKey = new Map(outputs.screenshots.map((entry, index) => [screenshotKey(entry.width, entry.height, entry.theme),- entry,+ { ...entry, stagedPath: ownership.stagedOutputs.screenshots[index].path },]));for (const viewport of VISUAL_CHECK_VIEWPORTS) {@@ -843,8 +2130,9 @@ export async function runVisualCheck({artifactPath: artifact,...viewport,theme: 'light',- ...(screenshot ? { screenshotPath: screenshot.path } : {}),+ ...(screenshot ? { screenshotPath: screenshot.stagedPath } : {}),});+ if (screenshot) registerStagedEvidence(ownership, screenshot.path);observations.set(key, observation({ ...viewport, theme: 'light', metrics }));}for (const viewport of CAPTURE_VIEWPORTS) {@@ -854,15 +2142,20 @@ export async function runVisualCheck({artifactPath: artifact,...viewport,theme: 'dark',- screenshotPath: screenshot.path,+ screenshotPath: screenshot.stagedPath,});+ registerStagedEvidence(ownership, screenshot.path);observations.set(key, observation({ ...viewport, theme: 'dark', metrics }));}- const afterBytes = fs.readFileSync(artifact);- verifyArtifact?.(afterBytes);- if (sha256(afterBytes) !== receipt.artifact.sha256 || afterBytes.byteLength !== receipt.artifact.bytes) {- throw new Error('The delivered artifact changed while visual-check was running.');+ let artifactVerification = verifyRegularFileBinding(capturedArtifact.binding);+ if (artifactVerification.status !== 'match') {+ throw regularFileCaptureError('The delivered artifact changed while visual-check was running', artifactVerification);+ }+ verifyArtifact?.(artifactBytes);+ artifactVerification = verifyRegularFileBinding(capturedArtifact.binding);+ if (artifactVerification.status !== 'match') {+ throw regularFileCaptureError('The delivered artifact changed while visual-check was running', artifactVerification);}receipt.containment.viewports = VISUAL_CHECK_VIEWPORTS.map(({ width, height }) => (@@ -890,12 +2183,28 @@ export async function runVisualCheck({receipt.captures.contactSheet = path.basename(outputs.contactSheet);receipt.status = containmentPass && readabilityPass && viewerChromePass ? 'pass' : 'fail';receipt.ok = containmentPass && readabilityPass && viewerChromePass;- writeAtomic(outputs.contactSheet, contactSheetHtml({+ writeStagedEvidence(ownership, outputs.contactSheet, contactSheetHtml({artifactPath: artifact,receipt,screenshots: receipt.captures.screenshots,}));- persistReceipt(outputs, receipt);+ recordVisualEvidenceFiles(receipt, outputs, ownership);+ writeStagedEvidence(ownership, outputs.receipt, `${JSON.stringify(receipt, null, 2)}\n`);+ const publication = commitVisualEvidence(+ artifact,+ outputs,+ ownership,+ visualEvidenceTargets(outputs).map((target) => target.path),+ );+ if (!publication.ok) {+ appendEvidencePublicationFailure(receipt, publication);+ receipt.ok = false;+ receipt.status = 'fail';+ return { exitCode: EXIT.fail, receipt };+ }+ if (appendEvidenceCleanupWarning(receipt, publication)) {+ return { exitCode: EXIT.fail, receipt };+ }return { exitCode: receipt.ok ? EXIT.pass : EXIT.fail, receipt };} catch (error) {receipt.status = 'fail';@@ -915,8 +2224,18 @@ export async function runVisualCheck({evidence: { reason: error.message },supportedFixes: ['resolve the reported Chrome inspection error, then rerun visual-check'],})];- return { exitCode: EXIT.fail, receipt: persistVisualCheckFailure(artifact, receipt, { outDir }) };+ return {+ exitCode: EXIT.fail,+ receipt: persistVisualCheckFailure(artifact, receipt, {+ outDir,+ compareSidecarParents,+ ownership,+ }),+ };} finally {if (browser?.close) await browser.close();}+ } finally {+ releaseRegularFileBinding(capturedArtifact.binding);+ }}diff --git a/archify/references/delivery-contract.md b/archify/references/delivery-contract.mdindex 1c4bf83c..652ebeb6 100644--- a/archify/references/delivery-contract.md+++ b/archify/references/delivery-contract.md@@ -11,13 +11,38 @@ their existing rule codes. Use the advertised `validate --json` orUnexpected implementation failures retain debugging information in humanmode and remain `internal/unclassified` in machine receipts.-Each output has three independent delivery metadata paths:+Each delivered output has two artifact-specific metadata paths. When an output+stem is too long for those derived filenames, Archify shortens it and appends a+stable hash:- `<output-stem>.delivery.json` records the latest completed attempt.- `<output-stem>.delivery-pending.json` is the recovery journal for an attemptin progress.-- `<output-stem>.delivery-lock.json` serializes attempts targeting the same- output.++For a literal artifact stem that already matches Archify's reserved bounded-name+marker, a pre-namespace raw provenance sidecar remains a read fallback when the+encoded sidecar is absent. A pre-namespace raw pending journal is an independent+fail-closed barrier: it blocks checks and redelivery even when an encoded pending+journal also exists, and neither journal is silently replaced.++One directory-wide `.archify-delivery-lock.json` serializes every delivery that+resolves into the same physical output directory. This deliberately prevents+case, Unicode-normalization, Windows short-name, and symbolic-link aliases from+creating independent owners for one filesystem location. The tradeoff is that+deliveries to different artifact names in one directory also run serially;+provenance and pending journals remain artifact-specific.++For migration safety, Archify also detects and preserves a legacy+`<output-stem>.delivery-lock.json` beside the requested artifact. An existing+legacy entry is a fail-closed recovery barrier. While a new delivery owns the+directory mutex, it also holds temporary legacy-format fences for the requested+spelling and an existing artifact's physical target spelling. It acquires the+directory lock first, then all required compatibility fences before writing a+journal or artifact, and removes the directory lock before those fences during+release. This blocks an older Archify binary using+either known spelling from entering the delivery. A legacy fence whose raw+HEAD-era filename exceeds the host component limit is omitted because the old+binary could not create that lock or deliver that artifact on the host either.`deliver` acquires the lock by exclusive `open(..., "wx")` before creating orreplacing the recovery journal. A successful exclusive create yields an@@ -27,7 +52,7 @@ lock release each verify the current capability inside the operation thatwould mutate shared state. A rejected contender does not create a journal orwrite failed provenance.-An existing lock is handled without automatic recovery:+An existing directory or legacy lock is handled without automatic recovery:| Observed lock state | Required `deliver` result || --- | --- |@@ -40,17 +65,35 @@ An existing lock is handled without automatic recovery:A `delivery/lock-stale` diagnostic identifies the absolute output and lockpaths plus the original PID and receipt ID. Recovery is deliberately explicit-and serial: stop all delivery attempts for that output, confirm that no active-delivery owns it and that the reported stale entry has not been replaced,-remove only the reported lock, then rerun `deliver`. Do not remove the artifact,-current provenance, or pending journal as part of stale-lock recovery.+and serial: stop all delivery attempts for that physical output directory,+confirm that no active delivery owns it and that the reported stale entry has+not been replaced, remove only the reported lock, then rerun `deliver`. Do not+remove an artifact, current provenance, or pending journal as part of+stale-lock recovery.The lock protocol targets Node.js 18 or later on a local filesystem withcooperating Archify processes. PID, receipt, and file-identity comparisons are-defensive checks, not an atomic compare-and-swap. This contract does not claim-distributed-lock correctness on NFS, SMB, or other network filesystems, and it-cannot prevent an external process that ignores the protocol from replacing-shared paths.+defensive checks, not an atomic compare-and-swap. Compatibility fences cover+the requested spelling and an existing physical-target spelling; they cannot+enumerate arbitrary hard-link names or previously unknown filesystem aliases,+so mixed-version delivery through such aliases remains out of scope. This+contract does not claim distributed-lock correctness on NFS, SMB, or other+network filesystems, and it cannot prevent an external process that ignores+the protocol from replacing shared paths.++Every atomic HTML publisher (`render`, `deliver`, `compare`, and `preview`)+captures the requested directory entry, canonical write slot, physical parent,+and existing target type, device/inode identity, and mode before staging, then+revalidates that snapshot immediately before replacement. An existing write+target must be a regular file with exactly one hard-link name. A target with+multiple hard-link names fails closed with `output/target-hardlinked`: atomic+rename can replace the requested name, but cannot update unknown sibling names+without abandoning crash-atomic publication. Hard links remain supported for+read identity and input/alias collision checks; they are unsupported only as+write targets. A symbolic link to a single-link regular file remains supported:+publication preserves the symbolic-link entry and atomically replaces or+creates its resolved target. Directory, FIFO, socket, device, changing mode,+new claimant, and indeterminate identity cases fail before replacement.After ownership is established, `deliver` creates the journal before renderingand keeps it through the recoverable HTML/sidecar pair commit. It removes the@@ -58,8 +101,9 @@ journal only after that commit completes. A validation, render, or pair-commitfailure, or a process interruption, may therefore leave a journal. The journalis a safety barrier: `check` and `visual-check` fail closed when any directoryentry exists at the journal or lock path, including an unreadable file,-symlink, or dangling symlink. Run deliveries targeting the same output path-serially; one attempt must finish or be recovered before another begins.+symlink, or dangling symlink. Run deliveries targeting the same physical output+directory serially; one attempt must finish or be recovered before another+begins.A successful sidecar has `schemaVersion: 1`, `status: "current"`,`command: "deliver"`, a unique `receiptId`, the diagram `type`, an absolute@@ -68,7 +112,10 @@ artifact, and specification/artifact SHA-256 and byte counts. Checkers treat amissing, malformed, unsupported, or inconsistent field as invalid. They alsoreject a sidecar symlink, including a dangling one. A checker binds provenanceto the artifact bytes it actually checks and verifies that binding again before-reporting success; a concurrent byte change fails.+reporting success; a concurrent byte change fails. The provenance directory+entry itself must be a single-link regular file: `deliver` and strict check fail+closed with `delivery/provenance-hardlink-unsupported` when it has another hard+link, without scanning for or guessing the sibling name.If a currently verified owner fails after an older HTML exists, Archify writesa new `status: "failed"` sidecar and leaves the journal until recovery is@@ -95,10 +142,44 @@ node bin/archify.mjs check <output.html> --require-provenancenode bin/archify.mjs visual-check <output.html> --json --require-provenance```-Use `validate` after every candidate edit. CLI HTML output paths must end in `.html`, including after symbolic-link resolution.-Compare receipt paths must end in `.json`. Explicit CLI paths may be absolute or-outside the current working directory; authored `meta.output` remains confined-to that directory. A type mismatch fails before writing with+## Output path contracts++Archify intentionally separates durable authored paths from command-line paths:++- Authored `meta.output` is a portable POSIX-relative path such as+ `reports/diagram.html`. It uses `/`, ends in a non-empty `.html` basename,+ and cannot contain an absolute or drive-relative prefix, URI, backslash,+ empty or dot segment, control character, unpaired UTF-16 surrogate, Windows+ alternate-data-stream separator or invalid filename character, trailing dot+ or space, DOS device name, or a component over either the 255-byte UTF-8 or+ 255-code-unit UTF-16 limit. It resolves from the current working directory+ and must remain physically inside that directory, with an `.html` target,+ after symbolic links are followed. The durable output/archive profile also+ conservatively rejects a Windows 8.3 short-name shape such as `PROGRA~1`;+ descriptive repo/Git POSIX paths use a separate profile and are exempt.+- Explicit CLI output arguments use the active host's native syntax. They may+ be relative or absolute, use native separators, and resolve outside the+ current working directory. On Windows, ordinary drive-absolute, UNC, and+ relative paths (including ordinary `.` and `..` navigation) are supported.+ A system-resolved 8.3 spelling of an existing file or directory is accepted+ when Archify can prove its physical identity; this native alias support does+ not relax the durable output/archive profile's 8.3-shaped-name rejection.+ Extended-length paths are limited to raw backslash-only `\\?\C:\...` and+ `\\?\UNC\server\share\...` forms without dot segments; device namespaces,+ malformed roots, drive-relative paths such as `C:file.html`, current-drive+ roots such as `\file.html`, alternate data streams, reserved device names,+ invalid or trailing filename characters, and overlong components fail+ closed. POSIX CLI paths retain POSIX filename rules rather than inheriting+ Windows spelling restrictions. Every host rejects NUL, unpaired surrogates,+ and components that exceed its supported bound.++These contracts are not interchangeable: an explicit CLI output does not hide+an invalid durable `meta.output`, and `validate` and `migrate` check authored+output syntax even when they do not publish to that path.++Use `validate` after every candidate edit. CLI HTML output paths must end in+`.html`, including after symbolic-link resolution. Compare receipt paths must+end in `.json`. A type mismatch fails before writing with`output/cli-extension` or `output/cli-resolved-extension`. These checks preventaccidental file-type overwrites; they do not sandbox explicit CLI directoriesor prevent replacement of an existing artifact of the expected type.@@ -131,8 +212,8 @@ capability still identifies that exact entry. A replacement is preserved.Filesystem and cleanup errors are reported separately from an active concurrentdelivery. An active, stale, unrecognized, or otherwise preserved lockindependently prevents checkers from accepting the prior artifact. Fix the-reported filesystem error before retrying, and use another output path if the-lock path contains unrelated data.+reported filesystem error before retrying, and use another physical output+directory if the lock path contains unrelated data.Lock release is part of delivery completion. If the artifact/provenance pairhas committed and the journal has finalized but the matching lock cannot be@@ -204,19 +285,45 @@ browser evidence cannot claim perceptual review.- `failed` maps from exit 1 and receipt `status: "fail"` when the inspection finds a defect, the command fails, or a runtime/capture error leaves the evidence incomplete.- `skipped` maps only from exit 2 and receipt `status: "skipped"` when Chrome/Chromium is unavailable and the inspection does not run.-Runtime or capture failures leave incomplete evidence and must not be normalized to `skipped`. Failed or skipped capture runs remove stale-image/contact-sheet sidecars rather than presenting prior evidence as current.-They do not invalidate an already successful deterministic delivery, and they-do not turn a perceptual visual review into passed or failed. Retry an-environmental failure through the supported command in a browser-capable-execution context when practical. Keep the packaged transport unchanged unless-the failure reproduces through that seam in a capable environment.--A provenance failure exits before browser inspection. That early exit removes-stale screenshots and the contact sheet, then persists a failed visual-check-receipt bound to the attempted artifact. If any stale-evidence cleanup or-failure-receipt write cannot complete, the diagnostic names that incomplete-cleanup; do not present remaining sidecars as current evidence.+Runtime or capture failures leave incomplete evidence and must not be normalized to `skipped`.+The receipt, contact sheet, and four PNGs form one owned evidence set. Before+capture, `visual-check` freezes every requested directory entry, its+canonical write slot and physical parent, and the target's absent/file state,+type, device/inode identity, and mode. Hard-linked evidence targets are not safe+write targets. All candidate files are created exclusively inside one random,+private staging directory beneath the physical evidence directory; the receipt+is published last. Each staged candidate must have exactly one hard-link name+before publication. The no-clobber publish link temporarily gives the staged+and final names a link count of two; unlinking the verified staged name must+leave the final entry with a link count of one. An unexpected external hard+link fails closed and its alias is never removed.++Immediately before committing anything, `visual-check` re-resolves and verifies+the complete six-path set. An absent-path claimant, existing-path replacement,+symbolic-link or dangling-link retarget, parent-topology change, hard link, or+indeterminate identity fails closed with `viewer/evidence-path-conflict`. The+claimant and every other final evidence path remain untouched. Cleanup removes+only this run's staged or published entries after rechecking their captured+identities; a changed or unknown entry is preserved.++An existing visual evidence set is replaceable only when a regular+`visual-check` receipt proves ownership of the same artifact and evidence+directory, and its exact sidecar manifest matches every existing contact-sheet+or PNG byte count and SHA-256 digest. A missing, malformed, unknown, mismatched,+or incomplete ownership record never authorizes deletion. Failed and skipped+runs retire prior screenshots/contact sheets only as part of the same verified+transaction when that ownership proof succeeds; otherwise they preserve all+unknown evidence and report `viewer/evidence-path-conflict`.++This rule also applies when Chrome is unavailable or provenance fails before+browser inspection: neither path may blindly delete stale-looking evidence. A+verified owned set may be atomically replaced by a skipped or failed receipt;+unowned evidence remains intact. These outcomes do not invalidate an already+successful deterministic delivery and do not turn a perceptual visual review+into passed or failed. Retry an environmental failure through the supported+command in a browser-capable execution context when practical. Keep the+packaged transport unchanged unless the failure reproduces through that seam in+a capable environment.## Optional openingdiff --git a/archify/renderers/shared/atomic-output.mjs b/archify/renderers/shared/atomic-output.mjsnew file mode 100644index 00000000..42ea7960--- /dev/null+++ b/archify/renderers/shared/atomic-output.mjs@@ -0,0 +1,981 @@+import { createHash, randomBytes } from 'node:crypto';+import fs from 'node:fs';+import path from 'node:path';++import { canonicalFuturePath } from './output-path.mjs';++function relation(status, code, details = {}) {+ return { status, reason: { code, ...details } };+}++function filesystemFailure(code, error, details = {}) {+ return relation('unknown', code, {+ ...details,+ ...(typeof error?.code === 'string' ? { systemCode: error.code } : {}),+ ...(typeof error?.message === 'string' ? { message: error.message } : {}),+ });+}++function entryType(metadata) {+ if (metadata.isFile()) return 'file';+ if (metadata.isSymbolicLink()) return 'symbolic-link';+ if (metadata.isDirectory()) return 'directory';+ if (metadata.isFIFO()) return 'fifo';+ if (metadata.isSocket()) return 'socket';+ if (metadata.isBlockDevice()) return 'block-device';+ if (metadata.isCharacterDevice()) return 'character-device';+ return 'other';+}++// Windows lstat can fall back to directory enumeration when a file handle+// cannot be opened, and that fallback reports a synthetic link count of one.+// Treat handle-backed fstat as authoritative and fail closed when it cannot be+// reconciled with the no-follow path snapshots on either side of the open.+function captureRegularFileHandle(filePath, initial, subject) {+ const pathKey = subject === 'target'+ ? 'commitPath'+ : subject === 'requested-entry'+ ? 'requestedPath'+ : 'candidatePath';+ if (initial.ino === 0n) {+ return relation('unknown', `${subject}-identity-unavailable`, { [pathKey]: filePath });+ }+ let descriptor;+ let handle;+ let current;+ let closeError;+ try {+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ const nonBlock = fs.constants.O_NONBLOCK || 0;+ descriptor = fs.openSync(filePath, fs.constants.O_RDONLY | noFollow | nonBlock);+ handle = fs.fstatSync(descriptor, { bigint: true });+ current = fs.lstatSync(filePath, { bigint: true });+ } catch (error) {+ return filesystemFailure(`${subject}-handle-inspection-failed`, error, {+ [pathKey]: filePath,+ });+ } finally {+ if (descriptor !== undefined) {+ try {+ fs.closeSync(descriptor);+ } catch (error) {+ closeError = error;+ }+ }+ }+ if (closeError) {+ return filesystemFailure(`${subject}-handle-close-failed`, closeError, {+ [pathKey]: filePath,+ });+ }+ if (!handle.isFile() || !current.isFile()+ || handle.ino === 0n || current.ino === 0n+ || handle.dev !== initial.dev || handle.ino !== initial.ino+ || current.dev !== handle.dev || current.ino !== handle.ino) {+ return relation('unknown', `${subject}-changed-during-inspection`, {+ [pathKey]: filePath,+ });+ }+ if (handle.nlink === 0n) {+ return relation('unknown', `${subject}-link-count-unavailable`, {+ [pathKey]: filePath,+ });+ }+ if (handle.nlink !== 1n) {+ return relation('unsupported', `${subject}-hardlinked`, {+ [pathKey]: filePath,+ links: handle.nlink.toString(),+ });+ }+ return { status: 'captured', metadata: handle };+}++const regularFileBindings = new WeakMap();+const digestChunkBytes = 64 * 1024;++function validExpectedLinks(value) {+ return Number.isSafeInteger(value) && value > 0;+}++function validateBindingExpectations(options) {+ const hasSha256 = options.expectedSha256 !== undefined;+ const hasBytes = options.expectedBytes !== undefined;+ const expectedIdentity = options.expectedIdentity;+ if (hasSha256 !== hasBytes+ || (hasSha256 && !/^[a-f\d]{64}$/i.test(options.expectedSha256))+ || (hasBytes && (!Number.isSafeInteger(options.expectedBytes) || options.expectedBytes < 0))+ || (options.expectedMode !== undefined+ && (!Number.isSafeInteger(options.expectedMode)+ || options.expectedMode < 0+ || options.expectedMode > 0o777))+ || (expectedIdentity !== undefined+ && (typeof expectedIdentity?.device !== 'bigint'+ || typeof expectedIdentity?.inode !== 'bigint'+ || expectedIdentity.inode === 0n))+ || typeof options.includeContent !== 'boolean'+ || !validExpectedLinks(options.expectedLinks)) {+ return relation('unknown', 'invalid-regular-file-binding-expectation');+ }+ return null;+}++function descriptorDigest(descriptor, expectedSize, subject, filePath, includeContent) {+ if (expectedSize < 0n || expectedSize > BigInt(Number.MAX_SAFE_INTEGER)) {+ return relation('unknown', `${subject}-size-unavailable`, { filePath });+ }+ const expectedBytes = Number(expectedSize);+ const digest = createHash('sha256');+ let capturedContent;+ let chunk;+ try {+ capturedContent = includeContent ? Buffer.allocUnsafe(expectedBytes) : null;+ chunk = capturedContent+ || Buffer.allocUnsafe(Math.min(digestChunkBytes, Math.max(1, expectedBytes)));+ } catch (error) {+ return filesystemFailure(`${subject}-content-inspection-failed`, error, { filePath });+ }+ let bytes = 0;+ try {+ while (bytes < expectedBytes) {+ const offset = includeContent ? bytes : 0;+ const read = fs.readSync(+ descriptor,+ chunk,+ offset,+ Math.min(digestChunkBytes, chunk.byteLength - offset, expectedBytes - bytes),+ bytes,+ );+ if (read === 0) break;+ digest.update(chunk.subarray(offset, offset + read));+ bytes += read;+ }+ } catch (error) {+ return filesystemFailure(`${subject}-content-inspection-failed`, error, { filePath });+ }+ return {+ status: 'inspected',+ sha256: digest.digest('hex'),+ bytes,+ ...(includeContent ? { buffer: capturedContent.subarray(0, bytes) } : {}),+ };+}++function sameHandleState(left, right) {+ return left.dev === right.dev+ && left.ino === right.ino+ && left.nlink === right.nlink+ && left.mode === right.mode+ && left.size === right.size+ && left.mtimeNs === right.mtimeNs+ && left.ctimeNs === right.ctimeNs;+}++function inspectRegularFileDescriptor({+ descriptor,+ filePath,+ identity,+ subject,+ expectedLinks,+ phase,+ includeContent = false,+}) {+ let beforeHandle;+ let beforePath;+ let afterHandle;+ let afterPath;+ let content;+ try {+ beforeHandle = fs.fstatSync(descriptor, { bigint: true });+ beforePath = fs.lstatSync(filePath, { bigint: true });+ } catch (error) {+ return filesystemFailure(`${subject}-handle-${phase}-failed`, error, { filePath });+ }+ if (!beforeHandle.isFile() || !beforePath.isFile()) {+ return relation('unsupported', `${subject}-not-regular-file`, {+ filePath,+ entryType: entryType(beforePath),+ });+ }+ if (beforeHandle.ino === 0n || beforePath.ino === 0n) {+ return relation('unknown', `${subject}-identity-unavailable`, { filePath });+ }+ if (beforeHandle.dev !== identity.device+ || beforeHandle.ino !== identity.inode+ || beforePath.dev !== beforeHandle.dev+ || beforePath.ino !== beforeHandle.ino) {+ return relation(phase === 'inspection' ? 'unknown' : 'different',+ `${subject}-${phase === 'inspection' ? 'changed-during-inspection' : 'identity-changed'}`,+ { filePath });+ }+ if (beforeHandle.nlink === 0n) {+ return relation('unknown', `${subject}-link-count-unavailable`, { filePath });+ }+ if (beforeHandle.nlink !== BigInt(expectedLinks)) {+ if (beforeHandle.nlink > BigInt(expectedLinks)) {+ return relation('unsupported', `${subject}-hardlinked`, {+ filePath,+ links: beforeHandle.nlink.toString(),+ });+ }+ return relation('different', `${subject}-link-count-changed`, {+ filePath,+ expectedLinks,+ currentLinks: beforeHandle.nlink.toString(),+ });+ }+ content = descriptorDigest(+ descriptor,+ beforeHandle.size,+ subject,+ filePath,+ includeContent,+ );+ if (content.status !== 'inspected') return content;+ try {+ afterHandle = fs.fstatSync(descriptor, { bigint: true });+ afterPath = fs.lstatSync(filePath, { bigint: true });+ } catch (error) {+ return filesystemFailure(`${subject}-handle-${phase}-failed`, error, { filePath });+ }+ if (!afterHandle.isFile() || !afterPath.isFile()+ || afterHandle.ino === 0n || afterPath.ino === 0n+ || afterHandle.dev !== identity.device || afterHandle.ino !== identity.inode+ || afterPath.dev !== afterHandle.dev || afterPath.ino !== afterHandle.ino) {+ return relation(phase === 'inspection' ? 'unknown' : 'different',+ `${subject}-${phase === 'inspection' ? 'changed-during-inspection' : 'identity-changed'}`,+ { filePath });+ }+ if (!sameHandleState(beforeHandle, afterHandle)) {+ return relation('unknown', `${subject}-changed-during-${phase}`, { filePath });+ }+ if (content.bytes !== Number(afterHandle.size)) {+ return relation('unknown', `${subject}-changed-during-${phase}`, { filePath });+ }+ return { status: 'inspected', metadata: afterHandle, content };+}++function closeCapturedDescriptor(descriptor, subject, filePath) {+ try {+ fs.closeSync(descriptor);+ return null;+ } catch (error) {+ return filesystemFailure(`${subject}-handle-close-failed`, error, { filePath });+ }+}++/**+ * Capture a regular file through an open descriptor. The opaque binding keeps+ * the descriptor alive so callers can prove that the same inode, mode and+ * bytes are still named by either the original path or a deliberate hard-link+ * publication path. Callers must release every successfully captured binding.+ */+export function captureRegularFileBinding(filePath, {+ subject = 'file',+ expectedSha256,+ expectedBytes,+ expectedMode,+ expectedIdentity,+ expectedLinks = 1,+ includeContent = false,+} = {}) {+ const options = {+ expectedSha256,+ expectedBytes,+ expectedMode,+ expectedIdentity,+ expectedLinks,+ includeContent,+ };+ const invalid = validateBindingExpectations(options);+ if (invalid) return invalid;+ const resolvedPath = path.resolve(filePath);+ let initial;+ try {+ initial = fs.lstatSync(resolvedPath, { bigint: true });+ } catch (error) {+ return filesystemFailure(`${subject}-inspection-failed`, error, { filePath: resolvedPath });+ }+ const type = entryType(initial);+ if (type !== 'file') {+ return relation('unsupported', `${subject}-not-regular-file`, {+ filePath: resolvedPath,+ entryType: type,+ });+ }+ if (initial.ino === 0n) {+ return relation('unknown', `${subject}-identity-unavailable`, { filePath: resolvedPath });+ }++ let descriptor;+ try {+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ const nonBlock = fs.constants.O_NONBLOCK || 0;+ descriptor = fs.openSync(resolvedPath, fs.constants.O_RDONLY | noFollow | nonBlock);+ } catch (error) {+ return filesystemFailure(`${subject}-handle-inspection-failed`, error, { filePath: resolvedPath });+ }+ const identity = { device: initial.dev, inode: initial.ino };+ if (expectedIdentity !== undefined+ && (identity.device !== expectedIdentity.device+ || identity.inode !== expectedIdentity.inode)) {+ const closeFailure = closeCapturedDescriptor(descriptor, subject, resolvedPath);+ return closeFailure || relation('different', `${subject}-identity-changed`, {+ filePath: resolvedPath,+ });+ }+ const inspected = inspectRegularFileDescriptor({+ descriptor,+ filePath: resolvedPath,+ identity,+ subject,+ expectedLinks,+ phase: 'inspection',+ includeContent,+ });+ if (inspected.status !== 'inspected') {+ const closeFailure = closeCapturedDescriptor(descriptor, subject, resolvedPath);+ return closeFailure || inspected;+ }+ const mode = Number(inspected.metadata.mode & 0o777n);+ if (expectedMode !== undefined && mode !== expectedMode) {+ const closeFailure = closeCapturedDescriptor(descriptor, subject, resolvedPath);+ return closeFailure || relation('different', `${subject}-mode-changed`, {+ filePath: resolvedPath,+ expectedMode,+ currentMode: mode,+ });+ }+ if (expectedSha256 !== undefined+ && (inspected.content.sha256.toLowerCase() !== expectedSha256.toLowerCase()+ || inspected.content.bytes !== expectedBytes)) {+ const closeFailure = closeCapturedDescriptor(descriptor, subject, resolvedPath);+ return closeFailure || relation('different', `${subject}-content-changed`, {+ filePath: resolvedPath,+ expectedSha256,+ currentSha256: inspected.content.sha256,+ expectedBytes,+ currentBytes: inspected.content.bytes,+ });+ }++ const binding = Object.freeze({});+ regularFileBindings.set(binding, {+ descriptor,+ filePath: resolvedPath,+ subject,+ expectedLinks,+ identity,+ mode,+ sha256: inspected.content.sha256,+ bytes: inspected.content.bytes,+ });+ return {+ status: 'captured',+ binding,+ identity: { ...identity, mode, links: inspected.metadata.nlink },+ content: {+ sha256: inspected.content.sha256,+ bytes: inspected.content.bytes,+ ...(includeContent ? { buffer: inspected.content.buffer } : {}),+ },+ mode,+ };+}++/** Verify a captured descriptor against its original or an alternate linked path. */+export function verifyRegularFileBinding(binding, { filePath, expectedLinks } = {}) {+ const captured = regularFileBindings.get(binding);+ if (!captured) return relation('unknown', 'regular-file-binding-unavailable');+ const links = expectedLinks ?? captured.expectedLinks;+ if (!validExpectedLinks(links)) {+ return relation('unknown', 'invalid-regular-file-binding-expectation');+ }+ const verificationPath = path.resolve(filePath ?? captured.filePath);+ const inspected = inspectRegularFileDescriptor({+ descriptor: captured.descriptor,+ filePath: verificationPath,+ identity: captured.identity,+ subject: captured.subject,+ expectedLinks: links,+ phase: 'verification',+ });+ if (inspected.status !== 'inspected') return inspected;+ const mode = Number(inspected.metadata.mode & 0o777n);+ if (mode !== captured.mode) {+ return relation('different', `${captured.subject}-mode-changed`, {+ filePath: verificationPath,+ previousMode: captured.mode,+ currentMode: mode,+ });+ }+ if (inspected.content.sha256 !== captured.sha256+ || inspected.content.bytes !== captured.bytes) {+ return relation('different', `${captured.subject}-content-changed`, {+ filePath: verificationPath,+ previousSha256: captured.sha256,+ currentSha256: inspected.content.sha256,+ previousBytes: captured.bytes,+ currentBytes: inspected.content.bytes,+ });+ }+ return relation('match', `${captured.subject}-binding-match`, {+ filePath: verificationPath,+ links,+ });+}++/** Close and invalidate a captured regular-file binding. */+export function releaseRegularFileBinding(binding) {+ const captured = regularFileBindings.get(binding);+ if (!captured) return relation('unknown', 'regular-file-binding-unavailable');+ regularFileBindings.delete(binding);+ const failure = closeCapturedDescriptor(+ captured.descriptor,+ captured.subject,+ captured.filePath,+ );+ return failure || relation('released', `${captured.subject}-binding-released`, {+ filePath: captured.filePath,+ });+}++function createRemovalQuarantine(parentPath) {+ for (let attempt = 0; attempt < 8; attempt += 1) {+ const directory = path.join(+ parentPath,+ `.archify-remove-${randomBytes(16).toString('hex')}`,+ );+ try {+ fs.mkdirSync(directory, { mode: 0o700 });+ return { status: 'created', directory };+ } catch (error) {+ if (error?.code !== 'EEXIST') {+ return filesystemFailure('removal-quarantine-create-failed', error, {+ parentPath,+ });+ }+ }+ }+ return relation('unknown', 'removal-quarantine-name-exhausted', { parentPath });+}++function removeEmptyQuarantine(directory) {+ try {+ fs.rmdirSync(directory);+ return null;+ } catch (error) {+ return filesystemFailure('removal-quarantine-cleanup-failed', error, {+ recoveryDirectory: directory,+ });+ }+}++function removalRecovery(subject, code, filePath, quarantineDirectory, quarantineFile, error) {+ return {+ status: 'recovery-required',+ reason: {+ code: `${subject}-${code}`,+ filePath,+ ...(typeof error?.code === 'string' ? { systemCode: error.code } : {}),+ ...(error?.message ? { message: error.message } : {}),+ },+ recoveryDirectory: quarantineDirectory,+ recoveryFile: quarantineFile,+ target: filePath,+ };+}++/**+ * Remove a public regular-file name without a verify-to-unlink race. The+ * public entry is first moved into an unpredictable private directory and is+ * deleted only after the caller's still-open binding proves that the moved+ * inode, mode and bytes are the owned entry. If the move captured a successor,+ * restore it with a no-clobber hard link or retain it as recovery material.+ * The caller retains ownership of `binding` and must release it separately.+ */+export function quarantineRemoveRegularFileBinding(binding, filePath, {+ subject = 'public-entry',+ expectedLinks = 1,+} = {}) {+ if (!validExpectedLinks(expectedLinks)) {+ return relation('unknown', 'invalid-regular-file-binding-expectation');+ }+ const resolvedPath = path.resolve(filePath);+ const quarantine = createRemovalQuarantine(path.dirname(resolvedPath));+ if (quarantine.status !== 'created') return quarantine;+ const quarantineFile = path.join(quarantine.directory, path.basename(resolvedPath));+ const removeEmpty = () => removeEmptyQuarantine(quarantine.directory);++ const beforeMove = verifyRegularFileBinding(binding, {+ filePath: resolvedPath,+ expectedLinks,+ });+ if (beforeMove.status !== 'match') {+ const cleanup = removeEmpty();+ return cleanup || beforeMove;+ }++ try {+ fs.renameSync(resolvedPath, quarantineFile);+ } catch (error) {+ const cleanup = removeEmpty();+ return cleanup || filesystemFailure(`${subject}-quarantine-move-failed`, error, {+ filePath: resolvedPath,+ });+ }++ const moved = verifyRegularFileBinding(binding, {+ filePath: quarantineFile,+ expectedLinks,+ });+ if (moved.status === 'match') {+ try {+ fs.unlinkSync(quarantineFile);+ } catch (error) {+ return removalRecovery(+ subject,+ 'quarantine-cleanup-failed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ error,+ );+ }+ const cleanup = removeEmpty();+ return cleanup || relation('removed', `${subject}-removed`, { filePath: resolvedPath });+ }++ let displaced;+ try {+ displaced = fs.lstatSync(quarantineFile, { bigint: true });+ } catch (error) {+ return removalRecovery(+ subject,+ 'replacement-inspection-failed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ error,+ );+ }+ if (displaced.ino === 0n || displaced.nlink === 0n) {+ return removalRecovery(+ subject,+ 'replacement-identity-unavailable',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ );+ }+ try {+ fs.linkSync(quarantineFile, resolvedPath);+ } catch (error) {+ return removalRecovery(+ subject,+ error?.code === 'EEXIST' ? 'replacement-restore-blocked' : 'replacement-restore-failed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ error,+ );+ }++ let restored;+ let retained;+ try {+ restored = fs.lstatSync(resolvedPath, { bigint: true });+ retained = fs.lstatSync(quarantineFile, { bigint: true });+ } catch (error) {+ return removalRecovery(+ subject,+ 'replacement-restore-verification-failed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ error,+ );+ }+ if (restored.dev !== displaced.dev || restored.ino !== displaced.ino+ || retained.dev !== displaced.dev || retained.ino !== displaced.ino+ || restored.nlink !== displaced.nlink + 1n+ || retained.nlink !== displaced.nlink + 1n) {+ return removalRecovery(+ subject,+ 'replacement-restore-identity-changed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ );+ }+ try {+ fs.unlinkSync(quarantineFile);+ } catch (error) {+ return removalRecovery(+ subject,+ 'replacement-quarantine-cleanup-failed',+ resolvedPath,+ quarantine.directory,+ quarantineFile,+ error,+ );+ }+ try {+ restored = fs.lstatSync(resolvedPath, { bigint: true });+ } catch (error) {+ const cleanup = removeEmpty();+ return cleanup || filesystemFailure(+ `${subject}-replacement-final-verification-failed`,+ error,+ { filePath: resolvedPath },+ );+ }+ if (restored.dev !== displaced.dev || restored.ino !== displaced.ino+ || restored.nlink !== displaced.nlink) {+ const cleanup = removeEmpty();+ return cleanup || relation('different', `${subject}-replacement-final-identity-changed`, {+ filePath: resolvedPath,+ });+ }+ const cleanup = removeEmpty();+ return cleanup || relation('preserved', `${subject}-replacement-restored`, {+ filePath: resolvedPath,+ priorState: moved.reason,+ });+}++/**+ * Create a no-clobber hard-link backup of a bound public file, then remove the+ * public name through the quarantine protocol above. The backup is reported as+ * verified only after both names have been reconciled with the open binding.+ */+export function backupPublicRegularFileBinding(binding, filePath, backupPath, {+ subject = 'public-entry',+} = {}) {+ const resolvedPath = path.resolve(filePath);+ const resolvedBackup = path.resolve(backupPath);+ const beforeLink = verifyRegularFileBinding(binding, {+ filePath: resolvedPath,+ expectedLinks: 1,+ });+ if (beforeLink.status !== 'match') {+ return { ...beforeLink, backupCreated: false, backupVerified: false };+ }+ try {+ fs.linkSync(resolvedPath, resolvedBackup);+ } catch (error) {+ return {+ ...filesystemFailure(`${subject}-backup-link-failed`, error, {+ filePath: resolvedPath,+ backupPath: resolvedBackup,+ }),+ backupCreated: false,+ backupVerified: false,+ };+ }+ for (const linkedPath of [resolvedPath, resolvedBackup]) {+ const linked = verifyRegularFileBinding(binding, {+ filePath: linkedPath,+ expectedLinks: 2,+ });+ if (linked.status !== 'match') {+ return {+ status: 'recovery-required',+ reason: {+ code: `${subject}-backup-binding-mismatch`,+ filePath: resolvedPath,+ backupPath: resolvedBackup,+ linkedState: linked.reason,+ },+ recoveryDirectory: path.dirname(resolvedBackup),+ recoveryFile: resolvedBackup,+ target: resolvedPath,+ backupCreated: true,+ backupVerified: false,+ };+ }+ }+ const removed = quarantineRemoveRegularFileBinding(binding, resolvedPath, {+ subject,+ expectedLinks: 2,+ });+ if (removed.status !== 'removed') {+ return {+ ...removed,+ backupPath: resolvedBackup,+ backupCreated: true,+ backupVerified: true,+ };+ }+ const finalized = verifyRegularFileBinding(binding, {+ filePath: resolvedBackup,+ expectedLinks: 1,+ });+ if (finalized.status !== 'match') {+ return {+ status: 'recovery-required',+ reason: {+ code: `${subject}-backup-finalization-failed`,+ filePath: resolvedPath,+ backupPath: resolvedBackup,+ backupState: finalized.reason,+ },+ recoveryDirectory: path.dirname(resolvedBackup),+ recoveryFile: resolvedBackup,+ target: resolvedPath,+ backupCreated: true,+ backupVerified: false,+ };+ }+ return {+ status: 'backed-up',+ reason: {+ code: `${subject}-backed-up`,+ filePath: resolvedPath,+ backupPath: resolvedBackup,+ },+ backupPath: resolvedBackup,+ backupCreated: true,+ backupVerified: true,+ };+}++/** Remove only the directory entry that still names a caller-owned inode. */+export function removeOwnedRegularFile(filePath, identity, { subject = 'candidate' } = {}) {+ const resolvedPath = path.resolve(filePath);+ let current;+ try {+ current = fs.lstatSync(resolvedPath, { bigint: true });+ } catch (error) {+ if (error.code === 'ENOENT') {+ return relation('absent', `${subject}-already-absent`, { filePath: resolvedPath });+ }+ return filesystemFailure(`${subject}-cleanup-inspection-failed`, error, {+ filePath: resolvedPath,+ });+ }+ if (!current.isFile()+ || current.ino === 0n+ || current.dev !== identity?.device+ || current.ino !== identity?.inode) {+ return relation('preserved', `${subject}-identity-changed`, { filePath: resolvedPath });+ }+ try {+ fs.unlinkSync(resolvedPath);+ return relation('removed', `${subject}-removed`, { filePath: resolvedPath });+ } catch (error) {+ if (error.code === 'ENOENT') {+ return relation('absent', `${subject}-already-absent`, { filePath: resolvedPath });+ }+ return filesystemFailure(`${subject}-cleanup-failed`, error, { filePath: resolvedPath });+ }+}++function captureWriteSlot(requestedPath) {+ let commitPath;+ try {+ commitPath = canonicalFuturePath(requestedPath);+ } catch (error) {+ const diagnostic = error?.archifyDiagnostics?.[0];+ return relation('unknown', 'canonicalization-failed', {+ ...(diagnostic?.code ? { diagnosticCode: diagnostic.code } : {}),+ ...(diagnostic?.evidence?.relation ? { relation: diagnostic.evidence.relation } : {}),+ });+ }++ const parentPath = path.dirname(commitPath);+ let parent;+ try {+ parent = fs.statSync(parentPath, { bigint: true });+ } catch (error) {+ return filesystemFailure('parent-inspection-failed', error, { commitPath, parentPath });+ }+ if (!parent.isDirectory()) {+ return relation('unknown', 'parent-not-directory', { commitPath, parentPath });+ }+ if (parent.ino === 0n) {+ return relation('unknown', 'parent-identity-unavailable', { commitPath, parentPath });+ }+ return {+ status: 'captured',+ slot: {+ commitPath,+ parentPath,+ name: path.basename(commitPath),+ parentDevice: parent.dev,+ parentInode: parent.ino,+ },+ };+}++function captureTarget(commitPath) {+ let metadata;+ try {+ // The canonical commit path names the directory entry that rename will+ // replace. Never follow a link introduced after canonicalization.+ metadata = fs.lstatSync(commitPath, { bigint: true });+ } catch (error) {+ if (error.code === 'ENOENT') {+ return { status: 'captured', target: { kind: 'absent' }, mode: null };+ }+ return filesystemFailure('target-inspection-failed', error, { commitPath });+ }++ const type = entryType(metadata);+ if (type !== 'file') {+ return relation('unsupported', 'target-not-regular-file', { commitPath, entryType: type });+ }+ const inspected = captureRegularFileHandle(commitPath, metadata, 'target');+ if (inspected.status !== 'captured') return inspected;+ metadata = inspected.metadata;+ return {+ status: 'captured',+ target: {+ kind: 'file',+ device: metadata.dev,+ inode: metadata.ino,+ mode: Number(metadata.mode & 0o777n),+ },+ mode: Number(metadata.mode & 0o777n),+ };+}++function captureRequestedEntry(requestedPath, policy) {+ let metadata;+ try {+ metadata = fs.lstatSync(requestedPath, { bigint: true });+ } catch (error) {+ if (error.code === 'ENOENT') {+ return { status: 'captured', entry: { kind: 'absent' } };+ }+ return filesystemFailure('requested-entry-inspection-failed', error, { requestedPath });+ }+ const type = entryType(metadata);+ if (policy === 'regular-or-absent' && type !== 'file') {+ return relation('unsupported', type === 'symbolic-link'+ ? 'requested-entry-symbolic-link'+ : 'requested-entry-not-regular-file', {+ requestedPath,+ entryType: type,+ });+ }+ if (metadata.ino === 0n) {+ return relation('unknown', 'requested-entry-identity-unavailable', { requestedPath });+ }+ if (policy === 'regular-or-absent') {+ const inspected = captureRegularFileHandle(requestedPath, metadata, 'requested-entry');+ if (inspected.status !== 'captured') return inspected;+ metadata = inspected.metadata;+ }+ return {+ status: 'captured',+ entry: {+ kind: 'existing',+ entryType: type,+ device: metadata.dev,+ inode: metadata.ino,+ },+ };+}++function requestedEntryMatches(left, right) {+ if (left.kind !== right.kind) return false;+ return left.kind === 'absent'+ || (left.entryType === right.entryType+ && left.device === right.device+ && left.inode === right.inode);+}++/**+ * Capture the physical directory-entry slot and target identity used by an+ * atomic rename. Hard links are intentionally unsupported: replacing one name+ * cannot update its other names while retaining crash-atomic publication.+ * `regular-or-absent` additionally rejects requested-entry symlinks and special+ * nodes for sidecars whose public name itself must never be followed.+ */+export function captureAtomicOutput(outputPath, { requestedEntryPolicy = 'followable-alias' } = {}) {+ if (!['followable-alias', 'regular-or-absent'].includes(requestedEntryPolicy)) {+ return relation('unknown', 'invalid-requested-entry-policy', { requestedEntryPolicy });+ }+ const requestedPath = path.resolve(outputPath);+ const requestedEntry = captureRequestedEntry(requestedPath, requestedEntryPolicy);+ if (requestedEntry.status !== 'captured') return requestedEntry;+ const slot = captureWriteSlot(requestedPath);+ if (slot.status !== 'captured') return slot;+ const target = captureTarget(slot.slot.commitPath);+ if (target.status !== 'captured') return target;+ const confirmedRequestedEntry = captureRequestedEntry(requestedPath, requestedEntryPolicy);+ if (confirmedRequestedEntry.status !== 'captured') return confirmedRequestedEntry;+ if (!requestedEntryMatches(confirmedRequestedEntry.entry, requestedEntry.entry)) {+ return relation('unknown', 'requested-entry-changed-during-inspection', { requestedPath });+ }+ return {+ status: 'captured',+ commitPath: slot.slot.commitPath,+ mode: target.mode,+ snapshot: {+ requestedPath,+ requestedEntryPolicy,+ requestedEntry: requestedEntry.entry,+ slot: slot.slot,+ target: target.target,+ },+ };+}++/** Re-resolve and verify the exact write slot plus its absent/file identity. */+export function verifyAtomicOutput(snapshot) {+ const currentRequestedEntry = captureRequestedEntry(+ snapshot.requestedPath,+ snapshot.requestedEntryPolicy || 'followable-alias',+ );+ if (currentRequestedEntry.status !== 'captured') return currentRequestedEntry;+ if (!requestedEntryMatches(currentRequestedEntry.entry, snapshot.requestedEntry)) {+ return relation('different', 'requested-entry-changed', {+ requestedPath: snapshot.requestedPath,+ previousKind: snapshot.requestedEntry.kind === 'absent'+ ? 'absent'+ : snapshot.requestedEntry.entryType,+ currentKind: currentRequestedEntry.entry.kind === 'absent'+ ? 'absent'+ : currentRequestedEntry.entry.entryType,+ });+ }+ const currentSlot = captureWriteSlot(snapshot.requestedPath);+ if (currentSlot.status !== 'captured') return currentSlot;+ const previousSlot = snapshot.slot;+ if (currentSlot.slot.parentDevice !== previousSlot.parentDevice+ || currentSlot.slot.parentInode !== previousSlot.parentInode+ || currentSlot.slot.name !== previousSlot.name) {+ return relation('different', 'write-slot-changed', {+ previousCommitPath: previousSlot.commitPath,+ currentCommitPath: currentSlot.slot.commitPath,+ });+ }++ const currentTarget = captureTarget(previousSlot.commitPath);+ if (currentTarget.status !== 'captured') return currentTarget;+ const previousTarget = snapshot.target;+ if (currentTarget.target.kind !== previousTarget.kind) {+ return relation('different', 'target-existence-changed', {+ commitPath: previousSlot.commitPath,+ previousKind: previousTarget.kind,+ currentKind: currentTarget.target.kind,+ });+ }+ if (previousTarget.kind === 'file'+ && (currentTarget.target.device !== previousTarget.device+ || currentTarget.target.inode !== previousTarget.inode)) {+ return relation('different', 'target-identity-changed', {+ commitPath: previousSlot.commitPath,+ });+ }+ if (previousTarget.kind === 'file'+ && currentTarget.target.mode !== previousTarget.mode) {+ return relation('different', 'target-mode-changed', {+ commitPath: previousSlot.commitPath,+ previousMode: previousTarget.mode,+ currentMode: currentTarget.target.mode,+ });+ }+ return relation('match', 'atomic-output-match', { commitPath: previousSlot.commitPath });+}diff --git a/archify/renderers/shared/cli.mjs b/archify/renderers/shared/cli.mjsindex 1d18d068..1a3944f2 100644--- a/archify/renderers/shared/cli.mjs+++ b/archify/renderers/shared/cli.mjs@@ -1,3 +1,4 @@+import { createHash } from 'node:crypto';import fs from 'node:fs';import path from 'node:path';import { applyTemplate, renderCards, esc } from './utils.mjs';@@ -5,11 +6,23 @@ import { validateSchema } from './validator.mjs';import { verifyRepositoryEvidence } from './repository-evidence.mjs';import { installRendererDiagnosticBoundary, throwDiagnosticError, throwDiagnosticProblems } from './diagnostics.mjs';import { validateEngineeringProfile } from './engineering-profiles.mjs';-import { resolveOutputPath } from './output-path.mjs';+import {+ resolveOutputPath,+ validateAuthoredOutputPath,+} from './output-path.mjs';+import {+ captureAtomicOutput,+ captureRegularFileBinding,+ releaseRegularFileBinding,+ removeOwnedRegularFile,+ verifyAtomicOutput,+ verifyRegularFileBinding,+} from './atomic-output.mjs';import { prepareDiagramBrandMarks } from './brand-marks.mjs';import { resolveLocale, translateMessage } from './i18n.mjs';const outputPathGuards = new Map();+let renderCandidateSequence = 0;// Common CLI head: node render-<type>.mjs [input.json] [output.html]// Keep this synchronous because callers also use it to establish the guarded@@ -46,6 +59,9 @@ export function loadDiagram({ rendererDir, diagramType, defaultExample, argv = psupportedFixes: ['repair the JSON syntax and run validation again'],}]);}+ if (typeof diagram?.meta?.output === 'string') {+ validateAuthoredOutputPath(diagram.meta.output);+ }validateSchema(diagramType, diagram);validateGuidedViews(diagramType, diagram);validateRelationshipIds(diagramType, diagram);@@ -97,6 +113,92 @@ function throwOutputError(error, output) {}]);}+function throwAtomicOutputFailure(result, output) {+ const reason = result.reason || { code: 'unclassified' };+ const changed = result.status === 'different';+ const candidate = reason.code.startsWith('candidate-');+ const nonRegular = ['target-not-regular-file', 'candidate-not-regular-file'].includes(reason.code);+ const hardlinked = ['target-hardlinked', 'candidate-hardlinked'].includes(reason.code);+ const message = changed+ ? 'Output target changed while the rendered artifact was being prepared.'+ : nonRegular+ ? candidate+ ? 'Temporary output candidate is no longer a regular file.'+ : 'Output already exists and is not a regular file.'+ : hardlinked+ ? candidate+ ? 'Temporary output candidate has multiple hard-link names.'+ : 'Output already exists through multiple hard-link names.'+ : 'Output target stability could not be determined safely before commit.';+ throwDiagnosticError(message, [{+ code: changed+ ? 'output/target-changed'+ : nonRegular+ ? 'output/target-not-regular-file'+ : hardlinked+ ? 'output/target-hardlinked'+ : 'output/target-indeterminate',+ message,+ subject: { output },+ evidence: { relation: reason },+ supportedFixes: [hardlinked+ ? 'choose a non-hardlinked output path; atomic replacement cannot update every hard-link name'+ : 'retry after other processes stop replacing or redirecting the output path'],+ }]);+}++function stageRenderedHtml(outputPath, html, mode) {+ for (let attempt = 0; attempt < 100; attempt += 1) {+ renderCandidateSequence += 1;+ const candidatePath = path.join(+ path.dirname(outputPath),+ `.archify-render-${process.pid}-${Date.now().toString(36)}-${renderCandidateSequence}.tmp`,+ );+ let descriptor;+ let identity;+ try {+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ descriptor = fs.openSync(+ candidatePath,+ fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | noFollow,+ mode ?? 0o666,+ );+ const metadata = fs.fstatSync(descriptor, { bigint: true });+ if (!metadata.isFile() || metadata.ino === 0n) {+ throw new Error('Temporary render candidate identity could not be verified safely.');+ }+ identity = { device: metadata.dev, inode: metadata.ino };+ fs.writeFileSync(descriptor, html);+ // Creation modes are filtered through the process umask. An atomic+ // replacement must retain the exact permissions of an existing target,+ // while a brand-new target should keep normal umask behavior.+ if (mode !== null) fs.fchmodSync(descriptor, mode);+ fs.closeSync(descriptor);+ descriptor = undefined;+ return { candidatePath, identity };+ } catch (error) {+ if (descriptor !== undefined) {+ try { fs.closeSync(descriptor); } catch {}+ }+ if (error.code === 'EEXIST') continue;+ if (identity) {+ const cleanup = removeOwnedRegularFile(candidatePath, identity);+ if (!['removed', 'absent', 'preserved'].includes(cleanup.status)) {+ const cleanupError = new Error(`${error.message}; temporary render candidate cleanup also failed.`);+ cleanupError.cause = error;+ throw cleanupError;+ }+ }+ throw error;+ }+ }+ const error = new Error(`Could not reserve a temporary render candidate beside "${outputPath}".`);+ error.code = 'EEXIST';+ error.errno = -17;+ error.syscall = 'open';+ throw error;+}+// Common CLI tail: fill the template and write the standalone HTML file.export function writeDiagram({ outPath, template, diagramType, meta, svg, cards, sourceEvidence = null }) {if (!START_TYPES.has(diagramType)) throw new Error(`writeDiagram: unknown diagram type ${JSON.stringify(diagramType)}`);@@ -111,14 +213,56 @@ export function writeDiagram({ outPath, template, diagramType, meta, svg, cards,guidedViews: meta.views || [],sourceEvidence,});+ let candidatePath;+ let candidateIdentity;+ let candidateBinding;try {- if (outputGuard) resolveOutputPath(outputGuard);fs.mkdirSync(path.dirname(outPath), { recursive: true });- fs.writeFileSync(outPath, html);+ const outputCapture = captureAtomicOutput(outPath);+ if (outputCapture.status !== 'captured') throwAtomicOutputFailure(outputCapture, outPath);+ const beforeStage = verifyAtomicOutput(outputCapture.snapshot);+ if (beforeStage.status !== 'match') throwAtomicOutputFailure(beforeStage, outPath);+ ({ candidatePath, identity: candidateIdentity } = stageRenderedHtml(+ outputCapture.commitPath,+ html,+ outputCapture.mode,+ ));++ // The renderer may spend substantial time building HTML after loadDiagram+ // establishes the guard. Re-run it after staging so a last-moment alias+ // cannot redirect the commit onto an input file.+ if (outputGuard) resolveOutputPath(outputGuard);+ const candidateCapture = captureRegularFileBinding(candidatePath, {+ subject: 'candidate',+ expectedSha256: createHash('sha256').update(html).digest('hex'),+ expectedBytes: Buffer.byteLength(html),+ expectedIdentity: candidateIdentity,+ ...(outputCapture.mode === null ? {} : { expectedMode: outputCapture.mode }),+ });+ if (candidateCapture.status !== 'captured') throwAtomicOutputFailure(candidateCapture, outPath);+ candidateBinding = candidateCapture.binding;+ const beforeCommit = verifyAtomicOutput(outputCapture.snapshot);+ if (beforeCommit.status !== 'match') throwAtomicOutputFailure(beforeCommit, outPath);+ const verifiedCandidate = verifyRegularFileBinding(candidateBinding);+ if (verifiedCandidate.status !== 'match') throwAtomicOutputFailure(verifiedCandidate, outPath);+ const releasedCandidate = releaseRegularFileBinding(candidateBinding);+ candidateBinding = undefined;+ if (releasedCandidate.status !== 'released') throwAtomicOutputFailure(releasedCandidate, outPath);+ fs.renameSync(candidatePath, outputCapture.commitPath);+ candidatePath = undefined;+ candidateIdentity = undefined;} catch (error) {throwOutputError(error, outPath);+ } finally {+ outputPathGuards.delete(outPath);+ if (candidateBinding) releaseRegularFileBinding(candidateBinding);+ if (candidatePath && candidateIdentity) {+ const cleanup = removeOwnedRegularFile(candidatePath, candidateIdentity);+ if (!['removed', 'absent', 'preserved'].includes(cleanup.status)) {+ throwAtomicOutputFailure(cleanup, outPath);+ }+ }}- outputPathGuards.delete(outPath);console.log(outPath);}diff --git a/archify/renderers/shared/generated-validators.mjs b/archify/renderers/shared/generated-validators.mjsindex 4839a942..0519c9ca 100644--- a/archify/renderers/shared/generated-validators.mjs+++ b/archify/renderers/shared/generated-validators.mjs@@ -1,5 +1,6 @@// Generated by scripts/generate-validators.mjs. Do not edit by hand.-"use strict";export const workflow = validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/workflow.schema.json","title":"Archify Workflow Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","lanes","nodes","edges"],"properties":{"schema_version":{"enum":[1,2]},"diagram_type":{"const":"workflow"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"type":"string"},"animation":{"enum":["trace","none"]},"visual_preset":{"enum":["classic","signal-flow","blueprint","editorial"]},"quality_profile":{"enum":["standard","showcase"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"frontend":{"$ref":"common.schema.json#/$defs/legendEntry"},"backend":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"},"cloud":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"messagebus":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":700},{"type":"number","minimum":240}],"items":false,"minItems":2,"maxItems":2}}},"lanes":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"variant":{"enum":["normal","exception"]}}}},"phases":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","label","fromCol","toCol"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"fromCol":{"type":"integer","minimum":0,"maximum":5},"toCol":{"type":"integer","minimum":0,"maximum":5},"variant":{"enum":["default","emphasis","security","dashed"]}}}},"groups":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","label","lane","fromCol","toCol"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"lane":{"$ref":"common.schema.json#/$defs/id"},"fromCol":{"type":"integer","minimum":0,"maximum":5},"toCol":{"type":"integer","minimum":0,"maximum":5},"variant":{"enum":["default","emphasis","security","dashed"]}}}},"mainPath":{"type":"array","minItems":2,"items":{"$ref":"common.schema.json#/$defs/id"}},"semanticChecks":{"type":"object","additionalProperties":false,"minProperties":1,"properties":{"allowedRoots":{"type":"array","items":{"$ref":"common.schema.json#/$defs/id"}},"allowedTerminals":{"type":"array","items":{"$ref":"common.schema.json#/$defs/id"}},"requiredEdges":{"type":"array","items":{"$ref":"#/$defs/semanticRelation"}},"requiredPaths":{"type":"array","items":{"$ref":"#/$defs/semanticRelation"}}}},"nodes":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","lane","col","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"lane":{"$ref":"common.schema.json#/$defs/id"},"col":{"type":"integer","minimum":0,"maximum":5},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"width":{"type":"number","minimum":32},"height":{"type":"number","minimum":32},"yOffset":{"type":"number"}}}},"edges":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"role":{"enum":["main","branch","async","return","error"]},"fromSide":{"$ref":"#/$defs/side"},"toSide":{"$ref":"#/$defs/side"},"route":{"enum":["auto","straight","drop","outside-right","return-left","bottom-channel","up-channel"]},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"channelX":{"type":"number"},"channelY":{"type":"number"},"bias":{"type":"number","minimum":0,"maximum":1},"width":{"type":"number","minimum":0.5}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}},"$defs":{"semanticRelation":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"}}},"side":{"enum":["left","right","top","bottom"]}}};const schema33 = {"enum":["en","zh-CN","es"]};const schema34 = {"type":"object","additionalProperties":false,"required":["url","revision"],"properties":{"url":{"type":"string","minLength":1},"provider":{"enum":["github","gitee"]},"link_mode":{"enum":["web","local-only"]},"revision":{"type":"string","pattern":"^[a-fA-F0-9]{40}$"}}};const schema38 = {"enum":["auto","all","hidden"]};const schema39 = {"type":"object","additionalProperties":false,"minProperties":1,"properties":{"label":{"type":"string","minLength":1,"maxLength":80},"visible":{"type":"boolean"}}};const schema36 = {"type":"string","pattern":"^[a-zA-Z][a-zA-Z0-9_-]*$"};const schema58 = {"enum":["frontend","backend","database","cloud","security","messagebus","external"]};const schema59 = {"oneOf":[{"type":"string","minLength":1,"maxLength":2048,"anyOf":[{"maxLength":80,"pattern":"^[^\\r\\n]+$"},{"pattern":"^https?://"}]},{"type":"object","additionalProperties":false,"required":["url","sha256"],"properties":{"url":{"type":"string","minLength":8,"maxLength":2048,"pattern":"^https?://"},"sha256":{"type":"string","pattern":"^[a-f0-9]{64}$"}}}]};const schema60 = {"type":"array","minItems":1,"maxItems":3,"items":{"type":"object","additionalProperties":false,"required":["path"],"properties":{"path":{"type":"string","minLength":1,"maxLength":240},"line":{"type":"integer","minimum":1},"end_line":{"type":"integer","minimum":1},"label":{"type":"string","minLength":1,"maxLength":48}}}};const schema64 = {"enum":["default","emphasis","security","dashed"]};const schema65 = {"enum":["left","right","top","bottom"]};const schema67 = {"type":"array","prefixItems":[{"type":"number"},{"type":"number"}],"items":false,"minItems":2,"maxItems":2};const schema69 = {"type":"array","items":{"type":"object","additionalProperties":false,"required":["dot","title","items"],"properties":{"dot":{"enum":["cyan","emerald","violet","amber","rose","orange","slate"]},"title":{"type":"string","minLength":1},"items":{"type":"array","items":{"type":"string"}}}}};const func1 = Object.prototype.hasOwnProperty;const func3 = function ucs2length(str) {+import { validatePortablePath } from './portable-path.mjs';+"use strict";const workflowSchema = validate20;const schema31 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/workflow.schema.json","title":"Archify Workflow Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","lanes","nodes","edges"],"properties":{"schema_version":{"enum":[1,2]},"diagram_type":{"const":"workflow"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"$ref":"common.schema.json#/$defs/portableOutputPath"},"animation":{"enum":["trace","none"]},"visual_preset":{"enum":["classic","signal-flow","blueprint","editorial"]},"quality_profile":{"enum":["standard","showcase"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"frontend":{"$ref":"common.schema.json#/$defs/legendEntry"},"backend":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"},"cloud":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"messagebus":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":700},{"type":"number","minimum":240}],"items":false,"minItems":2,"maxItems":2}}},"lanes":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"variant":{"enum":["normal","exception"]}}}},"phases":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","label","fromCol","toCol"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"fromCol":{"type":"integer","minimum":0,"maximum":5},"toCol":{"type":"integer","minimum":0,"maximum":5},"variant":{"enum":["default","emphasis","security","dashed"]}}}},"groups":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["id","label","lane","fromCol","toCol"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"lane":{"$ref":"common.schema.json#/$defs/id"},"fromCol":{"type":"integer","minimum":0,"maximum":5},"toCol":{"type":"integer","minimum":0,"maximum":5},"variant":{"enum":["default","emphasis","security","dashed"]}}}},"mainPath":{"type":"array","minItems":2,"items":{"$ref":"common.schema.json#/$defs/id"}},"semanticChecks":{"type":"object","additionalProperties":false,"minProperties":1,"properties":{"allowedRoots":{"type":"array","items":{"$ref":"common.schema.json#/$defs/id"}},"allowedTerminals":{"type":"array","items":{"$ref":"common.schema.json#/$defs/id"}},"requiredEdges":{"type":"array","items":{"$ref":"#/$defs/semanticRelation"}},"requiredPaths":{"type":"array","items":{"$ref":"#/$defs/semanticRelation"}}}},"nodes":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","lane","col","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"lane":{"$ref":"common.schema.json#/$defs/id"},"col":{"type":"integer","minimum":0,"maximum":5},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"width":{"type":"number","minimum":32},"height":{"type":"number","minimum":32},"yOffset":{"type":"number"}}}},"edges":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"role":{"enum":["main","branch","async","return","error"]},"fromSide":{"$ref":"#/$defs/side"},"toSide":{"$ref":"#/$defs/side"},"route":{"enum":["auto","straight","drop","outside-right","return-left","bottom-channel","up-channel"]},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"channelX":{"type":"number"},"channelY":{"type":"number"},"bias":{"type":"number","minimum":0,"maximum":1},"width":{"type":"number","minimum":0.5}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}},"$defs":{"semanticRelation":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"}}},"side":{"enum":["left","right","top","bottom"]}}};const schema33 = {"enum":["en","zh-CN","es"]};const schema34 = {"description":"A portable POSIX-relative HTML output path. It must be safe to interpret identically on every supported host filesystem.","type":"string","minLength":1,"pattern":"^[^/]+(?:/[^/]+)*$","allOf":[{"pattern":"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},{"not":{"pattern":"[\\\\<>:\"|?*\\u0000-\\u001F\\u007F-\\u009F]"}},{"not":{"pattern":"[\\uD800-\\uDFFF]"}},{"not":{"pattern":"(^|/)[.]{1,2}(/|$)"}},{"not":{"pattern":"[. ](/|$)"}},{"not":{"pattern":"(^|/)[^/]{256}"}},{"not":{"pattern":"(^|/)(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Nn][Ii][Nn][$]|[Cc][Oo][Nn][Oo][Uu][Tt][$]|[Cc][Oo][Mm][1-9¹²³]|[Ll][Pp][Tt][1-9¹²³])(?:[.]|/|$)"}},{"not":{"pattern":"(^|/)[^/]*~[1-9][0-9]*(?:[.]|/|$)"}}]};const schema35 = {"type":"object","additionalProperties":false,"required":["url","revision"],"properties":{"url":{"type":"string","minLength":1},"provider":{"enum":["github","gitee"]},"link_mode":{"enum":["web","local-only"]},"revision":{"type":"string","pattern":"^[a-fA-F0-9]{40}$"}}};const schema39 = {"enum":["auto","all","hidden"]};const schema40 = {"type":"object","additionalProperties":false,"minProperties":1,"properties":{"label":{"type":"string","minLength":1,"maxLength":80},"visible":{"type":"boolean"}}};const schema37 = {"type":"string","pattern":"^[a-zA-Z][a-zA-Z0-9_-]*$"};const schema59 = {"enum":["frontend","backend","database","cloud","security","messagebus","external"]};const schema60 = {"oneOf":[{"type":"string","minLength":1,"maxLength":2048,"anyOf":[{"maxLength":80,"pattern":"^[^\\r\\n]+$"},{"pattern":"^https?://"}]},{"type":"object","additionalProperties":false,"required":["url","sha256"],"properties":{"url":{"type":"string","minLength":8,"maxLength":2048,"pattern":"^https?://"},"sha256":{"type":"string","pattern":"^[a-f0-9]{64}$"}}}]};const schema61 = {"type":"array","minItems":1,"maxItems":3,"items":{"type":"object","additionalProperties":false,"required":["path"],"properties":{"path":{"type":"string","minLength":1,"maxLength":240},"line":{"type":"integer","minimum":1},"end_line":{"type":"integer","minimum":1},"label":{"type":"string","minLength":1,"maxLength":48}}}};const schema65 = {"enum":["default","emphasis","security","dashed"]};const schema66 = {"enum":["left","right","top","bottom"]};const schema68 = {"type":"array","prefixItems":[{"type":"number"},{"type":"number"}],"items":false,"minItems":2,"maxItems":2};const schema70 = {"type":"array","items":{"type":"object","additionalProperties":false,"required":["dot","title","items"],"properties":{"dot":{"enum":["cyan","emerald","violet","amber","rose","orange","slate"]},"title":{"type":"string","minLength":1},"items":{"type":"array","items":{"type":"string"}}}}};const func1 = Object.prototype.hasOwnProperty;const func3 = function ucs2length(str) {const len = str.length;let length = 0;let pos = 0;@@ -10,4 +11,124 @@&& (str.charCodeAt(pos) & 0xfc00) === 0xdc00) pos += 1;}return length;-};const pattern4 = new RegExp("^[a-fA-F0-9]{40}$", "u");const pattern5 = new RegExp("^[a-zA-Z][a-zA-Z0-9_-]*$", "u");const pattern18 = new RegExp("^[^\\r\\n]+$", "u");const pattern19 = new RegExp("^https?://", "u");const pattern21 = new RegExp("^[a-f0-9]{64}$", "u");const schema35 = {"type":"array","maxItems":5,"items":{"type":"object","additionalProperties":false,"required":["id","label","focus"],"properties":{"id":{"$ref":"#/$defs/id"},"label":{"type":"string","minLength":1,"maxLength":48},"focus":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/id"}},"note":{"type":"string","maxLength":140}}}};function validate22(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate22.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern5.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate22.errors = vErrors;return errors === 0;}validate22.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};const schema53 = {"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"}}};function validate24(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate24.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.from === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.to === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "from") || (key0 === "to"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.from !== undefined){let data0 = data.from;if(typeof data0 === "string"){if(!pattern5.test(data0)){const err3 = {instancePath:instancePath+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.to !== undefined){let data1 = data.to;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate24.errors = vErrors;return errors === 0;}validate24.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/workflow.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.lanes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lanes"},message:"must have required property '"+"lanes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.nodes === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "nodes"},message:"must have required property '"+"nodes"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.edges === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "edges"},message:"must have required property '"+"edges"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(func1.call(schema31.properties, key0))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){let data0 = data.schema_version;if(!((data0 === 1) || (data0 === 2))){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/enum",keyword:"enum",params:{allowedValues: schema31.properties.schema_version.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("workflow" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "workflow"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema31.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){if(typeof data2.output !== "string"){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"#/properties/meta/properties/output/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err16 = {instancePath:instancePath+"/meta/animation",schemaPath:"#/properties/meta/properties/animation/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.animation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err17 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"#/properties/meta/properties/visual_preset/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.visual_preset.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err18 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"#/properties/meta/properties/quality_profile/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.quality_profile.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err19 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data10.revision === undefined){const err20 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err21 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err22 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err24 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema34.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err25 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema34.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern4.test(data14)){const err26 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}if(data2.views !== undefined){if(!(validate22(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err29 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err30 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema38.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!(((((((key4 === "frontend") || (key4 === "backend")) || (key4 === "database")) || (key4 === "cloud")) || (key4 === "security")) || (key4 === "messagebus")) || (key4 === "external"))){const err31 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data18.frontend !== undefined){let data19 = data18.frontend;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err32 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err33 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err34 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func3(data20) < 1){const err35 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err37 = {instancePath:instancePath+"/meta/legend/entries/frontend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}}else {const err38 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data18.backend !== undefined){let data22 = data18.backend;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err39 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err40 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err41 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func3(data23) < 1){const err42 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}else {const err43 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err44 = {instancePath:instancePath+"/meta/legend/entries/backend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data18.database !== undefined){let data25 = data18.database;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err46 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err47 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err48 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}if(func3(data26) < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}else {const err50 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err51 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}}else {const err52 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}if(data18.cloud !== undefined){let data28 = data18.cloud;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err53 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err54 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err55 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func3(data29) < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err58 = {instancePath:instancePath+"/meta/legend/entries/cloud/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}}else {const err59 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}if(data18.security !== undefined){let data31 = data18.security;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err60 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err61 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err62 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}if(func3(data32) < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}else {const err64 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err65 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}}else {const err66 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}if(data18.messagebus !== undefined){let data34 = data18.messagebus;if(data34 && typeof data34 == "object" && !Array.isArray(data34)){if(Object.keys(data34).length < 1){const err67 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}for(const key10 in data34){if(!((key10 === "label") || (key10 === "visible"))){const err68 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}if(data34.label !== undefined){let data35 = data34.label;if(typeof data35 === "string"){if(func3(data35) > 80){const err69 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}if(func3(data35) < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}}else {const err71 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data34.visible !== undefined){if(typeof data34.visible !== "boolean"){const err72 = {instancePath:instancePath+"/meta/legend/entries/messagebus/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}}else {const err73 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}if(data18.external !== undefined){let data37 = data18.external;if(data37 && typeof data37 == "object" && !Array.isArray(data37)){if(Object.keys(data37).length < 1){const err74 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}for(const key11 in data37){if(!((key11 === "label") || (key11 === "visible"))){const err75 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}if(data37.label !== undefined){let data38 = data37.label;if(typeof data38 === "string"){if(func3(data38) > 80){const err76 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}if(func3(data38) < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}else {const err78 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data37.visible !== undefined){if(typeof data37.visible !== "boolean"){const err79 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}}}else {const err80 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}}else {const err81 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}}else {const err82 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}if(data2.viewBox !== undefined){let data40 = data2.viewBox;if(Array.isArray(data40)){if(data40.length > 2){const err83 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}if(data40.length < 2){const err84 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}const len0 = data40.length;if(len0 > 0){let data41 = data40[0];if((typeof data41 == "number") && (isFinite(data41))){if(data41 < 700 || isNaN(data41)){const err85 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 700},message:"must be >= 700"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}else {const err86 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}}if(len0 > 1){let data42 = data40[1];if((typeof data42 == "number") && (isFinite(data42))){if(data42 < 240 || isNaN(data42)){const err87 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 240},message:"must be >= 240"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}else {const err88 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}const len1 = data40.length;if(!(len1 <= 2)){const err89 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}else {const err90 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}}else {const err91 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}if(data.lanes !== undefined){let data43 = data.lanes;if(Array.isArray(data43)){if(data43.length < 1){const err92 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}const len2 = data43.length;for(let i0=0; i0<len2; i0++){let data44 = data43[i0];if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.id === undefined){const err93 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}if(data44.label === undefined){const err94 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}for(const key12 in data44){if(!(((key12 === "id") || (key12 === "label")) || (key12 === "variant"))){const err95 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}if(data44.id !== undefined){let data45 = data44.id;if(typeof data45 === "string"){if(!pattern5.test(data45)){const err96 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}else {const err97 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}if(data44.label !== undefined){let data46 = data44.label;if(typeof data46 === "string"){if(func3(data46) < 1){const err98 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}else {const err99 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data44.variant !== undefined){let data47 = data44.variant;if(!((data47 === "normal") || (data47 === "exception"))){const err100 = {instancePath:instancePath+"/lanes/" + i0+"/variant",schemaPath:"#/properties/lanes/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.lanes.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}}}else {const err101 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}}else {const err102 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data.phases !== undefined){let data48 = data.phases;if(Array.isArray(data48)){const len3 = data48.length;for(let i1=0; i1<len3; i1++){let data49 = data48[i1];if(data49 && typeof data49 == "object" && !Array.isArray(data49)){if(data49.id === undefined){const err103 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}if(data49.label === undefined){const err104 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}if(data49.fromCol === undefined){const err105 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "fromCol"},message:"must have required property '"+"fromCol"+"'"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}if(data49.toCol === undefined){const err106 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "toCol"},message:"must have required property '"+"toCol"+"'"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}for(const key13 in data49){if(!(((((key13 === "id") || (key13 === "label")) || (key13 === "fromCol")) || (key13 === "toCol")) || (key13 === "variant"))){const err107 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}if(data49.id !== undefined){let data50 = data49.id;if(typeof data50 === "string"){if(!pattern5.test(data50)){const err108 = {instancePath:instancePath+"/phases/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}else {const err109 = {instancePath:instancePath+"/phases/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}if(data49.label !== undefined){let data51 = data49.label;if(typeof data51 === "string"){if(func3(data51) < 1){const err110 = {instancePath:instancePath+"/phases/" + i1+"/label",schemaPath:"#/properties/phases/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}else {const err111 = {instancePath:instancePath+"/phases/" + i1+"/label",schemaPath:"#/properties/phases/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}if(data49.fromCol !== undefined){let data52 = data49.fromCol;if(!(((typeof data52 == "number") && (!(data52 % 1) && !isNaN(data52))) && (isFinite(data52)))){const err112 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}if((typeof data52 == "number") && (isFinite(data52))){if(data52 > 5 || isNaN(data52)){const err113 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}if(data52 < 0 || isNaN(data52)){const err114 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}}if(data49.toCol !== undefined){let data53 = data49.toCol;if(!(((typeof data53 == "number") && (!(data53 % 1) && !isNaN(data53))) && (isFinite(data53)))){const err115 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}if((typeof data53 == "number") && (isFinite(data53))){if(data53 > 5 || isNaN(data53)){const err116 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}if(data53 < 0 || isNaN(data53)){const err117 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}}}if(data49.variant !== undefined){let data54 = data49.variant;if(!((((data54 === "default") || (data54 === "emphasis")) || (data54 === "security")) || (data54 === "dashed"))){const err118 = {instancePath:instancePath+"/phases/" + i1+"/variant",schemaPath:"#/properties/phases/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.phases.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}}else {const err119 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}}else {const err120 = {instancePath:instancePath+"/phases",schemaPath:"#/properties/phases/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}if(data.groups !== undefined){let data55 = data.groups;if(Array.isArray(data55)){const len4 = data55.length;for(let i2=0; i2<len4; i2++){let data56 = data55[i2];if(data56 && typeof data56 == "object" && !Array.isArray(data56)){if(data56.id === undefined){const err121 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}if(data56.label === undefined){const err122 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}if(data56.lane === undefined){const err123 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}if(data56.fromCol === undefined){const err124 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "fromCol"},message:"must have required property '"+"fromCol"+"'"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}if(data56.toCol === undefined){const err125 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "toCol"},message:"must have required property '"+"toCol"+"'"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}for(const key14 in data56){if(!((((((key14 === "id") || (key14 === "label")) || (key14 === "lane")) || (key14 === "fromCol")) || (key14 === "toCol")) || (key14 === "variant"))){const err126 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}if(data56.id !== undefined){let data57 = data56.id;if(typeof data57 === "string"){if(!pattern5.test(data57)){const err127 = {instancePath:instancePath+"/groups/" + i2+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}}else {const err128 = {instancePath:instancePath+"/groups/" + i2+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}}if(data56.label !== undefined){let data58 = data56.label;if(typeof data58 === "string"){if(func3(data58) < 1){const err129 = {instancePath:instancePath+"/groups/" + i2+"/label",schemaPath:"#/properties/groups/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}else {const err130 = {instancePath:instancePath+"/groups/" + i2+"/label",schemaPath:"#/properties/groups/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}}if(data56.lane !== undefined){let data59 = data56.lane;if(typeof data59 === "string"){if(!pattern5.test(data59)){const err131 = {instancePath:instancePath+"/groups/" + i2+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}}else {const err132 = {instancePath:instancePath+"/groups/" + i2+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}}if(data56.fromCol !== undefined){let data60 = data56.fromCol;if(!(((typeof data60 == "number") && (!(data60 % 1) && !isNaN(data60))) && (isFinite(data60)))){const err133 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}if((typeof data60 == "number") && (isFinite(data60))){if(data60 > 5 || isNaN(data60)){const err134 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}if(data60 < 0 || isNaN(data60)){const err135 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}}}if(data56.toCol !== undefined){let data61 = data56.toCol;if(!(((typeof data61 == "number") && (!(data61 % 1) && !isNaN(data61))) && (isFinite(data61)))){const err136 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}if((typeof data61 == "number") && (isFinite(data61))){if(data61 > 5 || isNaN(data61)){const err137 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}if(data61 < 0 || isNaN(data61)){const err138 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}}if(data56.variant !== undefined){let data62 = data56.variant;if(!((((data62 === "default") || (data62 === "emphasis")) || (data62 === "security")) || (data62 === "dashed"))){const err139 = {instancePath:instancePath+"/groups/" + i2+"/variant",schemaPath:"#/properties/groups/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.groups.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}}else {const err140 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}}else {const err141 = {instancePath:instancePath+"/groups",schemaPath:"#/properties/groups/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}}if(data.mainPath !== undefined){let data63 = data.mainPath;if(Array.isArray(data63)){if(data63.length < 2){const err142 = {instancePath:instancePath+"/mainPath",schemaPath:"#/properties/mainPath/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}const len5 = data63.length;for(let i3=0; i3<len5; i3++){let data64 = data63[i3];if(typeof data64 === "string"){if(!pattern5.test(data64)){const err143 = {instancePath:instancePath+"/mainPath/" + i3,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}else {const err144 = {instancePath:instancePath+"/mainPath/" + i3,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}}}else {const err145 = {instancePath:instancePath+"/mainPath",schemaPath:"#/properties/mainPath/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}if(data.semanticChecks !== undefined){let data65 = data.semanticChecks;if(data65 && typeof data65 == "object" && !Array.isArray(data65)){if(Object.keys(data65).length < 1){const err146 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}for(const key15 in data65){if(!((((key15 === "allowedRoots") || (key15 === "allowedTerminals")) || (key15 === "requiredEdges")) || (key15 === "requiredPaths"))){const err147 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}if(data65.allowedRoots !== undefined){let data66 = data65.allowedRoots;if(Array.isArray(data66)){const len6 = data66.length;for(let i4=0; i4<len6; i4++){let data67 = data66[i4];if(typeof data67 === "string"){if(!pattern5.test(data67)){const err148 = {instancePath:instancePath+"/semanticChecks/allowedRoots/" + i4,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}else {const err149 = {instancePath:instancePath+"/semanticChecks/allowedRoots/" + i4,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}}else {const err150 = {instancePath:instancePath+"/semanticChecks/allowedRoots",schemaPath:"#/properties/semanticChecks/properties/allowedRoots/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data65.allowedTerminals !== undefined){let data68 = data65.allowedTerminals;if(Array.isArray(data68)){const len7 = data68.length;for(let i5=0; i5<len7; i5++){let data69 = data68[i5];if(typeof data69 === "string"){if(!pattern5.test(data69)){const err151 = {instancePath:instancePath+"/semanticChecks/allowedTerminals/" + i5,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}}else {const err152 = {instancePath:instancePath+"/semanticChecks/allowedTerminals/" + i5,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}else {const err153 = {instancePath:instancePath+"/semanticChecks/allowedTerminals",schemaPath:"#/properties/semanticChecks/properties/allowedTerminals/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}}if(data65.requiredEdges !== undefined){let data70 = data65.requiredEdges;if(Array.isArray(data70)){const len8 = data70.length;for(let i6=0; i6<len8; i6++){if(!(validate24(data70[i6], {instancePath:instancePath+"/semanticChecks/requiredEdges/" + i6,parentData:data70,parentDataProperty:i6,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate24.errors : vErrors.concat(validate24.errors);errors = vErrors.length;}}}else {const err154 = {instancePath:instancePath+"/semanticChecks/requiredEdges",schemaPath:"#/properties/semanticChecks/properties/requiredEdges/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}if(data65.requiredPaths !== undefined){let data72 = data65.requiredPaths;if(Array.isArray(data72)){const len9 = data72.length;for(let i7=0; i7<len9; i7++){if(!(validate24(data72[i7], {instancePath:instancePath+"/semanticChecks/requiredPaths/" + i7,parentData:data72,parentDataProperty:i7,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate24.errors : vErrors.concat(validate24.errors);errors = vErrors.length;}}}else {const err155 = {instancePath:instancePath+"/semanticChecks/requiredPaths",schemaPath:"#/properties/semanticChecks/properties/requiredPaths/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}}else {const err156 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}if(data.nodes !== undefined){let data74 = data.nodes;if(Array.isArray(data74)){if(data74.length < 1){const err157 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}const len10 = data74.length;for(let i8=0; i8<len10; i8++){let data75 = data74[i8];if(data75 && typeof data75 == "object" && !Array.isArray(data75)){if(data75.id === undefined){const err158 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}if(data75.lane === undefined){const err159 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}if(data75.col === undefined){const err160 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "col"},message:"must have required property '"+"col"+"'"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}if(data75.type === undefined){const err161 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}if(data75.label === undefined){const err162 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}for(const key16 in data75){if(!(func1.call(schema31.properties.nodes.items.properties, key16))){const err163 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}}if(data75.id !== undefined){let data76 = data75.id;if(typeof data76 === "string"){if(!pattern5.test(data76)){const err164 = {instancePath:instancePath+"/nodes/" + i8+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}else {const err165 = {instancePath:instancePath+"/nodes/" + i8+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data75.lane !== undefined){let data77 = data75.lane;if(typeof data77 === "string"){if(!pattern5.test(data77)){const err166 = {instancePath:instancePath+"/nodes/" + i8+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}else {const err167 = {instancePath:instancePath+"/nodes/" + i8+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data75.col !== undefined){let data78 = data75.col;if(!(((typeof data78 == "number") && (!(data78 % 1) && !isNaN(data78))) && (isFinite(data78)))){const err168 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}if((typeof data78 == "number") && (isFinite(data78))){if(data78 > 5 || isNaN(data78)){const err169 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}if(data78 < 0 || isNaN(data78)){const err170 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}}if(data75.type !== undefined){let data79 = data75.type;if(!(((((((data79 === "frontend") || (data79 === "backend")) || (data79 === "database")) || (data79 === "cloud")) || (data79 === "security")) || (data79 === "messagebus")) || (data79 === "external"))){const err171 = {instancePath:instancePath+"/nodes/" + i8+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema58.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(data75.label !== undefined){let data80 = data75.label;if(typeof data80 === "string"){if(func3(data80) < 1){const err172 = {instancePath:instancePath+"/nodes/" + i8+"/label",schemaPath:"#/properties/nodes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}else {const err173 = {instancePath:instancePath+"/nodes/" + i8+"/label",schemaPath:"#/properties/nodes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}if(data75.sublabel !== undefined){if(typeof data75.sublabel !== "string"){const err174 = {instancePath:instancePath+"/nodes/" + i8+"/sublabel",schemaPath:"#/properties/nodes/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}if(data75.tag !== undefined){if(typeof data75.tag !== "string"){const err175 = {instancePath:instancePath+"/nodes/" + i8+"/tag",schemaPath:"#/properties/nodes/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}if(data75.brand !== undefined){let data83 = data75.brand;const _errs190 = errors;let valid57 = false;let passing0 = null;const _errs191 = errors;const _errs193 = errors;let valid58 = false;const _errs194 = errors;if(typeof data83 === "string"){if(func3(data83) > 80){const err176 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}if(!pattern18.test(data83)){const err177 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}var _valid1 = _errs194 === errors;valid58 = valid58 || _valid1;const _errs195 = errors;if(typeof data83 === "string"){if(!pattern19.test(data83)){const err178 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}var _valid1 = _errs195 === errors;valid58 = valid58 || _valid1;if(!valid58){const err179 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}else {errors = _errs193;if(vErrors !== null){if(_errs193){vErrors.length = _errs193;}else {vErrors = null;}}}if(typeof data83 === "string"){if(func3(data83) > 2048){const err180 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}if(func3(data83) < 1){const err181 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}else {const err182 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}var _valid0 = _errs191 === errors;if(_valid0){valid57 = true;passing0 = 0;}const _errs196 = errors;if(data83 && typeof data83 == "object" && !Array.isArray(data83)){if(data83.url === undefined){const err183 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}if(data83.sha256 === undefined){const err184 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}for(const key17 in data83){if(!((key17 === "url") || (key17 === "sha256"))){const err185 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}}if(data83.url !== undefined){let data84 = data83.url;if(typeof data84 === "string"){if(func3(data84) > 2048){const err186 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}if(func3(data84) < 8){const err187 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}if(!pattern19.test(data84)){const err188 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}else {const err189 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}if(data83.sha256 !== undefined){let data85 = data83.sha256;if(typeof data85 === "string"){if(!pattern21.test(data85)){const err190 = {instancePath:instancePath+"/nodes/" + i8+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}else {const err191 = {instancePath:instancePath+"/nodes/" + i8+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}}else {const err192 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}var _valid0 = _errs196 === errors;if(_valid0 && valid57){valid57 = false;passing0 = [passing0, 1];}else {if(_valid0){valid57 = true;passing0 = 1;}}if(!valid57){const err193 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}else {errors = _errs190;if(vErrors !== null){if(_errs190){vErrors.length = _errs190;}else {vErrors = null;}}}}if(data75.sources !== undefined){let data86 = data75.sources;if(Array.isArray(data86)){if(data86.length > 3){const err194 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}if(data86.length < 1){const err195 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}const len11 = data86.length;for(let i9=0; i9<len11; i9++){let data87 = data86[i9];if(data87 && typeof data87 == "object" && !Array.isArray(data87)){if(data87.path === undefined){const err196 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}for(const key18 in data87){if(!((((key18 === "path") || (key18 === "line")) || (key18 === "end_line")) || (key18 === "label"))){const err197 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}}if(data87.path !== undefined){let data88 = data87.path;if(typeof data88 === "string"){if(func3(data88) > 240){const err198 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}if(func3(data88) < 1){const err199 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}else {const err200 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}}if(data87.line !== undefined){let data89 = data87.line;if(!(((typeof data89 == "number") && (!(data89 % 1) && !isNaN(data89))) && (isFinite(data89)))){const err201 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}if((typeof data89 == "number") && (isFinite(data89))){if(data89 < 1 || isNaN(data89)){const err202 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}}}if(data87.end_line !== undefined){let data90 = data87.end_line;if(!(((typeof data90 == "number") && (!(data90 % 1) && !isNaN(data90))) && (isFinite(data90)))){const err203 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}if((typeof data90 == "number") && (isFinite(data90))){if(data90 < 1 || isNaN(data90)){const err204 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}}}if(data87.label !== undefined){let data91 = data87.label;if(typeof data91 === "string"){if(func3(data91) > 48){const err205 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}if(func3(data91) < 1){const err206 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}else {const err207 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}}}else {const err208 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}}}else {const err209 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}if(data75.width !== undefined){let data92 = data75.width;if((typeof data92 == "number") && (isFinite(data92))){if(data92 < 32 || isNaN(data92)){const err210 = {instancePath:instancePath+"/nodes/" + i8+"/width",schemaPath:"#/properties/nodes/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 32},message:"must be >= 32"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}}else {const err211 = {instancePath:instancePath+"/nodes/" + i8+"/width",schemaPath:"#/properties/nodes/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}}if(data75.height !== undefined){let data93 = data75.height;if((typeof data93 == "number") && (isFinite(data93))){if(data93 < 32 || isNaN(data93)){const err212 = {instancePath:instancePath+"/nodes/" + i8+"/height",schemaPath:"#/properties/nodes/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 32},message:"must be >= 32"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}}else {const err213 = {instancePath:instancePath+"/nodes/" + i8+"/height",schemaPath:"#/properties/nodes/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}}if(data75.yOffset !== undefined){let data94 = data75.yOffset;if(!((typeof data94 == "number") && (isFinite(data94)))){const err214 = {instancePath:instancePath+"/nodes/" + i8+"/yOffset",schemaPath:"#/properties/nodes/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}}}else {const err215 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}}}else {const err216 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}if(data.edges !== undefined){let data95 = data.edges;if(Array.isArray(data95)){const len12 = data95.length;for(let i10=0; i10<len12; i10++){let data96 = data95[i10];if(data96 && typeof data96 == "object" && !Array.isArray(data96)){if(data96.from === undefined){const err217 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}if(data96.to === undefined){const err218 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}for(const key19 in data96){if(!(func1.call(schema31.properties.edges.items.properties, key19))){const err219 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key19},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}if(data96.id !== undefined){let data97 = data96.id;if(typeof data97 === "string"){if(!pattern5.test(data97)){const err220 = {instancePath:instancePath+"/edges/" + i10+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}}else {const err221 = {instancePath:instancePath+"/edges/" + i10+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}if(data96.from !== undefined){let data98 = data96.from;if(typeof data98 === "string"){if(!pattern5.test(data98)){const err222 = {instancePath:instancePath+"/edges/" + i10+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}}else {const err223 = {instancePath:instancePath+"/edges/" + i10+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err223];}else {vErrors.push(err223);}errors++;}}if(data96.to !== undefined){let data99 = data96.to;if(typeof data99 === "string"){if(!pattern5.test(data99)){const err224 = {instancePath:instancePath+"/edges/" + i10+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err224];}else {vErrors.push(err224);}errors++;}}else {const err225 = {instancePath:instancePath+"/edges/" + i10+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err225];}else {vErrors.push(err225);}errors++;}}if(data96.label !== undefined){if(typeof data96.label !== "string"){const err226 = {instancePath:instancePath+"/edges/" + i10+"/label",schemaPath:"#/properties/edges/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err226];}else {vErrors.push(err226);}errors++;}}if(data96.variant !== undefined){let data101 = data96.variant;if(!((((data101 === "default") || (data101 === "emphasis")) || (data101 === "security")) || (data101 === "dashed"))){const err227 = {instancePath:instancePath+"/edges/" + i10+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema64.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err227];}else {vErrors.push(err227);}errors++;}}if(data96.role !== undefined){let data102 = data96.role;if(!(((((data102 === "main") || (data102 === "branch")) || (data102 === "async")) || (data102 === "return")) || (data102 === "error"))){const err228 = {instancePath:instancePath+"/edges/" + i10+"/role",schemaPath:"#/properties/edges/items/properties/role/enum",keyword:"enum",params:{allowedValues: schema31.properties.edges.items.properties.role.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err228];}else {vErrors.push(err228);}errors++;}}if(data96.fromSide !== undefined){let data103 = data96.fromSide;if(!((((data103 === "left") || (data103 === "right")) || (data103 === "top")) || (data103 === "bottom"))){const err229 = {instancePath:instancePath+"/edges/" + i10+"/fromSide",schemaPath:"#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err229];}else {vErrors.push(err229);}errors++;}}if(data96.toSide !== undefined){let data104 = data96.toSide;if(!((((data104 === "left") || (data104 === "right")) || (data104 === "top")) || (data104 === "bottom"))){const err230 = {instancePath:instancePath+"/edges/" + i10+"/toSide",schemaPath:"#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err230];}else {vErrors.push(err230);}errors++;}}if(data96.route !== undefined){let data105 = data96.route;if(!(((((((data105 === "auto") || (data105 === "straight")) || (data105 === "drop")) || (data105 === "outside-right")) || (data105 === "return-left")) || (data105 === "bottom-channel")) || (data105 === "up-channel"))){const err231 = {instancePath:instancePath+"/edges/" + i10+"/route",schemaPath:"#/properties/edges/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema31.properties.edges.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err231];}else {vErrors.push(err231);}errors++;}}if(data96.via !== undefined){let data106 = data96.via;if(Array.isArray(data106)){const len13 = data106.length;for(let i11=0; i11<len13; i11++){let data107 = data106[i11];if(Array.isArray(data107)){if(data107.length > 2){const err232 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err232];}else {vErrors.push(err232);}errors++;}if(data107.length < 2){const err233 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err233];}else {vErrors.push(err233);}errors++;}const len14 = data107.length;if(len14 > 0){let data108 = data107[0];if(!((typeof data108 == "number") && (isFinite(data108)))){const err234 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err234];}else {vErrors.push(err234);}errors++;}}if(len14 > 1){let data109 = data107[1];if(!((typeof data109 == "number") && (isFinite(data109)))){const err235 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err235];}else {vErrors.push(err235);}errors++;}}const len15 = data107.length;if(!(len15 <= 2)){const err236 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err236];}else {vErrors.push(err236);}errors++;}}else {const err237 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err237];}else {vErrors.push(err237);}errors++;}}}else {const err238 = {instancePath:instancePath+"/edges/" + i10+"/via",schemaPath:"#/properties/edges/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err238];}else {vErrors.push(err238);}errors++;}}if(data96.labelAt !== undefined){let data110 = data96.labelAt;if(Array.isArray(data110)){if(data110.length > 2){const err239 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err239];}else {vErrors.push(err239);}errors++;}if(data110.length < 2){const err240 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err240];}else {vErrors.push(err240);}errors++;}const len16 = data110.length;if(len16 > 0){let data111 = data110[0];if(!((typeof data111 == "number") && (isFinite(data111)))){const err241 = {instancePath:instancePath+"/edges/" + i10+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err241];}else {vErrors.push(err241);}errors++;}}if(len16 > 1){let data112 = data110[1];if(!((typeof data112 == "number") && (isFinite(data112)))){const err242 = {instancePath:instancePath+"/edges/" + i10+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err242];}else {vErrors.push(err242);}errors++;}}const len17 = data110.length;if(!(len17 <= 2)){const err243 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err243];}else {vErrors.push(err243);}errors++;}}else {const err244 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err244];}else {vErrors.push(err244);}errors++;}}if(data96.labelDx !== undefined){let data113 = data96.labelDx;if(!((typeof data113 == "number") && (isFinite(data113)))){const err245 = {instancePath:instancePath+"/edges/" + i10+"/labelDx",schemaPath:"#/properties/edges/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err245];}else {vErrors.push(err245);}errors++;}}if(data96.labelDy !== undefined){let data114 = data96.labelDy;if(!((typeof data114 == "number") && (isFinite(data114)))){const err246 = {instancePath:instancePath+"/edges/" + i10+"/labelDy",schemaPath:"#/properties/edges/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err246];}else {vErrors.push(err246);}errors++;}}if(data96.labelSegment !== undefined){let data115 = data96.labelSegment;if(!(((typeof data115 == "number") && (!(data115 % 1) && !isNaN(data115))) && (isFinite(data115)))){const err247 = {instancePath:instancePath+"/edges/" + i10+"/labelSegment",schemaPath:"#/properties/edges/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err247];}else {vErrors.push(err247);}errors++;}if((typeof data115 == "number") && (isFinite(data115))){if(data115 < 0 || isNaN(data115)){const err248 = {instancePath:instancePath+"/edges/" + i10+"/labelSegment",schemaPath:"#/properties/edges/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err248];}else {vErrors.push(err248);}errors++;}}}if(data96.channelX !== undefined){let data116 = data96.channelX;if(!((typeof data116 == "number") && (isFinite(data116)))){const err249 = {instancePath:instancePath+"/edges/" + i10+"/channelX",schemaPath:"#/properties/edges/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err249];}else {vErrors.push(err249);}errors++;}}if(data96.channelY !== undefined){let data117 = data96.channelY;if(!((typeof data117 == "number") && (isFinite(data117)))){const err250 = {instancePath:instancePath+"/edges/" + i10+"/channelY",schemaPath:"#/properties/edges/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err250];}else {vErrors.push(err250);}errors++;}}if(data96.bias !== undefined){let data118 = data96.bias;if((typeof data118 == "number") && (isFinite(data118))){if(data118 > 1 || isNaN(data118)){const err251 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err251];}else {vErrors.push(err251);}errors++;}if(data118 < 0 || isNaN(data118)){const err252 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err252];}else {vErrors.push(err252);}errors++;}}else {const err253 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err253];}else {vErrors.push(err253);}errors++;}}if(data96.width !== undefined){let data119 = data96.width;if((typeof data119 == "number") && (isFinite(data119))){if(data119 < 0.5 || isNaN(data119)){const err254 = {instancePath:instancePath+"/edges/" + i10+"/width",schemaPath:"#/properties/edges/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err254];}else {vErrors.push(err254);}errors++;}}else {const err255 = {instancePath:instancePath+"/edges/" + i10+"/width",schemaPath:"#/properties/edges/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err255];}else {vErrors.push(err255);}errors++;}}}else {const err256 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err256];}else {vErrors.push(err256);}errors++;}}}else {const err257 = {instancePath:instancePath+"/edges",schemaPath:"#/properties/edges/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err257];}else {vErrors.push(err257);}errors++;}}if(data.cards !== undefined){let data120 = data.cards;if(Array.isArray(data120)){const len18 = data120.length;for(let i12=0; i12<len18; i12++){let data121 = data120[i12];if(data121 && typeof data121 == "object" && !Array.isArray(data121)){if(data121.dot === undefined){const err258 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err258];}else {vErrors.push(err258);}errors++;}if(data121.title === undefined){const err259 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err259];}else {vErrors.push(err259);}errors++;}if(data121.items === undefined){const err260 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err260];}else {vErrors.push(err260);}errors++;}for(const key20 in data121){if(!(((key20 === "dot") || (key20 === "title")) || (key20 === "items"))){const err261 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key20},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err261];}else {vErrors.push(err261);}errors++;}}if(data121.dot !== undefined){let data122 = data121.dot;if(!(((((((data122 === "cyan") || (data122 === "emerald")) || (data122 === "violet")) || (data122 === "amber")) || (data122 === "rose")) || (data122 === "orange")) || (data122 === "slate"))){const err262 = {instancePath:instancePath+"/cards/" + i12+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema69.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err262];}else {vErrors.push(err262);}errors++;}}if(data121.title !== undefined){let data123 = data121.title;if(typeof data123 === "string"){if(func3(data123) < 1){const err263 = {instancePath:instancePath+"/cards/" + i12+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err263];}else {vErrors.push(err263);}errors++;}}else {const err264 = {instancePath:instancePath+"/cards/" + i12+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err264];}else {vErrors.push(err264);}errors++;}}if(data121.items !== undefined){let data124 = data121.items;if(Array.isArray(data124)){const len19 = data124.length;for(let i13=0; i13<len19; i13++){if(typeof data124[i13] !== "string"){const err265 = {instancePath:instancePath+"/cards/" + i12+"/items/" + i13,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err265];}else {vErrors.push(err265);}errors++;}}}else {const err266 = {instancePath:instancePath+"/cards/" + i12+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err266];}else {vErrors.push(err266);}errors++;}}}else {const err267 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err267];}else {vErrors.push(err267);}errors++;}}}else {const err268 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err268];}else {vErrors.push(err268);}errors++;}}}else {const err269 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err269];}else {vErrors.push(err269);}errors++;}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};export const sequence = validate27;const schema70 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/sequence.schema.json","title":"Archify Sequence Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","participants","messages"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"sequence"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"type":"string"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"column_fit":{"description":"Horizontal participant layout. Omit this field or use fixed for the stable 86px boxes and 108px gap. Use spread when a wide viewBox would leave unused horizontal space or meaningful participant labels do not fit the fixed boxes; spread derives wider boxes and gaps from the viewBox without changing participant order or message semantics.","enum":["fixed","spread"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"default":{"$ref":"common.schema.json#/$defs/legendEntry"},"emphasis":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"dashed":{"$ref":"common.schema.json#/$defs/legendEntry"},"return":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":480},{"type":"number","minimum":480}],"items":false,"minItems":2,"maxItems":2}}},"participants":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"}}}},"segments":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to","label"],"properties":{"from":{"type":"number"},"to":{"type":"number"},"label":{"type":"string","minLength":1}}}},"messages":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["from","to","y","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"y":{"type":"number","minimum":160},"label":{"type":"string","minLength":1},"variant":{"enum":["default","emphasis","security","dashed","return"]},"note":{"type":"string"}}}},"activations":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["participant","from","to"],"properties":{"participant":{"$ref":"common.schema.json#/$defs/id"},"from":{"type":"number"},"to":{"type":"number"},"type":{"$ref":"common.schema.json#/$defs/componentType"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};const schema72 = {"enum":["trace","none"]};const schema73 = {"enum":["classic","signal-flow","blueprint","editorial"]};const schema74 = {"enum":["standard","showcase"]};function validate28(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate28.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern5.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate28.errors = vErrors;return errors === 0;}validate28.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate27(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/sequence.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate27.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.participants === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "participants"},message:"must have required property '"+"participants"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.messages === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "messages"},message:"must have required property '"+"messages"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!((((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "participants")) || (key0 === "segments")) || (key0 === "messages")) || (key0 === "activations")) || (key0 === "cards"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err6 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.diagram_type !== undefined){if("sequence" !== data.diagram_type){const err7 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "sequence"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err8 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}for(const key1 in data2){if(!(func1.call(schema70.properties.meta.properties, key1))){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err10 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err12 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err13 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.output !== undefined){if(typeof data2.output !== "string"){const err14 = {instancePath:instancePath+"/meta/output",schemaPath:"#/properties/meta/properties/output/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err15 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema72.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err16 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema73.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err17 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data2.column_fit !== undefined){let data10 = data2.column_fit;if(!((data10 === "fixed") || (data10 === "spread"))){const err18 = {instancePath:instancePath+"/meta/column_fit",schemaPath:"#/properties/meta/properties/column_fit/enum",keyword:"enum",params:{allowedValues: schema70.properties.meta.properties.column_fit.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data2.repository !== undefined){let data11 = data2.repository;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.url === undefined){const err19 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data11.revision === undefined){const err20 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}for(const key2 in data11){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err21 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data11.url !== undefined){let data12 = data11.url;if(typeof data12 === "string"){if(func3(data12) < 1){const err22 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data11.provider !== undefined){let data13 = data11.provider;if(!((data13 === "github") || (data13 === "gitee"))){const err24 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema34.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data11.link_mode !== undefined){let data14 = data11.link_mode;if(!((data14 === "web") || (data14 === "local-only"))){const err25 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema34.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data11.revision !== undefined){let data15 = data11.revision;if(typeof data15 === "string"){if(!pattern4.test(data15)){const err26 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}if(data2.views !== undefined){if(!(validate28(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate28.errors : vErrors.concat(validate28.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data17 = data2.legend;if(data17 && typeof data17 == "object" && !Array.isArray(data17)){for(const key3 in data17){if(!((key3 === "mode") || (key3 === "entries"))){const err29 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data17.mode !== undefined){let data18 = data17.mode;if(!(((data18 === "auto") || (data18 === "all")) || (data18 === "hidden"))){const err30 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema38.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data17.entries !== undefined){let data19 = data17.entries;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){for(const key4 in data19){if(!(((((key4 === "default") || (key4 === "emphasis")) || (key4 === "security")) || (key4 === "dashed")) || (key4 === "return"))){const err31 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data19.default !== undefined){let data20 = data19.default;if(data20 && typeof data20 == "object" && !Array.isArray(data20)){if(Object.keys(data20).length < 1){const err32 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}for(const key5 in data20){if(!((key5 === "label") || (key5 === "visible"))){const err33 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data20.label !== undefined){let data21 = data20.label;if(typeof data21 === "string"){if(func3(data21) > 80){const err34 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func3(data21) < 1){const err35 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data20.visible !== undefined){if(typeof data20.visible !== "boolean"){const err37 = {instancePath:instancePath+"/meta/legend/entries/default/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}}else {const err38 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data19.emphasis !== undefined){let data23 = data19.emphasis;if(data23 && typeof data23 == "object" && !Array.isArray(data23)){if(Object.keys(data23).length < 1){const err39 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}for(const key6 in data23){if(!((key6 === "label") || (key6 === "visible"))){const err40 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data23.label !== undefined){let data24 = data23.label;if(typeof data24 === "string"){if(func3(data24) > 80){const err41 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func3(data24) < 1){const err42 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}else {const err43 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}if(data23.visible !== undefined){if(typeof data23.visible !== "boolean"){const err44 = {instancePath:instancePath+"/meta/legend/entries/emphasis/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data19.security !== undefined){let data26 = data19.security;if(data26 && typeof data26 == "object" && !Array.isArray(data26)){if(Object.keys(data26).length < 1){const err46 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}for(const key7 in data26){if(!((key7 === "label") || (key7 === "visible"))){const err47 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data26.label !== undefined){let data27 = data26.label;if(typeof data27 === "string"){if(func3(data27) > 80){const err48 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}if(func3(data27) < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}else {const err50 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data26.visible !== undefined){if(typeof data26.visible !== "boolean"){const err51 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}}else {const err52 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}if(data19.dashed !== undefined){let data29 = data19.dashed;if(data29 && typeof data29 == "object" && !Array.isArray(data29)){if(Object.keys(data29).length < 1){const err53 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}for(const key8 in data29){if(!((key8 === "label") || (key8 === "visible"))){const err54 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data29.label !== undefined){let data30 = data29.label;if(typeof data30 === "string"){if(func3(data30) > 80){const err55 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func3(data30) < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data29.visible !== undefined){if(typeof data29.visible !== "boolean"){const err58 = {instancePath:instancePath+"/meta/legend/entries/dashed/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}}else {const err59 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}if(data19.return !== undefined){let data32 = data19.return;if(data32 && typeof data32 == "object" && !Array.isArray(data32)){if(Object.keys(data32).length < 1){const err60 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}for(const key9 in data32){if(!((key9 === "label") || (key9 === "visible"))){const err61 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}if(data32.label !== undefined){let data33 = data32.label;if(typeof data33 === "string"){if(func3(data33) > 80){const err62 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}if(func3(data33) < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}else {const err64 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data32.visible !== undefined){if(typeof data32.visible !== "boolean"){const err65 = {instancePath:instancePath+"/meta/legend/entries/return/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}}else {const err66 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}}else {const err68 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}if(data2.viewBox !== undefined){let data35 = data2.viewBox;if(Array.isArray(data35)){if(data35.length > 2){const err69 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}if(data35.length < 2){const err70 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}const len0 = data35.length;if(len0 > 0){let data36 = data35[0];if((typeof data36 == "number") && (isFinite(data36))){if(data36 < 480 || isNaN(data36)){const err71 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 480},message:"must be >= 480"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}else {const err72 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}if(len0 > 1){let data37 = data35[1];if((typeof data37 == "number") && (isFinite(data37))){if(data37 < 480 || isNaN(data37)){const err73 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 480},message:"must be >= 480"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}const len1 = data35.length;if(!(len1 <= 2)){const err75 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}else {const err76 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}}else {const err77 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}if(data.participants !== undefined){let data38 = data.participants;if(Array.isArray(data38)){if(data38.length < 2){const err78 = {instancePath:instancePath+"/participants",schemaPath:"#/properties/participants/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}const len2 = data38.length;for(let i0=0; i0<len2; i0++){let data39 = data38[i0];if(data39 && typeof data39 == "object" && !Array.isArray(data39)){if(data39.id === undefined){const err79 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}if(data39.type === undefined){const err80 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}if(data39.label === undefined){const err81 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}for(const key10 in data39){if(!((((((key10 === "id") || (key10 === "type")) || (key10 === "label")) || (key10 === "sublabel")) || (key10 === "brand")) || (key10 === "sources"))){const err82 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}if(data39.id !== undefined){let data40 = data39.id;if(typeof data40 === "string"){if(!pattern5.test(data40)){const err83 = {instancePath:instancePath+"/participants/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}else {const err84 = {instancePath:instancePath+"/participants/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}if(data39.type !== undefined){let data41 = data39.type;if(!(((((((data41 === "frontend") || (data41 === "backend")) || (data41 === "database")) || (data41 === "cloud")) || (data41 === "security")) || (data41 === "messagebus")) || (data41 === "external"))){const err85 = {instancePath:instancePath+"/participants/" + i0+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema58.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data39.label !== undefined){let data42 = data39.label;if(typeof data42 === "string"){if(func3(data42) < 1){const err86 = {instancePath:instancePath+"/participants/" + i0+"/label",schemaPath:"#/properties/participants/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}}else {const err87 = {instancePath:instancePath+"/participants/" + i0+"/label",schemaPath:"#/properties/participants/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}if(data39.sublabel !== undefined){if(typeof data39.sublabel !== "string"){const err88 = {instancePath:instancePath+"/participants/" + i0+"/sublabel",schemaPath:"#/properties/participants/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}if(data39.brand !== undefined){let data44 = data39.brand;const _errs103 = errors;let valid28 = false;let passing0 = null;const _errs104 = errors;const _errs106 = errors;let valid29 = false;const _errs107 = errors;if(typeof data44 === "string"){if(func3(data44) > 80){const err89 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}if(!pattern18.test(data44)){const err90 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}var _valid1 = _errs107 === errors;valid29 = valid29 || _valid1;const _errs108 = errors;if(typeof data44 === "string"){if(!pattern19.test(data44)){const err91 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}var _valid1 = _errs108 === errors;valid29 = valid29 || _valid1;if(!valid29){const err92 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}else {errors = _errs106;if(vErrors !== null){if(_errs106){vErrors.length = _errs106;}else {vErrors = null;}}}if(typeof data44 === "string"){if(func3(data44) > 2048){const err93 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}if(func3(data44) < 1){const err94 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}else {const err95 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}var _valid0 = _errs104 === errors;if(_valid0){valid28 = true;passing0 = 0;}const _errs109 = errors;if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.url === undefined){const err96 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}if(data44.sha256 === undefined){const err97 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}for(const key11 in data44){if(!((key11 === "url") || (key11 === "sha256"))){const err98 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data44.url !== undefined){let data45 = data44.url;if(typeof data45 === "string"){if(func3(data45) > 2048){const err99 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}if(func3(data45) < 8){const err100 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}if(!pattern19.test(data45)){const err101 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}else {const err102 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data44.sha256 !== undefined){let data46 = data44.sha256;if(typeof data46 === "string"){if(!pattern21.test(data46)){const err103 = {instancePath:instancePath+"/participants/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}else {const err104 = {instancePath:instancePath+"/participants/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}}else {const err105 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}var _valid0 = _errs109 === errors;if(_valid0 && valid28){valid28 = false;passing0 = [passing0, 1];}else {if(_valid0){valid28 = true;passing0 = 1;}}if(!valid28){const err106 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}else {errors = _errs103;if(vErrors !== null){if(_errs103){vErrors.length = _errs103;}else {vErrors = null;}}}}if(data39.sources !== undefined){let data47 = data39.sources;if(Array.isArray(data47)){if(data47.length > 3){const err107 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}if(data47.length < 1){const err108 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}const len3 = data47.length;for(let i1=0; i1<len3; i1++){let data48 = data47[i1];if(data48 && typeof data48 == "object" && !Array.isArray(data48)){if(data48.path === undefined){const err109 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}for(const key12 in data48){if(!((((key12 === "path") || (key12 === "line")) || (key12 === "end_line")) || (key12 === "label"))){const err110 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}if(data48.path !== undefined){let data49 = data48.path;if(typeof data49 === "string"){if(func3(data49) > 240){const err111 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}if(func3(data49) < 1){const err112 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}}else {const err113 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}if(data48.line !== undefined){let data50 = data48.line;if(!(((typeof data50 == "number") && (!(data50 % 1) && !isNaN(data50))) && (isFinite(data50)))){const err114 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}if((typeof data50 == "number") && (isFinite(data50))){if(data50 < 1 || isNaN(data50)){const err115 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}}if(data48.end_line !== undefined){let data51 = data48.end_line;if(!(((typeof data51 == "number") && (!(data51 % 1) && !isNaN(data51))) && (isFinite(data51)))){const err116 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}if((typeof data51 == "number") && (isFinite(data51))){if(data51 < 1 || isNaN(data51)){const err117 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}}}if(data48.label !== undefined){let data52 = data48.label;if(typeof data52 === "string"){if(func3(data52) > 48){const err118 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}if(func3(data52) < 1){const err119 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}else {const err120 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}}else {const err121 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}}else {const err122 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}}else {const err123 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}}else {const err124 = {instancePath:instancePath+"/participants",schemaPath:"#/properties/participants/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}}if(data.segments !== undefined){let data53 = data.segments;if(Array.isArray(data53)){const len4 = data53.length;for(let i2=0; i2<len4; i2++){let data54 = data53[i2];if(data54 && typeof data54 == "object" && !Array.isArray(data54)){if(data54.from === undefined){const err125 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}if(data54.to === undefined){const err126 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}if(data54.label === undefined){const err127 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}for(const key13 in data54){if(!(((key13 === "from") || (key13 === "to")) || (key13 === "label"))){const err128 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}}if(data54.from !== undefined){let data55 = data54.from;if(!((typeof data55 == "number") && (isFinite(data55)))){const err129 = {instancePath:instancePath+"/segments/" + i2+"/from",schemaPath:"#/properties/segments/items/properties/from/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}if(data54.to !== undefined){let data56 = data54.to;if(!((typeof data56 == "number") && (isFinite(data56)))){const err130 = {instancePath:instancePath+"/segments/" + i2+"/to",schemaPath:"#/properties/segments/items/properties/to/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}}if(data54.label !== undefined){let data57 = data54.label;if(typeof data57 === "string"){if(func3(data57) < 1){const err131 = {instancePath:instancePath+"/segments/" + i2+"/label",schemaPath:"#/properties/segments/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}}else {const err132 = {instancePath:instancePath+"/segments/" + i2+"/label",schemaPath:"#/properties/segments/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}}}else {const err133 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}}else {const err134 = {instancePath:instancePath+"/segments",schemaPath:"#/properties/segments/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}}if(data.messages !== undefined){let data58 = data.messages;if(Array.isArray(data58)){if(data58.length < 1){const err135 = {instancePath:instancePath+"/messages",schemaPath:"#/properties/messages/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}const len5 = data58.length;for(let i3=0; i3<len5; i3++){let data59 = data58[i3];if(data59 && typeof data59 == "object" && !Array.isArray(data59)){if(data59.from === undefined){const err136 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}if(data59.to === undefined){const err137 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}if(data59.y === undefined){const err138 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "y"},message:"must have required property '"+"y"+"'"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}if(data59.label === undefined){const err139 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}for(const key14 in data59){if(!(((((((key14 === "id") || (key14 === "from")) || (key14 === "to")) || (key14 === "y")) || (key14 === "label")) || (key14 === "variant")) || (key14 === "note"))){const err140 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}if(data59.id !== undefined){let data60 = data59.id;if(typeof data60 === "string"){if(!pattern5.test(data60)){const err141 = {instancePath:instancePath+"/messages/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}}else {const err142 = {instancePath:instancePath+"/messages/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}}if(data59.from !== undefined){let data61 = data59.from;if(typeof data61 === "string"){if(!pattern5.test(data61)){const err143 = {instancePath:instancePath+"/messages/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}else {const err144 = {instancePath:instancePath+"/messages/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}}if(data59.to !== undefined){let data62 = data59.to;if(typeof data62 === "string"){if(!pattern5.test(data62)){const err145 = {instancePath:instancePath+"/messages/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}else {const err146 = {instancePath:instancePath+"/messages/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}}if(data59.y !== undefined){let data63 = data59.y;if((typeof data63 == "number") && (isFinite(data63))){if(data63 < 160 || isNaN(data63)){const err147 = {instancePath:instancePath+"/messages/" + i3+"/y",schemaPath:"#/properties/messages/items/properties/y/minimum",keyword:"minimum",params:{comparison: ">=", limit: 160},message:"must be >= 160"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}else {const err148 = {instancePath:instancePath+"/messages/" + i3+"/y",schemaPath:"#/properties/messages/items/properties/y/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}if(data59.label !== undefined){let data64 = data59.label;if(typeof data64 === "string"){if(func3(data64) < 1){const err149 = {instancePath:instancePath+"/messages/" + i3+"/label",schemaPath:"#/properties/messages/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}else {const err150 = {instancePath:instancePath+"/messages/" + i3+"/label",schemaPath:"#/properties/messages/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data59.variant !== undefined){let data65 = data59.variant;if(!(((((data65 === "default") || (data65 === "emphasis")) || (data65 === "security")) || (data65 === "dashed")) || (data65 === "return"))){const err151 = {instancePath:instancePath+"/messages/" + i3+"/variant",schemaPath:"#/properties/messages/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema70.properties.messages.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}}if(data59.note !== undefined){if(typeof data59.note !== "string"){const err152 = {instancePath:instancePath+"/messages/" + i3+"/note",schemaPath:"#/properties/messages/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}else {const err153 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}}}else {const err154 = {instancePath:instancePath+"/messages",schemaPath:"#/properties/messages/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}if(data.activations !== undefined){let data67 = data.activations;if(Array.isArray(data67)){const len6 = data67.length;for(let i4=0; i4<len6; i4++){let data68 = data67[i4];if(data68 && typeof data68 == "object" && !Array.isArray(data68)){if(data68.participant === undefined){const err155 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "participant"},message:"must have required property '"+"participant"+"'"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}if(data68.from === undefined){const err156 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}if(data68.to === undefined){const err157 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}for(const key15 in data68){if(!((((key15 === "participant") || (key15 === "from")) || (key15 === "to")) || (key15 === "type"))){const err158 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}if(data68.participant !== undefined){let data69 = data68.participant;if(typeof data69 === "string"){if(!pattern5.test(data69)){const err159 = {instancePath:instancePath+"/activations/" + i4+"/participant",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}else {const err160 = {instancePath:instancePath+"/activations/" + i4+"/participant",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}if(data68.from !== undefined){let data70 = data68.from;if(!((typeof data70 == "number") && (isFinite(data70)))){const err161 = {instancePath:instancePath+"/activations/" + i4+"/from",schemaPath:"#/properties/activations/items/properties/from/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}if(data68.to !== undefined){let data71 = data68.to;if(!((typeof data71 == "number") && (isFinite(data71)))){const err162 = {instancePath:instancePath+"/activations/" + i4+"/to",schemaPath:"#/properties/activations/items/properties/to/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}if(data68.type !== undefined){let data72 = data68.type;if(!(((((((data72 === "frontend") || (data72 === "backend")) || (data72 === "database")) || (data72 === "cloud")) || (data72 === "security")) || (data72 === "messagebus")) || (data72 === "external"))){const err163 = {instancePath:instancePath+"/activations/" + i4+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema58.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}}}else {const err164 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}}else {const err165 = {instancePath:instancePath+"/activations",schemaPath:"#/properties/activations/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data.cards !== undefined){let data73 = data.cards;if(Array.isArray(data73)){const len7 = data73.length;for(let i5=0; i5<len7; i5++){let data74 = data73[i5];if(data74 && typeof data74 == "object" && !Array.isArray(data74)){if(data74.dot === undefined){const err166 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}if(data74.title === undefined){const err167 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}if(data74.items === undefined){const err168 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}for(const key16 in data74){if(!(((key16 === "dot") || (key16 === "title")) || (key16 === "items"))){const err169 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}if(data74.dot !== undefined){let data75 = data74.dot;if(!(((((((data75 === "cyan") || (data75 === "emerald")) || (data75 === "violet")) || (data75 === "amber")) || (data75 === "rose")) || (data75 === "orange")) || (data75 === "slate"))){const err170 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema69.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}if(data74.title !== undefined){let data76 = data74.title;if(typeof data76 === "string"){if(func3(data76) < 1){const err171 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}else {const err172 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}if(data74.items !== undefined){let data77 = data74.items;if(Array.isArray(data77)){const len8 = data77.length;for(let i6=0; i6<len8; i6++){if(typeof data77[i6] !== "string"){const err173 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}}else {const err174 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}}else {const err175 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}}else {const err176 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}}else {const err177 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}validate27.errors = vErrors;return errors === 0;}validate27.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};export const dataflow = validate30;const schema95 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/dataflow.schema.json","title":"Archify Data Flow Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","stages","nodes","flows"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"dataflow"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"type":"string"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"default":{"$ref":"common.schema.json#/$defs/legendEntry"},"emphasis":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"dashed":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":360},{"type":"number","minimum":360}],"items":false,"minItems":2,"maxItems":2}}},"stages":{"type":"array","minItems":2,"maxItems":5,"items":{"type":"object","additionalProperties":false,"required":["label"],"properties":{"label":{"type":"string","minLength":1}}}},"nodes":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label","stage","row"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"stage":{"type":"integer","minimum":0},"row":{"type":"integer","minimum":0},"width":{"type":"number","minimum":48},"height":{"type":"number","minimum":36},"yOffset":{"type":"number"}}}},"flows":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"classification":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"route":{"enum":["auto","straight","vertical-channel","bottom-channel","top-channel"]},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"channelX":{"type":"number"},"channelY":{"type":"number"},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};const schema118 = {"enum":["left","right","top","bottom"]};const schema122 = {"type":"number","minimum":0.5};function validate31(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate31.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern5.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate31.errors = vErrors;return errors === 0;}validate31.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate30(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/dataflow.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate30.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.stages === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "stages"},message:"must have required property '"+"stages"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.nodes === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "nodes"},message:"must have required property '"+"nodes"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.flows === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "flows"},message:"must have required property '"+"flows"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "stages")) || (key0 === "nodes")) || (key0 === "flows")) || (key0 === "cards"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("dataflow" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "dataflow"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema95.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){if(typeof data2.output !== "string"){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"#/properties/meta/properties/output/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err16 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema72.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err17 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema73.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err18 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err19 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data10.revision === undefined){const err20 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err21 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err22 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err24 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema34.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err25 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema34.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern4.test(data14)){const err26 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}if(data2.views !== undefined){if(!(validate31(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate31.errors : vErrors.concat(validate31.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err29 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err30 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema38.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!(((((key4 === "default") || (key4 === "emphasis")) || (key4 === "security")) || (key4 === "dashed")) || (key4 === "database"))){const err31 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data18.default !== undefined){let data19 = data18.default;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err32 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err33 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err34 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func3(data20) < 1){const err35 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err37 = {instancePath:instancePath+"/meta/legend/entries/default/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}}else {const err38 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data18.emphasis !== undefined){let data22 = data18.emphasis;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err39 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err40 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err41 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func3(data23) < 1){const err42 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}else {const err43 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err44 = {instancePath:instancePath+"/meta/legend/entries/emphasis/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data18.security !== undefined){let data25 = data18.security;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err46 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err47 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err48 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}if(func3(data26) < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}else {const err50 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err51 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}}else {const err52 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}if(data18.dashed !== undefined){let data28 = data18.dashed;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err53 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err54 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err55 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func3(data29) < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err58 = {instancePath:instancePath+"/meta/legend/entries/dashed/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}}else {const err59 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}if(data18.database !== undefined){let data31 = data18.database;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err60 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err61 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err62 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}if(func3(data32) < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}else {const err64 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err65 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}}else {const err66 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}}else {const err68 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}if(data2.viewBox !== undefined){let data34 = data2.viewBox;if(Array.isArray(data34)){if(data34.length > 2){const err69 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}if(data34.length < 2){const err70 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}const len0 = data34.length;if(len0 > 0){let data35 = data34[0];if((typeof data35 == "number") && (isFinite(data35))){if(data35 < 360 || isNaN(data35)){const err71 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 360},message:"must be >= 360"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}else {const err72 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}if(len0 > 1){let data36 = data34[1];if((typeof data36 == "number") && (isFinite(data36))){if(data36 < 360 || isNaN(data36)){const err73 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 360},message:"must be >= 360"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}const len1 = data34.length;if(!(len1 <= 2)){const err75 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}else {const err76 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}}else {const err77 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}if(data.stages !== undefined){let data37 = data.stages;if(Array.isArray(data37)){if(data37.length > 5){const err78 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}if(data37.length < 2){const err79 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}const len2 = data37.length;for(let i0=0; i0<len2; i0++){let data38 = data37[i0];if(data38 && typeof data38 == "object" && !Array.isArray(data38)){if(data38.label === undefined){const err80 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}for(const key10 in data38){if(!(key10 === "label")){const err81 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data38.label !== undefined){let data39 = data38.label;if(typeof data39 === "string"){if(func3(data39) < 1){const err82 = {instancePath:instancePath+"/stages/" + i0+"/label",schemaPath:"#/properties/stages/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}else {const err83 = {instancePath:instancePath+"/stages/" + i0+"/label",schemaPath:"#/properties/stages/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}}else {const err84 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}}else {const err85 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data.nodes !== undefined){let data40 = data.nodes;if(Array.isArray(data40)){if(data40.length < 2){const err86 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}const len3 = data40.length;for(let i1=0; i1<len3; i1++){let data41 = data40[i1];if(data41 && typeof data41 == "object" && !Array.isArray(data41)){if(data41.id === undefined){const err87 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}if(data41.type === undefined){const err88 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}if(data41.label === undefined){const err89 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}if(data41.stage === undefined){const err90 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "stage"},message:"must have required property '"+"stage"+"'"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}if(data41.row === undefined){const err91 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "row"},message:"must have required property '"+"row"+"'"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}for(const key11 in data41){if(!(func1.call(schema95.properties.nodes.items.properties, key11))){const err92 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}if(data41.id !== undefined){let data42 = data41.id;if(typeof data42 === "string"){if(!pattern5.test(data42)){const err93 = {instancePath:instancePath+"/nodes/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}else {const err94 = {instancePath:instancePath+"/nodes/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}if(data41.type !== undefined){let data43 = data41.type;if(!(((((((data43 === "frontend") || (data43 === "backend")) || (data43 === "database")) || (data43 === "cloud")) || (data43 === "security")) || (data43 === "messagebus")) || (data43 === "external"))){const err95 = {instancePath:instancePath+"/nodes/" + i1+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema58.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}if(data41.label !== undefined){let data44 = data41.label;if(typeof data44 === "string"){if(func3(data44) < 1){const err96 = {instancePath:instancePath+"/nodes/" + i1+"/label",schemaPath:"#/properties/nodes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}else {const err97 = {instancePath:instancePath+"/nodes/" + i1+"/label",schemaPath:"#/properties/nodes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}if(data41.sublabel !== undefined){if(typeof data41.sublabel !== "string"){const err98 = {instancePath:instancePath+"/nodes/" + i1+"/sublabel",schemaPath:"#/properties/nodes/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data41.tag !== undefined){if(typeof data41.tag !== "string"){const err99 = {instancePath:instancePath+"/nodes/" + i1+"/tag",schemaPath:"#/properties/nodes/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data41.brand !== undefined){let data47 = data41.brand;const _errs111 = errors;let valid31 = false;let passing0 = null;const _errs112 = errors;const _errs114 = errors;let valid32 = false;const _errs115 = errors;if(typeof data47 === "string"){if(func3(data47) > 80){const err100 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}if(!pattern18.test(data47)){const err101 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}var _valid1 = _errs115 === errors;valid32 = valid32 || _valid1;const _errs116 = errors;if(typeof data47 === "string"){if(!pattern19.test(data47)){const err102 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}var _valid1 = _errs116 === errors;valid32 = valid32 || _valid1;if(!valid32){const err103 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}else {errors = _errs114;if(vErrors !== null){if(_errs114){vErrors.length = _errs114;}else {vErrors = null;}}}if(typeof data47 === "string"){if(func3(data47) > 2048){const err104 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}if(func3(data47) < 1){const err105 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}else {const err106 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}var _valid0 = _errs112 === errors;if(_valid0){valid31 = true;passing0 = 0;}const _errs117 = errors;if(data47 && typeof data47 == "object" && !Array.isArray(data47)){if(data47.url === undefined){const err107 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}if(data47.sha256 === undefined){const err108 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}for(const key12 in data47){if(!((key12 === "url") || (key12 === "sha256"))){const err109 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}if(data47.url !== undefined){let data48 = data47.url;if(typeof data48 === "string"){if(func3(data48) > 2048){const err110 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}if(func3(data48) < 8){const err111 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}if(!pattern19.test(data48)){const err112 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}}else {const err113 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}if(data47.sha256 !== undefined){let data49 = data47.sha256;if(typeof data49 === "string"){if(!pattern21.test(data49)){const err114 = {instancePath:instancePath+"/nodes/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}else {const err115 = {instancePath:instancePath+"/nodes/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}}else {const err116 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}var _valid0 = _errs117 === errors;if(_valid0 && valid31){valid31 = false;passing0 = [passing0, 1];}else {if(_valid0){valid31 = true;passing0 = 1;}}if(!valid31){const err117 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}else {errors = _errs111;if(vErrors !== null){if(_errs111){vErrors.length = _errs111;}else {vErrors = null;}}}}if(data41.sources !== undefined){let data50 = data41.sources;if(Array.isArray(data50)){if(data50.length > 3){const err118 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}if(data50.length < 1){const err119 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}const len4 = data50.length;for(let i2=0; i2<len4; i2++){let data51 = data50[i2];if(data51 && typeof data51 == "object" && !Array.isArray(data51)){if(data51.path === undefined){const err120 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}for(const key13 in data51){if(!((((key13 === "path") || (key13 === "line")) || (key13 === "end_line")) || (key13 === "label"))){const err121 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}if(data51.path !== undefined){let data52 = data51.path;if(typeof data52 === "string"){if(func3(data52) > 240){const err122 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}if(func3(data52) < 1){const err123 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}else {const err124 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}}if(data51.line !== undefined){let data53 = data51.line;if(!(((typeof data53 == "number") && (!(data53 % 1) && !isNaN(data53))) && (isFinite(data53)))){const err125 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}if((typeof data53 == "number") && (isFinite(data53))){if(data53 < 1 || isNaN(data53)){const err126 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}}if(data51.end_line !== undefined){let data54 = data51.end_line;if(!(((typeof data54 == "number") && (!(data54 % 1) && !isNaN(data54))) && (isFinite(data54)))){const err127 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}if((typeof data54 == "number") && (isFinite(data54))){if(data54 < 1 || isNaN(data54)){const err128 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}}}if(data51.label !== undefined){let data55 = data51.label;if(typeof data55 === "string"){if(func3(data55) > 48){const err129 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}if(func3(data55) < 1){const err130 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}}else {const err131 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}}}else {const err132 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}}}else {const err133 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}if(data41.stage !== undefined){let data56 = data41.stage;if(!(((typeof data56 == "number") && (!(data56 % 1) && !isNaN(data56))) && (isFinite(data56)))){const err134 = {instancePath:instancePath+"/nodes/" + i1+"/stage",schemaPath:"#/properties/nodes/items/properties/stage/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}if((typeof data56 == "number") && (isFinite(data56))){if(data56 < 0 || isNaN(data56)){const err135 = {instancePath:instancePath+"/nodes/" + i1+"/stage",schemaPath:"#/properties/nodes/items/properties/stage/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}}}if(data41.row !== undefined){let data57 = data41.row;if(!(((typeof data57 == "number") && (!(data57 % 1) && !isNaN(data57))) && (isFinite(data57)))){const err136 = {instancePath:instancePath+"/nodes/" + i1+"/row",schemaPath:"#/properties/nodes/items/properties/row/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}if((typeof data57 == "number") && (isFinite(data57))){if(data57 < 0 || isNaN(data57)){const err137 = {instancePath:instancePath+"/nodes/" + i1+"/row",schemaPath:"#/properties/nodes/items/properties/row/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}}if(data41.width !== undefined){let data58 = data41.width;if((typeof data58 == "number") && (isFinite(data58))){if(data58 < 48 || isNaN(data58)){const err138 = {instancePath:instancePath+"/nodes/" + i1+"/width",schemaPath:"#/properties/nodes/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 48},message:"must be >= 48"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}else {const err139 = {instancePath:instancePath+"/nodes/" + i1+"/width",schemaPath:"#/properties/nodes/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}if(data41.height !== undefined){let data59 = data41.height;if((typeof data59 == "number") && (isFinite(data59))){if(data59 < 36 || isNaN(data59)){const err140 = {instancePath:instancePath+"/nodes/" + i1+"/height",schemaPath:"#/properties/nodes/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 36},message:"must be >= 36"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}else {const err141 = {instancePath:instancePath+"/nodes/" + i1+"/height",schemaPath:"#/properties/nodes/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}}if(data41.yOffset !== undefined){let data60 = data41.yOffset;if(!((typeof data60 == "number") && (isFinite(data60)))){const err142 = {instancePath:instancePath+"/nodes/" + i1+"/yOffset",schemaPath:"#/properties/nodes/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}}}else {const err143 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}}else {const err144 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}}if(data.flows !== undefined){let data61 = data.flows;if(Array.isArray(data61)){const len5 = data61.length;for(let i3=0; i3<len5; i3++){let data62 = data61[i3];if(data62 && typeof data62 == "object" && !Array.isArray(data62)){if(data62.from === undefined){const err145 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}if(data62.to === undefined){const err146 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}if(data62.label === undefined){const err147 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}for(const key14 in data62){if(!(func1.call(schema95.properties.flows.items.properties, key14))){const err148 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}if(data62.id !== undefined){let data63 = data62.id;if(typeof data63 === "string"){if(!pattern5.test(data63)){const err149 = {instancePath:instancePath+"/flows/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}else {const err150 = {instancePath:instancePath+"/flows/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data62.from !== undefined){let data64 = data62.from;if(typeof data64 === "string"){if(!pattern5.test(data64)){const err151 = {instancePath:instancePath+"/flows/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}}else {const err152 = {instancePath:instancePath+"/flows/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}if(data62.to !== undefined){let data65 = data62.to;if(typeof data65 === "string"){if(!pattern5.test(data65)){const err153 = {instancePath:instancePath+"/flows/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}}else {const err154 = {instancePath:instancePath+"/flows/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}if(data62.label !== undefined){let data66 = data62.label;if(typeof data66 === "string"){if(func3(data66) < 1){const err155 = {instancePath:instancePath+"/flows/" + i3+"/label",schemaPath:"#/properties/flows/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}else {const err156 = {instancePath:instancePath+"/flows/" + i3+"/label",schemaPath:"#/properties/flows/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}if(data62.classification !== undefined){if(typeof data62.classification !== "string"){const err157 = {instancePath:instancePath+"/flows/" + i3+"/classification",schemaPath:"#/properties/flows/items/properties/classification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}if(data62.variant !== undefined){let data68 = data62.variant;if(!((((data68 === "default") || (data68 === "emphasis")) || (data68 === "security")) || (data68 === "dashed"))){const err158 = {instancePath:instancePath+"/flows/" + i3+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema64.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}if(data62.route !== undefined){let data69 = data62.route;if(!(((((data69 === "auto") || (data69 === "straight")) || (data69 === "vertical-channel")) || (data69 === "bottom-channel")) || (data69 === "top-channel"))){const err159 = {instancePath:instancePath+"/flows/" + i3+"/route",schemaPath:"#/properties/flows/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema95.properties.flows.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}if(data62.fromSide !== undefined){let data70 = data62.fromSide;if(!((((data70 === "left") || (data70 === "right")) || (data70 === "top")) || (data70 === "bottom"))){const err160 = {instancePath:instancePath+"/flows/" + i3+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}if(data62.toSide !== undefined){let data71 = data62.toSide;if(!((((data71 === "left") || (data71 === "right")) || (data71 === "top")) || (data71 === "bottom"))){const err161 = {instancePath:instancePath+"/flows/" + i3+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}if(data62.channelX !== undefined){let data72 = data62.channelX;if(!((typeof data72 == "number") && (isFinite(data72)))){const err162 = {instancePath:instancePath+"/flows/" + i3+"/channelX",schemaPath:"#/properties/flows/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}if(data62.channelY !== undefined){let data73 = data62.channelY;if(!((typeof data73 == "number") && (isFinite(data73)))){const err163 = {instancePath:instancePath+"/flows/" + i3+"/channelY",schemaPath:"#/properties/flows/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}}if(data62.labelAt !== undefined){let data74 = data62.labelAt;if(Array.isArray(data74)){if(data74.length > 2){const err164 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}if(data74.length < 2){const err165 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}const len6 = data74.length;if(len6 > 0){let data75 = data74[0];if(!((typeof data75 == "number") && (isFinite(data75)))){const err166 = {instancePath:instancePath+"/flows/" + i3+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}if(len6 > 1){let data76 = data74[1];if(!((typeof data76 == "number") && (isFinite(data76)))){const err167 = {instancePath:instancePath+"/flows/" + i3+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}const len7 = data74.length;if(!(len7 <= 2)){const err168 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}}else {const err169 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}if(data62.labelDx !== undefined){let data77 = data62.labelDx;if(!((typeof data77 == "number") && (isFinite(data77)))){const err170 = {instancePath:instancePath+"/flows/" + i3+"/labelDx",schemaPath:"#/properties/flows/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}if(data62.labelDy !== undefined){let data78 = data62.labelDy;if(!((typeof data78 == "number") && (isFinite(data78)))){const err171 = {instancePath:instancePath+"/flows/" + i3+"/labelDy",schemaPath:"#/properties/flows/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(data62.labelSegment !== undefined){let data79 = data62.labelSegment;if(!(((typeof data79 == "number") && (!(data79 % 1) && !isNaN(data79))) && (isFinite(data79)))){const err172 = {instancePath:instancePath+"/flows/" + i3+"/labelSegment",schemaPath:"#/properties/flows/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}if((typeof data79 == "number") && (isFinite(data79))){if(data79 < 0 || isNaN(data79)){const err173 = {instancePath:instancePath+"/flows/" + i3+"/labelSegment",schemaPath:"#/properties/flows/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}}if(data62.via !== undefined){let data80 = data62.via;if(Array.isArray(data80)){const len8 = data80.length;for(let i4=0; i4<len8; i4++){let data81 = data80[i4];if(Array.isArray(data81)){if(data81.length > 2){const err174 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}if(data81.length < 2){const err175 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}const len9 = data81.length;if(len9 > 0){let data82 = data81[0];if(!((typeof data82 == "number") && (isFinite(data82)))){const err176 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}if(len9 > 1){let data83 = data81[1];if(!((typeof data83 == "number") && (isFinite(data83)))){const err177 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}const len10 = data81.length;if(!(len10 <= 2)){const err178 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}else {const err179 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}}}else {const err180 = {instancePath:instancePath+"/flows/" + i3+"/via",schemaPath:"#/properties/flows/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}if(data62.width !== undefined){let data84 = data62.width;if((typeof data84 == "number") && (isFinite(data84))){if(data84 < 0.5 || isNaN(data84)){const err181 = {instancePath:instancePath+"/flows/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}else {const err182 = {instancePath:instancePath+"/flows/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}}else {const err183 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}}else {const err184 = {instancePath:instancePath+"/flows",schemaPath:"#/properties/flows/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data.cards !== undefined){let data85 = data.cards;if(Array.isArray(data85)){const len11 = data85.length;for(let i5=0; i5<len11; i5++){let data86 = data85[i5];if(data86 && typeof data86 == "object" && !Array.isArray(data86)){if(data86.dot === undefined){const err185 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}if(data86.title === undefined){const err186 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}if(data86.items === undefined){const err187 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}for(const key15 in data86){if(!(((key15 === "dot") || (key15 === "title")) || (key15 === "items"))){const err188 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}if(data86.dot !== undefined){let data87 = data86.dot;if(!(((((((data87 === "cyan") || (data87 === "emerald")) || (data87 === "violet")) || (data87 === "amber")) || (data87 === "rose")) || (data87 === "orange")) || (data87 === "slate"))){const err189 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema69.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}if(data86.title !== undefined){let data88 = data86.title;if(typeof data88 === "string"){if(func3(data88) < 1){const err190 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}else {const err191 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}if(data86.items !== undefined){let data89 = data86.items;if(Array.isArray(data89)){const len12 = data89.length;for(let i6=0; i6<len12; i6++){if(typeof data89[i6] !== "string"){const err192 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}}else {const err193 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}}else {const err194 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}}else {const err195 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}}else {const err196 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}validate30.errors = vErrors;return errors === 0;}validate30.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};export const lifecycle = validate33;const schema124 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/lifecycle.schema.json","title":"Archify Lifecycle Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","lanes","states","transitions"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"lifecycle"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"type":"string"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"start":{"$ref":"common.schema.json#/$defs/legendEntry"},"active":{"$ref":"common.schema.json#/$defs/legendEntry"},"waiting":{"$ref":"common.schema.json#/$defs/legendEntry"},"decision":{"$ref":"common.schema.json#/$defs/legendEntry"},"success":{"$ref":"common.schema.json#/$defs/legendEntry"},"failure":{"$ref":"common.schema.json#/$defs/legendEntry"},"neutral":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":420},{"type":"number","minimum":566}],"items":false,"minItems":2,"maxItems":2}}},"lanes":{"type":"array","minItems":1,"maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["id","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1}}}},"states":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label","lane","col"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"enum":["start","active","waiting","decision","success","failure","neutral","external"]},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"step":{"type":"string"},"lane":{"$ref":"common.schema.json#/$defs/id"},"col":{"type":"integer","minimum":0,"maximum":4},"width":{"type":"number","minimum":48},"height":{"type":"number","minimum":36},"yOffset":{"type":"number"}}}},"transitions":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"note":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"route":{"enum":["auto","straight","drop","bottom-channel","top-channel","right-channel","left-channel"]},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"channelX":{"type":"number"},"channelY":{"type":"number"},"cornerRadius":{"type":"number","minimum":0},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};function validate34(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate34.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern5.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate34.errors = vErrors;return errors === 0;}validate34.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate33(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/lifecycle.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate33.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.lanes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lanes"},message:"must have required property '"+"lanes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.states === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "states"},message:"must have required property '"+"states"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.transitions === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "transitions"},message:"must have required property '"+"transitions"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "lanes")) || (key0 === "states")) || (key0 === "transitions")) || (key0 === "cards"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("lifecycle" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "lifecycle"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema124.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){if(typeof data2.output !== "string"){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"#/properties/meta/properties/output/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err16 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema72.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err17 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema73.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err18 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err19 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}if(data10.revision === undefined){const err20 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err21 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err22 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}else {const err23 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err24 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema34.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err25 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema34.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern4.test(data14)){const err26 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}else {const err27 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}}else {const err28 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}if(data2.views !== undefined){if(!(validate34(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate34.errors : vErrors.concat(validate34.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err29 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err30 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema38.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!((((((((key4 === "start") || (key4 === "active")) || (key4 === "waiting")) || (key4 === "decision")) || (key4 === "success")) || (key4 === "failure")) || (key4 === "neutral")) || (key4 === "external"))){const err31 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data18.start !== undefined){let data19 = data18.start;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err32 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err33 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err34 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}if(func3(data20) < 1){const err35 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}else {const err36 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err37 = {instancePath:instancePath+"/meta/legend/entries/start/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}}else {const err38 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data18.active !== undefined){let data22 = data18.active;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err39 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err40 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err41 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}if(func3(data23) < 1){const err42 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}else {const err43 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err44 = {instancePath:instancePath+"/meta/legend/entries/active/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data18.waiting !== undefined){let data25 = data18.waiting;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err46 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err47 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err48 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}if(func3(data26) < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}else {const err50 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err51 = {instancePath:instancePath+"/meta/legend/entries/waiting/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}}else {const err52 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}if(data18.decision !== undefined){let data28 = data18.decision;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err53 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err54 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err55 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}if(func3(data29) < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}else {const err57 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err58 = {instancePath:instancePath+"/meta/legend/entries/decision/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}}else {const err59 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}if(data18.success !== undefined){let data31 = data18.success;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err60 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err61 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err62 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}if(func3(data32) < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}else {const err64 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err65 = {instancePath:instancePath+"/meta/legend/entries/success/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}}else {const err66 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}if(data18.failure !== undefined){let data34 = data18.failure;if(data34 && typeof data34 == "object" && !Array.isArray(data34)){if(Object.keys(data34).length < 1){const err67 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}for(const key10 in data34){if(!((key10 === "label") || (key10 === "visible"))){const err68 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}if(data34.label !== undefined){let data35 = data34.label;if(typeof data35 === "string"){if(func3(data35) > 80){const err69 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}if(func3(data35) < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}}else {const err71 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data34.visible !== undefined){if(typeof data34.visible !== "boolean"){const err72 = {instancePath:instancePath+"/meta/legend/entries/failure/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}}else {const err73 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}if(data18.neutral !== undefined){let data37 = data18.neutral;if(data37 && typeof data37 == "object" && !Array.isArray(data37)){if(Object.keys(data37).length < 1){const err74 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}for(const key11 in data37){if(!((key11 === "label") || (key11 === "visible"))){const err75 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}if(data37.label !== undefined){let data38 = data37.label;if(typeof data38 === "string"){if(func3(data38) > 80){const err76 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}if(func3(data38) < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}else {const err78 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data37.visible !== undefined){if(typeof data37.visible !== "boolean"){const err79 = {instancePath:instancePath+"/meta/legend/entries/neutral/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}}}else {const err80 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}if(data18.external !== undefined){let data40 = data18.external;if(data40 && typeof data40 == "object" && !Array.isArray(data40)){if(Object.keys(data40).length < 1){const err81 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}for(const key12 in data40){if(!((key12 === "label") || (key12 === "visible"))){const err82 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}if(data40.label !== undefined){let data41 = data40.label;if(typeof data41 === "string"){if(func3(data41) > 80){const err83 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}if(func3(data41) < 1){const err84 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}else {const err85 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data40.visible !== undefined){if(typeof data40.visible !== "boolean"){const err86 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}}}else {const err87 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}}else {const err88 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}}else {const err89 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}if(data2.viewBox !== undefined){let data43 = data2.viewBox;if(Array.isArray(data43)){if(data43.length > 2){const err90 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}if(data43.length < 2){const err91 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}const len0 = data43.length;if(len0 > 0){let data44 = data43[0];if((typeof data44 == "number") && (isFinite(data44))){if(data44 < 420 || isNaN(data44)){const err92 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 420},message:"must be >= 420"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}else {const err93 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}if(len0 > 1){let data45 = data43[1];if((typeof data45 == "number") && (isFinite(data45))){if(data45 < 566 || isNaN(data45)){const err94 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 566},message:"must be >= 566"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}else {const err95 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}const len1 = data43.length;if(!(len1 <= 2)){const err96 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}else {const err97 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}}else {const err98 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data.lanes !== undefined){let data46 = data.lanes;if(Array.isArray(data46)){if(data46.length > 4){const err99 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/maxItems",keyword:"maxItems",params:{limit: 4},message:"must NOT have more than 4 items"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}if(data46.length < 1){const err100 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}const len2 = data46.length;for(let i0=0; i0<len2; i0++){let data47 = data46[i0];if(data47 && typeof data47 == "object" && !Array.isArray(data47)){if(data47.id === undefined){const err101 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}if(data47.label === undefined){const err102 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}for(const key13 in data47){if(!((key13 === "id") || (key13 === "label"))){const err103 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}if(data47.id !== undefined){let data48 = data47.id;if(typeof data48 === "string"){if(!pattern5.test(data48)){const err104 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}else {const err105 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}if(data47.label !== undefined){let data49 = data47.label;if(typeof data49 === "string"){if(func3(data49) < 1){const err106 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}}else {const err107 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}}else {const err108 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}}else {const err109 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}if(data.states !== undefined){let data50 = data.states;if(Array.isArray(data50)){if(data50.length < 2){const err110 = {instancePath:instancePath+"/states",schemaPath:"#/properties/states/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}const len3 = data50.length;for(let i1=0; i1<len3; i1++){let data51 = data50[i1];if(data51 && typeof data51 == "object" && !Array.isArray(data51)){if(data51.id === undefined){const err111 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}if(data51.type === undefined){const err112 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}if(data51.label === undefined){const err113 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}if(data51.lane === undefined){const err114 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}if(data51.col === undefined){const err115 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "col"},message:"must have required property '"+"col"+"'"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}for(const key14 in data51){if(!(func1.call(schema124.properties.states.items.properties, key14))){const err116 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}}if(data51.id !== undefined){let data52 = data51.id;if(typeof data52 === "string"){if(!pattern5.test(data52)){const err117 = {instancePath:instancePath+"/states/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}}else {const err118 = {instancePath:instancePath+"/states/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}if(data51.type !== undefined){let data53 = data51.type;if(!((((((((data53 === "start") || (data53 === "active")) || (data53 === "waiting")) || (data53 === "decision")) || (data53 === "success")) || (data53 === "failure")) || (data53 === "neutral")) || (data53 === "external"))){const err119 = {instancePath:instancePath+"/states/" + i1+"/type",schemaPath:"#/properties/states/items/properties/type/enum",keyword:"enum",params:{allowedValues: schema124.properties.states.items.properties.type.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}if(data51.label !== undefined){let data54 = data51.label;if(typeof data54 === "string"){if(func3(data54) < 1){const err120 = {instancePath:instancePath+"/states/" + i1+"/label",schemaPath:"#/properties/states/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}else {const err121 = {instancePath:instancePath+"/states/" + i1+"/label",schemaPath:"#/properties/states/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}if(data51.sublabel !== undefined){if(typeof data51.sublabel !== "string"){const err122 = {instancePath:instancePath+"/states/" + i1+"/sublabel",schemaPath:"#/properties/states/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}if(data51.tag !== undefined){if(typeof data51.tag !== "string"){const err123 = {instancePath:instancePath+"/states/" + i1+"/tag",schemaPath:"#/properties/states/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}if(data51.brand !== undefined){let data57 = data51.brand;const _errs137 = errors;let valid37 = false;let passing0 = null;const _errs138 = errors;const _errs140 = errors;let valid38 = false;const _errs141 = errors;if(typeof data57 === "string"){if(func3(data57) > 80){const err124 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}if(!pattern18.test(data57)){const err125 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}}var _valid1 = _errs141 === errors;valid38 = valid38 || _valid1;const _errs142 = errors;if(typeof data57 === "string"){if(!pattern19.test(data57)){const err126 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}var _valid1 = _errs142 === errors;valid38 = valid38 || _valid1;if(!valid38){const err127 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}else {errors = _errs140;if(vErrors !== null){if(_errs140){vErrors.length = _errs140;}else {vErrors = null;}}}if(typeof data57 === "string"){if(func3(data57) > 2048){const err128 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}if(func3(data57) < 1){const err129 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}else {const err130 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}var _valid0 = _errs138 === errors;if(_valid0){valid37 = true;passing0 = 0;}const _errs143 = errors;if(data57 && typeof data57 == "object" && !Array.isArray(data57)){if(data57.url === undefined){const err131 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}if(data57.sha256 === undefined){const err132 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}for(const key15 in data57){if(!((key15 === "url") || (key15 === "sha256"))){const err133 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}if(data57.url !== undefined){let data58 = data57.url;if(typeof data58 === "string"){if(func3(data58) > 2048){const err134 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}if(func3(data58) < 8){const err135 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}if(!pattern19.test(data58)){const err136 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}else {const err137 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}if(data57.sha256 !== undefined){let data59 = data57.sha256;if(typeof data59 === "string"){if(!pattern21.test(data59)){const err138 = {instancePath:instancePath+"/states/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}else {const err139 = {instancePath:instancePath+"/states/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}}else {const err140 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}var _valid0 = _errs143 === errors;if(_valid0 && valid37){valid37 = false;passing0 = [passing0, 1];}else {if(_valid0){valid37 = true;passing0 = 1;}}if(!valid37){const err141 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}else {errors = _errs137;if(vErrors !== null){if(_errs137){vErrors.length = _errs137;}else {vErrors = null;}}}}if(data51.sources !== undefined){let data60 = data51.sources;if(Array.isArray(data60)){if(data60.length > 3){const err142 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}if(data60.length < 1){const err143 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}const len4 = data60.length;for(let i2=0; i2<len4; i2++){let data61 = data60[i2];if(data61 && typeof data61 == "object" && !Array.isArray(data61)){if(data61.path === undefined){const err144 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}for(const key16 in data61){if(!((((key16 === "path") || (key16 === "line")) || (key16 === "end_line")) || (key16 === "label"))){const err145 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}if(data61.path !== undefined){let data62 = data61.path;if(typeof data62 === "string"){if(func3(data62) > 240){const err146 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}if(func3(data62) < 1){const err147 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}else {const err148 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}if(data61.line !== undefined){let data63 = data61.line;if(!(((typeof data63 == "number") && (!(data63 % 1) && !isNaN(data63))) && (isFinite(data63)))){const err149 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}if((typeof data63 == "number") && (isFinite(data63))){if(data63 < 1 || isNaN(data63)){const err150 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}}if(data61.end_line !== undefined){let data64 = data61.end_line;if(!(((typeof data64 == "number") && (!(data64 % 1) && !isNaN(data64))) && (isFinite(data64)))){const err151 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if((typeof data64 == "number") && (isFinite(data64))){if(data64 < 1 || isNaN(data64)){const err152 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}if(data61.label !== undefined){let data65 = data61.label;if(typeof data65 === "string"){if(func3(data65) > 48){const err153 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}if(func3(data65) < 1){const err154 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}else {const err155 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}}else {const err156 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}}else {const err157 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}if(data51.step !== undefined){if(typeof data51.step !== "string"){const err158 = {instancePath:instancePath+"/states/" + i1+"/step",schemaPath:"#/properties/states/items/properties/step/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}if(data51.lane !== undefined){let data67 = data51.lane;if(typeof data67 === "string"){if(!pattern5.test(data67)){const err159 = {instancePath:instancePath+"/states/" + i1+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}else {const err160 = {instancePath:instancePath+"/states/" + i1+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}if(data51.col !== undefined){let data68 = data51.col;if(!(((typeof data68 == "number") && (!(data68 % 1) && !isNaN(data68))) && (isFinite(data68)))){const err161 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}if((typeof data68 == "number") && (isFinite(data68))){if(data68 > 4 || isNaN(data68)){const err162 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/maximum",keyword:"maximum",params:{comparison: "<=", limit: 4},message:"must be <= 4"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}if(data68 < 0 || isNaN(data68)){const err163 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}}}if(data51.width !== undefined){let data69 = data51.width;if((typeof data69 == "number") && (isFinite(data69))){if(data69 < 48 || isNaN(data69)){const err164 = {instancePath:instancePath+"/states/" + i1+"/width",schemaPath:"#/properties/states/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 48},message:"must be >= 48"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}else {const err165 = {instancePath:instancePath+"/states/" + i1+"/width",schemaPath:"#/properties/states/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data51.height !== undefined){let data70 = data51.height;if((typeof data70 == "number") && (isFinite(data70))){if(data70 < 36 || isNaN(data70)){const err166 = {instancePath:instancePath+"/states/" + i1+"/height",schemaPath:"#/properties/states/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 36},message:"must be >= 36"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}else {const err167 = {instancePath:instancePath+"/states/" + i1+"/height",schemaPath:"#/properties/states/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data51.yOffset !== undefined){let data71 = data51.yOffset;if(!((typeof data71 == "number") && (isFinite(data71)))){const err168 = {instancePath:instancePath+"/states/" + i1+"/yOffset",schemaPath:"#/properties/states/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}}}else {const err169 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}}else {const err170 = {instancePath:instancePath+"/states",schemaPath:"#/properties/states/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}if(data.transitions !== undefined){let data72 = data.transitions;if(Array.isArray(data72)){const len5 = data72.length;for(let i3=0; i3<len5; i3++){let data73 = data72[i3];if(data73 && typeof data73 == "object" && !Array.isArray(data73)){if(data73.from === undefined){const err171 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}if(data73.to === undefined){const err172 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}for(const key17 in data73){if(!(func1.call(schema124.properties.transitions.items.properties, key17))){const err173 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}if(data73.id !== undefined){let data74 = data73.id;if(typeof data74 === "string"){if(!pattern5.test(data74)){const err174 = {instancePath:instancePath+"/transitions/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}else {const err175 = {instancePath:instancePath+"/transitions/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}if(data73.from !== undefined){let data75 = data73.from;if(typeof data75 === "string"){if(!pattern5.test(data75)){const err176 = {instancePath:instancePath+"/transitions/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}else {const err177 = {instancePath:instancePath+"/transitions/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}if(data73.to !== undefined){let data76 = data73.to;if(typeof data76 === "string"){if(!pattern5.test(data76)){const err178 = {instancePath:instancePath+"/transitions/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}else {const err179 = {instancePath:instancePath+"/transitions/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}}if(data73.label !== undefined){if(typeof data73.label !== "string"){const err180 = {instancePath:instancePath+"/transitions/" + i3+"/label",schemaPath:"#/properties/transitions/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}if(data73.note !== undefined){if(typeof data73.note !== "string"){const err181 = {instancePath:instancePath+"/transitions/" + i3+"/note",schemaPath:"#/properties/transitions/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}if(data73.variant !== undefined){let data79 = data73.variant;if(!((((data79 === "default") || (data79 === "emphasis")) || (data79 === "security")) || (data79 === "dashed"))){const err182 = {instancePath:instancePath+"/transitions/" + i3+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema64.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}if(data73.route !== undefined){let data80 = data73.route;if(!(((((((data80 === "auto") || (data80 === "straight")) || (data80 === "drop")) || (data80 === "bottom-channel")) || (data80 === "top-channel")) || (data80 === "right-channel")) || (data80 === "left-channel"))){const err183 = {instancePath:instancePath+"/transitions/" + i3+"/route",schemaPath:"#/properties/transitions/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema124.properties.transitions.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}if(data73.fromSide !== undefined){let data81 = data73.fromSide;if(!((((data81 === "left") || (data81 === "right")) || (data81 === "top")) || (data81 === "bottom"))){const err184 = {instancePath:instancePath+"/transitions/" + i3+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data73.toSide !== undefined){let data82 = data73.toSide;if(!((((data82 === "left") || (data82 === "right")) || (data82 === "top")) || (data82 === "bottom"))){const err185 = {instancePath:instancePath+"/transitions/" + i3+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}}if(data73.channelX !== undefined){let data83 = data73.channelX;if(!((typeof data83 == "number") && (isFinite(data83)))){const err186 = {instancePath:instancePath+"/transitions/" + i3+"/channelX",schemaPath:"#/properties/transitions/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}}if(data73.channelY !== undefined){let data84 = data73.channelY;if(!((typeof data84 == "number") && (isFinite(data84)))){const err187 = {instancePath:instancePath+"/transitions/" + i3+"/channelY",schemaPath:"#/properties/transitions/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}if(data73.cornerRadius !== undefined){let data85 = data73.cornerRadius;if((typeof data85 == "number") && (isFinite(data85))){if(data85 < 0 || isNaN(data85)){const err188 = {instancePath:instancePath+"/transitions/" + i3+"/cornerRadius",schemaPath:"#/properties/transitions/items/properties/cornerRadius/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}else {const err189 = {instancePath:instancePath+"/transitions/" + i3+"/cornerRadius",schemaPath:"#/properties/transitions/items/properties/cornerRadius/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}if(data73.labelAt !== undefined){let data86 = data73.labelAt;if(Array.isArray(data86)){if(data86.length > 2){const err190 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}if(data86.length < 2){const err191 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}const len6 = data86.length;if(len6 > 0){let data87 = data86[0];if(!((typeof data87 == "number") && (isFinite(data87)))){const err192 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}if(len6 > 1){let data88 = data86[1];if(!((typeof data88 == "number") && (isFinite(data88)))){const err193 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}const len7 = data86.length;if(!(len7 <= 2)){const err194 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}else {const err195 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}if(data73.labelDx !== undefined){let data89 = data73.labelDx;if(!((typeof data89 == "number") && (isFinite(data89)))){const err196 = {instancePath:instancePath+"/transitions/" + i3+"/labelDx",schemaPath:"#/properties/transitions/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}}if(data73.labelDy !== undefined){let data90 = data73.labelDy;if(!((typeof data90 == "number") && (isFinite(data90)))){const err197 = {instancePath:instancePath+"/transitions/" + i3+"/labelDy",schemaPath:"#/properties/transitions/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}}if(data73.labelSegment !== undefined){let data91 = data73.labelSegment;if(!(((typeof data91 == "number") && (!(data91 % 1) && !isNaN(data91))) && (isFinite(data91)))){const err198 = {instancePath:instancePath+"/transitions/" + i3+"/labelSegment",schemaPath:"#/properties/transitions/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}if((typeof data91 == "number") && (isFinite(data91))){if(data91 < 0 || isNaN(data91)){const err199 = {instancePath:instancePath+"/transitions/" + i3+"/labelSegment",schemaPath:"#/properties/transitions/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}}if(data73.via !== undefined){let data92 = data73.via;if(Array.isArray(data92)){const len8 = data92.length;for(let i4=0; i4<len8; i4++){let data93 = data92[i4];if(Array.isArray(data93)){if(data93.length > 2){const err200 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}if(data93.length < 2){const err201 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}const len9 = data93.length;if(len9 > 0){let data94 = data93[0];if(!((typeof data94 == "number") && (isFinite(data94)))){const err202 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}}if(len9 > 1){let data95 = data93[1];if(!((typeof data95 == "number") && (isFinite(data95)))){const err203 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}}const len10 = data93.length;if(!(len10 <= 2)){const err204 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}}else {const err205 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}}else {const err206 = {instancePath:instancePath+"/transitions/" + i3+"/via",schemaPath:"#/properties/transitions/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}if(data73.width !== undefined){let data96 = data73.width;if((typeof data96 == "number") && (isFinite(data96))){if(data96 < 0.5 || isNaN(data96)){const err207 = {instancePath:instancePath+"/transitions/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}}else {const err208 = {instancePath:instancePath+"/transitions/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}}}else {const err209 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}}else {const err210 = {instancePath:instancePath+"/transitions",schemaPath:"#/properties/transitions/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}}if(data.cards !== undefined){let data97 = data.cards;if(Array.isArray(data97)){const len11 = data97.length;for(let i5=0; i5<len11; i5++){let data98 = data97[i5];if(data98 && typeof data98 == "object" && !Array.isArray(data98)){if(data98.dot === undefined){const err211 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}if(data98.title === undefined){const err212 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}if(data98.items === undefined){const err213 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}for(const key18 in data98){if(!(((key18 === "dot") || (key18 === "title")) || (key18 === "items"))){const err214 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}}if(data98.dot !== undefined){let data99 = data98.dot;if(!(((((((data99 === "cyan") || (data99 === "emerald")) || (data99 === "violet")) || (data99 === "amber")) || (data99 === "rose")) || (data99 === "orange")) || (data99 === "slate"))){const err215 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema69.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}}if(data98.title !== undefined){let data100 = data98.title;if(typeof data100 === "string"){if(func3(data100) < 1){const err216 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}else {const err217 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}}if(data98.items !== undefined){let data101 = data98.items;if(Array.isArray(data101)){const len12 = data101.length;for(let i6=0; i6<len12; i6++){if(typeof data101[i6] !== "string"){const err218 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}}}else {const err219 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}}else {const err220 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}}}else {const err221 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}}else {const err222 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}validate33.errors = vErrors;return errors === 0;}validate33.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};export const architecture = validate36;const schema157 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/architecture.schema.json","title":"Archify Architecture Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","components"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"architecture"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"type":"string"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"engineering_profile":{"enum":["deployment-ownership"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"frontend":{"$ref":"common.schema.json#/$defs/legendEntry"},"backend":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"},"cloud":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"messagebus":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":320},{"type":"number","minimum":240}],"items":false,"minItems":2,"maxItems":2}}},"layout":{"type":"object","additionalProperties":false,"required":["mode"],"properties":{"mode":{"enum":["grid"]},"origin":{"$ref":"common.schema.json#/$defs/point"},"cols":{"type":"integer","minimum":1,"maximum":12},"gapX":{"type":"number","minimum":0},"gapY":{"type":"number","minimum":0},"cellW":{"type":"number","minimum":40},"cellH":{"type":"number","minimum":24}}},"components":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"row":{"type":"integer","minimum":0},"col":{"type":"integer","minimum":0},"pos":{"$ref":"common.schema.json#/$defs/point"},"size":{"type":"array","prefixItems":[{"type":"number","exclusiveMinimum":0},{"type":"number","exclusiveMinimum":0}],"items":false,"minItems":2,"maxItems":2}}}},"boundaries":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","label","wraps"],"properties":{"kind":{"enum":["region","security-group"]},"label":{"type":"string","minLength":1},"wraps":{"type":"array","minItems":1,"items":{"$ref":"common.schema.json#/$defs/id"}},"pad":{"type":"number","minimum":0}}}},"connections":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"route":{"enum":["auto","straight","orthogonal-h","orthogonal-v"]},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};function validate37(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate37.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern5.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern5.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate37.errors = vErrors;return errors === 0;}validate37.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate36(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/architecture.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate36.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.components === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "components"},message:"must have required property '"+"components"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "layout")) || (key0 === "components")) || (key0 === "boundaries")) || (key0 === "connections")) || (key0 === "cards"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err5 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.diagram_type !== undefined){if("architecture" !== data.diagram_type){const err6 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "architecture"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err7 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key1 in data2){if(!(func1.call(schema157.properties.meta.properties, key1))){const err8 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err9 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err11 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err12 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.output !== undefined){if(typeof data2.output !== "string"){const err13 = {instancePath:instancePath+"/meta/output",schemaPath:"#/properties/meta/properties/output/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err14 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema72.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err15 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema73.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err16 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}if(data2.engineering_profile !== undefined){if(!(data2.engineering_profile === "deployment-ownership")){const err17 = {instancePath:instancePath+"/meta/engineering_profile",schemaPath:"#/properties/meta/properties/engineering_profile/enum",keyword:"enum",params:{allowedValues: schema157.properties.meta.properties.engineering_profile.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}if(data2.repository !== undefined){let data11 = data2.repository;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.url === undefined){const err18 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}if(data11.revision === undefined){const err19 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}for(const key2 in data11){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err20 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}if(data11.url !== undefined){let data12 = data11.url;if(typeof data12 === "string"){if(func3(data12) < 1){const err21 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}else {const err22 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}if(data11.provider !== undefined){let data13 = data11.provider;if(!((data13 === "github") || (data13 === "gitee"))){const err23 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema34.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}if(data11.link_mode !== undefined){let data14 = data11.link_mode;if(!((data14 === "web") || (data14 === "local-only"))){const err24 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema34.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}if(data11.revision !== undefined){let data15 = data11.revision;if(typeof data15 === "string"){if(!pattern4.test(data15)){const err25 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}else {const err26 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}}else {const err27 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}if(data2.views !== undefined){if(!(validate37(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate37.errors : vErrors.concat(validate37.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data17 = data2.legend;if(data17 && typeof data17 == "object" && !Array.isArray(data17)){for(const key3 in data17){if(!((key3 === "mode") || (key3 === "entries"))){const err28 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}if(data17.mode !== undefined){let data18 = data17.mode;if(!(((data18 === "auto") || (data18 === "all")) || (data18 === "hidden"))){const err29 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema38.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}if(data17.entries !== undefined){let data19 = data17.entries;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){for(const key4 in data19){if(!(((((((key4 === "frontend") || (key4 === "backend")) || (key4 === "database")) || (key4 === "cloud")) || (key4 === "security")) || (key4 === "messagebus")) || (key4 === "external"))){const err30 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data19.frontend !== undefined){let data20 = data19.frontend;if(data20 && typeof data20 == "object" && !Array.isArray(data20)){if(Object.keys(data20).length < 1){const err31 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}for(const key5 in data20){if(!((key5 === "label") || (key5 === "visible"))){const err32 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data20.label !== undefined){let data21 = data20.label;if(typeof data21 === "string"){if(func3(data21) > 80){const err33 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}if(func3(data21) < 1){const err34 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}else {const err35 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data20.visible !== undefined){if(typeof data20.visible !== "boolean"){const err36 = {instancePath:instancePath+"/meta/legend/entries/frontend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}}}else {const err37 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}if(data19.backend !== undefined){let data23 = data19.backend;if(data23 && typeof data23 == "object" && !Array.isArray(data23)){if(Object.keys(data23).length < 1){const err38 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}for(const key6 in data23){if(!((key6 === "label") || (key6 === "visible"))){const err39 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}if(data23.label !== undefined){let data24 = data23.label;if(typeof data24 === "string"){if(func3(data24) > 80){const err40 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}if(func3(data24) < 1){const err41 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}else {const err42 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data23.visible !== undefined){if(typeof data23.visible !== "boolean"){const err43 = {instancePath:instancePath+"/meta/legend/entries/backend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}}else {const err44 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}if(data19.database !== undefined){let data26 = data19.database;if(data26 && typeof data26 == "object" && !Array.isArray(data26)){if(Object.keys(data26).length < 1){const err45 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}for(const key7 in data26){if(!((key7 === "label") || (key7 === "visible"))){const err46 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data26.label !== undefined){let data27 = data26.label;if(typeof data27 === "string"){if(func3(data27) > 80){const err47 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}if(func3(data27) < 1){const err48 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}else {const err49 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}if(data26.visible !== undefined){if(typeof data26.visible !== "boolean"){const err50 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}}else {const err51 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}if(data19.cloud !== undefined){let data29 = data19.cloud;if(data29 && typeof data29 == "object" && !Array.isArray(data29)){if(Object.keys(data29).length < 1){const err52 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}for(const key8 in data29){if(!((key8 === "label") || (key8 === "visible"))){const err53 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data29.label !== undefined){let data30 = data29.label;if(typeof data30 === "string"){if(func3(data30) > 80){const err54 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}if(func3(data30) < 1){const err55 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}}else {const err56 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}if(data29.visible !== undefined){if(typeof data29.visible !== "boolean"){const err57 = {instancePath:instancePath+"/meta/legend/entries/cloud/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}}else {const err58 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}if(data19.security !== undefined){let data32 = data19.security;if(data32 && typeof data32 == "object" && !Array.isArray(data32)){if(Object.keys(data32).length < 1){const err59 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}for(const key9 in data32){if(!((key9 === "label") || (key9 === "visible"))){const err60 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}if(data32.label !== undefined){let data33 = data32.label;if(typeof data33 === "string"){if(func3(data33) > 80){const err61 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}if(func3(data33) < 1){const err62 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}}else {const err63 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}if(data32.visible !== undefined){if(typeof data32.visible !== "boolean"){const err64 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}}else {const err65 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}if(data19.messagebus !== undefined){let data35 = data19.messagebus;if(data35 && typeof data35 == "object" && !Array.isArray(data35)){if(Object.keys(data35).length < 1){const err66 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}for(const key10 in data35){if(!((key10 === "label") || (key10 === "visible"))){const err67 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data35.label !== undefined){let data36 = data35.label;if(typeof data36 === "string"){if(func3(data36) > 80){const err68 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}if(func3(data36) < 1){const err69 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}}else {const err70 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}}if(data35.visible !== undefined){if(typeof data35.visible !== "boolean"){const err71 = {instancePath:instancePath+"/meta/legend/entries/messagebus/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}}else {const err72 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}if(data19.external !== undefined){let data38 = data19.external;if(data38 && typeof data38 == "object" && !Array.isArray(data38)){if(Object.keys(data38).length < 1){const err73 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}for(const key11 in data38){if(!((key11 === "label") || (key11 === "visible"))){const err74 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}if(data38.label !== undefined){let data39 = data38.label;if(typeof data39 === "string"){if(func3(data39) > 80){const err75 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}if(func3(data39) < 1){const err76 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}else {const err77 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}if(data38.visible !== undefined){if(typeof data38.visible !== "boolean"){const err78 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}}else {const err79 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}}}else {const err80 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}}else {const err81 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data2.viewBox !== undefined){let data41 = data2.viewBox;if(Array.isArray(data41)){if(data41.length > 2){const err82 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}if(data41.length < 2){const err83 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}const len0 = data41.length;if(len0 > 0){let data42 = data41[0];if((typeof data42 == "number") && (isFinite(data42))){if(data42 < 320 || isNaN(data42)){const err84 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 320},message:"must be >= 320"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}else {const err85 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(len0 > 1){let data43 = data41[1];if((typeof data43 == "number") && (isFinite(data43))){if(data43 < 240 || isNaN(data43)){const err86 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 240},message:"must be >= 240"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}}else {const err87 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}const len1 = data41.length;if(!(len1 <= 2)){const err88 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}else {const err89 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}}else {const err90 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}if(data.layout !== undefined){let data44 = data.layout;if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.mode === undefined){const err91 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}for(const key12 in data44){if(!(((((((key12 === "mode") || (key12 === "origin")) || (key12 === "cols")) || (key12 === "gapX")) || (key12 === "gapY")) || (key12 === "cellW")) || (key12 === "cellH"))){const err92 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}if(data44.mode !== undefined){if(!(data44.mode === "grid")){const err93 = {instancePath:instancePath+"/layout/mode",schemaPath:"#/properties/layout/properties/mode/enum",keyword:"enum",params:{allowedValues: schema157.properties.layout.properties.mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}if(data44.origin !== undefined){let data46 = data44.origin;if(Array.isArray(data46)){if(data46.length > 2){const err94 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}if(data46.length < 2){const err95 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}const len2 = data46.length;if(len2 > 0){let data47 = data46[0];if(!((typeof data47 == "number") && (isFinite(data47)))){const err96 = {instancePath:instancePath+"/layout/origin/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}if(len2 > 1){let data48 = data46[1];if(!((typeof data48 == "number") && (isFinite(data48)))){const err97 = {instancePath:instancePath+"/layout/origin/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}const len3 = data46.length;if(!(len3 <= 2)){const err98 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}else {const err99 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data44.cols !== undefined){let data49 = data44.cols;if(!(((typeof data49 == "number") && (!(data49 % 1) && !isNaN(data49))) && (isFinite(data49)))){const err100 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}if((typeof data49 == "number") && (isFinite(data49))){if(data49 > 12 || isNaN(data49)){const err101 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/maximum",keyword:"maximum",params:{comparison: "<=", limit: 12},message:"must be <= 12"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}if(data49 < 1 || isNaN(data49)){const err102 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}}if(data44.gapX !== undefined){let data50 = data44.gapX;if((typeof data50 == "number") && (isFinite(data50))){if(data50 < 0 || isNaN(data50)){const err103 = {instancePath:instancePath+"/layout/gapX",schemaPath:"#/properties/layout/properties/gapX/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}else {const err104 = {instancePath:instancePath+"/layout/gapX",schemaPath:"#/properties/layout/properties/gapX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}if(data44.gapY !== undefined){let data51 = data44.gapY;if((typeof data51 == "number") && (isFinite(data51))){if(data51 < 0 || isNaN(data51)){const err105 = {instancePath:instancePath+"/layout/gapY",schemaPath:"#/properties/layout/properties/gapY/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}else {const err106 = {instancePath:instancePath+"/layout/gapY",schemaPath:"#/properties/layout/properties/gapY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}}if(data44.cellW !== undefined){let data52 = data44.cellW;if((typeof data52 == "number") && (isFinite(data52))){if(data52 < 40 || isNaN(data52)){const err107 = {instancePath:instancePath+"/layout/cellW",schemaPath:"#/properties/layout/properties/cellW/minimum",keyword:"minimum",params:{comparison: ">=", limit: 40},message:"must be >= 40"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}else {const err108 = {instancePath:instancePath+"/layout/cellW",schemaPath:"#/properties/layout/properties/cellW/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}if(data44.cellH !== undefined){let data53 = data44.cellH;if((typeof data53 == "number") && (isFinite(data53))){if(data53 < 24 || isNaN(data53)){const err109 = {instancePath:instancePath+"/layout/cellH",schemaPath:"#/properties/layout/properties/cellH/minimum",keyword:"minimum",params:{comparison: ">=", limit: 24},message:"must be >= 24"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}else {const err110 = {instancePath:instancePath+"/layout/cellH",schemaPath:"#/properties/layout/properties/cellH/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}}else {const err111 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}if(data.components !== undefined){let data54 = data.components;if(Array.isArray(data54)){if(data54.length < 1){const err112 = {instancePath:instancePath+"/components",schemaPath:"#/properties/components/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}const len4 = data54.length;for(let i0=0; i0<len4; i0++){let data55 = data54[i0];if(data55 && typeof data55 == "object" && !Array.isArray(data55)){if(data55.id === undefined){const err113 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}if(data55.type === undefined){const err114 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}if(data55.label === undefined){const err115 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}for(const key13 in data55){if(!(func1.call(schema157.properties.components.items.properties, key13))){const err116 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}}if(data55.id !== undefined){let data56 = data55.id;if(typeof data56 === "string"){if(!pattern5.test(data56)){const err117 = {instancePath:instancePath+"/components/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}}else {const err118 = {instancePath:instancePath+"/components/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}if(data55.type !== undefined){let data57 = data55.type;if(!(((((((data57 === "frontend") || (data57 === "backend")) || (data57 === "database")) || (data57 === "cloud")) || (data57 === "security")) || (data57 === "messagebus")) || (data57 === "external"))){const err119 = {instancePath:instancePath+"/components/" + i0+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema58.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}if(data55.label !== undefined){let data58 = data55.label;if(typeof data58 === "string"){if(func3(data58) < 1){const err120 = {instancePath:instancePath+"/components/" + i0+"/label",schemaPath:"#/properties/components/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}else {const err121 = {instancePath:instancePath+"/components/" + i0+"/label",schemaPath:"#/properties/components/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}if(data55.sublabel !== undefined){if(typeof data55.sublabel !== "string"){const err122 = {instancePath:instancePath+"/components/" + i0+"/sublabel",schemaPath:"#/properties/components/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}if(data55.tag !== undefined){if(typeof data55.tag !== "string"){const err123 = {instancePath:instancePath+"/components/" + i0+"/tag",schemaPath:"#/properties/components/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}if(data55.brand !== undefined){let data61 = data55.brand;const _errs142 = errors;let valid35 = false;let passing0 = null;const _errs143 = errors;const _errs145 = errors;let valid36 = false;const _errs146 = errors;if(typeof data61 === "string"){if(func3(data61) > 80){const err124 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}if(!pattern18.test(data61)){const err125 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}}var _valid1 = _errs146 === errors;valid36 = valid36 || _valid1;const _errs147 = errors;if(typeof data61 === "string"){if(!pattern19.test(data61)){const err126 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}var _valid1 = _errs147 === errors;valid36 = valid36 || _valid1;if(!valid36){const err127 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}else {errors = _errs145;if(vErrors !== null){if(_errs145){vErrors.length = _errs145;}else {vErrors = null;}}}if(typeof data61 === "string"){if(func3(data61) > 2048){const err128 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}if(func3(data61) < 1){const err129 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}else {const err130 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}var _valid0 = _errs143 === errors;if(_valid0){valid35 = true;passing0 = 0;}const _errs148 = errors;if(data61 && typeof data61 == "object" && !Array.isArray(data61)){if(data61.url === undefined){const err131 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}if(data61.sha256 === undefined){const err132 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}for(const key14 in data61){if(!((key14 === "url") || (key14 === "sha256"))){const err133 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}if(data61.url !== undefined){let data62 = data61.url;if(typeof data62 === "string"){if(func3(data62) > 2048){const err134 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}if(func3(data62) < 8){const err135 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}if(!pattern19.test(data62)){const err136 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}else {const err137 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}if(data61.sha256 !== undefined){let data63 = data61.sha256;if(typeof data63 === "string"){if(!pattern21.test(data63)){const err138 = {instancePath:instancePath+"/components/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}else {const err139 = {instancePath:instancePath+"/components/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}}else {const err140 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}var _valid0 = _errs148 === errors;if(_valid0 && valid35){valid35 = false;passing0 = [passing0, 1];}else {if(_valid0){valid35 = true;passing0 = 1;}}if(!valid35){const err141 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}else {errors = _errs142;if(vErrors !== null){if(_errs142){vErrors.length = _errs142;}else {vErrors = null;}}}}if(data55.sources !== undefined){let data64 = data55.sources;if(Array.isArray(data64)){if(data64.length > 3){const err142 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}if(data64.length < 1){const err143 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}const len5 = data64.length;for(let i1=0; i1<len5; i1++){let data65 = data64[i1];if(data65 && typeof data65 == "object" && !Array.isArray(data65)){if(data65.path === undefined){const err144 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}for(const key15 in data65){if(!((((key15 === "path") || (key15 === "line")) || (key15 === "end_line")) || (key15 === "label"))){const err145 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}if(data65.path !== undefined){let data66 = data65.path;if(typeof data66 === "string"){if(func3(data66) > 240){const err146 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}if(func3(data66) < 1){const err147 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}else {const err148 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}if(data65.line !== undefined){let data67 = data65.line;if(!(((typeof data67 == "number") && (!(data67 % 1) && !isNaN(data67))) && (isFinite(data67)))){const err149 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}if((typeof data67 == "number") && (isFinite(data67))){if(data67 < 1 || isNaN(data67)){const err150 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}}if(data65.end_line !== undefined){let data68 = data65.end_line;if(!(((typeof data68 == "number") && (!(data68 % 1) && !isNaN(data68))) && (isFinite(data68)))){const err151 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if((typeof data68 == "number") && (isFinite(data68))){if(data68 < 1 || isNaN(data68)){const err152 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}if(data65.label !== undefined){let data69 = data65.label;if(typeof data69 === "string"){if(func3(data69) > 48){const err153 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}if(func3(data69) < 1){const err154 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}else {const err155 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}}else {const err156 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}}else {const err157 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}if(data55.row !== undefined){let data70 = data55.row;if(!(((typeof data70 == "number") && (!(data70 % 1) && !isNaN(data70))) && (isFinite(data70)))){const err158 = {instancePath:instancePath+"/components/" + i0+"/row",schemaPath:"#/properties/components/items/properties/row/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}if((typeof data70 == "number") && (isFinite(data70))){if(data70 < 0 || isNaN(data70)){const err159 = {instancePath:instancePath+"/components/" + i0+"/row",schemaPath:"#/properties/components/items/properties/row/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}}if(data55.col !== undefined){let data71 = data55.col;if(!(((typeof data71 == "number") && (!(data71 % 1) && !isNaN(data71))) && (isFinite(data71)))){const err160 = {instancePath:instancePath+"/components/" + i0+"/col",schemaPath:"#/properties/components/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}if((typeof data71 == "number") && (isFinite(data71))){if(data71 < 0 || isNaN(data71)){const err161 = {instancePath:instancePath+"/components/" + i0+"/col",schemaPath:"#/properties/components/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}}if(data55.pos !== undefined){let data72 = data55.pos;if(Array.isArray(data72)){if(data72.length > 2){const err162 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}if(data72.length < 2){const err163 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}const len6 = data72.length;if(len6 > 0){let data73 = data72[0];if(!((typeof data73 == "number") && (isFinite(data73)))){const err164 = {instancePath:instancePath+"/components/" + i0+"/pos/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}if(len6 > 1){let data74 = data72[1];if(!((typeof data74 == "number") && (isFinite(data74)))){const err165 = {instancePath:instancePath+"/components/" + i0+"/pos/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}const len7 = data72.length;if(!(len7 <= 2)){const err166 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}else {const err167 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data55.size !== undefined){let data75 = data55.size;if(Array.isArray(data75)){if(data75.length > 2){const err168 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}if(data75.length < 2){const err169 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}const len8 = data75.length;if(len8 > 0){let data76 = data75[0];if((typeof data76 == "number") && (isFinite(data76))){if(data76 <= 0 || isNaN(data76)){const err170 = {instancePath:instancePath+"/components/" + i0+"/size/0",schemaPath:"#/properties/components/items/properties/size/prefixItems/0/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison: ">", limit: 0},message:"must be > 0"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}else {const err171 = {instancePath:instancePath+"/components/" + i0+"/size/0",schemaPath:"#/properties/components/items/properties/size/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(len8 > 1){let data77 = data75[1];if((typeof data77 == "number") && (isFinite(data77))){if(data77 <= 0 || isNaN(data77)){const err172 = {instancePath:instancePath+"/components/" + i0+"/size/1",schemaPath:"#/properties/components/items/properties/size/prefixItems/1/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison: ">", limit: 0},message:"must be > 0"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}else {const err173 = {instancePath:instancePath+"/components/" + i0+"/size/1",schemaPath:"#/properties/components/items/properties/size/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}const len9 = data75.length;if(!(len9 <= 2)){const err174 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}else {const err175 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}}else {const err176 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}}else {const err177 = {instancePath:instancePath+"/components",schemaPath:"#/properties/components/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}if(data.boundaries !== undefined){let data78 = data.boundaries;if(Array.isArray(data78)){const len10 = data78.length;for(let i2=0; i2<len10; i2++){let data79 = data78[i2];if(data79 && typeof data79 == "object" && !Array.isArray(data79)){if(data79.kind === undefined){const err178 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}if(data79.label === undefined){const err179 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}if(data79.wraps === undefined){const err180 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "wraps"},message:"must have required property '"+"wraps"+"'"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}for(const key16 in data79){if(!((((key16 === "kind") || (key16 === "label")) || (key16 === "wraps")) || (key16 === "pad"))){const err181 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}if(data79.kind !== undefined){let data80 = data79.kind;if(!((data80 === "region") || (data80 === "security-group"))){const err182 = {instancePath:instancePath+"/boundaries/" + i2+"/kind",schemaPath:"#/properties/boundaries/items/properties/kind/enum",keyword:"enum",params:{allowedValues: schema157.properties.boundaries.items.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}if(data79.label !== undefined){let data81 = data79.label;if(typeof data81 === "string"){if(func3(data81) < 1){const err183 = {instancePath:instancePath+"/boundaries/" + i2+"/label",schemaPath:"#/properties/boundaries/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}else {const err184 = {instancePath:instancePath+"/boundaries/" + i2+"/label",schemaPath:"#/properties/boundaries/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data79.wraps !== undefined){let data82 = data79.wraps;if(Array.isArray(data82)){if(data82.length < 1){const err185 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps",schemaPath:"#/properties/boundaries/items/properties/wraps/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}const len11 = data82.length;for(let i3=0; i3<len11; i3++){let data83 = data82[i3];if(typeof data83 === "string"){if(!pattern5.test(data83)){const err186 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps/" + i3,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}}else {const err187 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps/" + i3,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}}else {const err188 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps",schemaPath:"#/properties/boundaries/items/properties/wraps/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}if(data79.pad !== undefined){let data84 = data79.pad;if((typeof data84 == "number") && (isFinite(data84))){if(data84 < 0 || isNaN(data84)){const err189 = {instancePath:instancePath+"/boundaries/" + i2+"/pad",schemaPath:"#/properties/boundaries/items/properties/pad/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}else {const err190 = {instancePath:instancePath+"/boundaries/" + i2+"/pad",schemaPath:"#/properties/boundaries/items/properties/pad/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}}else {const err191 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}}else {const err192 = {instancePath:instancePath+"/boundaries",schemaPath:"#/properties/boundaries/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}if(data.connections !== undefined){let data85 = data.connections;if(Array.isArray(data85)){const len12 = data85.length;for(let i4=0; i4<len12; i4++){let data86 = data85[i4];if(data86 && typeof data86 == "object" && !Array.isArray(data86)){if(data86.from === undefined){const err193 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}if(data86.to === undefined){const err194 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}for(const key17 in data86){if(!(func1.call(schema157.properties.connections.items.properties, key17))){const err195 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}if(data86.id !== undefined){let data87 = data86.id;if(typeof data87 === "string"){if(!pattern5.test(data87)){const err196 = {instancePath:instancePath+"/connections/" + i4+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}}else {const err197 = {instancePath:instancePath+"/connections/" + i4+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}}if(data86.from !== undefined){let data88 = data86.from;if(typeof data88 === "string"){if(!pattern5.test(data88)){const err198 = {instancePath:instancePath+"/connections/" + i4+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}}else {const err199 = {instancePath:instancePath+"/connections/" + i4+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}if(data86.to !== undefined){let data89 = data86.to;if(typeof data89 === "string"){if(!pattern5.test(data89)){const err200 = {instancePath:instancePath+"/connections/" + i4+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}}else {const err201 = {instancePath:instancePath+"/connections/" + i4+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}}if(data86.label !== undefined){if(typeof data86.label !== "string"){const err202 = {instancePath:instancePath+"/connections/" + i4+"/label",schemaPath:"#/properties/connections/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}}if(data86.variant !== undefined){let data91 = data86.variant;if(!((((data91 === "default") || (data91 === "emphasis")) || (data91 === "security")) || (data91 === "dashed"))){const err203 = {instancePath:instancePath+"/connections/" + i4+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema64.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}}if(data86.fromSide !== undefined){let data92 = data86.fromSide;if(!((((data92 === "left") || (data92 === "right")) || (data92 === "top")) || (data92 === "bottom"))){const err204 = {instancePath:instancePath+"/connections/" + i4+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}}if(data86.toSide !== undefined){let data93 = data86.toSide;if(!((((data93 === "left") || (data93 === "right")) || (data93 === "top")) || (data93 === "bottom"))){const err205 = {instancePath:instancePath+"/connections/" + i4+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema118.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}if(data86.route !== undefined){let data94 = data86.route;if(!((((data94 === "auto") || (data94 === "straight")) || (data94 === "orthogonal-h")) || (data94 === "orthogonal-v"))){const err206 = {instancePath:instancePath+"/connections/" + i4+"/route",schemaPath:"#/properties/connections/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema157.properties.connections.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}if(data86.via !== undefined){let data95 = data86.via;if(Array.isArray(data95)){const len13 = data95.length;for(let i5=0; i5<len13; i5++){let data96 = data95[i5];if(Array.isArray(data96)){if(data96.length > 2){const err207 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}if(data96.length < 2){const err208 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}const len14 = data96.length;if(len14 > 0){let data97 = data96[0];if(!((typeof data97 == "number") && (isFinite(data97)))){const err209 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}if(len14 > 1){let data98 = data96[1];if(!((typeof data98 == "number") && (isFinite(data98)))){const err210 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}}const len15 = data96.length;if(!(len15 <= 2)){const err211 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}}else {const err212 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}}}else {const err213 = {instancePath:instancePath+"/connections/" + i4+"/via",schemaPath:"#/properties/connections/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}}if(data86.labelAt !== undefined){let data99 = data86.labelAt;if(Array.isArray(data99)){if(data99.length > 2){const err214 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}if(data99.length < 2){const err215 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}const len16 = data99.length;if(len16 > 0){let data100 = data99[0];if(!((typeof data100 == "number") && (isFinite(data100)))){const err216 = {instancePath:instancePath+"/connections/" + i4+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}if(len16 > 1){let data101 = data99[1];if(!((typeof data101 == "number") && (isFinite(data101)))){const err217 = {instancePath:instancePath+"/connections/" + i4+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}}const len17 = data99.length;if(!(len17 <= 2)){const err218 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}}else {const err219 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}if(data86.labelDx !== undefined){let data102 = data86.labelDx;if(!((typeof data102 == "number") && (isFinite(data102)))){const err220 = {instancePath:instancePath+"/connections/" + i4+"/labelDx",schemaPath:"#/properties/connections/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}}if(data86.labelDy !== undefined){let data103 = data86.labelDy;if(!((typeof data103 == "number") && (isFinite(data103)))){const err221 = {instancePath:instancePath+"/connections/" + i4+"/labelDy",schemaPath:"#/properties/connections/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}if(data86.labelSegment !== undefined){let data104 = data86.labelSegment;if(!(((typeof data104 == "number") && (!(data104 % 1) && !isNaN(data104))) && (isFinite(data104)))){const err222 = {instancePath:instancePath+"/connections/" + i4+"/labelSegment",schemaPath:"#/properties/connections/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}if((typeof data104 == "number") && (isFinite(data104))){if(data104 < 0 || isNaN(data104)){const err223 = {instancePath:instancePath+"/connections/" + i4+"/labelSegment",schemaPath:"#/properties/connections/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err223];}else {vErrors.push(err223);}errors++;}}}if(data86.width !== undefined){let data105 = data86.width;if((typeof data105 == "number") && (isFinite(data105))){if(data105 < 0.5 || isNaN(data105)){const err224 = {instancePath:instancePath+"/connections/" + i4+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err224];}else {vErrors.push(err224);}errors++;}}else {const err225 = {instancePath:instancePath+"/connections/" + i4+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err225];}else {vErrors.push(err225);}errors++;}}}else {const err226 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err226];}else {vErrors.push(err226);}errors++;}}}else {const err227 = {instancePath:instancePath+"/connections",schemaPath:"#/properties/connections/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err227];}else {vErrors.push(err227);}errors++;}}if(data.cards !== undefined){let data106 = data.cards;if(Array.isArray(data106)){const len18 = data106.length;for(let i6=0; i6<len18; i6++){let data107 = data106[i6];if(data107 && typeof data107 == "object" && !Array.isArray(data107)){if(data107.dot === undefined){const err228 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err228];}else {vErrors.push(err228);}errors++;}if(data107.title === undefined){const err229 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err229];}else {vErrors.push(err229);}errors++;}if(data107.items === undefined){const err230 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err230];}else {vErrors.push(err230);}errors++;}for(const key18 in data107){if(!(((key18 === "dot") || (key18 === "title")) || (key18 === "items"))){const err231 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err231];}else {vErrors.push(err231);}errors++;}}if(data107.dot !== undefined){let data108 = data107.dot;if(!(((((((data108 === "cyan") || (data108 === "emerald")) || (data108 === "violet")) || (data108 === "amber")) || (data108 === "rose")) || (data108 === "orange")) || (data108 === "slate"))){const err232 = {instancePath:instancePath+"/cards/" + i6+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema69.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err232];}else {vErrors.push(err232);}errors++;}}if(data107.title !== undefined){let data109 = data107.title;if(typeof data109 === "string"){if(func3(data109) < 1){const err233 = {instancePath:instancePath+"/cards/" + i6+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err233];}else {vErrors.push(err233);}errors++;}}else {const err234 = {instancePath:instancePath+"/cards/" + i6+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err234];}else {vErrors.push(err234);}errors++;}}if(data107.items !== undefined){let data110 = data107.items;if(Array.isArray(data110)){const len19 = data110.length;for(let i7=0; i7<len19; i7++){if(typeof data110[i7] !== "string"){const err235 = {instancePath:instancePath+"/cards/" + i6+"/items/" + i7,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err235];}else {vErrors.push(err235);}errors++;}}}else {const err236 = {instancePath:instancePath+"/cards/" + i6+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err236];}else {vErrors.push(err236);}errors++;}}}else {const err237 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err237];}else {vErrors.push(err237);}errors++;}}}else {const err238 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err238];}else {vErrors.push(err238);}errors++;}}}else {const err239 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err239];}else {vErrors.push(err239);}errors++;}validate36.errors = vErrors;return errors === 0;}validate36.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};+};const pattern4 = new RegExp("(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$", "u");const pattern5 = new RegExp("[\\\\<>:\"|?*\\u0000-\\u001F\\u007F-\\u009F]", "u");const pattern6 = new RegExp("[\\uD800-\\uDFFF]", "u");const pattern7 = new RegExp("(^|/)[.]{1,2}(/|$)", "u");const pattern8 = new RegExp("[. ](/|$)", "u");const pattern9 = new RegExp("(^|/)[^/]{256}", "u");const pattern10 = new RegExp("(^|/)(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Nn][Ii][Nn][$]|[Cc][Oo][Nn][Oo][Uu][Tt][$]|[Cc][Oo][Mm][1-9¹²³]|[Ll][Pp][Tt][1-9¹²³])(?:[.]|/|$)", "u");const pattern11 = new RegExp("(^|/)[^/]*~[1-9][0-9]*(?:[.]|/|$)", "u");const pattern12 = new RegExp("^[^/]+(?:/[^/]+)*$", "u");const pattern13 = new RegExp("^[a-fA-F0-9]{40}$", "u");const pattern14 = new RegExp("^[a-zA-Z][a-zA-Z0-9_-]*$", "u");const pattern27 = new RegExp("^[^\\r\\n]+$", "u");const pattern28 = new RegExp("^https?://", "u");const pattern30 = new RegExp("^[a-f0-9]{64}$", "u");const schema36 = {"type":"array","maxItems":5,"items":{"type":"object","additionalProperties":false,"required":["id","label","focus"],"properties":{"id":{"$ref":"#/$defs/id"},"label":{"type":"string","minLength":1,"maxLength":48},"focus":{"type":"array","minItems":1,"items":{"$ref":"#/$defs/id"}},"note":{"type":"string","maxLength":140}}}};function validate22(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate22.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern14.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate22.errors = vErrors;return errors === 0;}validate22.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};const schema54 = {"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"}}};function validate24(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate24.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.from === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.to === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}for(const key0 in data){if(!((key0 === "from") || (key0 === "to"))){const err2 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}if(data.from !== undefined){let data0 = data.from;if(typeof data0 === "string"){if(!pattern14.test(data0)){const err3 = {instancePath:instancePath+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}}else {const err4 = {instancePath:instancePath+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.to !== undefined){let data1 = data.to;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}}else {const err7 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}validate24.errors = vErrors;return errors === 0;}validate24.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/workflow.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.lanes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lanes"},message:"must have required property '"+"lanes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.nodes === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "nodes"},message:"must have required property '"+"nodes"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.edges === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "edges"},message:"must have required property '"+"edges"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(func1.call(schema31.properties, key0))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){let data0 = data.schema_version;if(!((data0 === 1) || (data0 === 2))){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/enum",keyword:"enum",params:{allowedValues: schema31.properties.schema_version.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("workflow" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "workflow"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema31.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){let data6 = data2.output;if(typeof data6 === "string"){if(!pattern4.test(data6)){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/0/pattern",keyword:"pattern",params:{pattern: "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},message:"must match pattern \""+"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"+"\""};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}const _errs18 = errors;const _errs19 = errors;if(typeof data6 === "string"){if(!pattern5.test(data6)){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}var valid5 = _errs19 === errors;if(valid5){const err17 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}else {errors = _errs18;if(vErrors !== null){if(_errs18){vErrors.length = _errs18;}else {vErrors = null;}}}const _errs21 = errors;const _errs22 = errors;if(typeof data6 === "string"){if(!pattern6.test(data6)){const err18 = {};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}var valid6 = _errs22 === errors;if(valid6){const err19 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}}const _errs24 = errors;const _errs25 = errors;if(typeof data6 === "string"){if(!pattern7.test(data6)){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}var valid7 = _errs25 === errors;if(valid7){const err21 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}else {errors = _errs24;if(vErrors !== null){if(_errs24){vErrors.length = _errs24;}else {vErrors = null;}}}const _errs27 = errors;const _errs28 = errors;if(typeof data6 === "string"){if(!pattern8.test(data6)){const err22 = {};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}var valid8 = _errs28 === errors;if(valid8){const err23 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/4/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}}const _errs30 = errors;const _errs31 = errors;if(typeof data6 === "string"){if(!pattern9.test(data6)){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}var valid9 = _errs31 === errors;if(valid9){const err25 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/5/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}else {errors = _errs30;if(vErrors !== null){if(_errs30){vErrors.length = _errs30;}else {vErrors = null;}}}const _errs33 = errors;const _errs34 = errors;if(typeof data6 === "string"){if(!pattern10.test(data6)){const err26 = {};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}var valid10 = _errs34 === errors;if(valid10){const err27 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/6/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}const _errs36 = errors;const _errs37 = errors;if(typeof data6 === "string"){if(!pattern11.test(data6)){const err28 = {};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}var valid11 = _errs37 === errors;if(valid11){const err29 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/7/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}else {errors = _errs36;if(vErrors !== null){if(_errs36){vErrors.length = _errs36;}else {vErrors = null;}}}if(typeof data6 === "string"){if(func3(data6) < 1){const err30 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}if(!pattern12.test(data6)){const err31 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/pattern",keyword:"pattern",params:{pattern: "^[^/]+(?:/[^/]+)*$"},message:"must match pattern \""+"^[^/]+(?:/[^/]+)*$"+"\""};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}else {const err32 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err33 = {instancePath:instancePath+"/meta/animation",schemaPath:"#/properties/meta/properties/animation/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.animation.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err34 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"#/properties/meta/properties/visual_preset/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.visual_preset.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err35 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"#/properties/meta/properties/quality_profile/enum",keyword:"enum",params:{allowedValues: schema31.properties.meta.properties.quality_profile.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err36 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(data10.revision === undefined){const err37 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err38 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err39 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err41 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema35.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err42 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema35.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern13.test(data14)){const err43 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data2.views !== undefined){if(!(validate22(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate22.errors : vErrors.concat(validate22.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err46 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err47 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema39.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!(((((((key4 === "frontend") || (key4 === "backend")) || (key4 === "database")) || (key4 === "cloud")) || (key4 === "security")) || (key4 === "messagebus")) || (key4 === "external"))){const err48 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}if(data18.frontend !== undefined){let data19 = data18.frontend;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err50 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err51 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}if(func3(data20) < 1){const err52 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}else {const err53 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err54 = {instancePath:instancePath+"/meta/legend/entries/frontend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}}else {const err55 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}}if(data18.backend !== undefined){let data22 = data18.backend;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err57 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err58 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}if(func3(data23) < 1){const err59 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}else {const err60 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err61 = {instancePath:instancePath+"/meta/legend/entries/backend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}}else {const err62 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}}if(data18.database !== undefined){let data25 = data18.database;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err64 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err65 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(func3(data26) < 1){const err66 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err68 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}}else {const err69 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}}if(data18.cloud !== undefined){let data28 = data18.cloud;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err71 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err72 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}if(func3(data29) < 1){const err73 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err75 = {instancePath:instancePath+"/meta/legend/entries/cloud/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}}else {const err76 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}if(data18.security !== undefined){let data31 = data18.security;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err78 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err79 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}if(func3(data32) < 1){const err80 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}else {const err81 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err82 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}}else {const err83 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}if(data18.messagebus !== undefined){let data34 = data18.messagebus;if(data34 && typeof data34 == "object" && !Array.isArray(data34)){if(Object.keys(data34).length < 1){const err84 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}for(const key10 in data34){if(!((key10 === "label") || (key10 === "visible"))){const err85 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data34.label !== undefined){let data35 = data34.label;if(typeof data35 === "string"){if(func3(data35) > 80){const err86 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}if(func3(data35) < 1){const err87 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}else {const err88 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}if(data34.visible !== undefined){if(typeof data34.visible !== "boolean"){const err89 = {instancePath:instancePath+"/meta/legend/entries/messagebus/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}}else {const err90 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}if(data18.external !== undefined){let data37 = data18.external;if(data37 && typeof data37 == "object" && !Array.isArray(data37)){if(Object.keys(data37).length < 1){const err91 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}for(const key11 in data37){if(!((key11 === "label") || (key11 === "visible"))){const err92 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}if(data37.label !== undefined){let data38 = data37.label;if(typeof data38 === "string"){if(func3(data38) > 80){const err93 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}if(func3(data38) < 1){const err94 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}else {const err95 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}if(data37.visible !== undefined){if(typeof data37.visible !== "boolean"){const err96 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}}else {const err97 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}}else {const err98 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}}else {const err99 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data2.viewBox !== undefined){let data40 = data2.viewBox;if(Array.isArray(data40)){if(data40.length > 2){const err100 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}if(data40.length < 2){const err101 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}const len0 = data40.length;if(len0 > 0){let data41 = data40[0];if((typeof data41 == "number") && (isFinite(data41))){if(data41 < 700 || isNaN(data41)){const err102 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 700},message:"must be >= 700"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}else {const err103 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}if(len0 > 1){let data42 = data40[1];if((typeof data42 == "number") && (isFinite(data42))){if(data42 < 240 || isNaN(data42)){const err104 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 240},message:"must be >= 240"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}else {const err105 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}const len1 = data40.length;if(!(len1 <= 2)){const err106 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}}else {const err107 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}}else {const err108 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}if(data.lanes !== undefined){let data43 = data.lanes;if(Array.isArray(data43)){if(data43.length < 1){const err109 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}const len2 = data43.length;for(let i0=0; i0<len2; i0++){let data44 = data43[i0];if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.id === undefined){const err110 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}if(data44.label === undefined){const err111 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}for(const key12 in data44){if(!(((key12 === "id") || (key12 === "label")) || (key12 === "variant"))){const err112 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}}if(data44.id !== undefined){let data45 = data44.id;if(typeof data45 === "string"){if(!pattern14.test(data45)){const err113 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}else {const err114 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}if(data44.label !== undefined){let data46 = data44.label;if(typeof data46 === "string"){if(func3(data46) < 1){const err115 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}else {const err116 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}}if(data44.variant !== undefined){let data47 = data44.variant;if(!((data47 === "normal") || (data47 === "exception"))){const err117 = {instancePath:instancePath+"/lanes/" + i0+"/variant",schemaPath:"#/properties/lanes/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.lanes.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}}}else {const err118 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}}else {const err119 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}if(data.phases !== undefined){let data48 = data.phases;if(Array.isArray(data48)){const len3 = data48.length;for(let i1=0; i1<len3; i1++){let data49 = data48[i1];if(data49 && typeof data49 == "object" && !Array.isArray(data49)){if(data49.id === undefined){const err120 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}if(data49.label === undefined){const err121 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}if(data49.fromCol === undefined){const err122 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "fromCol"},message:"must have required property '"+"fromCol"+"'"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}if(data49.toCol === undefined){const err123 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/required",keyword:"required",params:{missingProperty: "toCol"},message:"must have required property '"+"toCol"+"'"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}for(const key13 in data49){if(!(((((key13 === "id") || (key13 === "label")) || (key13 === "fromCol")) || (key13 === "toCol")) || (key13 === "variant"))){const err124 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}}if(data49.id !== undefined){let data50 = data49.id;if(typeof data50 === "string"){if(!pattern14.test(data50)){const err125 = {instancePath:instancePath+"/phases/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}}else {const err126 = {instancePath:instancePath+"/phases/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}if(data49.label !== undefined){let data51 = data49.label;if(typeof data51 === "string"){if(func3(data51) < 1){const err127 = {instancePath:instancePath+"/phases/" + i1+"/label",schemaPath:"#/properties/phases/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}}else {const err128 = {instancePath:instancePath+"/phases/" + i1+"/label",schemaPath:"#/properties/phases/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}}if(data49.fromCol !== undefined){let data52 = data49.fromCol;if(!(((typeof data52 == "number") && (!(data52 % 1) && !isNaN(data52))) && (isFinite(data52)))){const err129 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}if((typeof data52 == "number") && (isFinite(data52))){if(data52 > 5 || isNaN(data52)){const err130 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}if(data52 < 0 || isNaN(data52)){const err131 = {instancePath:instancePath+"/phases/" + i1+"/fromCol",schemaPath:"#/properties/phases/items/properties/fromCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}}}if(data49.toCol !== undefined){let data53 = data49.toCol;if(!(((typeof data53 == "number") && (!(data53 % 1) && !isNaN(data53))) && (isFinite(data53)))){const err132 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}if((typeof data53 == "number") && (isFinite(data53))){if(data53 > 5 || isNaN(data53)){const err133 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}if(data53 < 0 || isNaN(data53)){const err134 = {instancePath:instancePath+"/phases/" + i1+"/toCol",schemaPath:"#/properties/phases/items/properties/toCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}}}if(data49.variant !== undefined){let data54 = data49.variant;if(!((((data54 === "default") || (data54 === "emphasis")) || (data54 === "security")) || (data54 === "dashed"))){const err135 = {instancePath:instancePath+"/phases/" + i1+"/variant",schemaPath:"#/properties/phases/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.phases.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}}}else {const err136 = {instancePath:instancePath+"/phases/" + i1,schemaPath:"#/properties/phases/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}}else {const err137 = {instancePath:instancePath+"/phases",schemaPath:"#/properties/phases/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}if(data.groups !== undefined){let data55 = data.groups;if(Array.isArray(data55)){const len4 = data55.length;for(let i2=0; i2<len4; i2++){let data56 = data55[i2];if(data56 && typeof data56 == "object" && !Array.isArray(data56)){if(data56.id === undefined){const err138 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}if(data56.label === undefined){const err139 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}if(data56.lane === undefined){const err140 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}if(data56.fromCol === undefined){const err141 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "fromCol"},message:"must have required property '"+"fromCol"+"'"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}if(data56.toCol === undefined){const err142 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/required",keyword:"required",params:{missingProperty: "toCol"},message:"must have required property '"+"toCol"+"'"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}for(const key14 in data56){if(!((((((key14 === "id") || (key14 === "label")) || (key14 === "lane")) || (key14 === "fromCol")) || (key14 === "toCol")) || (key14 === "variant"))){const err143 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}if(data56.id !== undefined){let data57 = data56.id;if(typeof data57 === "string"){if(!pattern14.test(data57)){const err144 = {instancePath:instancePath+"/groups/" + i2+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}}else {const err145 = {instancePath:instancePath+"/groups/" + i2+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}if(data56.label !== undefined){let data58 = data56.label;if(typeof data58 === "string"){if(func3(data58) < 1){const err146 = {instancePath:instancePath+"/groups/" + i2+"/label",schemaPath:"#/properties/groups/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}}else {const err147 = {instancePath:instancePath+"/groups/" + i2+"/label",schemaPath:"#/properties/groups/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}if(data56.lane !== undefined){let data59 = data56.lane;if(typeof data59 === "string"){if(!pattern14.test(data59)){const err148 = {instancePath:instancePath+"/groups/" + i2+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}else {const err149 = {instancePath:instancePath+"/groups/" + i2+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}if(data56.fromCol !== undefined){let data60 = data56.fromCol;if(!(((typeof data60 == "number") && (!(data60 % 1) && !isNaN(data60))) && (isFinite(data60)))){const err150 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}if((typeof data60 == "number") && (isFinite(data60))){if(data60 > 5 || isNaN(data60)){const err151 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if(data60 < 0 || isNaN(data60)){const err152 = {instancePath:instancePath+"/groups/" + i2+"/fromCol",schemaPath:"#/properties/groups/items/properties/fromCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}if(data56.toCol !== undefined){let data61 = data56.toCol;if(!(((typeof data61 == "number") && (!(data61 % 1) && !isNaN(data61))) && (isFinite(data61)))){const err153 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}if((typeof data61 == "number") && (isFinite(data61))){if(data61 > 5 || isNaN(data61)){const err154 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}if(data61 < 0 || isNaN(data61)){const err155 = {instancePath:instancePath+"/groups/" + i2+"/toCol",schemaPath:"#/properties/groups/items/properties/toCol/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}}if(data56.variant !== undefined){let data62 = data56.variant;if(!((((data62 === "default") || (data62 === "emphasis")) || (data62 === "security")) || (data62 === "dashed"))){const err156 = {instancePath:instancePath+"/groups/" + i2+"/variant",schemaPath:"#/properties/groups/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema31.properties.groups.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}}else {const err157 = {instancePath:instancePath+"/groups/" + i2,schemaPath:"#/properties/groups/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}}else {const err158 = {instancePath:instancePath+"/groups",schemaPath:"#/properties/groups/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}if(data.mainPath !== undefined){let data63 = data.mainPath;if(Array.isArray(data63)){if(data63.length < 2){const err159 = {instancePath:instancePath+"/mainPath",schemaPath:"#/properties/mainPath/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}const len5 = data63.length;for(let i3=0; i3<len5; i3++){let data64 = data63[i3];if(typeof data64 === "string"){if(!pattern14.test(data64)){const err160 = {instancePath:instancePath+"/mainPath/" + i3,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}else {const err161 = {instancePath:instancePath+"/mainPath/" + i3,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}}else {const err162 = {instancePath:instancePath+"/mainPath",schemaPath:"#/properties/mainPath/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}if(data.semanticChecks !== undefined){let data65 = data.semanticChecks;if(data65 && typeof data65 == "object" && !Array.isArray(data65)){if(Object.keys(data65).length < 1){const err163 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}for(const key15 in data65){if(!((((key15 === "allowedRoots") || (key15 === "allowedTerminals")) || (key15 === "requiredEdges")) || (key15 === "requiredPaths"))){const err164 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}if(data65.allowedRoots !== undefined){let data66 = data65.allowedRoots;if(Array.isArray(data66)){const len6 = data66.length;for(let i4=0; i4<len6; i4++){let data67 = data66[i4];if(typeof data67 === "string"){if(!pattern14.test(data67)){const err165 = {instancePath:instancePath+"/semanticChecks/allowedRoots/" + i4,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}else {const err166 = {instancePath:instancePath+"/semanticChecks/allowedRoots/" + i4,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}}else {const err167 = {instancePath:instancePath+"/semanticChecks/allowedRoots",schemaPath:"#/properties/semanticChecks/properties/allowedRoots/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data65.allowedTerminals !== undefined){let data68 = data65.allowedTerminals;if(Array.isArray(data68)){const len7 = data68.length;for(let i5=0; i5<len7; i5++){let data69 = data68[i5];if(typeof data69 === "string"){if(!pattern14.test(data69)){const err168 = {instancePath:instancePath+"/semanticChecks/allowedTerminals/" + i5,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}}else {const err169 = {instancePath:instancePath+"/semanticChecks/allowedTerminals/" + i5,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}}else {const err170 = {instancePath:instancePath+"/semanticChecks/allowedTerminals",schemaPath:"#/properties/semanticChecks/properties/allowedTerminals/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}if(data65.requiredEdges !== undefined){let data70 = data65.requiredEdges;if(Array.isArray(data70)){const len8 = data70.length;for(let i6=0; i6<len8; i6++){if(!(validate24(data70[i6], {instancePath:instancePath+"/semanticChecks/requiredEdges/" + i6,parentData:data70,parentDataProperty:i6,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate24.errors : vErrors.concat(validate24.errors);errors = vErrors.length;}}}else {const err171 = {instancePath:instancePath+"/semanticChecks/requiredEdges",schemaPath:"#/properties/semanticChecks/properties/requiredEdges/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(data65.requiredPaths !== undefined){let data72 = data65.requiredPaths;if(Array.isArray(data72)){const len9 = data72.length;for(let i7=0; i7<len9; i7++){if(!(validate24(data72[i7], {instancePath:instancePath+"/semanticChecks/requiredPaths/" + i7,parentData:data72,parentDataProperty:i7,rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate24.errors : vErrors.concat(validate24.errors);errors = vErrors.length;}}}else {const err172 = {instancePath:instancePath+"/semanticChecks/requiredPaths",schemaPath:"#/properties/semanticChecks/properties/requiredPaths/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}}else {const err173 = {instancePath:instancePath+"/semanticChecks",schemaPath:"#/properties/semanticChecks/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}if(data.nodes !== undefined){let data74 = data.nodes;if(Array.isArray(data74)){if(data74.length < 1){const err174 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}const len10 = data74.length;for(let i8=0; i8<len10; i8++){let data75 = data74[i8];if(data75 && typeof data75 == "object" && !Array.isArray(data75)){if(data75.id === undefined){const err175 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}if(data75.lane === undefined){const err176 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}if(data75.col === undefined){const err177 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "col"},message:"must have required property '"+"col"+"'"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}if(data75.type === undefined){const err178 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}if(data75.label === undefined){const err179 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}for(const key16 in data75){if(!(func1.call(schema31.properties.nodes.items.properties, key16))){const err180 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}if(data75.id !== undefined){let data76 = data75.id;if(typeof data76 === "string"){if(!pattern14.test(data76)){const err181 = {instancePath:instancePath+"/nodes/" + i8+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}else {const err182 = {instancePath:instancePath+"/nodes/" + i8+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}if(data75.lane !== undefined){let data77 = data75.lane;if(typeof data77 === "string"){if(!pattern14.test(data77)){const err183 = {instancePath:instancePath+"/nodes/" + i8+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}else {const err184 = {instancePath:instancePath+"/nodes/" + i8+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data75.col !== undefined){let data78 = data75.col;if(!(((typeof data78 == "number") && (!(data78 % 1) && !isNaN(data78))) && (isFinite(data78)))){const err185 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}if((typeof data78 == "number") && (isFinite(data78))){if(data78 > 5 || isNaN(data78)){const err186 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/maximum",keyword:"maximum",params:{comparison: "<=", limit: 5},message:"must be <= 5"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}if(data78 < 0 || isNaN(data78)){const err187 = {instancePath:instancePath+"/nodes/" + i8+"/col",schemaPath:"#/properties/nodes/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}}if(data75.type !== undefined){let data79 = data75.type;if(!(((((((data79 === "frontend") || (data79 === "backend")) || (data79 === "database")) || (data79 === "cloud")) || (data79 === "security")) || (data79 === "messagebus")) || (data79 === "external"))){const err188 = {instancePath:instancePath+"/nodes/" + i8+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema59.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}if(data75.label !== undefined){let data80 = data75.label;if(typeof data80 === "string"){if(func3(data80) < 1){const err189 = {instancePath:instancePath+"/nodes/" + i8+"/label",schemaPath:"#/properties/nodes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}else {const err190 = {instancePath:instancePath+"/nodes/" + i8+"/label",schemaPath:"#/properties/nodes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}if(data75.sublabel !== undefined){if(typeof data75.sublabel !== "string"){const err191 = {instancePath:instancePath+"/nodes/" + i8+"/sublabel",schemaPath:"#/properties/nodes/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}if(data75.tag !== undefined){if(typeof data75.tag !== "string"){const err192 = {instancePath:instancePath+"/nodes/" + i8+"/tag",schemaPath:"#/properties/nodes/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}if(data75.brand !== undefined){let data83 = data75.brand;const _errs213 = errors;let valid66 = false;let passing0 = null;const _errs214 = errors;const _errs216 = errors;let valid67 = false;const _errs217 = errors;if(typeof data83 === "string"){if(func3(data83) > 80){const err193 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}if(!pattern27.test(data83)){const err194 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}var _valid1 = _errs217 === errors;valid67 = valid67 || _valid1;const _errs218 = errors;if(typeof data83 === "string"){if(!pattern28.test(data83)){const err195 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}var _valid1 = _errs218 === errors;valid67 = valid67 || _valid1;if(!valid67){const err196 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}else {errors = _errs216;if(vErrors !== null){if(_errs216){vErrors.length = _errs216;}else {vErrors = null;}}}if(typeof data83 === "string"){if(func3(data83) > 2048){const err197 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}if(func3(data83) < 1){const err198 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}}else {const err199 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}var _valid0 = _errs214 === errors;if(_valid0){valid66 = true;passing0 = 0;}const _errs219 = errors;if(data83 && typeof data83 == "object" && !Array.isArray(data83)){if(data83.url === undefined){const err200 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}if(data83.sha256 === undefined){const err201 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}for(const key17 in data83){if(!((key17 === "url") || (key17 === "sha256"))){const err202 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}}if(data83.url !== undefined){let data84 = data83.url;if(typeof data84 === "string"){if(func3(data84) > 2048){const err203 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}if(func3(data84) < 8){const err204 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}if(!pattern28.test(data84)){const err205 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}else {const err206 = {instancePath:instancePath+"/nodes/" + i8+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}if(data83.sha256 !== undefined){let data85 = data83.sha256;if(typeof data85 === "string"){if(!pattern30.test(data85)){const err207 = {instancePath:instancePath+"/nodes/" + i8+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}}else {const err208 = {instancePath:instancePath+"/nodes/" + i8+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}}}else {const err209 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}var _valid0 = _errs219 === errors;if(_valid0 && valid66){valid66 = false;passing0 = [passing0, 1];}else {if(_valid0){valid66 = true;passing0 = 1;}}if(!valid66){const err210 = {instancePath:instancePath+"/nodes/" + i8+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}else {errors = _errs213;if(vErrors !== null){if(_errs213){vErrors.length = _errs213;}else {vErrors = null;}}}}if(data75.sources !== undefined){let data86 = data75.sources;if(Array.isArray(data86)){if(data86.length > 3){const err211 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}if(data86.length < 1){const err212 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}const len11 = data86.length;for(let i9=0; i9<len11; i9++){let data87 = data86[i9];if(data87 && typeof data87 == "object" && !Array.isArray(data87)){if(data87.path === undefined){const err213 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}for(const key18 in data87){if(!((((key18 === "path") || (key18 === "line")) || (key18 === "end_line")) || (key18 === "label"))){const err214 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}}if(data87.path !== undefined){let data88 = data87.path;if(typeof data88 === "string"){if(func3(data88) > 240){const err215 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}if(func3(data88) < 1){const err216 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}else {const err217 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}}if(data87.line !== undefined){let data89 = data87.line;if(!(((typeof data89 == "number") && (!(data89 % 1) && !isNaN(data89))) && (isFinite(data89)))){const err218 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}if((typeof data89 == "number") && (isFinite(data89))){if(data89 < 1 || isNaN(data89)){const err219 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}}if(data87.end_line !== undefined){let data90 = data87.end_line;if(!(((typeof data90 == "number") && (!(data90 % 1) && !isNaN(data90))) && (isFinite(data90)))){const err220 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}if((typeof data90 == "number") && (isFinite(data90))){if(data90 < 1 || isNaN(data90)){const err221 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}}if(data87.label !== undefined){let data91 = data87.label;if(typeof data91 === "string"){if(func3(data91) > 48){const err222 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}if(func3(data91) < 1){const err223 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err223];}else {vErrors.push(err223);}errors++;}}else {const err224 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err224];}else {vErrors.push(err224);}errors++;}}}else {const err225 = {instancePath:instancePath+"/nodes/" + i8+"/sources/" + i9,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err225];}else {vErrors.push(err225);}errors++;}}}else {const err226 = {instancePath:instancePath+"/nodes/" + i8+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err226];}else {vErrors.push(err226);}errors++;}}if(data75.width !== undefined){let data92 = data75.width;if((typeof data92 == "number") && (isFinite(data92))){if(data92 < 32 || isNaN(data92)){const err227 = {instancePath:instancePath+"/nodes/" + i8+"/width",schemaPath:"#/properties/nodes/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 32},message:"must be >= 32"};if(vErrors === null){vErrors = [err227];}else {vErrors.push(err227);}errors++;}}else {const err228 = {instancePath:instancePath+"/nodes/" + i8+"/width",schemaPath:"#/properties/nodes/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err228];}else {vErrors.push(err228);}errors++;}}if(data75.height !== undefined){let data93 = data75.height;if((typeof data93 == "number") && (isFinite(data93))){if(data93 < 32 || isNaN(data93)){const err229 = {instancePath:instancePath+"/nodes/" + i8+"/height",schemaPath:"#/properties/nodes/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 32},message:"must be >= 32"};if(vErrors === null){vErrors = [err229];}else {vErrors.push(err229);}errors++;}}else {const err230 = {instancePath:instancePath+"/nodes/" + i8+"/height",schemaPath:"#/properties/nodes/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err230];}else {vErrors.push(err230);}errors++;}}if(data75.yOffset !== undefined){let data94 = data75.yOffset;if(!((typeof data94 == "number") && (isFinite(data94)))){const err231 = {instancePath:instancePath+"/nodes/" + i8+"/yOffset",schemaPath:"#/properties/nodes/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err231];}else {vErrors.push(err231);}errors++;}}}else {const err232 = {instancePath:instancePath+"/nodes/" + i8,schemaPath:"#/properties/nodes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err232];}else {vErrors.push(err232);}errors++;}}}else {const err233 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err233];}else {vErrors.push(err233);}errors++;}}if(data.edges !== undefined){let data95 = data.edges;if(Array.isArray(data95)){const len12 = data95.length;for(let i10=0; i10<len12; i10++){let data96 = data95[i10];if(data96 && typeof data96 == "object" && !Array.isArray(data96)){if(data96.from === undefined){const err234 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err234];}else {vErrors.push(err234);}errors++;}if(data96.to === undefined){const err235 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err235];}else {vErrors.push(err235);}errors++;}for(const key19 in data96){if(!(func1.call(schema31.properties.edges.items.properties, key19))){const err236 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key19},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err236];}else {vErrors.push(err236);}errors++;}}if(data96.id !== undefined){let data97 = data96.id;if(typeof data97 === "string"){if(!pattern14.test(data97)){const err237 = {instancePath:instancePath+"/edges/" + i10+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err237];}else {vErrors.push(err237);}errors++;}}else {const err238 = {instancePath:instancePath+"/edges/" + i10+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err238];}else {vErrors.push(err238);}errors++;}}if(data96.from !== undefined){let data98 = data96.from;if(typeof data98 === "string"){if(!pattern14.test(data98)){const err239 = {instancePath:instancePath+"/edges/" + i10+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err239];}else {vErrors.push(err239);}errors++;}}else {const err240 = {instancePath:instancePath+"/edges/" + i10+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err240];}else {vErrors.push(err240);}errors++;}}if(data96.to !== undefined){let data99 = data96.to;if(typeof data99 === "string"){if(!pattern14.test(data99)){const err241 = {instancePath:instancePath+"/edges/" + i10+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err241];}else {vErrors.push(err241);}errors++;}}else {const err242 = {instancePath:instancePath+"/edges/" + i10+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err242];}else {vErrors.push(err242);}errors++;}}if(data96.label !== undefined){if(typeof data96.label !== "string"){const err243 = {instancePath:instancePath+"/edges/" + i10+"/label",schemaPath:"#/properties/edges/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err243];}else {vErrors.push(err243);}errors++;}}if(data96.variant !== undefined){let data101 = data96.variant;if(!((((data101 === "default") || (data101 === "emphasis")) || (data101 === "security")) || (data101 === "dashed"))){const err244 = {instancePath:instancePath+"/edges/" + i10+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err244];}else {vErrors.push(err244);}errors++;}}if(data96.role !== undefined){let data102 = data96.role;if(!(((((data102 === "main") || (data102 === "branch")) || (data102 === "async")) || (data102 === "return")) || (data102 === "error"))){const err245 = {instancePath:instancePath+"/edges/" + i10+"/role",schemaPath:"#/properties/edges/items/properties/role/enum",keyword:"enum",params:{allowedValues: schema31.properties.edges.items.properties.role.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err245];}else {vErrors.push(err245);}errors++;}}if(data96.fromSide !== undefined){let data103 = data96.fromSide;if(!((((data103 === "left") || (data103 === "right")) || (data103 === "top")) || (data103 === "bottom"))){const err246 = {instancePath:instancePath+"/edges/" + i10+"/fromSide",schemaPath:"#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema66.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err246];}else {vErrors.push(err246);}errors++;}}if(data96.toSide !== undefined){let data104 = data96.toSide;if(!((((data104 === "left") || (data104 === "right")) || (data104 === "top")) || (data104 === "bottom"))){const err247 = {instancePath:instancePath+"/edges/" + i10+"/toSide",schemaPath:"#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema66.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err247];}else {vErrors.push(err247);}errors++;}}if(data96.route !== undefined){let data105 = data96.route;if(!(((((((data105 === "auto") || (data105 === "straight")) || (data105 === "drop")) || (data105 === "outside-right")) || (data105 === "return-left")) || (data105 === "bottom-channel")) || (data105 === "up-channel"))){const err248 = {instancePath:instancePath+"/edges/" + i10+"/route",schemaPath:"#/properties/edges/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema31.properties.edges.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err248];}else {vErrors.push(err248);}errors++;}}if(data96.via !== undefined){let data106 = data96.via;if(Array.isArray(data106)){const len13 = data106.length;for(let i11=0; i11<len13; i11++){let data107 = data106[i11];if(Array.isArray(data107)){if(data107.length > 2){const err249 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err249];}else {vErrors.push(err249);}errors++;}if(data107.length < 2){const err250 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err250];}else {vErrors.push(err250);}errors++;}const len14 = data107.length;if(len14 > 0){let data108 = data107[0];if(!((typeof data108 == "number") && (isFinite(data108)))){const err251 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err251];}else {vErrors.push(err251);}errors++;}}if(len14 > 1){let data109 = data107[1];if(!((typeof data109 == "number") && (isFinite(data109)))){const err252 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err252];}else {vErrors.push(err252);}errors++;}}const len15 = data107.length;if(!(len15 <= 2)){const err253 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err253];}else {vErrors.push(err253);}errors++;}}else {const err254 = {instancePath:instancePath+"/edges/" + i10+"/via/" + i11,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err254];}else {vErrors.push(err254);}errors++;}}}else {const err255 = {instancePath:instancePath+"/edges/" + i10+"/via",schemaPath:"#/properties/edges/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err255];}else {vErrors.push(err255);}errors++;}}if(data96.labelAt !== undefined){let data110 = data96.labelAt;if(Array.isArray(data110)){if(data110.length > 2){const err256 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err256];}else {vErrors.push(err256);}errors++;}if(data110.length < 2){const err257 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err257];}else {vErrors.push(err257);}errors++;}const len16 = data110.length;if(len16 > 0){let data111 = data110[0];if(!((typeof data111 == "number") && (isFinite(data111)))){const err258 = {instancePath:instancePath+"/edges/" + i10+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err258];}else {vErrors.push(err258);}errors++;}}if(len16 > 1){let data112 = data110[1];if(!((typeof data112 == "number") && (isFinite(data112)))){const err259 = {instancePath:instancePath+"/edges/" + i10+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err259];}else {vErrors.push(err259);}errors++;}}const len17 = data110.length;if(!(len17 <= 2)){const err260 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err260];}else {vErrors.push(err260);}errors++;}}else {const err261 = {instancePath:instancePath+"/edges/" + i10+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err261];}else {vErrors.push(err261);}errors++;}}if(data96.labelDx !== undefined){let data113 = data96.labelDx;if(!((typeof data113 == "number") && (isFinite(data113)))){const err262 = {instancePath:instancePath+"/edges/" + i10+"/labelDx",schemaPath:"#/properties/edges/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err262];}else {vErrors.push(err262);}errors++;}}if(data96.labelDy !== undefined){let data114 = data96.labelDy;if(!((typeof data114 == "number") && (isFinite(data114)))){const err263 = {instancePath:instancePath+"/edges/" + i10+"/labelDy",schemaPath:"#/properties/edges/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err263];}else {vErrors.push(err263);}errors++;}}if(data96.labelSegment !== undefined){let data115 = data96.labelSegment;if(!(((typeof data115 == "number") && (!(data115 % 1) && !isNaN(data115))) && (isFinite(data115)))){const err264 = {instancePath:instancePath+"/edges/" + i10+"/labelSegment",schemaPath:"#/properties/edges/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err264];}else {vErrors.push(err264);}errors++;}if((typeof data115 == "number") && (isFinite(data115))){if(data115 < 0 || isNaN(data115)){const err265 = {instancePath:instancePath+"/edges/" + i10+"/labelSegment",schemaPath:"#/properties/edges/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err265];}else {vErrors.push(err265);}errors++;}}}if(data96.channelX !== undefined){let data116 = data96.channelX;if(!((typeof data116 == "number") && (isFinite(data116)))){const err266 = {instancePath:instancePath+"/edges/" + i10+"/channelX",schemaPath:"#/properties/edges/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err266];}else {vErrors.push(err266);}errors++;}}if(data96.channelY !== undefined){let data117 = data96.channelY;if(!((typeof data117 == "number") && (isFinite(data117)))){const err267 = {instancePath:instancePath+"/edges/" + i10+"/channelY",schemaPath:"#/properties/edges/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err267];}else {vErrors.push(err267);}errors++;}}if(data96.bias !== undefined){let data118 = data96.bias;if((typeof data118 == "number") && (isFinite(data118))){if(data118 > 1 || isNaN(data118)){const err268 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/maximum",keyword:"maximum",params:{comparison: "<=", limit: 1},message:"must be <= 1"};if(vErrors === null){vErrors = [err268];}else {vErrors.push(err268);}errors++;}if(data118 < 0 || isNaN(data118)){const err269 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err269];}else {vErrors.push(err269);}errors++;}}else {const err270 = {instancePath:instancePath+"/edges/" + i10+"/bias",schemaPath:"#/properties/edges/items/properties/bias/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err270];}else {vErrors.push(err270);}errors++;}}if(data96.width !== undefined){let data119 = data96.width;if((typeof data119 == "number") && (isFinite(data119))){if(data119 < 0.5 || isNaN(data119)){const err271 = {instancePath:instancePath+"/edges/" + i10+"/width",schemaPath:"#/properties/edges/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err271];}else {vErrors.push(err271);}errors++;}}else {const err272 = {instancePath:instancePath+"/edges/" + i10+"/width",schemaPath:"#/properties/edges/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err272];}else {vErrors.push(err272);}errors++;}}}else {const err273 = {instancePath:instancePath+"/edges/" + i10,schemaPath:"#/properties/edges/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err273];}else {vErrors.push(err273);}errors++;}}}else {const err274 = {instancePath:instancePath+"/edges",schemaPath:"#/properties/edges/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err274];}else {vErrors.push(err274);}errors++;}}if(data.cards !== undefined){let data120 = data.cards;if(Array.isArray(data120)){const len18 = data120.length;for(let i12=0; i12<len18; i12++){let data121 = data120[i12];if(data121 && typeof data121 == "object" && !Array.isArray(data121)){if(data121.dot === undefined){const err275 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err275];}else {vErrors.push(err275);}errors++;}if(data121.title === undefined){const err276 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err276];}else {vErrors.push(err276);}errors++;}if(data121.items === undefined){const err277 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err277];}else {vErrors.push(err277);}errors++;}for(const key20 in data121){if(!(((key20 === "dot") || (key20 === "title")) || (key20 === "items"))){const err278 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key20},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err278];}else {vErrors.push(err278);}errors++;}}if(data121.dot !== undefined){let data122 = data121.dot;if(!(((((((data122 === "cyan") || (data122 === "emerald")) || (data122 === "violet")) || (data122 === "amber")) || (data122 === "rose")) || (data122 === "orange")) || (data122 === "slate"))){const err279 = {instancePath:instancePath+"/cards/" + i12+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema70.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err279];}else {vErrors.push(err279);}errors++;}}if(data121.title !== undefined){let data123 = data121.title;if(typeof data123 === "string"){if(func3(data123) < 1){const err280 = {instancePath:instancePath+"/cards/" + i12+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err280];}else {vErrors.push(err280);}errors++;}}else {const err281 = {instancePath:instancePath+"/cards/" + i12+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err281];}else {vErrors.push(err281);}errors++;}}if(data121.items !== undefined){let data124 = data121.items;if(Array.isArray(data124)){const len19 = data124.length;for(let i13=0; i13<len19; i13++){if(typeof data124[i13] !== "string"){const err282 = {instancePath:instancePath+"/cards/" + i12+"/items/" + i13,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err282];}else {vErrors.push(err282);}errors++;}}}else {const err283 = {instancePath:instancePath+"/cards/" + i12+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err283];}else {vErrors.push(err283);}errors++;}}}else {const err284 = {instancePath:instancePath+"/cards/" + i12,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err284];}else {vErrors.push(err284);}errors++;}}}else {const err285 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err285];}else {vErrors.push(err285);}errors++;}}}else {const err286 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err286];}else {vErrors.push(err286);}errors++;}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const sequenceSchema = validate27;const schema71 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/sequence.schema.json","title":"Archify Sequence Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","participants","messages"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"sequence"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"$ref":"common.schema.json#/$defs/portableOutputPath"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"column_fit":{"description":"Horizontal participant layout. Omit this field or use fixed for the stable 86px boxes and 108px gap. Use spread when a wide viewBox would leave unused horizontal space or meaningful participant labels do not fit the fixed boxes; spread derives wider boxes and gaps from the viewBox without changing participant order or message semantics.","enum":["fixed","spread"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"default":{"$ref":"common.schema.json#/$defs/legendEntry"},"emphasis":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"dashed":{"$ref":"common.schema.json#/$defs/legendEntry"},"return":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":480},{"type":"number","minimum":480}],"items":false,"minItems":2,"maxItems":2}}},"participants":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"}}}},"segments":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to","label"],"properties":{"from":{"type":"number"},"to":{"type":"number"},"label":{"type":"string","minLength":1}}}},"messages":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["from","to","y","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"y":{"type":"number","minimum":160},"label":{"type":"string","minLength":1},"variant":{"enum":["default","emphasis","security","dashed","return"]},"note":{"type":"string"}}}},"activations":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["participant","from","to"],"properties":{"participant":{"$ref":"common.schema.json#/$defs/id"},"from":{"type":"number"},"to":{"type":"number"},"type":{"$ref":"common.schema.json#/$defs/componentType"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};const schema74 = {"enum":["trace","none"]};const schema75 = {"enum":["classic","signal-flow","blueprint","editorial"]};const schema76 = {"enum":["standard","showcase"]};function validate28(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate28.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern14.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate28.errors = vErrors;return errors === 0;}validate28.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate27(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/sequence.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate27.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.participants === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "participants"},message:"must have required property '"+"participants"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.messages === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "messages"},message:"must have required property '"+"messages"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}for(const key0 in data){if(!((((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "participants")) || (key0 === "segments")) || (key0 === "messages")) || (key0 === "activations")) || (key0 === "cards"))){const err5 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err6 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.diagram_type !== undefined){if("sequence" !== data.diagram_type){const err7 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "sequence"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err8 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}for(const key1 in data2){if(!(func1.call(schema71.properties.meta.properties, key1))){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err10 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}else {const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err12 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err13 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.output !== undefined){let data6 = data2.output;if(typeof data6 === "string"){if(!pattern4.test(data6)){const err14 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/0/pattern",keyword:"pattern",params:{pattern: "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},message:"must match pattern \""+"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"+"\""};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}const _errs18 = errors;const _errs19 = errors;if(typeof data6 === "string"){if(!pattern5.test(data6)){const err15 = {};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}var valid5 = _errs19 === errors;if(valid5){const err16 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}else {errors = _errs18;if(vErrors !== null){if(_errs18){vErrors.length = _errs18;}else {vErrors = null;}}}const _errs21 = errors;const _errs22 = errors;if(typeof data6 === "string"){if(!pattern6.test(data6)){const err17 = {};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}}var valid6 = _errs22 === errors;if(valid6){const err18 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}else {errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}}const _errs24 = errors;const _errs25 = errors;if(typeof data6 === "string"){if(!pattern7.test(data6)){const err19 = {};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}}var valid7 = _errs25 === errors;if(valid7){const err20 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}else {errors = _errs24;if(vErrors !== null){if(_errs24){vErrors.length = _errs24;}else {vErrors = null;}}}const _errs27 = errors;const _errs28 = errors;if(typeof data6 === "string"){if(!pattern8.test(data6)){const err21 = {};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}}var valid8 = _errs28 === errors;if(valid8){const err22 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/4/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}else {errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}}const _errs30 = errors;const _errs31 = errors;if(typeof data6 === "string"){if(!pattern9.test(data6)){const err23 = {};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}}var valid9 = _errs31 === errors;if(valid9){const err24 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/5/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}else {errors = _errs30;if(vErrors !== null){if(_errs30){vErrors.length = _errs30;}else {vErrors = null;}}}const _errs33 = errors;const _errs34 = errors;if(typeof data6 === "string"){if(!pattern10.test(data6)){const err25 = {};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}}var valid10 = _errs34 === errors;if(valid10){const err26 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/6/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}const _errs36 = errors;const _errs37 = errors;if(typeof data6 === "string"){if(!pattern11.test(data6)){const err27 = {};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}}var valid11 = _errs37 === errors;if(valid11){const err28 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/7/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}else {errors = _errs36;if(vErrors !== null){if(_errs36){vErrors.length = _errs36;}else {vErrors = null;}}}if(typeof data6 === "string"){if(func3(data6) < 1){const err29 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}if(!pattern12.test(data6)){const err30 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/pattern",keyword:"pattern",params:{pattern: "^[^/]+(?:/[^/]+)*$"},message:"must match pattern \""+"^[^/]+(?:/[^/]+)*$"+"\""};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}else {const err31 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err32 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err33 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err34 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema76.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data2.column_fit !== undefined){let data10 = data2.column_fit;if(!((data10 === "fixed") || (data10 === "spread"))){const err35 = {instancePath:instancePath+"/meta/column_fit",schemaPath:"#/properties/meta/properties/column_fit/enum",keyword:"enum",params:{allowedValues: schema71.properties.meta.properties.column_fit.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data2.repository !== undefined){let data11 = data2.repository;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.url === undefined){const err36 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(data11.revision === undefined){const err37 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}for(const key2 in data11){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err38 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data11.url !== undefined){let data12 = data11.url;if(typeof data12 === "string"){if(func3(data12) < 1){const err39 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data11.provider !== undefined){let data13 = data11.provider;if(!((data13 === "github") || (data13 === "gitee"))){const err41 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema35.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data11.link_mode !== undefined){let data14 = data11.link_mode;if(!((data14 === "web") || (data14 === "local-only"))){const err42 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema35.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data11.revision !== undefined){let data15 = data11.revision;if(typeof data15 === "string"){if(!pattern13.test(data15)){const err43 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data2.views !== undefined){if(!(validate28(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate28.errors : vErrors.concat(validate28.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data17 = data2.legend;if(data17 && typeof data17 == "object" && !Array.isArray(data17)){for(const key3 in data17){if(!((key3 === "mode") || (key3 === "entries"))){const err46 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data17.mode !== undefined){let data18 = data17.mode;if(!(((data18 === "auto") || (data18 === "all")) || (data18 === "hidden"))){const err47 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema39.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data17.entries !== undefined){let data19 = data17.entries;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){for(const key4 in data19){if(!(((((key4 === "default") || (key4 === "emphasis")) || (key4 === "security")) || (key4 === "dashed")) || (key4 === "return"))){const err48 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}if(data19.default !== undefined){let data20 = data19.default;if(data20 && typeof data20 == "object" && !Array.isArray(data20)){if(Object.keys(data20).length < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}for(const key5 in data20){if(!((key5 === "label") || (key5 === "visible"))){const err50 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data20.label !== undefined){let data21 = data20.label;if(typeof data21 === "string"){if(func3(data21) > 80){const err51 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}if(func3(data21) < 1){const err52 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}else {const err53 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data20.visible !== undefined){if(typeof data20.visible !== "boolean"){const err54 = {instancePath:instancePath+"/meta/legend/entries/default/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}}else {const err55 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}}if(data19.emphasis !== undefined){let data23 = data19.emphasis;if(data23 && typeof data23 == "object" && !Array.isArray(data23)){if(Object.keys(data23).length < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}for(const key6 in data23){if(!((key6 === "label") || (key6 === "visible"))){const err57 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data23.label !== undefined){let data24 = data23.label;if(typeof data24 === "string"){if(func3(data24) > 80){const err58 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}if(func3(data24) < 1){const err59 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}else {const err60 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}if(data23.visible !== undefined){if(typeof data23.visible !== "boolean"){const err61 = {instancePath:instancePath+"/meta/legend/entries/emphasis/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}}else {const err62 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}}if(data19.security !== undefined){let data26 = data19.security;if(data26 && typeof data26 == "object" && !Array.isArray(data26)){if(Object.keys(data26).length < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}for(const key7 in data26){if(!((key7 === "label") || (key7 === "visible"))){const err64 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data26.label !== undefined){let data27 = data26.label;if(typeof data27 === "string"){if(func3(data27) > 80){const err65 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(func3(data27) < 1){const err66 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data26.visible !== undefined){if(typeof data26.visible !== "boolean"){const err68 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}}else {const err69 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}}if(data19.dashed !== undefined){let data29 = data19.dashed;if(data29 && typeof data29 == "object" && !Array.isArray(data29)){if(Object.keys(data29).length < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}for(const key8 in data29){if(!((key8 === "label") || (key8 === "visible"))){const err71 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data29.label !== undefined){let data30 = data29.label;if(typeof data30 === "string"){if(func3(data30) > 80){const err72 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}if(func3(data30) < 1){const err73 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}if(data29.visible !== undefined){if(typeof data29.visible !== "boolean"){const err75 = {instancePath:instancePath+"/meta/legend/entries/dashed/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}}else {const err76 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}if(data19.return !== undefined){let data32 = data19.return;if(data32 && typeof data32 == "object" && !Array.isArray(data32)){if(Object.keys(data32).length < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}for(const key9 in data32){if(!((key9 === "label") || (key9 === "visible"))){const err78 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data32.label !== undefined){let data33 = data32.label;if(typeof data33 === "string"){if(func3(data33) > 80){const err79 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}if(func3(data33) < 1){const err80 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}else {const err81 = {instancePath:instancePath+"/meta/legend/entries/return/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data32.visible !== undefined){if(typeof data32.visible !== "boolean"){const err82 = {instancePath:instancePath+"/meta/legend/entries/return/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}}else {const err83 = {instancePath:instancePath+"/meta/legend/entries/return",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}}else {const err84 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}}else {const err85 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data2.viewBox !== undefined){let data35 = data2.viewBox;if(Array.isArray(data35)){if(data35.length > 2){const err86 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}if(data35.length < 2){const err87 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}const len0 = data35.length;if(len0 > 0){let data36 = data35[0];if((typeof data36 == "number") && (isFinite(data36))){if(data36 < 480 || isNaN(data36)){const err88 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 480},message:"must be >= 480"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}else {const err89 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}if(len0 > 1){let data37 = data35[1];if((typeof data37 == "number") && (isFinite(data37))){if(data37 < 480 || isNaN(data37)){const err90 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 480},message:"must be >= 480"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}else {const err91 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}const len1 = data35.length;if(!(len1 <= 2)){const err92 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}else {const err93 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}}else {const err94 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}if(data.participants !== undefined){let data38 = data.participants;if(Array.isArray(data38)){if(data38.length < 2){const err95 = {instancePath:instancePath+"/participants",schemaPath:"#/properties/participants/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}const len2 = data38.length;for(let i0=0; i0<len2; i0++){let data39 = data38[i0];if(data39 && typeof data39 == "object" && !Array.isArray(data39)){if(data39.id === undefined){const err96 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}if(data39.type === undefined){const err97 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}if(data39.label === undefined){const err98 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}for(const key10 in data39){if(!((((((key10 === "id") || (key10 === "type")) || (key10 === "label")) || (key10 === "sublabel")) || (key10 === "brand")) || (key10 === "sources"))){const err99 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data39.id !== undefined){let data40 = data39.id;if(typeof data40 === "string"){if(!pattern14.test(data40)){const err100 = {instancePath:instancePath+"/participants/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}}else {const err101 = {instancePath:instancePath+"/participants/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}if(data39.type !== undefined){let data41 = data39.type;if(!(((((((data41 === "frontend") || (data41 === "backend")) || (data41 === "database")) || (data41 === "cloud")) || (data41 === "security")) || (data41 === "messagebus")) || (data41 === "external"))){const err102 = {instancePath:instancePath+"/participants/" + i0+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema59.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data39.label !== undefined){let data42 = data39.label;if(typeof data42 === "string"){if(func3(data42) < 1){const err103 = {instancePath:instancePath+"/participants/" + i0+"/label",schemaPath:"#/properties/participants/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}else {const err104 = {instancePath:instancePath+"/participants/" + i0+"/label",schemaPath:"#/properties/participants/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}if(data39.sublabel !== undefined){if(typeof data39.sublabel !== "string"){const err105 = {instancePath:instancePath+"/participants/" + i0+"/sublabel",schemaPath:"#/properties/participants/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}if(data39.brand !== undefined){let data44 = data39.brand;const _errs126 = errors;let valid37 = false;let passing0 = null;const _errs127 = errors;const _errs129 = errors;let valid38 = false;const _errs130 = errors;if(typeof data44 === "string"){if(func3(data44) > 80){const err106 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}if(!pattern27.test(data44)){const err107 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}var _valid1 = _errs130 === errors;valid38 = valid38 || _valid1;const _errs131 = errors;if(typeof data44 === "string"){if(!pattern28.test(data44)){const err108 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}}var _valid1 = _errs131 === errors;valid38 = valid38 || _valid1;if(!valid38){const err109 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}else {errors = _errs129;if(vErrors !== null){if(_errs129){vErrors.length = _errs129;}else {vErrors = null;}}}if(typeof data44 === "string"){if(func3(data44) > 2048){const err110 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}if(func3(data44) < 1){const err111 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}else {const err112 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}var _valid0 = _errs127 === errors;if(_valid0){valid37 = true;passing0 = 0;}const _errs132 = errors;if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.url === undefined){const err113 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}if(data44.sha256 === undefined){const err114 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}for(const key11 in data44){if(!((key11 === "url") || (key11 === "sha256"))){const err115 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}if(data44.url !== undefined){let data45 = data44.url;if(typeof data45 === "string"){if(func3(data45) > 2048){const err116 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}if(func3(data45) < 8){const err117 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}if(!pattern28.test(data45)){const err118 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}else {const err119 = {instancePath:instancePath+"/participants/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}if(data44.sha256 !== undefined){let data46 = data44.sha256;if(typeof data46 === "string"){if(!pattern30.test(data46)){const err120 = {instancePath:instancePath+"/participants/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}else {const err121 = {instancePath:instancePath+"/participants/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}}else {const err122 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}var _valid0 = _errs132 === errors;if(_valid0 && valid37){valid37 = false;passing0 = [passing0, 1];}else {if(_valid0){valid37 = true;passing0 = 1;}}if(!valid37){const err123 = {instancePath:instancePath+"/participants/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}else {errors = _errs126;if(vErrors !== null){if(_errs126){vErrors.length = _errs126;}else {vErrors = null;}}}}if(data39.sources !== undefined){let data47 = data39.sources;if(Array.isArray(data47)){if(data47.length > 3){const err124 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}if(data47.length < 1){const err125 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}const len3 = data47.length;for(let i1=0; i1<len3; i1++){let data48 = data47[i1];if(data48 && typeof data48 == "object" && !Array.isArray(data48)){if(data48.path === undefined){const err126 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}for(const key12 in data48){if(!((((key12 === "path") || (key12 === "line")) || (key12 === "end_line")) || (key12 === "label"))){const err127 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}}if(data48.path !== undefined){let data49 = data48.path;if(typeof data49 === "string"){if(func3(data49) > 240){const err128 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}if(func3(data49) < 1){const err129 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}else {const err130 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}}if(data48.line !== undefined){let data50 = data48.line;if(!(((typeof data50 == "number") && (!(data50 % 1) && !isNaN(data50))) && (isFinite(data50)))){const err131 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}if((typeof data50 == "number") && (isFinite(data50))){if(data50 < 1 || isNaN(data50)){const err132 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}}}if(data48.end_line !== undefined){let data51 = data48.end_line;if(!(((typeof data51 == "number") && (!(data51 % 1) && !isNaN(data51))) && (isFinite(data51)))){const err133 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}if((typeof data51 == "number") && (isFinite(data51))){if(data51 < 1 || isNaN(data51)){const err134 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}}}if(data48.label !== undefined){let data52 = data48.label;if(typeof data52 === "string"){if(func3(data52) > 48){const err135 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}if(func3(data52) < 1){const err136 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}else {const err137 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}}else {const err138 = {instancePath:instancePath+"/participants/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}}else {const err139 = {instancePath:instancePath+"/participants/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}}else {const err140 = {instancePath:instancePath+"/participants/" + i0,schemaPath:"#/properties/participants/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}}else {const err141 = {instancePath:instancePath+"/participants",schemaPath:"#/properties/participants/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}}if(data.segments !== undefined){let data53 = data.segments;if(Array.isArray(data53)){const len4 = data53.length;for(let i2=0; i2<len4; i2++){let data54 = data53[i2];if(data54 && typeof data54 == "object" && !Array.isArray(data54)){if(data54.from === undefined){const err142 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}if(data54.to === undefined){const err143 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}if(data54.label === undefined){const err144 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}for(const key13 in data54){if(!(((key13 === "from") || (key13 === "to")) || (key13 === "label"))){const err145 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}if(data54.from !== undefined){let data55 = data54.from;if(!((typeof data55 == "number") && (isFinite(data55)))){const err146 = {instancePath:instancePath+"/segments/" + i2+"/from",schemaPath:"#/properties/segments/items/properties/from/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}}if(data54.to !== undefined){let data56 = data54.to;if(!((typeof data56 == "number") && (isFinite(data56)))){const err147 = {instancePath:instancePath+"/segments/" + i2+"/to",schemaPath:"#/properties/segments/items/properties/to/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}if(data54.label !== undefined){let data57 = data54.label;if(typeof data57 === "string"){if(func3(data57) < 1){const err148 = {instancePath:instancePath+"/segments/" + i2+"/label",schemaPath:"#/properties/segments/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}else {const err149 = {instancePath:instancePath+"/segments/" + i2+"/label",schemaPath:"#/properties/segments/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}}else {const err150 = {instancePath:instancePath+"/segments/" + i2,schemaPath:"#/properties/segments/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}}else {const err151 = {instancePath:instancePath+"/segments",schemaPath:"#/properties/segments/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}}if(data.messages !== undefined){let data58 = data.messages;if(Array.isArray(data58)){if(data58.length < 1){const err152 = {instancePath:instancePath+"/messages",schemaPath:"#/properties/messages/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}const len5 = data58.length;for(let i3=0; i3<len5; i3++){let data59 = data58[i3];if(data59 && typeof data59 == "object" && !Array.isArray(data59)){if(data59.from === undefined){const err153 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}if(data59.to === undefined){const err154 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}if(data59.y === undefined){const err155 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "y"},message:"must have required property '"+"y"+"'"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}if(data59.label === undefined){const err156 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}for(const key14 in data59){if(!(((((((key14 === "id") || (key14 === "from")) || (key14 === "to")) || (key14 === "y")) || (key14 === "label")) || (key14 === "variant")) || (key14 === "note"))){const err157 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}if(data59.id !== undefined){let data60 = data59.id;if(typeof data60 === "string"){if(!pattern14.test(data60)){const err158 = {instancePath:instancePath+"/messages/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}else {const err159 = {instancePath:instancePath+"/messages/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}if(data59.from !== undefined){let data61 = data59.from;if(typeof data61 === "string"){if(!pattern14.test(data61)){const err160 = {instancePath:instancePath+"/messages/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}else {const err161 = {instancePath:instancePath+"/messages/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}if(data59.to !== undefined){let data62 = data59.to;if(typeof data62 === "string"){if(!pattern14.test(data62)){const err162 = {instancePath:instancePath+"/messages/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}else {const err163 = {instancePath:instancePath+"/messages/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}}if(data59.y !== undefined){let data63 = data59.y;if((typeof data63 == "number") && (isFinite(data63))){if(data63 < 160 || isNaN(data63)){const err164 = {instancePath:instancePath+"/messages/" + i3+"/y",schemaPath:"#/properties/messages/items/properties/y/minimum",keyword:"minimum",params:{comparison: ">=", limit: 160},message:"must be >= 160"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}else {const err165 = {instancePath:instancePath+"/messages/" + i3+"/y",schemaPath:"#/properties/messages/items/properties/y/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data59.label !== undefined){let data64 = data59.label;if(typeof data64 === "string"){if(func3(data64) < 1){const err166 = {instancePath:instancePath+"/messages/" + i3+"/label",schemaPath:"#/properties/messages/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}else {const err167 = {instancePath:instancePath+"/messages/" + i3+"/label",schemaPath:"#/properties/messages/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data59.variant !== undefined){let data65 = data59.variant;if(!(((((data65 === "default") || (data65 === "emphasis")) || (data65 === "security")) || (data65 === "dashed")) || (data65 === "return"))){const err168 = {instancePath:instancePath+"/messages/" + i3+"/variant",schemaPath:"#/properties/messages/items/properties/variant/enum",keyword:"enum",params:{allowedValues: schema71.properties.messages.items.properties.variant.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}}if(data59.note !== undefined){if(typeof data59.note !== "string"){const err169 = {instancePath:instancePath+"/messages/" + i3+"/note",schemaPath:"#/properties/messages/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}}else {const err170 = {instancePath:instancePath+"/messages/" + i3,schemaPath:"#/properties/messages/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}}else {const err171 = {instancePath:instancePath+"/messages",schemaPath:"#/properties/messages/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(data.activations !== undefined){let data67 = data.activations;if(Array.isArray(data67)){const len6 = data67.length;for(let i4=0; i4<len6; i4++){let data68 = data67[i4];if(data68 && typeof data68 == "object" && !Array.isArray(data68)){if(data68.participant === undefined){const err172 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "participant"},message:"must have required property '"+"participant"+"'"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}if(data68.from === undefined){const err173 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}if(data68.to === undefined){const err174 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}for(const key15 in data68){if(!((((key15 === "participant") || (key15 === "from")) || (key15 === "to")) || (key15 === "type"))){const err175 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}if(data68.participant !== undefined){let data69 = data68.participant;if(typeof data69 === "string"){if(!pattern14.test(data69)){const err176 = {instancePath:instancePath+"/activations/" + i4+"/participant",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}else {const err177 = {instancePath:instancePath+"/activations/" + i4+"/participant",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}if(data68.from !== undefined){let data70 = data68.from;if(!((typeof data70 == "number") && (isFinite(data70)))){const err178 = {instancePath:instancePath+"/activations/" + i4+"/from",schemaPath:"#/properties/activations/items/properties/from/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}if(data68.to !== undefined){let data71 = data68.to;if(!((typeof data71 == "number") && (isFinite(data71)))){const err179 = {instancePath:instancePath+"/activations/" + i4+"/to",schemaPath:"#/properties/activations/items/properties/to/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}}if(data68.type !== undefined){let data72 = data68.type;if(!(((((((data72 === "frontend") || (data72 === "backend")) || (data72 === "database")) || (data72 === "cloud")) || (data72 === "security")) || (data72 === "messagebus")) || (data72 === "external"))){const err180 = {instancePath:instancePath+"/activations/" + i4+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema59.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}}else {const err181 = {instancePath:instancePath+"/activations/" + i4,schemaPath:"#/properties/activations/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}}else {const err182 = {instancePath:instancePath+"/activations",schemaPath:"#/properties/activations/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}if(data.cards !== undefined){let data73 = data.cards;if(Array.isArray(data73)){const len7 = data73.length;for(let i5=0; i5<len7; i5++){let data74 = data73[i5];if(data74 && typeof data74 == "object" && !Array.isArray(data74)){if(data74.dot === undefined){const err183 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}if(data74.title === undefined){const err184 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}if(data74.items === undefined){const err185 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}for(const key16 in data74){if(!(((key16 === "dot") || (key16 === "title")) || (key16 === "items"))){const err186 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}}if(data74.dot !== undefined){let data75 = data74.dot;if(!(((((((data75 === "cyan") || (data75 === "emerald")) || (data75 === "violet")) || (data75 === "amber")) || (data75 === "rose")) || (data75 === "orange")) || (data75 === "slate"))){const err187 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema70.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}if(data74.title !== undefined){let data76 = data74.title;if(typeof data76 === "string"){if(func3(data76) < 1){const err188 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}else {const err189 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}if(data74.items !== undefined){let data77 = data74.items;if(Array.isArray(data77)){const len8 = data77.length;for(let i6=0; i6<len8; i6++){if(typeof data77[i6] !== "string"){const err190 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}}else {const err191 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}}else {const err192 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}}else {const err193 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}}else {const err194 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}validate27.errors = vErrors;return errors === 0;}validate27.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const dataflowSchema = validate30;const schema97 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/dataflow.schema.json","title":"Archify Data Flow Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","stages","nodes","flows"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"dataflow"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"$ref":"common.schema.json#/$defs/portableOutputPath"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"default":{"$ref":"common.schema.json#/$defs/legendEntry"},"emphasis":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"dashed":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":360},{"type":"number","minimum":360}],"items":false,"minItems":2,"maxItems":2}}},"stages":{"type":"array","minItems":2,"maxItems":5,"items":{"type":"object","additionalProperties":false,"required":["label"],"properties":{"label":{"type":"string","minLength":1}}}},"nodes":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label","stage","row"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"stage":{"type":"integer","minimum":0},"row":{"type":"integer","minimum":0},"width":{"type":"number","minimum":48},"height":{"type":"number","minimum":36},"yOffset":{"type":"number"}}}},"flows":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1},"classification":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"route":{"enum":["auto","straight","vertical-channel","bottom-channel","top-channel"]},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"channelX":{"type":"number"},"channelY":{"type":"number"},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};const schema121 = {"enum":["left","right","top","bottom"]};const schema125 = {"type":"number","minimum":0.5};function validate31(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate31.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern14.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate31.errors = vErrors;return errors === 0;}validate31.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate30(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/dataflow.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate30.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.stages === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "stages"},message:"must have required property '"+"stages"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.nodes === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "nodes"},message:"must have required property '"+"nodes"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.flows === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "flows"},message:"must have required property '"+"flows"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "stages")) || (key0 === "nodes")) || (key0 === "flows")) || (key0 === "cards"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("dataflow" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "dataflow"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema97.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){let data6 = data2.output;if(typeof data6 === "string"){if(!pattern4.test(data6)){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/0/pattern",keyword:"pattern",params:{pattern: "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},message:"must match pattern \""+"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"+"\""};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}const _errs18 = errors;const _errs19 = errors;if(typeof data6 === "string"){if(!pattern5.test(data6)){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}var valid5 = _errs19 === errors;if(valid5){const err17 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}else {errors = _errs18;if(vErrors !== null){if(_errs18){vErrors.length = _errs18;}else {vErrors = null;}}}const _errs21 = errors;const _errs22 = errors;if(typeof data6 === "string"){if(!pattern6.test(data6)){const err18 = {};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}var valid6 = _errs22 === errors;if(valid6){const err19 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}}const _errs24 = errors;const _errs25 = errors;if(typeof data6 === "string"){if(!pattern7.test(data6)){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}var valid7 = _errs25 === errors;if(valid7){const err21 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}else {errors = _errs24;if(vErrors !== null){if(_errs24){vErrors.length = _errs24;}else {vErrors = null;}}}const _errs27 = errors;const _errs28 = errors;if(typeof data6 === "string"){if(!pattern8.test(data6)){const err22 = {};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}var valid8 = _errs28 === errors;if(valid8){const err23 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/4/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}}const _errs30 = errors;const _errs31 = errors;if(typeof data6 === "string"){if(!pattern9.test(data6)){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}var valid9 = _errs31 === errors;if(valid9){const err25 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/5/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}else {errors = _errs30;if(vErrors !== null){if(_errs30){vErrors.length = _errs30;}else {vErrors = null;}}}const _errs33 = errors;const _errs34 = errors;if(typeof data6 === "string"){if(!pattern10.test(data6)){const err26 = {};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}var valid10 = _errs34 === errors;if(valid10){const err27 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/6/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}const _errs36 = errors;const _errs37 = errors;if(typeof data6 === "string"){if(!pattern11.test(data6)){const err28 = {};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}var valid11 = _errs37 === errors;if(valid11){const err29 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/7/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}else {errors = _errs36;if(vErrors !== null){if(_errs36){vErrors.length = _errs36;}else {vErrors = null;}}}if(typeof data6 === "string"){if(func3(data6) < 1){const err30 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}if(!pattern12.test(data6)){const err31 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/pattern",keyword:"pattern",params:{pattern: "^[^/]+(?:/[^/]+)*$"},message:"must match pattern \""+"^[^/]+(?:/[^/]+)*$"+"\""};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}else {const err32 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err33 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err34 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err35 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema76.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err36 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(data10.revision === undefined){const err37 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err38 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err39 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err41 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema35.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err42 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema35.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern13.test(data14)){const err43 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data2.views !== undefined){if(!(validate31(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate31.errors : vErrors.concat(validate31.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err46 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err47 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema39.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!(((((key4 === "default") || (key4 === "emphasis")) || (key4 === "security")) || (key4 === "dashed")) || (key4 === "database"))){const err48 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}if(data18.default !== undefined){let data19 = data18.default;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err50 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err51 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}if(func3(data20) < 1){const err52 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}else {const err53 = {instancePath:instancePath+"/meta/legend/entries/default/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err54 = {instancePath:instancePath+"/meta/legend/entries/default/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}}else {const err55 = {instancePath:instancePath+"/meta/legend/entries/default",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}}if(data18.emphasis !== undefined){let data22 = data18.emphasis;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err57 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err58 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}if(func3(data23) < 1){const err59 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}else {const err60 = {instancePath:instancePath+"/meta/legend/entries/emphasis/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err61 = {instancePath:instancePath+"/meta/legend/entries/emphasis/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}}else {const err62 = {instancePath:instancePath+"/meta/legend/entries/emphasis",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}}if(data18.security !== undefined){let data25 = data18.security;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err64 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err65 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(func3(data26) < 1){const err66 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err68 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}}else {const err69 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}}if(data18.dashed !== undefined){let data28 = data18.dashed;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err71 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err72 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}if(func3(data29) < 1){const err73 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/legend/entries/dashed/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err75 = {instancePath:instancePath+"/meta/legend/entries/dashed/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}}else {const err76 = {instancePath:instancePath+"/meta/legend/entries/dashed",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}if(data18.database !== undefined){let data31 = data18.database;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err78 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err79 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}if(func3(data32) < 1){const err80 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}else {const err81 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err82 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}}else {const err83 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}}else {const err84 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}}else {const err85 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data2.viewBox !== undefined){let data34 = data2.viewBox;if(Array.isArray(data34)){if(data34.length > 2){const err86 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}if(data34.length < 2){const err87 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}const len0 = data34.length;if(len0 > 0){let data35 = data34[0];if((typeof data35 == "number") && (isFinite(data35))){if(data35 < 360 || isNaN(data35)){const err88 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 360},message:"must be >= 360"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}else {const err89 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}if(len0 > 1){let data36 = data34[1];if((typeof data36 == "number") && (isFinite(data36))){if(data36 < 360 || isNaN(data36)){const err90 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 360},message:"must be >= 360"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}else {const err91 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}const len1 = data34.length;if(!(len1 <= 2)){const err92 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}else {const err93 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}}else {const err94 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}if(data.stages !== undefined){let data37 = data.stages;if(Array.isArray(data37)){if(data37.length > 5){const err95 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}if(data37.length < 2){const err96 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}const len2 = data37.length;for(let i0=0; i0<len2; i0++){let data38 = data37[i0];if(data38 && typeof data38 == "object" && !Array.isArray(data38)){if(data38.label === undefined){const err97 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}for(const key10 in data38){if(!(key10 === "label")){const err98 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data38.label !== undefined){let data39 = data38.label;if(typeof data39 === "string"){if(func3(data39) < 1){const err99 = {instancePath:instancePath+"/stages/" + i0+"/label",schemaPath:"#/properties/stages/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}else {const err100 = {instancePath:instancePath+"/stages/" + i0+"/label",schemaPath:"#/properties/stages/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}}}else {const err101 = {instancePath:instancePath+"/stages/" + i0,schemaPath:"#/properties/stages/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}}else {const err102 = {instancePath:instancePath+"/stages",schemaPath:"#/properties/stages/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data.nodes !== undefined){let data40 = data.nodes;if(Array.isArray(data40)){if(data40.length < 2){const err103 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}const len3 = data40.length;for(let i1=0; i1<len3; i1++){let data41 = data40[i1];if(data41 && typeof data41 == "object" && !Array.isArray(data41)){if(data41.id === undefined){const err104 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}if(data41.type === undefined){const err105 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}if(data41.label === undefined){const err106 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}if(data41.stage === undefined){const err107 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "stage"},message:"must have required property '"+"stage"+"'"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}if(data41.row === undefined){const err108 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/required",keyword:"required",params:{missingProperty: "row"},message:"must have required property '"+"row"+"'"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}for(const key11 in data41){if(!(func1.call(schema97.properties.nodes.items.properties, key11))){const err109 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}if(data41.id !== undefined){let data42 = data41.id;if(typeof data42 === "string"){if(!pattern14.test(data42)){const err110 = {instancePath:instancePath+"/nodes/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}else {const err111 = {instancePath:instancePath+"/nodes/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}if(data41.type !== undefined){let data43 = data41.type;if(!(((((((data43 === "frontend") || (data43 === "backend")) || (data43 === "database")) || (data43 === "cloud")) || (data43 === "security")) || (data43 === "messagebus")) || (data43 === "external"))){const err112 = {instancePath:instancePath+"/nodes/" + i1+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema59.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}}if(data41.label !== undefined){let data44 = data41.label;if(typeof data44 === "string"){if(func3(data44) < 1){const err113 = {instancePath:instancePath+"/nodes/" + i1+"/label",schemaPath:"#/properties/nodes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}else {const err114 = {instancePath:instancePath+"/nodes/" + i1+"/label",schemaPath:"#/properties/nodes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}if(data41.sublabel !== undefined){if(typeof data41.sublabel !== "string"){const err115 = {instancePath:instancePath+"/nodes/" + i1+"/sublabel",schemaPath:"#/properties/nodes/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}if(data41.tag !== undefined){if(typeof data41.tag !== "string"){const err116 = {instancePath:instancePath+"/nodes/" + i1+"/tag",schemaPath:"#/properties/nodes/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}}if(data41.brand !== undefined){let data47 = data41.brand;const _errs134 = errors;let valid40 = false;let passing0 = null;const _errs135 = errors;const _errs137 = errors;let valid41 = false;const _errs138 = errors;if(typeof data47 === "string"){if(func3(data47) > 80){const err117 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}if(!pattern27.test(data47)){const err118 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}}var _valid1 = _errs138 === errors;valid41 = valid41 || _valid1;const _errs139 = errors;if(typeof data47 === "string"){if(!pattern28.test(data47)){const err119 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}var _valid1 = _errs139 === errors;valid41 = valid41 || _valid1;if(!valid41){const err120 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}else {errors = _errs137;if(vErrors !== null){if(_errs137){vErrors.length = _errs137;}else {vErrors = null;}}}if(typeof data47 === "string"){if(func3(data47) > 2048){const err121 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}if(func3(data47) < 1){const err122 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}else {const err123 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}var _valid0 = _errs135 === errors;if(_valid0){valid40 = true;passing0 = 0;}const _errs140 = errors;if(data47 && typeof data47 == "object" && !Array.isArray(data47)){if(data47.url === undefined){const err124 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}if(data47.sha256 === undefined){const err125 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}for(const key12 in data47){if(!((key12 === "url") || (key12 === "sha256"))){const err126 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}if(data47.url !== undefined){let data48 = data47.url;if(typeof data48 === "string"){if(func3(data48) > 2048){const err127 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}if(func3(data48) < 8){const err128 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}if(!pattern28.test(data48)){const err129 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}}else {const err130 = {instancePath:instancePath+"/nodes/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}}if(data47.sha256 !== undefined){let data49 = data47.sha256;if(typeof data49 === "string"){if(!pattern30.test(data49)){const err131 = {instancePath:instancePath+"/nodes/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}}else {const err132 = {instancePath:instancePath+"/nodes/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}}}else {const err133 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}var _valid0 = _errs140 === errors;if(_valid0 && valid40){valid40 = false;passing0 = [passing0, 1];}else {if(_valid0){valid40 = true;passing0 = 1;}}if(!valid40){const err134 = {instancePath:instancePath+"/nodes/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}else {errors = _errs134;if(vErrors !== null){if(_errs134){vErrors.length = _errs134;}else {vErrors = null;}}}}if(data41.sources !== undefined){let data50 = data41.sources;if(Array.isArray(data50)){if(data50.length > 3){const err135 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}if(data50.length < 1){const err136 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}const len4 = data50.length;for(let i2=0; i2<len4; i2++){let data51 = data50[i2];if(data51 && typeof data51 == "object" && !Array.isArray(data51)){if(data51.path === undefined){const err137 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}for(const key13 in data51){if(!((((key13 === "path") || (key13 === "line")) || (key13 === "end_line")) || (key13 === "label"))){const err138 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}if(data51.path !== undefined){let data52 = data51.path;if(typeof data52 === "string"){if(func3(data52) > 240){const err139 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}if(func3(data52) < 1){const err140 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}else {const err141 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}}if(data51.line !== undefined){let data53 = data51.line;if(!(((typeof data53 == "number") && (!(data53 % 1) && !isNaN(data53))) && (isFinite(data53)))){const err142 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}if((typeof data53 == "number") && (isFinite(data53))){if(data53 < 1 || isNaN(data53)){const err143 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}}if(data51.end_line !== undefined){let data54 = data51.end_line;if(!(((typeof data54 == "number") && (!(data54 % 1) && !isNaN(data54))) && (isFinite(data54)))){const err144 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}if((typeof data54 == "number") && (isFinite(data54))){if(data54 < 1 || isNaN(data54)){const err145 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}}}if(data51.label !== undefined){let data55 = data51.label;if(typeof data55 === "string"){if(func3(data55) > 48){const err146 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}if(func3(data55) < 1){const err147 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}}else {const err148 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}}}else {const err149 = {instancePath:instancePath+"/nodes/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}}}else {const err150 = {instancePath:instancePath+"/nodes/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data41.stage !== undefined){let data56 = data41.stage;if(!(((typeof data56 == "number") && (!(data56 % 1) && !isNaN(data56))) && (isFinite(data56)))){const err151 = {instancePath:instancePath+"/nodes/" + i1+"/stage",schemaPath:"#/properties/nodes/items/properties/stage/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if((typeof data56 == "number") && (isFinite(data56))){if(data56 < 0 || isNaN(data56)){const err152 = {instancePath:instancePath+"/nodes/" + i1+"/stage",schemaPath:"#/properties/nodes/items/properties/stage/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}}}if(data41.row !== undefined){let data57 = data41.row;if(!(((typeof data57 == "number") && (!(data57 % 1) && !isNaN(data57))) && (isFinite(data57)))){const err153 = {instancePath:instancePath+"/nodes/" + i1+"/row",schemaPath:"#/properties/nodes/items/properties/row/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}if((typeof data57 == "number") && (isFinite(data57))){if(data57 < 0 || isNaN(data57)){const err154 = {instancePath:instancePath+"/nodes/" + i1+"/row",schemaPath:"#/properties/nodes/items/properties/row/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}}if(data41.width !== undefined){let data58 = data41.width;if((typeof data58 == "number") && (isFinite(data58))){if(data58 < 48 || isNaN(data58)){const err155 = {instancePath:instancePath+"/nodes/" + i1+"/width",schemaPath:"#/properties/nodes/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 48},message:"must be >= 48"};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}else {const err156 = {instancePath:instancePath+"/nodes/" + i1+"/width",schemaPath:"#/properties/nodes/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}if(data41.height !== undefined){let data59 = data41.height;if((typeof data59 == "number") && (isFinite(data59))){if(data59 < 36 || isNaN(data59)){const err157 = {instancePath:instancePath+"/nodes/" + i1+"/height",schemaPath:"#/properties/nodes/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 36},message:"must be >= 36"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}}else {const err158 = {instancePath:instancePath+"/nodes/" + i1+"/height",schemaPath:"#/properties/nodes/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}}if(data41.yOffset !== undefined){let data60 = data41.yOffset;if(!((typeof data60 == "number") && (isFinite(data60)))){const err159 = {instancePath:instancePath+"/nodes/" + i1+"/yOffset",schemaPath:"#/properties/nodes/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}}}else {const err160 = {instancePath:instancePath+"/nodes/" + i1,schemaPath:"#/properties/nodes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}}}else {const err161 = {instancePath:instancePath+"/nodes",schemaPath:"#/properties/nodes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}}if(data.flows !== undefined){let data61 = data.flows;if(Array.isArray(data61)){const len5 = data61.length;for(let i3=0; i3<len5; i3++){let data62 = data61[i3];if(data62 && typeof data62 == "object" && !Array.isArray(data62)){if(data62.from === undefined){const err162 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}if(data62.to === undefined){const err163 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}if(data62.label === undefined){const err164 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}for(const key14 in data62){if(!(func1.call(schema97.properties.flows.items.properties, key14))){const err165 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data62.id !== undefined){let data63 = data62.id;if(typeof data63 === "string"){if(!pattern14.test(data63)){const err166 = {instancePath:instancePath+"/flows/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}}else {const err167 = {instancePath:instancePath+"/flows/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}if(data62.from !== undefined){let data64 = data62.from;if(typeof data64 === "string"){if(!pattern14.test(data64)){const err168 = {instancePath:instancePath+"/flows/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}}else {const err169 = {instancePath:instancePath+"/flows/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}if(data62.to !== undefined){let data65 = data62.to;if(typeof data65 === "string"){if(!pattern14.test(data65)){const err170 = {instancePath:instancePath+"/flows/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}}else {const err171 = {instancePath:instancePath+"/flows/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}if(data62.label !== undefined){let data66 = data62.label;if(typeof data66 === "string"){if(func3(data66) < 1){const err172 = {instancePath:instancePath+"/flows/" + i3+"/label",schemaPath:"#/properties/flows/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}else {const err173 = {instancePath:instancePath+"/flows/" + i3+"/label",schemaPath:"#/properties/flows/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}if(data62.classification !== undefined){if(typeof data62.classification !== "string"){const err174 = {instancePath:instancePath+"/flows/" + i3+"/classification",schemaPath:"#/properties/flows/items/properties/classification/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}if(data62.variant !== undefined){let data68 = data62.variant;if(!((((data68 === "default") || (data68 === "emphasis")) || (data68 === "security")) || (data68 === "dashed"))){const err175 = {instancePath:instancePath+"/flows/" + i3+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}if(data62.route !== undefined){let data69 = data62.route;if(!(((((data69 === "auto") || (data69 === "straight")) || (data69 === "vertical-channel")) || (data69 === "bottom-channel")) || (data69 === "top-channel"))){const err176 = {instancePath:instancePath+"/flows/" + i3+"/route",schemaPath:"#/properties/flows/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema97.properties.flows.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}if(data62.fromSide !== undefined){let data70 = data62.fromSide;if(!((((data70 === "left") || (data70 === "right")) || (data70 === "top")) || (data70 === "bottom"))){const err177 = {instancePath:instancePath+"/flows/" + i3+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}if(data62.toSide !== undefined){let data71 = data62.toSide;if(!((((data71 === "left") || (data71 === "right")) || (data71 === "top")) || (data71 === "bottom"))){const err178 = {instancePath:instancePath+"/flows/" + i3+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}if(data62.channelX !== undefined){let data72 = data62.channelX;if(!((typeof data72 == "number") && (isFinite(data72)))){const err179 = {instancePath:instancePath+"/flows/" + i3+"/channelX",schemaPath:"#/properties/flows/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}}if(data62.channelY !== undefined){let data73 = data62.channelY;if(!((typeof data73 == "number") && (isFinite(data73)))){const err180 = {instancePath:instancePath+"/flows/" + i3+"/channelY",schemaPath:"#/properties/flows/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}if(data62.labelAt !== undefined){let data74 = data62.labelAt;if(Array.isArray(data74)){if(data74.length > 2){const err181 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}if(data74.length < 2){const err182 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}const len6 = data74.length;if(len6 > 0){let data75 = data74[0];if(!((typeof data75 == "number") && (isFinite(data75)))){const err183 = {instancePath:instancePath+"/flows/" + i3+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}if(len6 > 1){let data76 = data74[1];if(!((typeof data76 == "number") && (isFinite(data76)))){const err184 = {instancePath:instancePath+"/flows/" + i3+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}const len7 = data74.length;if(!(len7 <= 2)){const err185 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}}else {const err186 = {instancePath:instancePath+"/flows/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}}if(data62.labelDx !== undefined){let data77 = data62.labelDx;if(!((typeof data77 == "number") && (isFinite(data77)))){const err187 = {instancePath:instancePath+"/flows/" + i3+"/labelDx",schemaPath:"#/properties/flows/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}if(data62.labelDy !== undefined){let data78 = data62.labelDy;if(!((typeof data78 == "number") && (isFinite(data78)))){const err188 = {instancePath:instancePath+"/flows/" + i3+"/labelDy",schemaPath:"#/properties/flows/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}if(data62.labelSegment !== undefined){let data79 = data62.labelSegment;if(!(((typeof data79 == "number") && (!(data79 % 1) && !isNaN(data79))) && (isFinite(data79)))){const err189 = {instancePath:instancePath+"/flows/" + i3+"/labelSegment",schemaPath:"#/properties/flows/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}if((typeof data79 == "number") && (isFinite(data79))){if(data79 < 0 || isNaN(data79)){const err190 = {instancePath:instancePath+"/flows/" + i3+"/labelSegment",schemaPath:"#/properties/flows/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}}if(data62.via !== undefined){let data80 = data62.via;if(Array.isArray(data80)){const len8 = data80.length;for(let i4=0; i4<len8; i4++){let data81 = data80[i4];if(Array.isArray(data81)){if(data81.length > 2){const err191 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}if(data81.length < 2){const err192 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}const len9 = data81.length;if(len9 > 0){let data82 = data81[0];if(!((typeof data82 == "number") && (isFinite(data82)))){const err193 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}if(len9 > 1){let data83 = data81[1];if(!((typeof data83 == "number") && (isFinite(data83)))){const err194 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}const len10 = data81.length;if(!(len10 <= 2)){const err195 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}else {const err196 = {instancePath:instancePath+"/flows/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}}}else {const err197 = {instancePath:instancePath+"/flows/" + i3+"/via",schemaPath:"#/properties/flows/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}}if(data62.width !== undefined){let data84 = data62.width;if((typeof data84 == "number") && (isFinite(data84))){if(data84 < 0.5 || isNaN(data84)){const err198 = {instancePath:instancePath+"/flows/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}}else {const err199 = {instancePath:instancePath+"/flows/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}}else {const err200 = {instancePath:instancePath+"/flows/" + i3,schemaPath:"#/properties/flows/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}}}else {const err201 = {instancePath:instancePath+"/flows",schemaPath:"#/properties/flows/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}}if(data.cards !== undefined){let data85 = data.cards;if(Array.isArray(data85)){const len11 = data85.length;for(let i5=0; i5<len11; i5++){let data86 = data85[i5];if(data86 && typeof data86 == "object" && !Array.isArray(data86)){if(data86.dot === undefined){const err202 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}if(data86.title === undefined){const err203 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}if(data86.items === undefined){const err204 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}for(const key15 in data86){if(!(((key15 === "dot") || (key15 === "title")) || (key15 === "items"))){const err205 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}if(data86.dot !== undefined){let data87 = data86.dot;if(!(((((((data87 === "cyan") || (data87 === "emerald")) || (data87 === "violet")) || (data87 === "amber")) || (data87 === "rose")) || (data87 === "orange")) || (data87 === "slate"))){const err206 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema70.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}if(data86.title !== undefined){let data88 = data86.title;if(typeof data88 === "string"){if(func3(data88) < 1){const err207 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}}else {const err208 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}}if(data86.items !== undefined){let data89 = data86.items;if(Array.isArray(data89)){const len12 = data89.length;for(let i6=0; i6<len12; i6++){if(typeof data89[i6] !== "string"){const err209 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}}else {const err210 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}}}else {const err211 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}}}else {const err212 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}}}else {const err213 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}validate30.errors = vErrors;return errors === 0;}validate30.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const lifecycleSchema = validate33;const schema127 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/lifecycle.schema.json","title":"Archify Lifecycle Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","lanes","states","transitions"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"lifecycle"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"$ref":"common.schema.json#/$defs/portableOutputPath"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"start":{"$ref":"common.schema.json#/$defs/legendEntry"},"active":{"$ref":"common.schema.json#/$defs/legendEntry"},"waiting":{"$ref":"common.schema.json#/$defs/legendEntry"},"decision":{"$ref":"common.schema.json#/$defs/legendEntry"},"success":{"$ref":"common.schema.json#/$defs/legendEntry"},"failure":{"$ref":"common.schema.json#/$defs/legendEntry"},"neutral":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":420},{"type":"number","minimum":566}],"items":false,"minItems":2,"maxItems":2}}},"lanes":{"type":"array","minItems":1,"maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["id","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string","minLength":1}}}},"states":{"type":"array","minItems":2,"items":{"type":"object","additionalProperties":false,"required":["id","type","label","lane","col"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"enum":["start","active","waiting","decision","success","failure","neutral","external"]},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"step":{"type":"string"},"lane":{"$ref":"common.schema.json#/$defs/id"},"col":{"type":"integer","minimum":0,"maximum":4},"width":{"type":"number","minimum":48},"height":{"type":"number","minimum":36},"yOffset":{"type":"number"}}}},"transitions":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"note":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"route":{"enum":["auto","straight","drop","bottom-channel","top-channel","right-channel","left-channel"]},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"channelX":{"type":"number"},"channelY":{"type":"number"},"cornerRadius":{"type":"number","minimum":0},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};function validate34(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate34.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern14.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate34.errors = vErrors;return errors === 0;}validate34.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate33(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/lifecycle.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate33.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.lanes === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "lanes"},message:"must have required property '"+"lanes"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(data.states === undefined){const err4 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "states"},message:"must have required property '"+"states"+"'"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}if(data.transitions === undefined){const err5 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "transitions"},message:"must have required property '"+"transitions"+"'"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}for(const key0 in data){if(!(((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "lanes")) || (key0 === "states")) || (key0 === "transitions")) || (key0 === "cards"))){const err6 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err7 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}}if(data.diagram_type !== undefined){if("lifecycle" !== data.diagram_type){const err8 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "lifecycle"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err9 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}for(const key1 in data2){if(!(func1.call(schema127.properties.meta.properties, key1))){const err10 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err11 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err13 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err14 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}if(data2.output !== undefined){let data6 = data2.output;if(typeof data6 === "string"){if(!pattern4.test(data6)){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/0/pattern",keyword:"pattern",params:{pattern: "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},message:"must match pattern \""+"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"+"\""};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}const _errs18 = errors;const _errs19 = errors;if(typeof data6 === "string"){if(!pattern5.test(data6)){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}var valid5 = _errs19 === errors;if(valid5){const err17 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}else {errors = _errs18;if(vErrors !== null){if(_errs18){vErrors.length = _errs18;}else {vErrors = null;}}}const _errs21 = errors;const _errs22 = errors;if(typeof data6 === "string"){if(!pattern6.test(data6)){const err18 = {};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}var valid6 = _errs22 === errors;if(valid6){const err19 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}}const _errs24 = errors;const _errs25 = errors;if(typeof data6 === "string"){if(!pattern7.test(data6)){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}var valid7 = _errs25 === errors;if(valid7){const err21 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}else {errors = _errs24;if(vErrors !== null){if(_errs24){vErrors.length = _errs24;}else {vErrors = null;}}}const _errs27 = errors;const _errs28 = errors;if(typeof data6 === "string"){if(!pattern8.test(data6)){const err22 = {};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}var valid8 = _errs28 === errors;if(valid8){const err23 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/4/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}}const _errs30 = errors;const _errs31 = errors;if(typeof data6 === "string"){if(!pattern9.test(data6)){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}var valid9 = _errs31 === errors;if(valid9){const err25 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/5/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}else {errors = _errs30;if(vErrors !== null){if(_errs30){vErrors.length = _errs30;}else {vErrors = null;}}}const _errs33 = errors;const _errs34 = errors;if(typeof data6 === "string"){if(!pattern10.test(data6)){const err26 = {};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}var valid10 = _errs34 === errors;if(valid10){const err27 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/6/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}const _errs36 = errors;const _errs37 = errors;if(typeof data6 === "string"){if(!pattern11.test(data6)){const err28 = {};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}}var valid11 = _errs37 === errors;if(valid11){const err29 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/7/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}else {errors = _errs36;if(vErrors !== null){if(_errs36){vErrors.length = _errs36;}else {vErrors = null;}}}if(typeof data6 === "string"){if(func3(data6) < 1){const err30 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}if(!pattern12.test(data6)){const err31 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/pattern",keyword:"pattern",params:{pattern: "^[^/]+(?:/[^/]+)*$"},message:"must match pattern \""+"^[^/]+(?:/[^/]+)*$"+"\""};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}else {const err32 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err33 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err34 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err35 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema76.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}}if(data2.repository !== undefined){let data10 = data2.repository;if(data10 && typeof data10 == "object" && !Array.isArray(data10)){if(data10.url === undefined){const err36 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}if(data10.revision === undefined){const err37 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}for(const key2 in data10){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err38 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}if(data10.url !== undefined){let data11 = data10.url;if(typeof data11 === "string"){if(func3(data11) < 1){const err39 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}else {const err40 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data10.provider !== undefined){let data12 = data10.provider;if(!((data12 === "github") || (data12 === "gitee"))){const err41 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema35.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data10.link_mode !== undefined){let data13 = data10.link_mode;if(!((data13 === "web") || (data13 === "local-only"))){const err42 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema35.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}if(data10.revision !== undefined){let data14 = data10.revision;if(typeof data14 === "string"){if(!pattern13.test(data14)){const err43 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}else {const err44 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}}else {const err45 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data2.views !== undefined){if(!(validate34(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate34.errors : vErrors.concat(validate34.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data16 = data2.legend;if(data16 && typeof data16 == "object" && !Array.isArray(data16)){for(const key3 in data16){if(!((key3 === "mode") || (key3 === "entries"))){const err46 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data16.mode !== undefined){let data17 = data16.mode;if(!(((data17 === "auto") || (data17 === "all")) || (data17 === "hidden"))){const err47 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema39.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data16.entries !== undefined){let data18 = data16.entries;if(data18 && typeof data18 == "object" && !Array.isArray(data18)){for(const key4 in data18){if(!((((((((key4 === "start") || (key4 === "active")) || (key4 === "waiting")) || (key4 === "decision")) || (key4 === "success")) || (key4 === "failure")) || (key4 === "neutral")) || (key4 === "external"))){const err48 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}}if(data18.start !== undefined){let data19 = data18.start;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){if(Object.keys(data19).length < 1){const err49 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}for(const key5 in data19){if(!((key5 === "label") || (key5 === "visible"))){const err50 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}}if(data19.label !== undefined){let data20 = data19.label;if(typeof data20 === "string"){if(func3(data20) > 80){const err51 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}if(func3(data20) < 1){const err52 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}else {const err53 = {instancePath:instancePath+"/meta/legend/entries/start/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}if(data19.visible !== undefined){if(typeof data19.visible !== "boolean"){const err54 = {instancePath:instancePath+"/meta/legend/entries/start/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}}else {const err55 = {instancePath:instancePath+"/meta/legend/entries/start",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}}if(data18.active !== undefined){let data22 = data18.active;if(data22 && typeof data22 == "object" && !Array.isArray(data22)){if(Object.keys(data22).length < 1){const err56 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}for(const key6 in data22){if(!((key6 === "label") || (key6 === "visible"))){const err57 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}}if(data22.label !== undefined){let data23 = data22.label;if(typeof data23 === "string"){if(func3(data23) > 80){const err58 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}if(func3(data23) < 1){const err59 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}else {const err60 = {instancePath:instancePath+"/meta/legend/entries/active/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}if(data22.visible !== undefined){if(typeof data22.visible !== "boolean"){const err61 = {instancePath:instancePath+"/meta/legend/entries/active/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}}else {const err62 = {instancePath:instancePath+"/meta/legend/entries/active",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}}if(data18.waiting !== undefined){let data25 = data18.waiting;if(data25 && typeof data25 == "object" && !Array.isArray(data25)){if(Object.keys(data25).length < 1){const err63 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}for(const key7 in data25){if(!((key7 === "label") || (key7 === "visible"))){const err64 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}}if(data25.label !== undefined){let data26 = data25.label;if(typeof data26 === "string"){if(func3(data26) > 80){const err65 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}if(func3(data26) < 1){const err66 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}else {const err67 = {instancePath:instancePath+"/meta/legend/entries/waiting/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}if(data25.visible !== undefined){if(typeof data25.visible !== "boolean"){const err68 = {instancePath:instancePath+"/meta/legend/entries/waiting/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}}else {const err69 = {instancePath:instancePath+"/meta/legend/entries/waiting",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}}if(data18.decision !== undefined){let data28 = data18.decision;if(data28 && typeof data28 == "object" && !Array.isArray(data28)){if(Object.keys(data28).length < 1){const err70 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}for(const key8 in data28){if(!((key8 === "label") || (key8 === "visible"))){const err71 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}}if(data28.label !== undefined){let data29 = data28.label;if(typeof data29 === "string"){if(func3(data29) > 80){const err72 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}if(func3(data29) < 1){const err73 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}else {const err74 = {instancePath:instancePath+"/meta/legend/entries/decision/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}if(data28.visible !== undefined){if(typeof data28.visible !== "boolean"){const err75 = {instancePath:instancePath+"/meta/legend/entries/decision/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}}else {const err76 = {instancePath:instancePath+"/meta/legend/entries/decision",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}}if(data18.success !== undefined){let data31 = data18.success;if(data31 && typeof data31 == "object" && !Array.isArray(data31)){if(Object.keys(data31).length < 1){const err77 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}for(const key9 in data31){if(!((key9 === "label") || (key9 === "visible"))){const err78 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}}if(data31.label !== undefined){let data32 = data31.label;if(typeof data32 === "string"){if(func3(data32) > 80){const err79 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}if(func3(data32) < 1){const err80 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}else {const err81 = {instancePath:instancePath+"/meta/legend/entries/success/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}if(data31.visible !== undefined){if(typeof data31.visible !== "boolean"){const err82 = {instancePath:instancePath+"/meta/legend/entries/success/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}}else {const err83 = {instancePath:instancePath+"/meta/legend/entries/success",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}}if(data18.failure !== undefined){let data34 = data18.failure;if(data34 && typeof data34 == "object" && !Array.isArray(data34)){if(Object.keys(data34).length < 1){const err84 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}for(const key10 in data34){if(!((key10 === "label") || (key10 === "visible"))){const err85 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}}if(data34.label !== undefined){let data35 = data34.label;if(typeof data35 === "string"){if(func3(data35) > 80){const err86 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}if(func3(data35) < 1){const err87 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}else {const err88 = {instancePath:instancePath+"/meta/legend/entries/failure/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}if(data34.visible !== undefined){if(typeof data34.visible !== "boolean"){const err89 = {instancePath:instancePath+"/meta/legend/entries/failure/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}}else {const err90 = {instancePath:instancePath+"/meta/legend/entries/failure",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}}if(data18.neutral !== undefined){let data37 = data18.neutral;if(data37 && typeof data37 == "object" && !Array.isArray(data37)){if(Object.keys(data37).length < 1){const err91 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}for(const key11 in data37){if(!((key11 === "label") || (key11 === "visible"))){const err92 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}}if(data37.label !== undefined){let data38 = data37.label;if(typeof data38 === "string"){if(func3(data38) > 80){const err93 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}if(func3(data38) < 1){const err94 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}else {const err95 = {instancePath:instancePath+"/meta/legend/entries/neutral/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}if(data37.visible !== undefined){if(typeof data37.visible !== "boolean"){const err96 = {instancePath:instancePath+"/meta/legend/entries/neutral/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}}else {const err97 = {instancePath:instancePath+"/meta/legend/entries/neutral",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}if(data18.external !== undefined){let data40 = data18.external;if(data40 && typeof data40 == "object" && !Array.isArray(data40)){if(Object.keys(data40).length < 1){const err98 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}for(const key12 in data40){if(!((key12 === "label") || (key12 === "visible"))){const err99 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}}if(data40.label !== undefined){let data41 = data40.label;if(typeof data41 === "string"){if(func3(data41) > 80){const err100 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}if(func3(data41) < 1){const err101 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}else {const err102 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(data40.visible !== undefined){if(typeof data40.visible !== "boolean"){const err103 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}}else {const err104 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}}else {const err105 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}}else {const err106 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}}if(data2.viewBox !== undefined){let data43 = data2.viewBox;if(Array.isArray(data43)){if(data43.length > 2){const err107 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}if(data43.length < 2){const err108 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}const len0 = data43.length;if(len0 > 0){let data44 = data43[0];if((typeof data44 == "number") && (isFinite(data44))){if(data44 < 420 || isNaN(data44)){const err109 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 420},message:"must be >= 420"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}else {const err110 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}if(len0 > 1){let data45 = data43[1];if((typeof data45 == "number") && (isFinite(data45))){if(data45 < 566 || isNaN(data45)){const err111 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 566},message:"must be >= 566"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}}else {const err112 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}}const len1 = data43.length;if(!(len1 <= 2)){const err113 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}else {const err114 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}}else {const err115 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}if(data.lanes !== undefined){let data46 = data.lanes;if(Array.isArray(data46)){if(data46.length > 4){const err116 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/maxItems",keyword:"maxItems",params:{limit: 4},message:"must NOT have more than 4 items"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}if(data46.length < 1){const err117 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}const len2 = data46.length;for(let i0=0; i0<len2; i0++){let data47 = data46[i0];if(data47 && typeof data47 == "object" && !Array.isArray(data47)){if(data47.id === undefined){const err118 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}if(data47.label === undefined){const err119 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}for(const key13 in data47){if(!((key13 === "id") || (key13 === "label"))){const err120 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}if(data47.id !== undefined){let data48 = data47.id;if(typeof data48 === "string"){if(!pattern14.test(data48)){const err121 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}else {const err122 = {instancePath:instancePath+"/lanes/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}if(data47.label !== undefined){let data49 = data47.label;if(typeof data49 === "string"){if(func3(data49) < 1){const err123 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}else {const err124 = {instancePath:instancePath+"/lanes/" + i0+"/label",schemaPath:"#/properties/lanes/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}}}else {const err125 = {instancePath:instancePath+"/lanes/" + i0,schemaPath:"#/properties/lanes/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}}}else {const err126 = {instancePath:instancePath+"/lanes",schemaPath:"#/properties/lanes/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}if(data.states !== undefined){let data50 = data.states;if(Array.isArray(data50)){if(data50.length < 2){const err127 = {instancePath:instancePath+"/states",schemaPath:"#/properties/states/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}const len3 = data50.length;for(let i1=0; i1<len3; i1++){let data51 = data50[i1];if(data51 && typeof data51 == "object" && !Array.isArray(data51)){if(data51.id === undefined){const err128 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}if(data51.type === undefined){const err129 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}if(data51.label === undefined){const err130 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}if(data51.lane === undefined){const err131 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "lane"},message:"must have required property '"+"lane"+"'"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}if(data51.col === undefined){const err132 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/required",keyword:"required",params:{missingProperty: "col"},message:"must have required property '"+"col"+"'"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}for(const key14 in data51){if(!(func1.call(schema127.properties.states.items.properties, key14))){const err133 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}if(data51.id !== undefined){let data52 = data51.id;if(typeof data52 === "string"){if(!pattern14.test(data52)){const err134 = {instancePath:instancePath+"/states/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}}else {const err135 = {instancePath:instancePath+"/states/" + i1+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}}if(data51.type !== undefined){let data53 = data51.type;if(!((((((((data53 === "start") || (data53 === "active")) || (data53 === "waiting")) || (data53 === "decision")) || (data53 === "success")) || (data53 === "failure")) || (data53 === "neutral")) || (data53 === "external"))){const err136 = {instancePath:instancePath+"/states/" + i1+"/type",schemaPath:"#/properties/states/items/properties/type/enum",keyword:"enum",params:{allowedValues: schema127.properties.states.items.properties.type.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}if(data51.label !== undefined){let data54 = data51.label;if(typeof data54 === "string"){if(func3(data54) < 1){const err137 = {instancePath:instancePath+"/states/" + i1+"/label",schemaPath:"#/properties/states/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}else {const err138 = {instancePath:instancePath+"/states/" + i1+"/label",schemaPath:"#/properties/states/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}if(data51.sublabel !== undefined){if(typeof data51.sublabel !== "string"){const err139 = {instancePath:instancePath+"/states/" + i1+"/sublabel",schemaPath:"#/properties/states/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}if(data51.tag !== undefined){if(typeof data51.tag !== "string"){const err140 = {instancePath:instancePath+"/states/" + i1+"/tag",schemaPath:"#/properties/states/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}if(data51.brand !== undefined){let data57 = data51.brand;const _errs160 = errors;let valid46 = false;let passing0 = null;const _errs161 = errors;const _errs163 = errors;let valid47 = false;const _errs164 = errors;if(typeof data57 === "string"){if(func3(data57) > 80){const err141 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}if(!pattern27.test(data57)){const err142 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}}var _valid1 = _errs164 === errors;valid47 = valid47 || _valid1;const _errs165 = errors;if(typeof data57 === "string"){if(!pattern28.test(data57)){const err143 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}var _valid1 = _errs165 === errors;valid47 = valid47 || _valid1;if(!valid47){const err144 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}else {errors = _errs163;if(vErrors !== null){if(_errs163){vErrors.length = _errs163;}else {vErrors = null;}}}if(typeof data57 === "string"){if(func3(data57) > 2048){const err145 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}if(func3(data57) < 1){const err146 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}}else {const err147 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}var _valid0 = _errs161 === errors;if(_valid0){valid46 = true;passing0 = 0;}const _errs166 = errors;if(data57 && typeof data57 == "object" && !Array.isArray(data57)){if(data57.url === undefined){const err148 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}if(data57.sha256 === undefined){const err149 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}for(const key15 in data57){if(!((key15 === "url") || (key15 === "sha256"))){const err150 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data57.url !== undefined){let data58 = data57.url;if(typeof data58 === "string"){if(func3(data58) > 2048){const err151 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if(func3(data58) < 8){const err152 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}if(!pattern28.test(data58)){const err153 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}}else {const err154 = {instancePath:instancePath+"/states/" + i1+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}if(data57.sha256 !== undefined){let data59 = data57.sha256;if(typeof data59 === "string"){if(!pattern30.test(data59)){const err155 = {instancePath:instancePath+"/states/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}else {const err156 = {instancePath:instancePath+"/states/" + i1+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}}else {const err157 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}var _valid0 = _errs166 === errors;if(_valid0 && valid46){valid46 = false;passing0 = [passing0, 1];}else {if(_valid0){valid46 = true;passing0 = 1;}}if(!valid46){const err158 = {instancePath:instancePath+"/states/" + i1+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}else {errors = _errs160;if(vErrors !== null){if(_errs160){vErrors.length = _errs160;}else {vErrors = null;}}}}if(data51.sources !== undefined){let data60 = data51.sources;if(Array.isArray(data60)){if(data60.length > 3){const err159 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}if(data60.length < 1){const err160 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}const len4 = data60.length;for(let i2=0; i2<len4; i2++){let data61 = data60[i2];if(data61 && typeof data61 == "object" && !Array.isArray(data61)){if(data61.path === undefined){const err161 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}for(const key16 in data61){if(!((((key16 === "path") || (key16 === "line")) || (key16 === "end_line")) || (key16 === "label"))){const err162 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}if(data61.path !== undefined){let data62 = data61.path;if(typeof data62 === "string"){if(func3(data62) > 240){const err163 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}if(func3(data62) < 1){const err164 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}else {const err165 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data61.line !== undefined){let data63 = data61.line;if(!(((typeof data63 == "number") && (!(data63 % 1) && !isNaN(data63))) && (isFinite(data63)))){const err166 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}if((typeof data63 == "number") && (isFinite(data63))){if(data63 < 1 || isNaN(data63)){const err167 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}}if(data61.end_line !== undefined){let data64 = data61.end_line;if(!(((typeof data64 == "number") && (!(data64 % 1) && !isNaN(data64))) && (isFinite(data64)))){const err168 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}if((typeof data64 == "number") && (isFinite(data64))){if(data64 < 1 || isNaN(data64)){const err169 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}}if(data61.label !== undefined){let data65 = data61.label;if(typeof data65 === "string"){if(func3(data65) > 48){const err170 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}if(func3(data65) < 1){const err171 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}else {const err172 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}}else {const err173 = {instancePath:instancePath+"/states/" + i1+"/sources/" + i2,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}}else {const err174 = {instancePath:instancePath+"/states/" + i1+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}if(data51.step !== undefined){if(typeof data51.step !== "string"){const err175 = {instancePath:instancePath+"/states/" + i1+"/step",schemaPath:"#/properties/states/items/properties/step/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}}if(data51.lane !== undefined){let data67 = data51.lane;if(typeof data67 === "string"){if(!pattern14.test(data67)){const err176 = {instancePath:instancePath+"/states/" + i1+"/lane",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}else {const err177 = {instancePath:instancePath+"/states/" + i1+"/lane",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}}if(data51.col !== undefined){let data68 = data51.col;if(!(((typeof data68 == "number") && (!(data68 % 1) && !isNaN(data68))) && (isFinite(data68)))){const err178 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}if((typeof data68 == "number") && (isFinite(data68))){if(data68 > 4 || isNaN(data68)){const err179 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/maximum",keyword:"maximum",params:{comparison: "<=", limit: 4},message:"must be <= 4"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}if(data68 < 0 || isNaN(data68)){const err180 = {instancePath:instancePath+"/states/" + i1+"/col",schemaPath:"#/properties/states/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}}}if(data51.width !== undefined){let data69 = data51.width;if((typeof data69 == "number") && (isFinite(data69))){if(data69 < 48 || isNaN(data69)){const err181 = {instancePath:instancePath+"/states/" + i1+"/width",schemaPath:"#/properties/states/items/properties/width/minimum",keyword:"minimum",params:{comparison: ">=", limit: 48},message:"must be >= 48"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}else {const err182 = {instancePath:instancePath+"/states/" + i1+"/width",schemaPath:"#/properties/states/items/properties/width/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}if(data51.height !== undefined){let data70 = data51.height;if((typeof data70 == "number") && (isFinite(data70))){if(data70 < 36 || isNaN(data70)){const err183 = {instancePath:instancePath+"/states/" + i1+"/height",schemaPath:"#/properties/states/items/properties/height/minimum",keyword:"minimum",params:{comparison: ">=", limit: 36},message:"must be >= 36"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}else {const err184 = {instancePath:instancePath+"/states/" + i1+"/height",schemaPath:"#/properties/states/items/properties/height/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data51.yOffset !== undefined){let data71 = data51.yOffset;if(!((typeof data71 == "number") && (isFinite(data71)))){const err185 = {instancePath:instancePath+"/states/" + i1+"/yOffset",schemaPath:"#/properties/states/items/properties/yOffset/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}}}else {const err186 = {instancePath:instancePath+"/states/" + i1,schemaPath:"#/properties/states/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}}}else {const err187 = {instancePath:instancePath+"/states",schemaPath:"#/properties/states/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}if(data.transitions !== undefined){let data72 = data.transitions;if(Array.isArray(data72)){const len5 = data72.length;for(let i3=0; i3<len5; i3++){let data73 = data72[i3];if(data73 && typeof data73 == "object" && !Array.isArray(data73)){if(data73.from === undefined){const err188 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}if(data73.to === undefined){const err189 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}for(const key17 in data73){if(!(func1.call(schema127.properties.transitions.items.properties, key17))){const err190 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}if(data73.id !== undefined){let data74 = data73.id;if(typeof data74 === "string"){if(!pattern14.test(data74)){const err191 = {instancePath:instancePath+"/transitions/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}else {const err192 = {instancePath:instancePath+"/transitions/" + i3+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}if(data73.from !== undefined){let data75 = data73.from;if(typeof data75 === "string"){if(!pattern14.test(data75)){const err193 = {instancePath:instancePath+"/transitions/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}else {const err194 = {instancePath:instancePath+"/transitions/" + i3+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}if(data73.to !== undefined){let data76 = data73.to;if(typeof data76 === "string"){if(!pattern14.test(data76)){const err195 = {instancePath:instancePath+"/transitions/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}}else {const err196 = {instancePath:instancePath+"/transitions/" + i3+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}}if(data73.label !== undefined){if(typeof data73.label !== "string"){const err197 = {instancePath:instancePath+"/transitions/" + i3+"/label",schemaPath:"#/properties/transitions/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}}if(data73.note !== undefined){if(typeof data73.note !== "string"){const err198 = {instancePath:instancePath+"/transitions/" + i3+"/note",schemaPath:"#/properties/transitions/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}}if(data73.variant !== undefined){let data79 = data73.variant;if(!((((data79 === "default") || (data79 === "emphasis")) || (data79 === "security")) || (data79 === "dashed"))){const err199 = {instancePath:instancePath+"/transitions/" + i3+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}if(data73.route !== undefined){let data80 = data73.route;if(!(((((((data80 === "auto") || (data80 === "straight")) || (data80 === "drop")) || (data80 === "bottom-channel")) || (data80 === "top-channel")) || (data80 === "right-channel")) || (data80 === "left-channel"))){const err200 = {instancePath:instancePath+"/transitions/" + i3+"/route",schemaPath:"#/properties/transitions/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema127.properties.transitions.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}}if(data73.fromSide !== undefined){let data81 = data73.fromSide;if(!((((data81 === "left") || (data81 === "right")) || (data81 === "top")) || (data81 === "bottom"))){const err201 = {instancePath:instancePath+"/transitions/" + i3+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}}if(data73.toSide !== undefined){let data82 = data73.toSide;if(!((((data82 === "left") || (data82 === "right")) || (data82 === "top")) || (data82 === "bottom"))){const err202 = {instancePath:instancePath+"/transitions/" + i3+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}}if(data73.channelX !== undefined){let data83 = data73.channelX;if(!((typeof data83 == "number") && (isFinite(data83)))){const err203 = {instancePath:instancePath+"/transitions/" + i3+"/channelX",schemaPath:"#/properties/transitions/items/properties/channelX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}}if(data73.channelY !== undefined){let data84 = data73.channelY;if(!((typeof data84 == "number") && (isFinite(data84)))){const err204 = {instancePath:instancePath+"/transitions/" + i3+"/channelY",schemaPath:"#/properties/transitions/items/properties/channelY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}}if(data73.cornerRadius !== undefined){let data85 = data73.cornerRadius;if((typeof data85 == "number") && (isFinite(data85))){if(data85 < 0 || isNaN(data85)){const err205 = {instancePath:instancePath+"/transitions/" + i3+"/cornerRadius",schemaPath:"#/properties/transitions/items/properties/cornerRadius/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}else {const err206 = {instancePath:instancePath+"/transitions/" + i3+"/cornerRadius",schemaPath:"#/properties/transitions/items/properties/cornerRadius/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}if(data73.labelAt !== undefined){let data86 = data73.labelAt;if(Array.isArray(data86)){if(data86.length > 2){const err207 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}if(data86.length < 2){const err208 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}const len6 = data86.length;if(len6 > 0){let data87 = data86[0];if(!((typeof data87 == "number") && (isFinite(data87)))){const err209 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}if(len6 > 1){let data88 = data86[1];if(!((typeof data88 == "number") && (isFinite(data88)))){const err210 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}}const len7 = data86.length;if(!(len7 <= 2)){const err211 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}}else {const err212 = {instancePath:instancePath+"/transitions/" + i3+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}}if(data73.labelDx !== undefined){let data89 = data73.labelDx;if(!((typeof data89 == "number") && (isFinite(data89)))){const err213 = {instancePath:instancePath+"/transitions/" + i3+"/labelDx",schemaPath:"#/properties/transitions/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}}if(data73.labelDy !== undefined){let data90 = data73.labelDy;if(!((typeof data90 == "number") && (isFinite(data90)))){const err214 = {instancePath:instancePath+"/transitions/" + i3+"/labelDy",schemaPath:"#/properties/transitions/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}}if(data73.labelSegment !== undefined){let data91 = data73.labelSegment;if(!(((typeof data91 == "number") && (!(data91 % 1) && !isNaN(data91))) && (isFinite(data91)))){const err215 = {instancePath:instancePath+"/transitions/" + i3+"/labelSegment",schemaPath:"#/properties/transitions/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}if((typeof data91 == "number") && (isFinite(data91))){if(data91 < 0 || isNaN(data91)){const err216 = {instancePath:instancePath+"/transitions/" + i3+"/labelSegment",schemaPath:"#/properties/transitions/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}}if(data73.via !== undefined){let data92 = data73.via;if(Array.isArray(data92)){const len8 = data92.length;for(let i4=0; i4<len8; i4++){let data93 = data92[i4];if(Array.isArray(data93)){if(data93.length > 2){const err217 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}if(data93.length < 2){const err218 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}const len9 = data93.length;if(len9 > 0){let data94 = data93[0];if(!((typeof data94 == "number") && (isFinite(data94)))){const err219 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}if(len9 > 1){let data95 = data93[1];if(!((typeof data95 == "number") && (isFinite(data95)))){const err220 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}}const len10 = data93.length;if(!(len10 <= 2)){const err221 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}else {const err222 = {instancePath:instancePath+"/transitions/" + i3+"/via/" + i4,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}}}else {const err223 = {instancePath:instancePath+"/transitions/" + i3+"/via",schemaPath:"#/properties/transitions/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err223];}else {vErrors.push(err223);}errors++;}}if(data73.width !== undefined){let data96 = data73.width;if((typeof data96 == "number") && (isFinite(data96))){if(data96 < 0.5 || isNaN(data96)){const err224 = {instancePath:instancePath+"/transitions/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err224];}else {vErrors.push(err224);}errors++;}}else {const err225 = {instancePath:instancePath+"/transitions/" + i3+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err225];}else {vErrors.push(err225);}errors++;}}}else {const err226 = {instancePath:instancePath+"/transitions/" + i3,schemaPath:"#/properties/transitions/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err226];}else {vErrors.push(err226);}errors++;}}}else {const err227 = {instancePath:instancePath+"/transitions",schemaPath:"#/properties/transitions/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err227];}else {vErrors.push(err227);}errors++;}}if(data.cards !== undefined){let data97 = data.cards;if(Array.isArray(data97)){const len11 = data97.length;for(let i5=0; i5<len11; i5++){let data98 = data97[i5];if(data98 && typeof data98 == "object" && !Array.isArray(data98)){if(data98.dot === undefined){const err228 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err228];}else {vErrors.push(err228);}errors++;}if(data98.title === undefined){const err229 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err229];}else {vErrors.push(err229);}errors++;}if(data98.items === undefined){const err230 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err230];}else {vErrors.push(err230);}errors++;}for(const key18 in data98){if(!(((key18 === "dot") || (key18 === "title")) || (key18 === "items"))){const err231 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err231];}else {vErrors.push(err231);}errors++;}}if(data98.dot !== undefined){let data99 = data98.dot;if(!(((((((data99 === "cyan") || (data99 === "emerald")) || (data99 === "violet")) || (data99 === "amber")) || (data99 === "rose")) || (data99 === "orange")) || (data99 === "slate"))){const err232 = {instancePath:instancePath+"/cards/" + i5+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema70.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err232];}else {vErrors.push(err232);}errors++;}}if(data98.title !== undefined){let data100 = data98.title;if(typeof data100 === "string"){if(func3(data100) < 1){const err233 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err233];}else {vErrors.push(err233);}errors++;}}else {const err234 = {instancePath:instancePath+"/cards/" + i5+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err234];}else {vErrors.push(err234);}errors++;}}if(data98.items !== undefined){let data101 = data98.items;if(Array.isArray(data101)){const len12 = data101.length;for(let i6=0; i6<len12; i6++){if(typeof data101[i6] !== "string"){const err235 = {instancePath:instancePath+"/cards/" + i5+"/items/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err235];}else {vErrors.push(err235);}errors++;}}}else {const err236 = {instancePath:instancePath+"/cards/" + i5+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err236];}else {vErrors.push(err236);}errors++;}}}else {const err237 = {instancePath:instancePath+"/cards/" + i5,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err237];}else {vErrors.push(err237);}errors++;}}}else {const err238 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err238];}else {vErrors.push(err238);}errors++;}}}else {const err239 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err239];}else {vErrors.push(err239);}errors++;}validate33.errors = vErrors;return errors === 0;}validate33.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};const architectureSchema = validate36;const schema161 = {"$schema":"https://json-schema.org/draft/2020-12/schema","$id":"https://github.com/tt-a1i/archify/schemas/architecture.schema.json","title":"Archify Architecture Diagram","type":"object","additionalProperties":false,"required":["schema_version","diagram_type","meta","components"],"properties":{"schema_version":{"const":1},"diagram_type":{"const":"architecture"},"meta":{"type":"object","additionalProperties":false,"required":["title"],"properties":{"title":{"type":"string","minLength":1},"locale":{"$ref":"common.schema.json#/$defs/locale"},"subtitle":{"type":"string"},"output":{"$ref":"common.schema.json#/$defs/portableOutputPath"},"animation":{"$ref":"common.schema.json#/$defs/animation"},"visual_preset":{"$ref":"common.schema.json#/$defs/visualPreset"},"quality_profile":{"$ref":"common.schema.json#/$defs/qualityProfile"},"engineering_profile":{"enum":["deployment-ownership"]},"repository":{"$ref":"common.schema.json#/$defs/repository"},"views":{"$ref":"common.schema.json#/$defs/guidedViews"},"legend":{"type":"object","additionalProperties":false,"properties":{"mode":{"$ref":"common.schema.json#/$defs/legendMode"},"entries":{"type":"object","additionalProperties":false,"properties":{"frontend":{"$ref":"common.schema.json#/$defs/legendEntry"},"backend":{"$ref":"common.schema.json#/$defs/legendEntry"},"database":{"$ref":"common.schema.json#/$defs/legendEntry"},"cloud":{"$ref":"common.schema.json#/$defs/legendEntry"},"security":{"$ref":"common.schema.json#/$defs/legendEntry"},"messagebus":{"$ref":"common.schema.json#/$defs/legendEntry"},"external":{"$ref":"common.schema.json#/$defs/legendEntry"}}}}},"viewBox":{"type":"array","prefixItems":[{"type":"number","minimum":320},{"type":"number","minimum":240}],"items":false,"minItems":2,"maxItems":2}}},"layout":{"type":"object","additionalProperties":false,"required":["mode"],"properties":{"mode":{"enum":["grid"]},"origin":{"$ref":"common.schema.json#/$defs/point"},"cols":{"type":"integer","minimum":1,"maximum":12},"gapX":{"type":"number","minimum":0},"gapY":{"type":"number","minimum":0},"cellW":{"type":"number","minimum":40},"cellH":{"type":"number","minimum":24}}},"components":{"type":"array","minItems":1,"items":{"type":"object","additionalProperties":false,"required":["id","type","label"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"type":{"$ref":"common.schema.json#/$defs/componentType"},"label":{"type":"string","minLength":1},"sublabel":{"type":"string"},"tag":{"type":"string"},"brand":{"$ref":"common.schema.json#/$defs/brandMark"},"sources":{"$ref":"common.schema.json#/$defs/sourceReferences"},"row":{"type":"integer","minimum":0},"col":{"type":"integer","minimum":0},"pos":{"$ref":"common.schema.json#/$defs/point"},"size":{"type":"array","prefixItems":[{"type":"number","exclusiveMinimum":0},{"type":"number","exclusiveMinimum":0}],"items":false,"minItems":2,"maxItems":2}}}},"boundaries":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","label","wraps"],"properties":{"kind":{"enum":["region","security-group"]},"label":{"type":"string","minLength":1},"wraps":{"type":"array","minItems":1,"items":{"$ref":"common.schema.json#/$defs/id"}},"pad":{"type":"number","minimum":0}}}},"connections":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["from","to"],"properties":{"id":{"$ref":"common.schema.json#/$defs/id"},"from":{"$ref":"common.schema.json#/$defs/id"},"to":{"$ref":"common.schema.json#/$defs/id"},"label":{"type":"string"},"variant":{"$ref":"common.schema.json#/$defs/variant"},"fromSide":{"$ref":"common.schema.json#/$defs/side"},"toSide":{"$ref":"common.schema.json#/$defs/side"},"route":{"enum":["auto","straight","orthogonal-h","orthogonal-v"]},"via":{"type":"array","items":{"$ref":"common.schema.json#/$defs/point"}},"labelAt":{"$ref":"common.schema.json#/$defs/point"},"labelDx":{"type":"number"},"labelDy":{"type":"number"},"labelSegment":{"type":"integer","minimum":0},"width":{"$ref":"common.schema.json#/$defs/relationshipWidth"}}}},"cards":{"$ref":"common.schema.json#/$defs/cards"}}};function validate37(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){let vErrors = null;let errors = 0;const evaluated0 = validate37.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(Array.isArray(data)){if(data.length > 5){const err0 = {instancePath,schemaPath:"#/maxItems",keyword:"maxItems",params:{limit: 5},message:"must NOT have more than 5 items"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(data0 && typeof data0 == "object" && !Array.isArray(data0)){if(data0.id === undefined){const err1 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data0.label === undefined){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data0.focus === undefined){const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/required",keyword:"required",params:{missingProperty: "focus"},message:"must have required property '"+"focus"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data0){if(!((((key0 === "id") || (key0 === "label")) || (key0 === "focus")) || (key0 === "note"))){const err4 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data0.id !== undefined){let data1 = data0.id;if(typeof data1 === "string"){if(!pattern14.test(data1)){const err5 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}else {const err6 = {instancePath:instancePath+"/" + i0+"/id",schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data0.label !== undefined){let data2 = data0.label;if(typeof data2 === "string"){if(func3(data2) > 48){const err7 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(func3(data2) < 1){const err8 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}else {const err9 = {instancePath:instancePath+"/" + i0+"/label",schemaPath:"#/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}if(data0.focus !== undefined){let data3 = data0.focus;if(Array.isArray(data3)){if(data3.length < 1){const err10 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}const len1 = data3.length;for(let i1=0; i1<len1; i1++){let data4 = data3[i1];if(typeof data4 === "string"){if(!pattern14.test(data4)){const err11 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath:instancePath+"/" + i0+"/focus/" + i1,schemaPath:"#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}}else {const err13 = {instancePath:instancePath+"/" + i0+"/focus",schemaPath:"#/items/properties/focus/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}if(data0.note !== undefined){let data5 = data0.note;if(typeof data5 === "string"){if(func3(data5) > 140){const err14 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/maxLength",keyword:"maxLength",params:{limit: 140},message:"must NOT have more than 140 characters"};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}else {const err15 = {instancePath:instancePath+"/" + i0+"/note",schemaPath:"#/items/properties/note/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}}}else {const err16 = {instancePath:instancePath+"/" + i0,schemaPath:"#/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}}else {const err17 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}validate37.errors = vErrors;return errors === 0;}validate37.evaluated = {"items":true,"dynamicProps":false,"dynamicItems":false};function validate36(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://github.com/tt-a1i/archify/schemas/architecture.schema.json" */;let vErrors = null;let errors = 0;const evaluated0 = validate36.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(data && typeof data == "object" && !Array.isArray(data)){if(data.schema_version === undefined){const err0 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "schema_version"},message:"must have required property '"+"schema_version"+"'"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data.diagram_type === undefined){const err1 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "diagram_type"},message:"must have required property '"+"diagram_type"+"'"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}if(data.meta === undefined){const err2 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "meta"},message:"must have required property '"+"meta"+"'"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}if(data.components === undefined){const err3 = {instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: "components"},message:"must have required property '"+"components"+"'"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}for(const key0 in data){if(!((((((((key0 === "schema_version") || (key0 === "diagram_type")) || (key0 === "meta")) || (key0 === "layout")) || (key0 === "components")) || (key0 === "boundaries")) || (key0 === "connections")) || (key0 === "cards"))){const err4 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err4];}else {vErrors.push(err4);}errors++;}}if(data.schema_version !== undefined){if(1 !== data.schema_version){const err5 = {instancePath:instancePath+"/schema_version",schemaPath:"#/properties/schema_version/const",keyword:"const",params:{allowedValue: 1},message:"must be equal to constant"};if(vErrors === null){vErrors = [err5];}else {vErrors.push(err5);}errors++;}}if(data.diagram_type !== undefined){if("architecture" !== data.diagram_type){const err6 = {instancePath:instancePath+"/diagram_type",schemaPath:"#/properties/diagram_type/const",keyword:"const",params:{allowedValue: "architecture"},message:"must be equal to constant"};if(vErrors === null){vErrors = [err6];}else {vErrors.push(err6);}errors++;}}if(data.meta !== undefined){let data2 = data.meta;if(data2 && typeof data2 == "object" && !Array.isArray(data2)){if(data2.title === undefined){const err7 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}for(const key1 in data2){if(!(func1.call(schema161.properties.meta.properties, key1))){const err8 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key1},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err8];}else {vErrors.push(err8);}errors++;}}if(data2.title !== undefined){let data3 = data2.title;if(typeof data3 === "string"){if(func3(data3) < 1){const err9 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err9];}else {vErrors.push(err9);}errors++;}}else {const err10 = {instancePath:instancePath+"/meta/title",schemaPath:"#/properties/meta/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err10];}else {vErrors.push(err10);}errors++;}}if(data2.locale !== undefined){let data4 = data2.locale;if(!(((data4 === "en") || (data4 === "zh-CN")) || (data4 === "es"))){const err11 = {instancePath:instancePath+"/meta/locale",schemaPath:"common.schema.json#/$defs/locale/enum",keyword:"enum",params:{allowedValues: schema33.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}if(data2.subtitle !== undefined){if(typeof data2.subtitle !== "string"){const err12 = {instancePath:instancePath+"/meta/subtitle",schemaPath:"#/properties/meta/properties/subtitle/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}}if(data2.output !== undefined){let data6 = data2.output;if(typeof data6 === "string"){if(!pattern4.test(data6)){const err13 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/0/pattern",keyword:"pattern",params:{pattern: "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"},message:"must match pattern \""+"(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$"+"\""};if(vErrors === null){vErrors = [err13];}else {vErrors.push(err13);}errors++;}}const _errs18 = errors;const _errs19 = errors;if(typeof data6 === "string"){if(!pattern5.test(data6)){const err14 = {};if(vErrors === null){vErrors = [err14];}else {vErrors.push(err14);}errors++;}}var valid5 = _errs19 === errors;if(valid5){const err15 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err15];}else {vErrors.push(err15);}errors++;}else {errors = _errs18;if(vErrors !== null){if(_errs18){vErrors.length = _errs18;}else {vErrors = null;}}}const _errs21 = errors;const _errs22 = errors;if(typeof data6 === "string"){if(!pattern6.test(data6)){const err16 = {};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}}var valid6 = _errs22 === errors;if(valid6){const err17 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err17];}else {vErrors.push(err17);}errors++;}else {errors = _errs21;if(vErrors !== null){if(_errs21){vErrors.length = _errs21;}else {vErrors = null;}}}const _errs24 = errors;const _errs25 = errors;if(typeof data6 === "string"){if(!pattern7.test(data6)){const err18 = {};if(vErrors === null){vErrors = [err18];}else {vErrors.push(err18);}errors++;}}var valid7 = _errs25 === errors;if(valid7){const err19 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err19];}else {vErrors.push(err19);}errors++;}else {errors = _errs24;if(vErrors !== null){if(_errs24){vErrors.length = _errs24;}else {vErrors = null;}}}const _errs27 = errors;const _errs28 = errors;if(typeof data6 === "string"){if(!pattern8.test(data6)){const err20 = {};if(vErrors === null){vErrors = [err20];}else {vErrors.push(err20);}errors++;}}var valid8 = _errs28 === errors;if(valid8){const err21 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/4/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err21];}else {vErrors.push(err21);}errors++;}else {errors = _errs27;if(vErrors !== null){if(_errs27){vErrors.length = _errs27;}else {vErrors = null;}}}const _errs30 = errors;const _errs31 = errors;if(typeof data6 === "string"){if(!pattern9.test(data6)){const err22 = {};if(vErrors === null){vErrors = [err22];}else {vErrors.push(err22);}errors++;}}var valid9 = _errs31 === errors;if(valid9){const err23 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/5/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err23];}else {vErrors.push(err23);}errors++;}else {errors = _errs30;if(vErrors !== null){if(_errs30){vErrors.length = _errs30;}else {vErrors = null;}}}const _errs33 = errors;const _errs34 = errors;if(typeof data6 === "string"){if(!pattern10.test(data6)){const err24 = {};if(vErrors === null){vErrors = [err24];}else {vErrors.push(err24);}errors++;}}var valid10 = _errs34 === errors;if(valid10){const err25 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/6/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err25];}else {vErrors.push(err25);}errors++;}else {errors = _errs33;if(vErrors !== null){if(_errs33){vErrors.length = _errs33;}else {vErrors = null;}}}const _errs36 = errors;const _errs37 = errors;if(typeof data6 === "string"){if(!pattern11.test(data6)){const err26 = {};if(vErrors === null){vErrors = [err26];}else {vErrors.push(err26);}errors++;}}var valid11 = _errs37 === errors;if(valid11){const err27 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/allOf/7/not",keyword:"not",params:{},message:"must NOT be valid"};if(vErrors === null){vErrors = [err27];}else {vErrors.push(err27);}errors++;}else {errors = _errs36;if(vErrors !== null){if(_errs36){vErrors.length = _errs36;}else {vErrors = null;}}}if(typeof data6 === "string"){if(func3(data6) < 1){const err28 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err28];}else {vErrors.push(err28);}errors++;}if(!pattern12.test(data6)){const err29 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/pattern",keyword:"pattern",params:{pattern: "^[^/]+(?:/[^/]+)*$"},message:"must match pattern \""+"^[^/]+(?:/[^/]+)*$"+"\""};if(vErrors === null){vErrors = [err29];}else {vErrors.push(err29);}errors++;}}else {const err30 = {instancePath:instancePath+"/meta/output",schemaPath:"common.schema.json#/$defs/portableOutputPath/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err30];}else {vErrors.push(err30);}errors++;}}if(data2.animation !== undefined){let data7 = data2.animation;if(!((data7 === "trace") || (data7 === "none"))){const err31 = {instancePath:instancePath+"/meta/animation",schemaPath:"common.schema.json#/$defs/animation/enum",keyword:"enum",params:{allowedValues: schema74.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err31];}else {vErrors.push(err31);}errors++;}}if(data2.visual_preset !== undefined){let data8 = data2.visual_preset;if(!((((data8 === "classic") || (data8 === "signal-flow")) || (data8 === "blueprint")) || (data8 === "editorial"))){const err32 = {instancePath:instancePath+"/meta/visual_preset",schemaPath:"common.schema.json#/$defs/visualPreset/enum",keyword:"enum",params:{allowedValues: schema75.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err32];}else {vErrors.push(err32);}errors++;}}if(data2.quality_profile !== undefined){let data9 = data2.quality_profile;if(!((data9 === "standard") || (data9 === "showcase"))){const err33 = {instancePath:instancePath+"/meta/quality_profile",schemaPath:"common.schema.json#/$defs/qualityProfile/enum",keyword:"enum",params:{allowedValues: schema76.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err33];}else {vErrors.push(err33);}errors++;}}if(data2.engineering_profile !== undefined){if(!(data2.engineering_profile === "deployment-ownership")){const err34 = {instancePath:instancePath+"/meta/engineering_profile",schemaPath:"#/properties/meta/properties/engineering_profile/enum",keyword:"enum",params:{allowedValues: schema161.properties.meta.properties.engineering_profile.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err34];}else {vErrors.push(err34);}errors++;}}if(data2.repository !== undefined){let data11 = data2.repository;if(data11 && typeof data11 == "object" && !Array.isArray(data11)){if(data11.url === undefined){const err35 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err35];}else {vErrors.push(err35);}errors++;}if(data11.revision === undefined){const err36 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/required",keyword:"required",params:{missingProperty: "revision"},message:"must have required property '"+"revision"+"'"};if(vErrors === null){vErrors = [err36];}else {vErrors.push(err36);}errors++;}for(const key2 in data11){if(!((((key2 === "url") || (key2 === "provider")) || (key2 === "link_mode")) || (key2 === "revision"))){const err37 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err37];}else {vErrors.push(err37);}errors++;}}if(data11.url !== undefined){let data12 = data11.url;if(typeof data12 === "string"){if(func3(data12) < 1){const err38 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err38];}else {vErrors.push(err38);}errors++;}}else {const err39 = {instancePath:instancePath+"/meta/repository/url",schemaPath:"common.schema.json#/$defs/repository/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err39];}else {vErrors.push(err39);}errors++;}}if(data11.provider !== undefined){let data13 = data11.provider;if(!((data13 === "github") || (data13 === "gitee"))){const err40 = {instancePath:instancePath+"/meta/repository/provider",schemaPath:"common.schema.json#/$defs/repository/properties/provider/enum",keyword:"enum",params:{allowedValues: schema35.properties.provider.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err40];}else {vErrors.push(err40);}errors++;}}if(data11.link_mode !== undefined){let data14 = data11.link_mode;if(!((data14 === "web") || (data14 === "local-only"))){const err41 = {instancePath:instancePath+"/meta/repository/link_mode",schemaPath:"common.schema.json#/$defs/repository/properties/link_mode/enum",keyword:"enum",params:{allowedValues: schema35.properties.link_mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err41];}else {vErrors.push(err41);}errors++;}}if(data11.revision !== undefined){let data15 = data11.revision;if(typeof data15 === "string"){if(!pattern13.test(data15)){const err42 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/pattern",keyword:"pattern",params:{pattern: "^[a-fA-F0-9]{40}$"},message:"must match pattern \""+"^[a-fA-F0-9]{40}$"+"\""};if(vErrors === null){vErrors = [err42];}else {vErrors.push(err42);}errors++;}}else {const err43 = {instancePath:instancePath+"/meta/repository/revision",schemaPath:"common.schema.json#/$defs/repository/properties/revision/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err43];}else {vErrors.push(err43);}errors++;}}}else {const err44 = {instancePath:instancePath+"/meta/repository",schemaPath:"common.schema.json#/$defs/repository/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err44];}else {vErrors.push(err44);}errors++;}}if(data2.views !== undefined){if(!(validate37(data2.views, {instancePath:instancePath+"/meta/views",parentData:data2,parentDataProperty:"views",rootData,dynamicAnchors}))){vErrors = vErrors === null ? validate37.errors : vErrors.concat(validate37.errors);errors = vErrors.length;}}if(data2.legend !== undefined){let data17 = data2.legend;if(data17 && typeof data17 == "object" && !Array.isArray(data17)){for(const key3 in data17){if(!((key3 === "mode") || (key3 === "entries"))){const err45 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err45];}else {vErrors.push(err45);}errors++;}}if(data17.mode !== undefined){let data18 = data17.mode;if(!(((data18 === "auto") || (data18 === "all")) || (data18 === "hidden"))){const err46 = {instancePath:instancePath+"/meta/legend/mode",schemaPath:"common.schema.json#/$defs/legendMode/enum",keyword:"enum",params:{allowedValues: schema39.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err46];}else {vErrors.push(err46);}errors++;}}if(data17.entries !== undefined){let data19 = data17.entries;if(data19 && typeof data19 == "object" && !Array.isArray(data19)){for(const key4 in data19){if(!(((((((key4 === "frontend") || (key4 === "backend")) || (key4 === "database")) || (key4 === "cloud")) || (key4 === "security")) || (key4 === "messagebus")) || (key4 === "external"))){const err47 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err47];}else {vErrors.push(err47);}errors++;}}if(data19.frontend !== undefined){let data20 = data19.frontend;if(data20 && typeof data20 == "object" && !Array.isArray(data20)){if(Object.keys(data20).length < 1){const err48 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err48];}else {vErrors.push(err48);}errors++;}for(const key5 in data20){if(!((key5 === "label") || (key5 === "visible"))){const err49 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key5},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err49];}else {vErrors.push(err49);}errors++;}}if(data20.label !== undefined){let data21 = data20.label;if(typeof data21 === "string"){if(func3(data21) > 80){const err50 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err50];}else {vErrors.push(err50);}errors++;}if(func3(data21) < 1){const err51 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err51];}else {vErrors.push(err51);}errors++;}}else {const err52 = {instancePath:instancePath+"/meta/legend/entries/frontend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err52];}else {vErrors.push(err52);}errors++;}}if(data20.visible !== undefined){if(typeof data20.visible !== "boolean"){const err53 = {instancePath:instancePath+"/meta/legend/entries/frontend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err53];}else {vErrors.push(err53);}errors++;}}}else {const err54 = {instancePath:instancePath+"/meta/legend/entries/frontend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err54];}else {vErrors.push(err54);}errors++;}}if(data19.backend !== undefined){let data23 = data19.backend;if(data23 && typeof data23 == "object" && !Array.isArray(data23)){if(Object.keys(data23).length < 1){const err55 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err55];}else {vErrors.push(err55);}errors++;}for(const key6 in data23){if(!((key6 === "label") || (key6 === "visible"))){const err56 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key6},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err56];}else {vErrors.push(err56);}errors++;}}if(data23.label !== undefined){let data24 = data23.label;if(typeof data24 === "string"){if(func3(data24) > 80){const err57 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err57];}else {vErrors.push(err57);}errors++;}if(func3(data24) < 1){const err58 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err58];}else {vErrors.push(err58);}errors++;}}else {const err59 = {instancePath:instancePath+"/meta/legend/entries/backend/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err59];}else {vErrors.push(err59);}errors++;}}if(data23.visible !== undefined){if(typeof data23.visible !== "boolean"){const err60 = {instancePath:instancePath+"/meta/legend/entries/backend/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err60];}else {vErrors.push(err60);}errors++;}}}else {const err61 = {instancePath:instancePath+"/meta/legend/entries/backend",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err61];}else {vErrors.push(err61);}errors++;}}if(data19.database !== undefined){let data26 = data19.database;if(data26 && typeof data26 == "object" && !Array.isArray(data26)){if(Object.keys(data26).length < 1){const err62 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err62];}else {vErrors.push(err62);}errors++;}for(const key7 in data26){if(!((key7 === "label") || (key7 === "visible"))){const err63 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key7},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err63];}else {vErrors.push(err63);}errors++;}}if(data26.label !== undefined){let data27 = data26.label;if(typeof data27 === "string"){if(func3(data27) > 80){const err64 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err64];}else {vErrors.push(err64);}errors++;}if(func3(data27) < 1){const err65 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err65];}else {vErrors.push(err65);}errors++;}}else {const err66 = {instancePath:instancePath+"/meta/legend/entries/database/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err66];}else {vErrors.push(err66);}errors++;}}if(data26.visible !== undefined){if(typeof data26.visible !== "boolean"){const err67 = {instancePath:instancePath+"/meta/legend/entries/database/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err67];}else {vErrors.push(err67);}errors++;}}}else {const err68 = {instancePath:instancePath+"/meta/legend/entries/database",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err68];}else {vErrors.push(err68);}errors++;}}if(data19.cloud !== undefined){let data29 = data19.cloud;if(data29 && typeof data29 == "object" && !Array.isArray(data29)){if(Object.keys(data29).length < 1){const err69 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err69];}else {vErrors.push(err69);}errors++;}for(const key8 in data29){if(!((key8 === "label") || (key8 === "visible"))){const err70 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key8},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err70];}else {vErrors.push(err70);}errors++;}}if(data29.label !== undefined){let data30 = data29.label;if(typeof data30 === "string"){if(func3(data30) > 80){const err71 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err71];}else {vErrors.push(err71);}errors++;}if(func3(data30) < 1){const err72 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err72];}else {vErrors.push(err72);}errors++;}}else {const err73 = {instancePath:instancePath+"/meta/legend/entries/cloud/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err73];}else {vErrors.push(err73);}errors++;}}if(data29.visible !== undefined){if(typeof data29.visible !== "boolean"){const err74 = {instancePath:instancePath+"/meta/legend/entries/cloud/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err74];}else {vErrors.push(err74);}errors++;}}}else {const err75 = {instancePath:instancePath+"/meta/legend/entries/cloud",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err75];}else {vErrors.push(err75);}errors++;}}if(data19.security !== undefined){let data32 = data19.security;if(data32 && typeof data32 == "object" && !Array.isArray(data32)){if(Object.keys(data32).length < 1){const err76 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err76];}else {vErrors.push(err76);}errors++;}for(const key9 in data32){if(!((key9 === "label") || (key9 === "visible"))){const err77 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key9},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err77];}else {vErrors.push(err77);}errors++;}}if(data32.label !== undefined){let data33 = data32.label;if(typeof data33 === "string"){if(func3(data33) > 80){const err78 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err78];}else {vErrors.push(err78);}errors++;}if(func3(data33) < 1){const err79 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err79];}else {vErrors.push(err79);}errors++;}}else {const err80 = {instancePath:instancePath+"/meta/legend/entries/security/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err80];}else {vErrors.push(err80);}errors++;}}if(data32.visible !== undefined){if(typeof data32.visible !== "boolean"){const err81 = {instancePath:instancePath+"/meta/legend/entries/security/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err81];}else {vErrors.push(err81);}errors++;}}}else {const err82 = {instancePath:instancePath+"/meta/legend/entries/security",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err82];}else {vErrors.push(err82);}errors++;}}if(data19.messagebus !== undefined){let data35 = data19.messagebus;if(data35 && typeof data35 == "object" && !Array.isArray(data35)){if(Object.keys(data35).length < 1){const err83 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err83];}else {vErrors.push(err83);}errors++;}for(const key10 in data35){if(!((key10 === "label") || (key10 === "visible"))){const err84 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key10},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err84];}else {vErrors.push(err84);}errors++;}}if(data35.label !== undefined){let data36 = data35.label;if(typeof data36 === "string"){if(func3(data36) > 80){const err85 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err85];}else {vErrors.push(err85);}errors++;}if(func3(data36) < 1){const err86 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err86];}else {vErrors.push(err86);}errors++;}}else {const err87 = {instancePath:instancePath+"/meta/legend/entries/messagebus/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err87];}else {vErrors.push(err87);}errors++;}}if(data35.visible !== undefined){if(typeof data35.visible !== "boolean"){const err88 = {instancePath:instancePath+"/meta/legend/entries/messagebus/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err88];}else {vErrors.push(err88);}errors++;}}}else {const err89 = {instancePath:instancePath+"/meta/legend/entries/messagebus",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err89];}else {vErrors.push(err89);}errors++;}}if(data19.external !== undefined){let data38 = data19.external;if(data38 && typeof data38 == "object" && !Array.isArray(data38)){if(Object.keys(data38).length < 1){const err90 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/minProperties",keyword:"minProperties",params:{limit: 1},message:"must NOT have fewer than 1 properties"};if(vErrors === null){vErrors = [err90];}else {vErrors.push(err90);}errors++;}for(const key11 in data38){if(!((key11 === "label") || (key11 === "visible"))){const err91 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key11},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err91];}else {vErrors.push(err91);}errors++;}}if(data38.label !== undefined){let data39 = data38.label;if(typeof data39 === "string"){if(func3(data39) > 80){const err92 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err92];}else {vErrors.push(err92);}errors++;}if(func3(data39) < 1){const err93 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err93];}else {vErrors.push(err93);}errors++;}}else {const err94 = {instancePath:instancePath+"/meta/legend/entries/external/label",schemaPath:"common.schema.json#/$defs/legendEntry/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err94];}else {vErrors.push(err94);}errors++;}}if(data38.visible !== undefined){if(typeof data38.visible !== "boolean"){const err95 = {instancePath:instancePath+"/meta/legend/entries/external/visible",schemaPath:"common.schema.json#/$defs/legendEntry/properties/visible/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"};if(vErrors === null){vErrors = [err95];}else {vErrors.push(err95);}errors++;}}}else {const err96 = {instancePath:instancePath+"/meta/legend/entries/external",schemaPath:"common.schema.json#/$defs/legendEntry/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err96];}else {vErrors.push(err96);}errors++;}}}else {const err97 = {instancePath:instancePath+"/meta/legend/entries",schemaPath:"#/properties/meta/properties/legend/properties/entries/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err97];}else {vErrors.push(err97);}errors++;}}}else {const err98 = {instancePath:instancePath+"/meta/legend",schemaPath:"#/properties/meta/properties/legend/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err98];}else {vErrors.push(err98);}errors++;}}if(data2.viewBox !== undefined){let data41 = data2.viewBox;if(Array.isArray(data41)){if(data41.length > 2){const err99 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err99];}else {vErrors.push(err99);}errors++;}if(data41.length < 2){const err100 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err100];}else {vErrors.push(err100);}errors++;}const len0 = data41.length;if(len0 > 0){let data42 = data41[0];if((typeof data42 == "number") && (isFinite(data42))){if(data42 < 320 || isNaN(data42)){const err101 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/minimum",keyword:"minimum",params:{comparison: ">=", limit: 320},message:"must be >= 320"};if(vErrors === null){vErrors = [err101];}else {vErrors.push(err101);}errors++;}}else {const err102 = {instancePath:instancePath+"/meta/viewBox/0",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err102];}else {vErrors.push(err102);}errors++;}}if(len0 > 1){let data43 = data41[1];if((typeof data43 == "number") && (isFinite(data43))){if(data43 < 240 || isNaN(data43)){const err103 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/minimum",keyword:"minimum",params:{comparison: ">=", limit: 240},message:"must be >= 240"};if(vErrors === null){vErrors = [err103];}else {vErrors.push(err103);}errors++;}}else {const err104 = {instancePath:instancePath+"/meta/viewBox/1",schemaPath:"#/properties/meta/properties/viewBox/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err104];}else {vErrors.push(err104);}errors++;}}const len1 = data41.length;if(!(len1 <= 2)){const err105 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err105];}else {vErrors.push(err105);}errors++;}}else {const err106 = {instancePath:instancePath+"/meta/viewBox",schemaPath:"#/properties/meta/properties/viewBox/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err106];}else {vErrors.push(err106);}errors++;}}}else {const err107 = {instancePath:instancePath+"/meta",schemaPath:"#/properties/meta/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err107];}else {vErrors.push(err107);}errors++;}}if(data.layout !== undefined){let data44 = data.layout;if(data44 && typeof data44 == "object" && !Array.isArray(data44)){if(data44.mode === undefined){const err108 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/required",keyword:"required",params:{missingProperty: "mode"},message:"must have required property '"+"mode"+"'"};if(vErrors === null){vErrors = [err108];}else {vErrors.push(err108);}errors++;}for(const key12 in data44){if(!(((((((key12 === "mode") || (key12 === "origin")) || (key12 === "cols")) || (key12 === "gapX")) || (key12 === "gapY")) || (key12 === "cellW")) || (key12 === "cellH"))){const err109 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key12},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err109];}else {vErrors.push(err109);}errors++;}}if(data44.mode !== undefined){if(!(data44.mode === "grid")){const err110 = {instancePath:instancePath+"/layout/mode",schemaPath:"#/properties/layout/properties/mode/enum",keyword:"enum",params:{allowedValues: schema161.properties.layout.properties.mode.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err110];}else {vErrors.push(err110);}errors++;}}if(data44.origin !== undefined){let data46 = data44.origin;if(Array.isArray(data46)){if(data46.length > 2){const err111 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err111];}else {vErrors.push(err111);}errors++;}if(data46.length < 2){const err112 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err112];}else {vErrors.push(err112);}errors++;}const len2 = data46.length;if(len2 > 0){let data47 = data46[0];if(!((typeof data47 == "number") && (isFinite(data47)))){const err113 = {instancePath:instancePath+"/layout/origin/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err113];}else {vErrors.push(err113);}errors++;}}if(len2 > 1){let data48 = data46[1];if(!((typeof data48 == "number") && (isFinite(data48)))){const err114 = {instancePath:instancePath+"/layout/origin/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err114];}else {vErrors.push(err114);}errors++;}}const len3 = data46.length;if(!(len3 <= 2)){const err115 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err115];}else {vErrors.push(err115);}errors++;}}else {const err116 = {instancePath:instancePath+"/layout/origin",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err116];}else {vErrors.push(err116);}errors++;}}if(data44.cols !== undefined){let data49 = data44.cols;if(!(((typeof data49 == "number") && (!(data49 % 1) && !isNaN(data49))) && (isFinite(data49)))){const err117 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err117];}else {vErrors.push(err117);}errors++;}if((typeof data49 == "number") && (isFinite(data49))){if(data49 > 12 || isNaN(data49)){const err118 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/maximum",keyword:"maximum",params:{comparison: "<=", limit: 12},message:"must be <= 12"};if(vErrors === null){vErrors = [err118];}else {vErrors.push(err118);}errors++;}if(data49 < 1 || isNaN(data49)){const err119 = {instancePath:instancePath+"/layout/cols",schemaPath:"#/properties/layout/properties/cols/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err119];}else {vErrors.push(err119);}errors++;}}}if(data44.gapX !== undefined){let data50 = data44.gapX;if((typeof data50 == "number") && (isFinite(data50))){if(data50 < 0 || isNaN(data50)){const err120 = {instancePath:instancePath+"/layout/gapX",schemaPath:"#/properties/layout/properties/gapX/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err120];}else {vErrors.push(err120);}errors++;}}else {const err121 = {instancePath:instancePath+"/layout/gapX",schemaPath:"#/properties/layout/properties/gapX/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err121];}else {vErrors.push(err121);}errors++;}}if(data44.gapY !== undefined){let data51 = data44.gapY;if((typeof data51 == "number") && (isFinite(data51))){if(data51 < 0 || isNaN(data51)){const err122 = {instancePath:instancePath+"/layout/gapY",schemaPath:"#/properties/layout/properties/gapY/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err122];}else {vErrors.push(err122);}errors++;}}else {const err123 = {instancePath:instancePath+"/layout/gapY",schemaPath:"#/properties/layout/properties/gapY/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err123];}else {vErrors.push(err123);}errors++;}}if(data44.cellW !== undefined){let data52 = data44.cellW;if((typeof data52 == "number") && (isFinite(data52))){if(data52 < 40 || isNaN(data52)){const err124 = {instancePath:instancePath+"/layout/cellW",schemaPath:"#/properties/layout/properties/cellW/minimum",keyword:"minimum",params:{comparison: ">=", limit: 40},message:"must be >= 40"};if(vErrors === null){vErrors = [err124];}else {vErrors.push(err124);}errors++;}}else {const err125 = {instancePath:instancePath+"/layout/cellW",schemaPath:"#/properties/layout/properties/cellW/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err125];}else {vErrors.push(err125);}errors++;}}if(data44.cellH !== undefined){let data53 = data44.cellH;if((typeof data53 == "number") && (isFinite(data53))){if(data53 < 24 || isNaN(data53)){const err126 = {instancePath:instancePath+"/layout/cellH",schemaPath:"#/properties/layout/properties/cellH/minimum",keyword:"minimum",params:{comparison: ">=", limit: 24},message:"must be >= 24"};if(vErrors === null){vErrors = [err126];}else {vErrors.push(err126);}errors++;}}else {const err127 = {instancePath:instancePath+"/layout/cellH",schemaPath:"#/properties/layout/properties/cellH/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err127];}else {vErrors.push(err127);}errors++;}}}else {const err128 = {instancePath:instancePath+"/layout",schemaPath:"#/properties/layout/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err128];}else {vErrors.push(err128);}errors++;}}if(data.components !== undefined){let data54 = data.components;if(Array.isArray(data54)){if(data54.length < 1){const err129 = {instancePath:instancePath+"/components",schemaPath:"#/properties/components/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err129];}else {vErrors.push(err129);}errors++;}const len4 = data54.length;for(let i0=0; i0<len4; i0++){let data55 = data54[i0];if(data55 && typeof data55 == "object" && !Array.isArray(data55)){if(data55.id === undefined){const err130 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "id"},message:"must have required property '"+"id"+"'"};if(vErrors === null){vErrors = [err130];}else {vErrors.push(err130);}errors++;}if(data55.type === undefined){const err131 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "type"},message:"must have required property '"+"type"+"'"};if(vErrors === null){vErrors = [err131];}else {vErrors.push(err131);}errors++;}if(data55.label === undefined){const err132 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err132];}else {vErrors.push(err132);}errors++;}for(const key13 in data55){if(!(func1.call(schema161.properties.components.items.properties, key13))){const err133 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key13},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err133];}else {vErrors.push(err133);}errors++;}}if(data55.id !== undefined){let data56 = data55.id;if(typeof data56 === "string"){if(!pattern14.test(data56)){const err134 = {instancePath:instancePath+"/components/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err134];}else {vErrors.push(err134);}errors++;}}else {const err135 = {instancePath:instancePath+"/components/" + i0+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err135];}else {vErrors.push(err135);}errors++;}}if(data55.type !== undefined){let data57 = data55.type;if(!(((((((data57 === "frontend") || (data57 === "backend")) || (data57 === "database")) || (data57 === "cloud")) || (data57 === "security")) || (data57 === "messagebus")) || (data57 === "external"))){const err136 = {instancePath:instancePath+"/components/" + i0+"/type",schemaPath:"common.schema.json#/$defs/componentType/enum",keyword:"enum",params:{allowedValues: schema59.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err136];}else {vErrors.push(err136);}errors++;}}if(data55.label !== undefined){let data58 = data55.label;if(typeof data58 === "string"){if(func3(data58) < 1){const err137 = {instancePath:instancePath+"/components/" + i0+"/label",schemaPath:"#/properties/components/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err137];}else {vErrors.push(err137);}errors++;}}else {const err138 = {instancePath:instancePath+"/components/" + i0+"/label",schemaPath:"#/properties/components/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err138];}else {vErrors.push(err138);}errors++;}}if(data55.sublabel !== undefined){if(typeof data55.sublabel !== "string"){const err139 = {instancePath:instancePath+"/components/" + i0+"/sublabel",schemaPath:"#/properties/components/items/properties/sublabel/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err139];}else {vErrors.push(err139);}errors++;}}if(data55.tag !== undefined){if(typeof data55.tag !== "string"){const err140 = {instancePath:instancePath+"/components/" + i0+"/tag",schemaPath:"#/properties/components/items/properties/tag/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err140];}else {vErrors.push(err140);}errors++;}}if(data55.brand !== undefined){let data61 = data55.brand;const _errs165 = errors;let valid44 = false;let passing0 = null;const _errs166 = errors;const _errs168 = errors;let valid45 = false;const _errs169 = errors;if(typeof data61 === "string"){if(func3(data61) > 80){const err141 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/maxLength",keyword:"maxLength",params:{limit: 80},message:"must NOT have more than 80 characters"};if(vErrors === null){vErrors = [err141];}else {vErrors.push(err141);}errors++;}if(!pattern27.test(data61)){const err142 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/0/pattern",keyword:"pattern",params:{pattern: "^[^\\r\\n]+$"},message:"must match pattern \""+"^[^\\r\\n]+$"+"\""};if(vErrors === null){vErrors = [err142];}else {vErrors.push(err142);}errors++;}}var _valid1 = _errs169 === errors;valid45 = valid45 || _valid1;const _errs170 = errors;if(typeof data61 === "string"){if(!pattern28.test(data61)){const err143 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf/1/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err143];}else {vErrors.push(err143);}errors++;}}var _valid1 = _errs170 === errors;valid45 = valid45 || _valid1;if(!valid45){const err144 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};if(vErrors === null){vErrors = [err144];}else {vErrors.push(err144);}errors++;}else {errors = _errs168;if(vErrors !== null){if(_errs168){vErrors.length = _errs168;}else {vErrors = null;}}}if(typeof data61 === "string"){if(func3(data61) > 2048){const err145 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err145];}else {vErrors.push(err145);}errors++;}if(func3(data61) < 1){const err146 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err146];}else {vErrors.push(err146);}errors++;}}else {const err147 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/0/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err147];}else {vErrors.push(err147);}errors++;}var _valid0 = _errs166 === errors;if(_valid0){valid44 = true;passing0 = 0;}const _errs171 = errors;if(data61 && typeof data61 == "object" && !Array.isArray(data61)){if(data61.url === undefined){const err148 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "url"},message:"must have required property '"+"url"+"'"};if(vErrors === null){vErrors = [err148];}else {vErrors.push(err148);}errors++;}if(data61.sha256 === undefined){const err149 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/required",keyword:"required",params:{missingProperty: "sha256"},message:"must have required property '"+"sha256"+"'"};if(vErrors === null){vErrors = [err149];}else {vErrors.push(err149);}errors++;}for(const key14 in data61){if(!((key14 === "url") || (key14 === "sha256"))){const err150 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key14},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err150];}else {vErrors.push(err150);}errors++;}}if(data61.url !== undefined){let data62 = data61.url;if(typeof data62 === "string"){if(func3(data62) > 2048){const err151 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/maxLength",keyword:"maxLength",params:{limit: 2048},message:"must NOT have more than 2048 characters"};if(vErrors === null){vErrors = [err151];}else {vErrors.push(err151);}errors++;}if(func3(data62) < 8){const err152 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/minLength",keyword:"minLength",params:{limit: 8},message:"must NOT have fewer than 8 characters"};if(vErrors === null){vErrors = [err152];}else {vErrors.push(err152);}errors++;}if(!pattern28.test(data62)){const err153 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/pattern",keyword:"pattern",params:{pattern: "^https?://"},message:"must match pattern \""+"^https?://"+"\""};if(vErrors === null){vErrors = [err153];}else {vErrors.push(err153);}errors++;}}else {const err154 = {instancePath:instancePath+"/components/" + i0+"/brand/url",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/url/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err154];}else {vErrors.push(err154);}errors++;}}if(data61.sha256 !== undefined){let data63 = data61.sha256;if(typeof data63 === "string"){if(!pattern30.test(data63)){const err155 = {instancePath:instancePath+"/components/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/pattern",keyword:"pattern",params:{pattern: "^[a-f0-9]{64}$"},message:"must match pattern \""+"^[a-f0-9]{64}$"+"\""};if(vErrors === null){vErrors = [err155];}else {vErrors.push(err155);}errors++;}}else {const err156 = {instancePath:instancePath+"/components/" + i0+"/brand/sha256",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/properties/sha256/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err156];}else {vErrors.push(err156);}errors++;}}}else {const err157 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf/1/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err157];}else {vErrors.push(err157);}errors++;}var _valid0 = _errs171 === errors;if(_valid0 && valid44){valid44 = false;passing0 = [passing0, 1];}else {if(_valid0){valid44 = true;passing0 = 1;}}if(!valid44){const err158 = {instancePath:instancePath+"/components/" + i0+"/brand",schemaPath:"common.schema.json#/$defs/brandMark/oneOf",keyword:"oneOf",params:{passingSchemas: passing0},message:"must match exactly one schema in oneOf"};if(vErrors === null){vErrors = [err158];}else {vErrors.push(err158);}errors++;}else {errors = _errs165;if(vErrors !== null){if(_errs165){vErrors.length = _errs165;}else {vErrors = null;}}}}if(data55.sources !== undefined){let data64 = data55.sources;if(Array.isArray(data64)){if(data64.length > 3){const err159 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/maxItems",keyword:"maxItems",params:{limit: 3},message:"must NOT have more than 3 items"};if(vErrors === null){vErrors = [err159];}else {vErrors.push(err159);}errors++;}if(data64.length < 1){const err160 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err160];}else {vErrors.push(err160);}errors++;}const len5 = data64.length;for(let i1=0; i1<len5; i1++){let data65 = data64[i1];if(data65 && typeof data65 == "object" && !Array.isArray(data65)){if(data65.path === undefined){const err161 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/required",keyword:"required",params:{missingProperty: "path"},message:"must have required property '"+"path"+"'"};if(vErrors === null){vErrors = [err161];}else {vErrors.push(err161);}errors++;}for(const key15 in data65){if(!((((key15 === "path") || (key15 === "line")) || (key15 === "end_line")) || (key15 === "label"))){const err162 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key15},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err162];}else {vErrors.push(err162);}errors++;}}if(data65.path !== undefined){let data66 = data65.path;if(typeof data66 === "string"){if(func3(data66) > 240){const err163 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/maxLength",keyword:"maxLength",params:{limit: 240},message:"must NOT have more than 240 characters"};if(vErrors === null){vErrors = [err163];}else {vErrors.push(err163);}errors++;}if(func3(data66) < 1){const err164 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err164];}else {vErrors.push(err164);}errors++;}}else {const err165 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/path",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/path/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err165];}else {vErrors.push(err165);}errors++;}}if(data65.line !== undefined){let data67 = data65.line;if(!(((typeof data67 == "number") && (!(data67 % 1) && !isNaN(data67))) && (isFinite(data67)))){const err166 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err166];}else {vErrors.push(err166);}errors++;}if((typeof data67 == "number") && (isFinite(data67))){if(data67 < 1 || isNaN(data67)){const err167 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err167];}else {vErrors.push(err167);}errors++;}}}if(data65.end_line !== undefined){let data68 = data65.end_line;if(!(((typeof data68 == "number") && (!(data68 % 1) && !isNaN(data68))) && (isFinite(data68)))){const err168 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err168];}else {vErrors.push(err168);}errors++;}if((typeof data68 == "number") && (isFinite(data68))){if(data68 < 1 || isNaN(data68)){const err169 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/end_line",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/end_line/minimum",keyword:"minimum",params:{comparison: ">=", limit: 1},message:"must be >= 1"};if(vErrors === null){vErrors = [err169];}else {vErrors.push(err169);}errors++;}}}if(data65.label !== undefined){let data69 = data65.label;if(typeof data69 === "string"){if(func3(data69) > 48){const err170 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/maxLength",keyword:"maxLength",params:{limit: 48},message:"must NOT have more than 48 characters"};if(vErrors === null){vErrors = [err170];}else {vErrors.push(err170);}errors++;}if(func3(data69) < 1){const err171 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err171];}else {vErrors.push(err171);}errors++;}}else {const err172 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1+"/label",schemaPath:"common.schema.json#/$defs/sourceReferences/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err172];}else {vErrors.push(err172);}errors++;}}}else {const err173 = {instancePath:instancePath+"/components/" + i0+"/sources/" + i1,schemaPath:"common.schema.json#/$defs/sourceReferences/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err173];}else {vErrors.push(err173);}errors++;}}}else {const err174 = {instancePath:instancePath+"/components/" + i0+"/sources",schemaPath:"common.schema.json#/$defs/sourceReferences/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err174];}else {vErrors.push(err174);}errors++;}}if(data55.row !== undefined){let data70 = data55.row;if(!(((typeof data70 == "number") && (!(data70 % 1) && !isNaN(data70))) && (isFinite(data70)))){const err175 = {instancePath:instancePath+"/components/" + i0+"/row",schemaPath:"#/properties/components/items/properties/row/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err175];}else {vErrors.push(err175);}errors++;}if((typeof data70 == "number") && (isFinite(data70))){if(data70 < 0 || isNaN(data70)){const err176 = {instancePath:instancePath+"/components/" + i0+"/row",schemaPath:"#/properties/components/items/properties/row/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err176];}else {vErrors.push(err176);}errors++;}}}if(data55.col !== undefined){let data71 = data55.col;if(!(((typeof data71 == "number") && (!(data71 % 1) && !isNaN(data71))) && (isFinite(data71)))){const err177 = {instancePath:instancePath+"/components/" + i0+"/col",schemaPath:"#/properties/components/items/properties/col/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err177];}else {vErrors.push(err177);}errors++;}if((typeof data71 == "number") && (isFinite(data71))){if(data71 < 0 || isNaN(data71)){const err178 = {instancePath:instancePath+"/components/" + i0+"/col",schemaPath:"#/properties/components/items/properties/col/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err178];}else {vErrors.push(err178);}errors++;}}}if(data55.pos !== undefined){let data72 = data55.pos;if(Array.isArray(data72)){if(data72.length > 2){const err179 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err179];}else {vErrors.push(err179);}errors++;}if(data72.length < 2){const err180 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err180];}else {vErrors.push(err180);}errors++;}const len6 = data72.length;if(len6 > 0){let data73 = data72[0];if(!((typeof data73 == "number") && (isFinite(data73)))){const err181 = {instancePath:instancePath+"/components/" + i0+"/pos/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err181];}else {vErrors.push(err181);}errors++;}}if(len6 > 1){let data74 = data72[1];if(!((typeof data74 == "number") && (isFinite(data74)))){const err182 = {instancePath:instancePath+"/components/" + i0+"/pos/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err182];}else {vErrors.push(err182);}errors++;}}const len7 = data72.length;if(!(len7 <= 2)){const err183 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err183];}else {vErrors.push(err183);}errors++;}}else {const err184 = {instancePath:instancePath+"/components/" + i0+"/pos",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err184];}else {vErrors.push(err184);}errors++;}}if(data55.size !== undefined){let data75 = data55.size;if(Array.isArray(data75)){if(data75.length > 2){const err185 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err185];}else {vErrors.push(err185);}errors++;}if(data75.length < 2){const err186 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err186];}else {vErrors.push(err186);}errors++;}const len8 = data75.length;if(len8 > 0){let data76 = data75[0];if((typeof data76 == "number") && (isFinite(data76))){if(data76 <= 0 || isNaN(data76)){const err187 = {instancePath:instancePath+"/components/" + i0+"/size/0",schemaPath:"#/properties/components/items/properties/size/prefixItems/0/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison: ">", limit: 0},message:"must be > 0"};if(vErrors === null){vErrors = [err187];}else {vErrors.push(err187);}errors++;}}else {const err188 = {instancePath:instancePath+"/components/" + i0+"/size/0",schemaPath:"#/properties/components/items/properties/size/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err188];}else {vErrors.push(err188);}errors++;}}if(len8 > 1){let data77 = data75[1];if((typeof data77 == "number") && (isFinite(data77))){if(data77 <= 0 || isNaN(data77)){const err189 = {instancePath:instancePath+"/components/" + i0+"/size/1",schemaPath:"#/properties/components/items/properties/size/prefixItems/1/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison: ">", limit: 0},message:"must be > 0"};if(vErrors === null){vErrors = [err189];}else {vErrors.push(err189);}errors++;}}else {const err190 = {instancePath:instancePath+"/components/" + i0+"/size/1",schemaPath:"#/properties/components/items/properties/size/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err190];}else {vErrors.push(err190);}errors++;}}const len9 = data75.length;if(!(len9 <= 2)){const err191 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err191];}else {vErrors.push(err191);}errors++;}}else {const err192 = {instancePath:instancePath+"/components/" + i0+"/size",schemaPath:"#/properties/components/items/properties/size/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err192];}else {vErrors.push(err192);}errors++;}}}else {const err193 = {instancePath:instancePath+"/components/" + i0,schemaPath:"#/properties/components/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err193];}else {vErrors.push(err193);}errors++;}}}else {const err194 = {instancePath:instancePath+"/components",schemaPath:"#/properties/components/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err194];}else {vErrors.push(err194);}errors++;}}if(data.boundaries !== undefined){let data78 = data.boundaries;if(Array.isArray(data78)){const len10 = data78.length;for(let i2=0; i2<len10; i2++){let data79 = data78[i2];if(data79 && typeof data79 == "object" && !Array.isArray(data79)){if(data79.kind === undefined){const err195 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "kind"},message:"must have required property '"+"kind"+"'"};if(vErrors === null){vErrors = [err195];}else {vErrors.push(err195);}errors++;}if(data79.label === undefined){const err196 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "label"},message:"must have required property '"+"label"+"'"};if(vErrors === null){vErrors = [err196];}else {vErrors.push(err196);}errors++;}if(data79.wraps === undefined){const err197 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/required",keyword:"required",params:{missingProperty: "wraps"},message:"must have required property '"+"wraps"+"'"};if(vErrors === null){vErrors = [err197];}else {vErrors.push(err197);}errors++;}for(const key16 in data79){if(!((((key16 === "kind") || (key16 === "label")) || (key16 === "wraps")) || (key16 === "pad"))){const err198 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key16},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err198];}else {vErrors.push(err198);}errors++;}}if(data79.kind !== undefined){let data80 = data79.kind;if(!((data80 === "region") || (data80 === "security-group"))){const err199 = {instancePath:instancePath+"/boundaries/" + i2+"/kind",schemaPath:"#/properties/boundaries/items/properties/kind/enum",keyword:"enum",params:{allowedValues: schema161.properties.boundaries.items.properties.kind.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err199];}else {vErrors.push(err199);}errors++;}}if(data79.label !== undefined){let data81 = data79.label;if(typeof data81 === "string"){if(func3(data81) < 1){const err200 = {instancePath:instancePath+"/boundaries/" + i2+"/label",schemaPath:"#/properties/boundaries/items/properties/label/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err200];}else {vErrors.push(err200);}errors++;}}else {const err201 = {instancePath:instancePath+"/boundaries/" + i2+"/label",schemaPath:"#/properties/boundaries/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err201];}else {vErrors.push(err201);}errors++;}}if(data79.wraps !== undefined){let data82 = data79.wraps;if(Array.isArray(data82)){if(data82.length < 1){const err202 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps",schemaPath:"#/properties/boundaries/items/properties/wraps/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err202];}else {vErrors.push(err202);}errors++;}const len11 = data82.length;for(let i3=0; i3<len11; i3++){let data83 = data82[i3];if(typeof data83 === "string"){if(!pattern14.test(data83)){const err203 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps/" + i3,schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err203];}else {vErrors.push(err203);}errors++;}}else {const err204 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps/" + i3,schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err204];}else {vErrors.push(err204);}errors++;}}}else {const err205 = {instancePath:instancePath+"/boundaries/" + i2+"/wraps",schemaPath:"#/properties/boundaries/items/properties/wraps/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err205];}else {vErrors.push(err205);}errors++;}}if(data79.pad !== undefined){let data84 = data79.pad;if((typeof data84 == "number") && (isFinite(data84))){if(data84 < 0 || isNaN(data84)){const err206 = {instancePath:instancePath+"/boundaries/" + i2+"/pad",schemaPath:"#/properties/boundaries/items/properties/pad/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err206];}else {vErrors.push(err206);}errors++;}}else {const err207 = {instancePath:instancePath+"/boundaries/" + i2+"/pad",schemaPath:"#/properties/boundaries/items/properties/pad/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err207];}else {vErrors.push(err207);}errors++;}}}else {const err208 = {instancePath:instancePath+"/boundaries/" + i2,schemaPath:"#/properties/boundaries/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err208];}else {vErrors.push(err208);}errors++;}}}else {const err209 = {instancePath:instancePath+"/boundaries",schemaPath:"#/properties/boundaries/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err209];}else {vErrors.push(err209);}errors++;}}if(data.connections !== undefined){let data85 = data.connections;if(Array.isArray(data85)){const len12 = data85.length;for(let i4=0; i4<len12; i4++){let data86 = data85[i4];if(data86 && typeof data86 == "object" && !Array.isArray(data86)){if(data86.from === undefined){const err210 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/required",keyword:"required",params:{missingProperty: "from"},message:"must have required property '"+"from"+"'"};if(vErrors === null){vErrors = [err210];}else {vErrors.push(err210);}errors++;}if(data86.to === undefined){const err211 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/required",keyword:"required",params:{missingProperty: "to"},message:"must have required property '"+"to"+"'"};if(vErrors === null){vErrors = [err211];}else {vErrors.push(err211);}errors++;}for(const key17 in data86){if(!(func1.call(schema161.properties.connections.items.properties, key17))){const err212 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key17},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err212];}else {vErrors.push(err212);}errors++;}}if(data86.id !== undefined){let data87 = data86.id;if(typeof data87 === "string"){if(!pattern14.test(data87)){const err213 = {instancePath:instancePath+"/connections/" + i4+"/id",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err213];}else {vErrors.push(err213);}errors++;}}else {const err214 = {instancePath:instancePath+"/connections/" + i4+"/id",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err214];}else {vErrors.push(err214);}errors++;}}if(data86.from !== undefined){let data88 = data86.from;if(typeof data88 === "string"){if(!pattern14.test(data88)){const err215 = {instancePath:instancePath+"/connections/" + i4+"/from",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err215];}else {vErrors.push(err215);}errors++;}}else {const err216 = {instancePath:instancePath+"/connections/" + i4+"/from",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err216];}else {vErrors.push(err216);}errors++;}}if(data86.to !== undefined){let data89 = data86.to;if(typeof data89 === "string"){if(!pattern14.test(data89)){const err217 = {instancePath:instancePath+"/connections/" + i4+"/to",schemaPath:"common.schema.json#/$defs/id/pattern",keyword:"pattern",params:{pattern: "^[a-zA-Z][a-zA-Z0-9_-]*$"},message:"must match pattern \""+"^[a-zA-Z][a-zA-Z0-9_-]*$"+"\""};if(vErrors === null){vErrors = [err217];}else {vErrors.push(err217);}errors++;}}else {const err218 = {instancePath:instancePath+"/connections/" + i4+"/to",schemaPath:"common.schema.json#/$defs/id/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err218];}else {vErrors.push(err218);}errors++;}}if(data86.label !== undefined){if(typeof data86.label !== "string"){const err219 = {instancePath:instancePath+"/connections/" + i4+"/label",schemaPath:"#/properties/connections/items/properties/label/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err219];}else {vErrors.push(err219);}errors++;}}if(data86.variant !== undefined){let data91 = data86.variant;if(!((((data91 === "default") || (data91 === "emphasis")) || (data91 === "security")) || (data91 === "dashed"))){const err220 = {instancePath:instancePath+"/connections/" + i4+"/variant",schemaPath:"common.schema.json#/$defs/variant/enum",keyword:"enum",params:{allowedValues: schema65.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err220];}else {vErrors.push(err220);}errors++;}}if(data86.fromSide !== undefined){let data92 = data86.fromSide;if(!((((data92 === "left") || (data92 === "right")) || (data92 === "top")) || (data92 === "bottom"))){const err221 = {instancePath:instancePath+"/connections/" + i4+"/fromSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err221];}else {vErrors.push(err221);}errors++;}}if(data86.toSide !== undefined){let data93 = data86.toSide;if(!((((data93 === "left") || (data93 === "right")) || (data93 === "top")) || (data93 === "bottom"))){const err222 = {instancePath:instancePath+"/connections/" + i4+"/toSide",schemaPath:"common.schema.json#/$defs/side/enum",keyword:"enum",params:{allowedValues: schema121.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err222];}else {vErrors.push(err222);}errors++;}}if(data86.route !== undefined){let data94 = data86.route;if(!((((data94 === "auto") || (data94 === "straight")) || (data94 === "orthogonal-h")) || (data94 === "orthogonal-v"))){const err223 = {instancePath:instancePath+"/connections/" + i4+"/route",schemaPath:"#/properties/connections/items/properties/route/enum",keyword:"enum",params:{allowedValues: schema161.properties.connections.items.properties.route.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err223];}else {vErrors.push(err223);}errors++;}}if(data86.via !== undefined){let data95 = data86.via;if(Array.isArray(data95)){const len13 = data95.length;for(let i5=0; i5<len13; i5++){let data96 = data95[i5];if(Array.isArray(data96)){if(data96.length > 2){const err224 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err224];}else {vErrors.push(err224);}errors++;}if(data96.length < 2){const err225 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err225];}else {vErrors.push(err225);}errors++;}const len14 = data96.length;if(len14 > 0){let data97 = data96[0];if(!((typeof data97 == "number") && (isFinite(data97)))){const err226 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5+"/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err226];}else {vErrors.push(err226);}errors++;}}if(len14 > 1){let data98 = data96[1];if(!((typeof data98 == "number") && (isFinite(data98)))){const err227 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5+"/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err227];}else {vErrors.push(err227);}errors++;}}const len15 = data96.length;if(!(len15 <= 2)){const err228 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err228];}else {vErrors.push(err228);}errors++;}}else {const err229 = {instancePath:instancePath+"/connections/" + i4+"/via/" + i5,schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err229];}else {vErrors.push(err229);}errors++;}}}else {const err230 = {instancePath:instancePath+"/connections/" + i4+"/via",schemaPath:"#/properties/connections/items/properties/via/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err230];}else {vErrors.push(err230);}errors++;}}if(data86.labelAt !== undefined){let data99 = data86.labelAt;if(Array.isArray(data99)){if(data99.length > 2){const err231 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/maxItems",keyword:"maxItems",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err231];}else {vErrors.push(err231);}errors++;}if(data99.length < 2){const err232 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/minItems",keyword:"minItems",params:{limit: 2},message:"must NOT have fewer than 2 items"};if(vErrors === null){vErrors = [err232];}else {vErrors.push(err232);}errors++;}const len16 = data99.length;if(len16 > 0){let data100 = data99[0];if(!((typeof data100 == "number") && (isFinite(data100)))){const err233 = {instancePath:instancePath+"/connections/" + i4+"/labelAt/0",schemaPath:"common.schema.json#/$defs/point/prefixItems/0/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err233];}else {vErrors.push(err233);}errors++;}}if(len16 > 1){let data101 = data99[1];if(!((typeof data101 == "number") && (isFinite(data101)))){const err234 = {instancePath:instancePath+"/connections/" + i4+"/labelAt/1",schemaPath:"common.schema.json#/$defs/point/prefixItems/1/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err234];}else {vErrors.push(err234);}errors++;}}const len17 = data99.length;if(!(len17 <= 2)){const err235 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/items",keyword:"items",params:{limit: 2},message:"must NOT have more than 2 items"};if(vErrors === null){vErrors = [err235];}else {vErrors.push(err235);}errors++;}}else {const err236 = {instancePath:instancePath+"/connections/" + i4+"/labelAt",schemaPath:"common.schema.json#/$defs/point/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err236];}else {vErrors.push(err236);}errors++;}}if(data86.labelDx !== undefined){let data102 = data86.labelDx;if(!((typeof data102 == "number") && (isFinite(data102)))){const err237 = {instancePath:instancePath+"/connections/" + i4+"/labelDx",schemaPath:"#/properties/connections/items/properties/labelDx/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err237];}else {vErrors.push(err237);}errors++;}}if(data86.labelDy !== undefined){let data103 = data86.labelDy;if(!((typeof data103 == "number") && (isFinite(data103)))){const err238 = {instancePath:instancePath+"/connections/" + i4+"/labelDy",schemaPath:"#/properties/connections/items/properties/labelDy/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err238];}else {vErrors.push(err238);}errors++;}}if(data86.labelSegment !== undefined){let data104 = data86.labelSegment;if(!(((typeof data104 == "number") && (!(data104 % 1) && !isNaN(data104))) && (isFinite(data104)))){const err239 = {instancePath:instancePath+"/connections/" + i4+"/labelSegment",schemaPath:"#/properties/connections/items/properties/labelSegment/type",keyword:"type",params:{type: "integer"},message:"must be integer"};if(vErrors === null){vErrors = [err239];}else {vErrors.push(err239);}errors++;}if((typeof data104 == "number") && (isFinite(data104))){if(data104 < 0 || isNaN(data104)){const err240 = {instancePath:instancePath+"/connections/" + i4+"/labelSegment",schemaPath:"#/properties/connections/items/properties/labelSegment/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0},message:"must be >= 0"};if(vErrors === null){vErrors = [err240];}else {vErrors.push(err240);}errors++;}}}if(data86.width !== undefined){let data105 = data86.width;if((typeof data105 == "number") && (isFinite(data105))){if(data105 < 0.5 || isNaN(data105)){const err241 = {instancePath:instancePath+"/connections/" + i4+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/minimum",keyword:"minimum",params:{comparison: ">=", limit: 0.5},message:"must be >= 0.5"};if(vErrors === null){vErrors = [err241];}else {vErrors.push(err241);}errors++;}}else {const err242 = {instancePath:instancePath+"/connections/" + i4+"/width",schemaPath:"common.schema.json#/$defs/relationshipWidth/type",keyword:"type",params:{type: "number"},message:"must be number"};if(vErrors === null){vErrors = [err242];}else {vErrors.push(err242);}errors++;}}}else {const err243 = {instancePath:instancePath+"/connections/" + i4,schemaPath:"#/properties/connections/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err243];}else {vErrors.push(err243);}errors++;}}}else {const err244 = {instancePath:instancePath+"/connections",schemaPath:"#/properties/connections/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err244];}else {vErrors.push(err244);}errors++;}}if(data.cards !== undefined){let data106 = data.cards;if(Array.isArray(data106)){const len18 = data106.length;for(let i6=0; i6<len18; i6++){let data107 = data106[i6];if(data107 && typeof data107 == "object" && !Array.isArray(data107)){if(data107.dot === undefined){const err245 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "dot"},message:"must have required property '"+"dot"+"'"};if(vErrors === null){vErrors = [err245];}else {vErrors.push(err245);}errors++;}if(data107.title === undefined){const err246 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "title"},message:"must have required property '"+"title"+"'"};if(vErrors === null){vErrors = [err246];}else {vErrors.push(err246);}errors++;}if(data107.items === undefined){const err247 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/required",keyword:"required",params:{missingProperty: "items"},message:"must have required property '"+"items"+"'"};if(vErrors === null){vErrors = [err247];}else {vErrors.push(err247);}errors++;}for(const key18 in data107){if(!(((key18 === "dot") || (key18 === "title")) || (key18 === "items"))){const err248 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key18},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err248];}else {vErrors.push(err248);}errors++;}}if(data107.dot !== undefined){let data108 = data107.dot;if(!(((((((data108 === "cyan") || (data108 === "emerald")) || (data108 === "violet")) || (data108 === "amber")) || (data108 === "rose")) || (data108 === "orange")) || (data108 === "slate"))){const err249 = {instancePath:instancePath+"/cards/" + i6+"/dot",schemaPath:"common.schema.json#/$defs/cards/items/properties/dot/enum",keyword:"enum",params:{allowedValues: schema70.items.properties.dot.enum},message:"must be equal to one of the allowed values"};if(vErrors === null){vErrors = [err249];}else {vErrors.push(err249);}errors++;}}if(data107.title !== undefined){let data109 = data107.title;if(typeof data109 === "string"){if(func3(data109) < 1){const err250 = {instancePath:instancePath+"/cards/" + i6+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/minLength",keyword:"minLength",params:{limit: 1},message:"must NOT have fewer than 1 characters"};if(vErrors === null){vErrors = [err250];}else {vErrors.push(err250);}errors++;}}else {const err251 = {instancePath:instancePath+"/cards/" + i6+"/title",schemaPath:"common.schema.json#/$defs/cards/items/properties/title/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err251];}else {vErrors.push(err251);}errors++;}}if(data107.items !== undefined){let data110 = data107.items;if(Array.isArray(data110)){const len19 = data110.length;for(let i7=0; i7<len19; i7++){if(typeof data110[i7] !== "string"){const err252 = {instancePath:instancePath+"/cards/" + i6+"/items/" + i7,schemaPath:"common.schema.json#/$defs/cards/items/properties/items/items/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err252];}else {vErrors.push(err252);}errors++;}}}else {const err253 = {instancePath:instancePath+"/cards/" + i6+"/items",schemaPath:"common.schema.json#/$defs/cards/items/properties/items/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err253];}else {vErrors.push(err253);}errors++;}}}else {const err254 = {instancePath:instancePath+"/cards/" + i6,schemaPath:"common.schema.json#/$defs/cards/items/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err254];}else {vErrors.push(err254);}errors++;}}}else {const err255 = {instancePath:instancePath+"/cards",schemaPath:"common.schema.json#/$defs/cards/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err255];}else {vErrors.push(err255);}errors++;}}}else {const err256 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"};if(vErrors === null){vErrors = [err256];}else {vErrors.push(err256);}errors++;}validate36.errors = vErrors;return errors === 0;}validate36.evaluated = {"props":true,"dynamicProps":false,"dynamicItems":false};+export function workflow(data, context = undefined) {+ if (!workflowSchema(data, context)) {+ workflow.errors = workflowSchema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ workflow.errors = [{+ instancePath: `${context?.instancePath || ''}/meta/output`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ workflow.errors = null;+ return true;+}+workflow.evaluated = workflowSchema.evaluated;+export function sequence(data, context = undefined) {+ if (!sequenceSchema(data, context)) {+ sequence.errors = sequenceSchema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ sequence.errors = [{+ instancePath: `${context?.instancePath || ''}/meta/output`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ sequence.errors = null;+ return true;+}+sequence.evaluated = sequenceSchema.evaluated;+export function dataflow(data, context = undefined) {+ if (!dataflowSchema(data, context)) {+ dataflow.errors = dataflowSchema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ dataflow.errors = [{+ instancePath: `${context?.instancePath || ''}/meta/output`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ dataflow.errors = null;+ return true;+}+dataflow.evaluated = dataflowSchema.evaluated;+export function lifecycle(data, context = undefined) {+ if (!lifecycleSchema(data, context)) {+ lifecycle.errors = lifecycleSchema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ lifecycle.errors = [{+ instancePath: `${context?.instancePath || ''}/meta/output`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ lifecycle.errors = null;+ return true;+}+lifecycle.evaluated = lifecycleSchema.evaluated;+export function architecture(data, context = undefined) {+ if (!architectureSchema(data, context)) {+ architecture.errors = architectureSchema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ architecture.errors = [{+ instancePath: `${context?.instancePath || ''}/meta/output`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ architecture.errors = null;+ return true;+}+architecture.evaluated = architectureSchema.evaluated;diff --git a/archify/renderers/shared/output-path.mjs b/archify/renderers/shared/output-path.mjsindex e8e480a2..fc7aa039 100644--- a/archify/renderers/shared/output-path.mjs+++ b/archify/renderers/shared/output-path.mjs@@ -1,236 +1,309 @@-import fs from 'node:fs';import path from 'node:path';+import { containedBy, resolvePhysicalLocation, sameLocation } from './path-semantics.mjs';+import { PortablePathError, validatePortablePath } from './portable-path.mjs';-const MAX_SYMLINK_DEPTH = 64;-const directorySemanticsCache = new Map();-let semanticsProbeSequence = 0;--function splitAbsolute(absolutePath) {- const root = path.parse(absolutePath).root;- return {- root,- segments: absolutePath.slice(root.length).split(path.sep).filter(Boolean),- };-}--function canonicalize(targetPath, depth) {- const absolutePath = path.resolve(targetPath);- const { root, segments } = splitAbsolute(absolutePath);- let current = root;-- for (let index = 0; index < segments.length; index += 1) {- const candidate = path.join(current, segments[index]);- let stat;- try {- stat = fs.lstatSync(candidate);- } catch (error) {- if (error.code === 'ENOENT' || error.code === 'ENOTDIR') {- return path.resolve(current, ...segments.slice(index));- }- throw error;- }-- if (stat.isSymbolicLink()) {- if (depth >= MAX_SYMLINK_DEPTH) {- const error = new Error(`Could not resolve path because a symbolic-link cycle includes "${candidate}".`);- error.code = 'ELOOP';- error.path = candidate;- throw error;- }- const link = fs.readlinkSync(candidate);- const linkTarget = path.isAbsolute(link) ? link : path.resolve(path.dirname(candidate), link);- return canonicalize(path.join(linkTarget, ...segments.slice(index + 1)), depth + 1);- }-- current = fs.realpathSync.native(candidate);+export function canonicalFuturePath(targetPath) {+ const resolution = resolvePhysicalLocation(targetPath);+ if (resolution.status === 'resolved') {+ if (resolution.location.kind === 'existing') return resolution.location.path;+ return path.join(+ resolution.location.ancestorPath,+ ...resolution.location.unresolved,+ );}-- return path.normalize(current);+ const output = path.resolve(targetPath);+ if (resolution.reason.code === 'symlink-cycle') {+ throw new OutputPathError(`Output path contains a symbolic-link cycle: "${output}".`, {+ code: 'output/symlink-cycle',+ message: 'Output path could not be resolved because it contains a symbolic-link cycle.',+ subject: { output },+ evidence: { relation: resolution.reason },+ supportedFixes: ['remove the symbolic-link cycle or choose an output path outside it'],+ });+ }+ throw new OutputPathError('Output path could not be resolved safely.', {+ code: 'output/path-resolution-indeterminate',+ message: 'Output path could not be resolved safely for the requested filesystem location.',+ subject: { output },+ evidence: { relation: resolution.reason },+ supportedFixes: ['use an ordinary local filesystem path that can be resolved safely, then retry'],+ });}-export function canonicalFuturePath(targetPath) {- try {- return canonicalize(targetPath, 0);- } catch (error) {- if (error?.code !== 'ELOOP') throw error;- const output = path.resolve(targetPath);+export function pathsAlias(leftPath, rightPath) {+ const relation = sameLocation(leftPath, rightPath);+ if (relation.status === 'match') return true;+ if (relation.status === 'different') return false;+ if (relation.reason.code === 'ancestor-not-directory') return false;+ if (relation.reason.code === 'symlink-cycle') {+ const output = path.resolve(relation.reason.side === 'right' ? rightPath : leftPath);throw new OutputPathError(`Output path contains a symbolic-link cycle: "${output}".`, {code: 'output/symlink-cycle',message: 'Output path could not be resolved because it contains a symbolic-link cycle.',subject: { output },- evidence: {- systemCode: 'ELOOP',- ...(error.path ? { cycleAt: path.resolve(error.path) } : {}),- },+ evidence: { relation: relation.reason },supportedFixes: ['remove the symbolic-link cycle or choose an output path outside it'],});}+ throw new OutputPathError('Path identity could not be determined safely.', {+ code: 'output/path-identity-indeterminate',+ message: 'Path identity could not be determined safely for the requested filesystem location.',+ subject: { left: path.resolve(leftPath), right: path.resolve(rightPath) },+ evidence: { relation: relation.reason },+ supportedFixes: ['use ordinary local filesystem paths whose identity can be verified, then retry'],+ });}-function hasFileIdentity(stat) {- return stat.ino !== 0 && stat.ino !== 0n;+function pathIsInside(directoryPath, targetPath) {+ const relation = containedBy(directoryPath, targetPath);+ if (relation.status === 'match') return true;+ if (relation.status === 'different') return false;+ throw new OutputPathError('Output containment could not be determined safely.', {+ code: 'output/containment-indeterminate',+ message: 'Output containment could not be determined safely for the requested filesystem location.',+ subject: { output: path.resolve(targetPath), cwd: path.resolve(directoryPath) },+ evidence: { relation: relation.reason },+ supportedFixes: ['use an output beneath an ordinary local directory whose identity can be verified'],+ });}-function sameFileIdentity(left, right) {- return hasFileIdentity(left)- && hasFileIdentity(right)- && left.dev === right.dev- && left.ino === right.ino;+function authoredOutputDiagnostic(error, rawOutput) {+ const absolute = error?.reason === 'absolute';+ const code = absolute ? 'output/meta-absolute' : 'output/meta-path-syntax';+ const message = absolute+ ? 'meta.output must be a relative path resolved from the current working directory.'+ : 'meta.output must be a portable POSIX-relative path.';+ return {+ code,+ message,+ subject: { output: rawOutput, path: '/meta/output' },+ evidence: {+ reason: error?.reason || 'invalid',+ ...(error?.segmentIndex !== undefined ? { segmentIndex: error.segmentIndex } : {}),+ ...(error?.segment !== undefined ? { segment: error.segment } : {}),+ ...(error?.utf8Bytes !== undefined ? { utf8Bytes: error.utf8Bytes } : {}),+ ...(error?.utf16CodeUnits !== undefined ? { utf16CodeUnits: error.utf16CodeUnits } : {}),+ ...(error?.limit !== undefined ? { limit: error.limit } : {}),+ },+ supportedFixes: ['set meta.output to a portable relative .html path such as reports/diagram.html'],+ };}-function nearestExistingDirectory(targetPath) {- let directory = path.dirname(targetPath);- while (true) {- try {- const stat = fs.statSync(directory);- if (stat.isDirectory()) {- return {- path: fs.realpathSync.native(directory),- stat,- };- }- } catch (error) {- if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') return null;- }- const parent = path.dirname(directory);- if (parent === directory) return null;- directory = parent;- }+function nativeOutputDiagnostic(rawOutput, reason, details = {}) {+ return {+ code: 'output/native-path-syntax',+ message: 'The output path is not a valid native filesystem path on this host.',+ subject: { output: rawOutput },+ evidence: { reason, ...details },+ supportedFixes: ['choose an ordinary filesystem path without device names, alternate data streams, trailing dots or spaces, or overlong components'],+ };}-function directoryIdentityKey(directory) {- if (!hasFileIdentity(directory.stat)) return null;- return `${directory.stat.dev}:${directory.stat.ino}`;+function throwNativeOutputDiagnostic(rawOutput, reason, details = {}) {+ const diagnostic = nativeOutputDiagnostic(rawOutput, reason, details);+ throw new OutputPathError(diagnostic.message, diagnostic);}-function probeNamesAlias(directoryPath, authoredName, lookupName) {- let fileDescriptor;- let created = false;- let result = null;- let cleaned = true;- const authoredPath = path.join(directoryPath, authoredName);- const lookupPath = path.join(directoryPath, lookupName);- try {- fileDescriptor = fs.openSync(authoredPath, 'wx', 0o600);- created = true;- fs.closeSync(fileDescriptor);- fileDescriptor = undefined;+function windowsExtendedTailComponents(rawOutput, tail) {+ const authoredComponents = tail.split('\\');+ // Preserve one trailing separator for directory arguments, but never repair+ // an empty component inside the raw extended namespace.+ if (authoredComponents.slice(0, -1).some((component) => component.length === 0)) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-extended-root');+ }+ return authoredComponents.filter(Boolean);+}- let authored;- let lookup;- try {- authored = fs.statSync(authoredPath);- lookup = fs.statSync(lookupPath);- } catch (error) {- if (error.code === 'ENOENT') result = false;- }- if (authored && lookup) {- if (sameFileIdentity(authored, lookup)) {- result = true;- } else {- try {- result = fs.realpathSync.native(authoredPath) === fs.realpathSync.native(lookupPath);- } catch {- result = null;- }- }- }- } catch {- result = null;- } finally {- if (fileDescriptor !== undefined) {- try {- fs.closeSync(fileDescriptor);- } catch {- cleaned = false;- }- }- if (created) {- try {- fs.unlinkSync(authoredPath);- } catch {- cleaned = false;- }+function validateWindowsNativeComponent(rawOutput, component, componentIndex) {+ try {+ // Prefix the component so a colon is classified as an ADS separator,+ // rather than allowing the generic URI detector to claim it first.+ validatePortablePath(`native/${component}`, { profile: 'output' });+ } catch (error) {+ if (!(error instanceof PortablePathError)) throw error;+ // Native Windows arguments may intentionally name an existing 8.3 alias.+ // Portable authored/archive paths reject that ambiguous spelling, while+ // native resolution lets the filesystem prove the existing target.+ if (error.reason === 'windows-short-name') {+ if (component.length <= 255) return;+ throwNativeOutputDiagnostic(rawOutput, 'component-too-long', {+ component,+ componentIndex,+ utf16CodeUnits: component.length,+ limit: 255,+ });}+ // Native Windows filesystems bound components in UTF-16 code units. The+ // stricter UTF-8 bound belongs to portable authored/archive names only.+ if (error.reason === 'component-too-long' && error.utf16CodeUnits <= 255) return;+ throwNativeOutputDiagnostic(rawOutput, error.reason, {+ component,+ componentIndex,+ ...(error.character !== undefined ? { character: error.character } : {}),+ ...(error.utf8Bytes !== undefined ? { utf8Bytes: error.utf8Bytes } : {}),+ ...(error.utf16CodeUnits !== undefined ? { utf16CodeUnits: error.utf16CodeUnits } : {}),+ ...(error.limit !== undefined ? { limit: error.limit } : {}),+ });}- return cleaned ? result : null;}-function probeDirectorySemantics(directory) {- const cacheKey = directoryIdentityKey(directory);- if (cacheKey && directorySemanticsCache.has(cacheKey)) {- return directorySemanticsCache.get(cacheKey);+function windowsExtendedPathComponents(rawOutput) {+ // The extended-length namespace deliberately bypasses Win32 normalization.+ // Inspect its original spelling so a dot segment cannot retarget a UNC share.+ if (rawOutput.includes('/')) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-extended-separator', { character: '/' });+ }+ if (/^\\\\\?\\(?:GLOBALROOT|Device)(?:\\|$)/iu.test(rawOutput)) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-device-namespace');}- semanticsProbeSequence += 1;- const suffix = `${process.pid}-${Date.now().toString(36)}-${semanticsProbeSequence}`;- const caseAuthored = `.archify-Case-Probe-${suffix}`;- const normalizationAuthored = `.archify-norm-\u00e9-probe-${suffix}`;- const semantics = {- caseInsensitive: probeNamesAlias(- directory.path,- caseAuthored,- caseAuthored.toLowerCase(),- ),- normalizationInsensitive: probeNamesAlias(- directory.path,- normalizationAuthored,- normalizationAuthored.normalize('NFD'),- ),- };- if (- cacheKey- && semantics.caseInsensitive !== null- && semantics.normalizationInsensitive !== null- ) {- directorySemanticsCache.set(cacheKey, semantics);+ const drive = rawOutput.match(/^\\\\\?\\[A-Za-z]:\\/u);+ if (drive) {+ return windowsExtendedTailComponents(rawOutput, rawOutput.slice(drive[0].length));}- return semantics;-}-function sameDirectory(left, right) {- return left.path === right.path || sameFileIdentity(left.stat, right.stat);-}+ const uncPrefix = rawOutput.match(/^\\\\\?\\UNC\\/iu);+ if (uncPrefix) {+ const authoredTail = rawOutput.slice(uncPrefix[0].length);+ const components = authoredTail.split('\\');+ if (components.length < 2 || components[0].length === 0 || components[1].length === 0) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-extended-root');+ }+ return windowsExtendedTailComponents(rawOutput, authoredTail);+ }-function futurePathsAlias(leftPath, rightPath) {- const left = canonicalFuturePath(leftPath);- const right = canonicalFuturePath(rightPath);- if (left === right) return true;+ throwNativeOutputDiagnostic(rawOutput, 'windows-extended-root');+}- const leftDirectory = nearestExistingDirectory(left);- const rightDirectory = nearestExistingDirectory(right);- if (!leftDirectory || !rightDirectory || !sameDirectory(leftDirectory, rightDirectory)) {- return false;+function validateWindowsRawUncRoot(rawOutput) {+ if (!/^[\\/]{2}/u.test(rawOutput) || /^[\\/]{2}[.?][\\/]/u.test(rawOutput)) return;+ // Validate the raw server/share boundary before win32.normalize can collapse+ // an empty share or mix the two UNC separator spellings.+ if (!/^([\\/])\1[^\\/]+\1[^\\/]+(?:[\\/]|$)/u.test(rawOutput)) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-unc-root');}+}- const semantics = probeDirectorySemantics(leftDirectory);- let comparableLeft = path.relative(leftDirectory.path, left);- let comparableRight = path.relative(rightDirectory.path, right);- if (semantics.normalizationInsensitive !== false) {- comparableLeft = comparableLeft.normalize('NFC');- comparableRight = comparableRight.normalize('NFC');+function windowsPathComponents(rawOutput, normalized) {+ const authoredUncPrefix = /^[\\/]{2}/u.test(rawOutput);+ if (/^\\\\\.\\/u.test(normalized)) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-device-namespace');+ }+ if (/^\\\\\?\\/u.test(normalized)) {+ throwNativeOutputDiagnostic(rawOutput, 'windows-extended-root');+ }+ if (normalized.startsWith('\\\\')) {+ const unc = normalized.match(/^\\\\([^\\]+)\\([^\\]+)(?:\\|$)/u);+ if (!unc) throwNativeOutputDiagnostic(rawOutput, 'windows-unc-root');+ validateWindowsNativeComponent(rawOutput, unc[1], 0);+ validateWindowsNativeComponent(rawOutput, unc[2], 1);+ return normalized.slice(unc[0].length).split('\\').filter(Boolean);}- if (semantics.caseInsensitive !== false) {- comparableLeft = comparableLeft.toLowerCase();- comparableRight = comparableRight.toLowerCase();+ if (authoredUncPrefix) throwNativeOutputDiagnostic(rawOutput, 'windows-unc-root');+ if (normalized.startsWith('\\')) {+ throwNativeOutputDiagnostic(rawOutput, 'current-drive-rooted');}- return comparableLeft === comparableRight;+ const root = path.win32.parse(normalized).root;+ return normalized+ .slice(root.length)+ .split(/[\\/]+/u)+ // normalize() retains leading navigation for a relative path. Those dot+ // segments are path syntax, not filename components subject to name rules.+ .filter((component) => component && component !== '.' && component !== '..');}-export function pathsAlias(leftPath, rightPath) {- if (futurePathsAlias(leftPath, rightPath)) return true;- try {- const left = fs.statSync(leftPath);- const right = fs.statSync(rightPath);- return sameFileIdentity(left, right);- } catch {- return false;+/**+ * Validate command-line/default output paths using the active host's native+ * syntax. Unlike authored portable paths, absolute paths and native separators+ * remain supported. File outputs reject a trailing separator before native+ * resolution can erase it; directory callers must opt in explicitly. The+ * component bound also protects derived sidecars from failing after an+ * operation has already started mutating the destination.+ */+export function validateNativeOutputPath(+ rawOutput,+ { platform = process.platform, kind = 'file' } = {},+) {+ if (kind !== 'file' && kind !== 'directory') {+ throw new TypeError(`Unsupported native output path kind: ${JSON.stringify(kind)}`);+ }+ if (typeof rawOutput !== 'string' || rawOutput.length === 0) {+ throwNativeOutputDiagnostic(rawOutput, 'empty');+ }+ if (rawOutput.includes('\0')) throwNativeOutputDiagnostic(rawOutput, 'nul-character');+ if (/[\uD800-\uDFFF]/u.test(rawOutput)) {+ throwNativeOutputDiagnostic(rawOutput, 'unpaired-surrogate');+ }+ const hasTrailingSeparator = platform === 'win32'+ ? /[\\/]$/u.test(rawOutput)+ : rawOutput.endsWith(path.posix.sep);+ if (kind === 'file' && hasTrailingSeparator) {+ throwNativeOutputDiagnostic(rawOutput, 'trailing-separator', { kind });+ }++ let normalized;+ let components;+ if (platform === 'win32') {+ if (/^[A-Za-z]:(?:$|[^\\/])/u.test(rawOutput)) {+ throwNativeOutputDiagnostic(rawOutput, 'drive-relative');+ }+ const extendedPrefix = rawOutput.startsWith('\\\\?\\');+ if (extendedPrefix) {+ components = windowsExtendedPathComponents(rawOutput);+ } else {+ validateWindowsRawUncRoot(rawOutput);+ normalized = path.win32.normalize(rawOutput);+ components = windowsPathComponents(rawOutput, normalized);+ }+ for (const [componentIndex, component] of components.entries()) {+ validateWindowsNativeComponent(rawOutput, component, componentIndex);+ }+ } else {+ normalized = path.resolve(rawOutput);+ const root = path.parse(normalized).root;+ components = normalized.slice(root.length).split(path.sep).filter(Boolean);+ for (const [componentIndex, component] of components.entries()) {+ const utf8Bytes = Buffer.byteLength(component, 'utf8');+ if (utf8Bytes > 255) {+ throwNativeOutputDiagnostic(rawOutput, 'component-too-long', {+ component,+ componentIndex,+ utf8Bytes,+ limit: 255,+ });+ }+ }}+ return rawOutput;}-function pathIsInside(directoryPath, targetPath) {- const relative = path.relative(canonicalFuturePath(directoryPath), canonicalFuturePath(targetPath));- return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`));+/** Validate a CLI directory argument before native resolution can normalize away its raw syntax. */+export function resolveNativeOutputDirectory(+ rawDirectory,+ { platform = process.platform, cwd = process.cwd() } = {},+) {+ validateNativeOutputPath(rawDirectory, { platform, kind: 'directory' });+ const pathApi = platform === 'win32' ? path.win32 : path.posix;+ return pathApi.resolve(cwd, rawDirectory);+}++export function validateAuthoredOutputPath(rawOutput) {+ try {+ validatePortablePath(rawOutput, { profile: 'output' });+ } catch (error) {+ if (!(error instanceof PortablePathError)) throw error;+ const diagnostic = authoredOutputDiagnostic(error, rawOutput);+ throw new OutputPathError(diagnostic.message, diagnostic);+ }+ if (path.posix.extname(rawOutput).toLowerCase() !== '.html') {+ throw new OutputPathError('meta.output must target an .html file.', {+ code: 'output/meta-extension',+ message: 'meta.output must target an .html file.',+ subject: { output: rawOutput, path: '/meta/output' },+ supportedFixes: ['change meta.output to a portable path ending in .html'],+ });+ }+ return rawOutput;}export class OutputPathError extends Error {@@ -256,28 +329,16 @@ export function resolveOutputPath({otherOutputPaths = [],cwd = process.cwd(),requiredExtension = '.html',+ platform = process.platform,}) {- const rawOutput = requestedOutput || authoredOutput || defaultOutput;- const source = requestedOutput ? 'cli' : (authoredOutput ? 'meta' : 'default');- if (- source === 'meta'- && (path.isAbsolute(rawOutput) || path.posix.isAbsolute(rawOutput) || path.win32.isAbsolute(rawOutput))- ) {- throw new OutputPathError('meta.output must be a relative path.', {- code: 'output/meta-absolute',- message: 'meta.output must be a relative path resolved from the current working directory.',- subject: { output: rawOutput },- supportedFixes: ['set meta.output to a relative .html path inside the current working directory'],- });- }- if (source === 'meta' && path.extname(rawOutput).toLowerCase() !== '.html') {- throw new OutputPathError('meta.output must target an .html file.', {- code: 'output/meta-extension',- message: 'meta.output must target an .html file.',- subject: { output: rawOutput },- supportedFixes: ['change meta.output to a path ending in .html'],- });- }+ if (authoredOutput !== undefined) validateAuthoredOutputPath(authoredOutput);+ const source = requestedOutput !== undefined+ ? 'cli'+ : (authoredOutput !== undefined ? 'meta' : 'default');+ const rawOutput = source === 'cli'+ ? requestedOutput+ : (source === 'meta' ? authoredOutput : defaultOutput);+ if (source !== 'meta') validateNativeOutputPath(rawOutput, { platform, kind: 'file' });const outputPath = path.resolve(cwd, rawOutput);if (source === 'meta' && path.extname(canonicalFuturePath(outputPath)).toLowerCase() !== '.html') {throw new OutputPathError('meta.output must resolve to an .html file.', {diff --git a/archify/renderers/shared/path-semantics.mjs b/archify/renderers/shared/path-semantics.mjsnew file mode 100644index 00000000..8638bb77--- /dev/null+++ b/archify/renderers/shared/path-semantics.mjs@@ -0,0 +1,946 @@+import crypto from 'node:crypto';+import fs from 'node:fs';+import path from 'node:path';++const MAX_SYMLINK_DEPTH = 64;+const RECENT_PROBE_NAME_LIMIT = 128;+const recentProbeNames = new Set();++function result(status, code, details = {}) {+ return {+ status,+ reason: {+ code,+ ...details,+ },+ };+}++function unknown(code, details = {}) {+ return result('unknown', code, details);+}++function systemFailure(code, error, details = {}) {+ return unknown(code, {+ ...details,+ ...(typeof error?.code === 'string' ? { systemCode: error.code } : {}),+ ...(typeof error?.recoveryPath === 'string' ? { recoveryPath: error.recoveryPath } : {}),+ ...(typeof error?.restoredAtTarget === 'boolean'+ ? { restoredAtTarget: error.restoredAtTarget }+ : {}),+ });+}++function hostPath() {+ return process.platform === 'win32' ? path.win32 : path.posix;+}++function absolutePath(input, side, basePath = process.cwd()) {+ if (typeof input !== 'string' || input.length === 0) {+ return {+ ok: false,+ failure: unknown('invalid-path', { side }),+ };+ }++ try {+ const pathApi = hostPath();+ if (pathApi.isAbsolute(input)) return { ok: true, path: input };+ if (pathApi.parse(input).root) {+ return {+ ok: false,+ failure: unknown('drive-relative-path', { side }),+ };+ }+ const separator = basePath.endsWith(pathApi.sep) ? '' : pathApi.sep;+ return { ok: true, path: `${basePath}${separator}${input}` };+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('invalid-path', error, { side }),+ };+ }+}++function rootFailure(code, side) {+ return {+ ok: false,+ failure: unknown(code, { side }),+ };+}++function splitWindowsExtendedTail(tail, side, { internalRelativeLinkTarget = false } = {}) {+ const authoredSegments = tail.split('\\');+ // A single final separator is harmless, while an internal empty segment+ // would require normalizing a raw extended path before it reaches Windows.+ if (!internalRelativeLinkTarget+ && authoredSegments.slice(0, -1).some((component) => component.length === 0)) {+ return rootFailure('windows-root-invalid', side);+ }+ const segments = authoredSegments.filter(Boolean);+ if (!internalRelativeLinkTarget+ && segments.some((component) => component === '.' || component === '..')) {+ return rootFailure('windows-root-invalid', side);+ }+ return { ok: true, segments };+}++function splitWindowsAbsolute(absolute, side, { internalRelativeLinkTarget = false } = {}) {+ if (/^[\\/]{2}\.[\\/]/u.test(absolute)) {+ return rootFailure('windows-namespace-unsupported', side);+ }+ if (/^[\\/]{2}\?[\\/]/u.test(absolute) && !absolute.startsWith('\\\\?\\')) {+ return rootFailure('windows-namespace-unsupported', side);+ }++ if (absolute.startsWith('\\\\?\\')) {+ if (absolute.includes('/')) return rootFailure('windows-root-invalid', side);+ if (+ /^\\\\\?\\(?:GLOBALROOT|Device)(?:\\|$)/iu.test(absolute)+ || /^\\\\\?\\Volume\{/iu.test(absolute)+ ) {+ return rootFailure('windows-namespace-unsupported', side);+ }++ const extendedUnc = absolute.match(/^(\\\\\?\\UNC\\([^\\]+)\\([^\\]+))(?:\\(.*))?$/iu);+ if (extendedUnc) {+ if ([extendedUnc[2], extendedUnc[3]].some((component) => component === '.' || component === '..')) {+ return rootFailure('windows-root-invalid', side);+ }+ const tail = splitWindowsExtendedTail(+ extendedUnc[4] || '',+ side,+ { internalRelativeLinkTarget },+ );+ if (!tail.ok) return tail;+ return {+ ok: true,+ root: `${extendedUnc[1]}\\`,+ segments: tail.segments,+ };+ }++ const extendedDrive = absolute.match(/^(\\\\\?\\[A-Za-z]:\\)(.*)$/u);+ if (extendedDrive) {+ const tail = splitWindowsExtendedTail(+ extendedDrive[2],+ side,+ { internalRelativeLinkTarget },+ );+ if (!tail.ok) return tail;+ return {+ ok: true,+ root: extendedDrive[1],+ segments: tail.segments,+ };+ }+ return rootFailure('windows-root-invalid', side);+ }++ const unc = absolute.match(/^[\\/]{2}([^\\/]+)[\\/]([^\\/]+)(?:[\\/](.*))?$/u);+ if (unc) {+ if ([unc[1], unc[2]].some((component) => component === '.' || component === '..')) {+ return rootFailure('windows-root-invalid', side);+ }+ return {+ ok: true,+ root: `\\\\${unc[1]}\\${unc[2]}\\`,+ segments: (unc[3] || '').split(/[\\/]+/u).filter(Boolean),+ };+ }++ const drive = absolute.match(/^([A-Za-z]:)[\\/](.*)$/u);+ if (drive) {+ return {+ ok: true,+ root: `${drive[1]}\\`,+ segments: drive[2].split(/[\\/]+/u).filter(Boolean),+ };+ }+ return rootFailure('windows-root-invalid', side);+}++function splitAbsolute(absolute, side, options) {+ if (process.platform === 'win32') return splitWindowsAbsolute(absolute, side, options);+ const root = path.posix.parse(absolute).root;+ return {+ ok: true,+ root,+ segments: absolute.slice(root.length).split(/\/+/u).filter(Boolean),+ };+}++function statBigInt(targetPath) {+ return fs.statSync(targetPath, { bigint: true });+}++function hasStableIdentity(stat) {+ return typeof stat?.dev === 'bigint'+ && typeof stat?.ino === 'bigint'+ && stat.ino !== 0n;+}++function compareKnownEntries(left, right, operation) {+ if (hasStableIdentity(left.stat) && hasStableIdentity(right.stat)) {+ const matches = left.stat.dev === right.stat.dev && left.stat.ino === right.stat.ino;+ return result(matches ? 'match' : 'different', matches ? 'file-identity-match' : 'file-identity-different', {+ operation,+ method: 'bigint-stat',+ });+ }++ if (left.realPath === right.realPath) {+ return result('match', 'native-realpath-match', {+ operation,+ method: 'native-realpath',+ });+ }++ return unknown('file-identity-unavailable', {+ operation,+ method: 'bigint-stat-and-native-realpath',+ });+}++function rememberProbeName(name) {+ recentProbeNames.add(name);+ if (recentProbeNames.size > RECENT_PROBE_NAME_LIMIT) {+ recentProbeNames.delete(recentProbeNames.values().next().value);+ }+}++function probeInterference(message, code = 'ARCHIFY_PROBE_IDENTITY_CHANGED', details = {}) {+ const error = new Error(message);+ error.code = code;+ Object.assign(error, details);+ return error;+}++function sameStableIdentity(left, right) {+ return hasStableIdentity(left)+ && hasStableIdentity(right)+ && left.dev === right.dev+ && left.ino === right.ino;+}++function preserveQuarantinedReplacement(quarantinePath, targetPath) {+ try {+ fs.linkSync(quarantinePath, targetPath);+ return { restoredAtTarget: true };+ } catch {+ // Preserve the quarantined entry when the original name was concurrently+ // occupied or the host cannot create a hard link. Never overwrite either.+ return { restoredAtTarget: false };+ }+}++function removeOwnedProbe(targetPath, expectedStat) {+ let currentStat;+ try {+ currentStat = fs.lstatSync(targetPath, { bigint: true });+ } catch (error) {+ if (error?.code === 'ENOENT') {+ return probeInterference('filesystem probe disappeared before cleanup', 'ARCHIFY_PROBE_MISSING');+ }+ return error;+ }+ if (!sameStableIdentity(expectedStat, currentStat)) {+ return probeInterference('filesystem probe identity changed before cleanup');+ }++ const quarantineName = `.archify-path-semantics-cleanup-${process.pid}-${crypto.randomBytes(10).toString('hex')}`;+ const quarantinePath = path.join(path.dirname(targetPath), quarantineName);+ rememberProbeName(quarantineName);+ try {+ // Move the checked name into a fresh, unpublished quarantine namespace.+ // A replacement introduced after the check is moved rather than deleted.+ fs.renameSync(targetPath, quarantinePath);+ } catch (error) {+ return error;+ }++ let quarantineStat;+ try {+ quarantineStat = fs.lstatSync(quarantinePath, { bigint: true });+ } catch (error) {+ error.recoveryPath = quarantinePath;+ error.restoredAtTarget = false;+ return error;+ }+ if (!sameStableIdentity(expectedStat, quarantineStat)) {+ const recovery = preserveQuarantinedReplacement(quarantinePath, targetPath);+ return probeInterference(+ 'filesystem probe identity changed during cleanup',+ 'ARCHIFY_PROBE_IDENTITY_CHANGED',+ { recoveryPath: quarantinePath, ...recovery },+ );+ }++ try {+ // The quarantine spelling did not exist before the atomic rename and is+ // never returned to callers. Legitimate target-path replacements therefore+ // remain outside the only namespace we unlink.+ fs.unlinkSync(quarantinePath);+ return null;+ } catch (error) {+ error.recoveryPath = quarantinePath;+ error.restoredAtTarget = false;+ return error;+ }+}++function resolvePlan({ root, segments }, side, depth) {+ if (depth > MAX_SYMLINK_DEPTH) {+ return {+ ok: false,+ failure: unknown('symlink-cycle', { side }),+ };+ }++ let current;+ let currentStat;+ try {+ current = fs.realpathSync.native(root);+ currentStat = statBigInt(current);+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('root-resolution-failed', error, { side }),+ };+ }++ for (let index = 0; index < segments.length; index += 1) {+ const segment = segments[index];+ if (segment === '.') continue;+ if (segment === '..') {+ if (!currentStat.isDirectory()) {+ return {+ ok: false,+ failure: unknown('ancestor-not-directory', { side, segmentIndex: index }),+ };+ }+ try {+ current = fs.realpathSync.native(hostPath().dirname(current));+ currentStat = statBigInt(current);+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('path-resolution-failed', error, { side, segmentIndex: index }),+ };+ }+ continue;+ }++ const candidate = hostPath().join(current, segment);+ let candidateStat;+ try {+ candidateStat = fs.lstatSync(candidate, { bigint: true });+ } catch (error) {+ if (error?.code === 'ENOENT') {+ if (!currentStat.isDirectory()) {+ return {+ ok: false,+ failure: unknown('ancestor-not-directory', { side, segmentIndex: index }),+ };+ }+ const unresolved = segments.slice(index).filter((item) => item !== '.');+ if (unresolved.includes('..')) {+ return {+ ok: false,+ failure: unknown('future-parent-traversal-indeterminate', {+ side,+ segmentIndex: index,+ }),+ };+ }+ return {+ ok: true,+ existing: false,+ ancestor: {+ realPath: current,+ stat: currentStat,+ },+ unresolved,+ };+ }+ if (error?.code === 'ENOTDIR') {+ return {+ ok: false,+ failure: systemFailure('ancestor-not-directory', error, { side, segmentIndex: index }),+ };+ }+ return {+ ok: false,+ failure: systemFailure('path-resolution-failed', error, { side, segmentIndex: index }),+ };+ }++ if (candidateStat.isSymbolicLink()) {+ let linkPlan;+ try {+ const authoredTarget = fs.readlinkSync(candidate);+ const pathApi = hostPath();+ const internalRelativeLinkTarget = !pathApi.isAbsolute(authoredTarget)+ && !pathApi.parse(authoredTarget).root;+ const parsedTarget = absolutePath(authoredTarget, side, hostPath().dirname(candidate));+ if (!parsedTarget.ok) return parsedTarget;+ const target = splitAbsolute(parsedTarget.path, side, { internalRelativeLinkTarget });+ if (!target.ok) return target;+ linkPlan = {+ root: target.root,+ segments: [...target.segments, ...segments.slice(index + 1)],+ };+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('symlink-resolution-failed', error, { side, segmentIndex: index }),+ };+ }+ return resolvePlan(linkPlan, side, depth + 1);+ }++ if (index < segments.length - 1 && !candidateStat.isDirectory()) {+ return {+ ok: false,+ failure: unknown('ancestor-not-directory', { side, segmentIndex: index }),+ };+ }++ try {+ current = fs.realpathSync.native(candidate);+ currentStat = statBigInt(current);+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('path-resolution-failed', error, { side, segmentIndex: index }),+ };+ }+ }++ return {+ ok: true,+ existing: true,+ entry: {+ realPath: current,+ stat: currentStat,+ },+ unresolved: [],+ };+}++function resolveLocation(input, side) {+ const parsed = absolutePath(input, side);+ if (!parsed.ok) return parsed;+ const plan = splitAbsolute(parsed.path, side);+ if (!plan.ok) return plan;+ return resolvePlan(plan, side, 0);+}++function semanticNameEnvelope(name) {+ const names = new Set([name]);+ const pending = [name];+ while (pending.length > 0 && names.size <= 64) {+ const current = pending.shift();+ const candidates = [+ current.normalize('NFC'),+ current.normalize('NFD'),+ current.toLocaleLowerCase('en-US'),+ current.toLocaleUpperCase('en-US'),+ ];+ for (const candidate of candidates) {+ if (names.has(candidate)) continue;+ names.add(candidate);+ pending.push(candidate);+ }+ }+ return names.size <= 64 ? names : null;+}++function semanticEnvelopesOverlap(leftName, rightName) {+ const left = semanticNameEnvelope(leftName);+ const right = semanticNameEnvelope(rightName);+ if (!left || !right) return true;+ for (const spelling of left) {+ if (right.has(spelling)) return true;+ }+ return false;+}++function windowsDeviceName(name) {+ const stem = name.split('.')[0].replace(/[ .]+$/u, '').toUpperCase();+ return /^(?:CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[1-9¹²³]|LPT[1-9¹²³])$/u.test(stem);+}++function futureWindowsNameRisk(leftName, rightName) {+ if (process.platform !== 'win32') return null;+ const windowsShortName = /~[1-9][0-9]*(?:\.|$)/iu;+ if (windowsShortName.test(leftName) || windowsShortName.test(rightName)) {+ return unknown('future-short-name-indeterminate', { method: 'windows-8dot3' });+ }+ if (windowsDeviceName(leftName) || windowsDeviceName(rightName)) {+ return unknown('future-device-name-indeterminate', { method: 'windows-device-name' });+ }+ if (/[ .]$/.test(leftName) || /[ .]$/.test(rightName)) {+ return unknown('future-trim-name-indeterminate', { method: 'windows-trim-alias' });+ }+ return null;+}++/**+ * Resolve one existing or future path through the host filesystem without+ * exposing a string key for identity comparisons.+ */+export function resolvePhysicalLocation(targetPath) {+ const resolution = resolveLocation(targetPath, 'target');+ if (!resolution.ok) return resolution.failure;+ if (resolution.existing) {+ return {+ status: 'resolved',+ location: {+ kind: 'existing',+ path: resolution.entry.realPath,+ },+ reason: {+ code: 'existing-native-realpath',+ method: 'native-realpath',+ },+ };+ }+ return {+ status: 'resolved',+ location: {+ kind: 'future',+ ancestorPath: resolution.ancestor.realPath,+ unresolved: [...resolution.unresolved],+ },+ reason: {+ code: 'future-physical-ancestor',+ method: 'native-realpath',+ },+ };+}++function probeNameAlias(directoryPath, leftName, rightName) {+ if (leftName === rightName) {+ return result('match', 'future-name-exact', { method: 'lexical-exact' });+ }+ if (recentProbeNames.has(leftName) || recentProbeNames.has(rightName)) {+ return result('different', 'internal-probe-name', { method: 'probe-suppression' });+ }+ const windowsRisk = futureWindowsNameRisk(leftName, rightName);+ if (windowsRisk) return windowsRisk;+ if (!semanticEnvelopesOverlap(leftName, rightName)) {+ return result('different', 'future-name-distinct', { method: 'semantic-envelope' });+ }++ const prefix = `.archify-path-semantics-${process.pid}-${crypto.randomBytes(10).toString('hex')}-`;+ const probeName = `${prefix}${leftName}`;+ const lookupName = `${prefix}${rightName}`;+ const componentLength = (name) => process.platform === 'win32'+ ? name.length+ : Buffer.byteLength(name, 'utf8');+ if (componentLength(probeName) > 255 || componentLength(lookupName) > 255) {+ return unknown('future-name-probe-unrepresentable', {+ method: 'direct-filesystem-probe',+ systemCode: 'ENAMETOOLONG',+ });+ }++ let probePath;+ let probeStat;+ let descriptor;+ let comparison;+ let cleanupError;+ try {+ // Probe entries must live directly in the directory being queried. On+ // Windows case sensitivity is per-directory and a child may not inherit it.+ rememberProbeName(probeName);+ rememberProbeName(lookupName);+ probePath = path.join(directoryPath, probeName);+ const lookupPath = path.join(directoryPath, lookupName);+ descriptor = fs.openSync(probePath, 'wx', 0o600);+ probeStat = fs.fstatSync(descriptor, { bigint: true });+ fs.closeSync(descriptor);+ descriptor = undefined;++ let authoredStat;+ let lookupStat;+ try {+ authoredStat = statBigInt(probePath);+ lookupStat = statBigInt(lookupPath);+ } catch (error) {+ if (error?.code === 'ENOENT') {+ comparison = result('different', 'future-name-different', { method: 'filesystem-probe' });+ } else {+ comparison = systemFailure('future-name-probe-failed', error, { method: 'filesystem-probe' });+ }+ }++ if (!comparison) {+ const identity = compareKnownEntries(+ { realPath: fs.realpathSync.native(probePath), stat: authoredStat },+ { realPath: fs.realpathSync.native(lookupPath), stat: lookupStat },+ 'future-name',+ );+ if (identity.status === 'match') {+ comparison = result('match', 'future-name-alias', { method: 'filesystem-probe' });+ } else if (identity.status === 'different') {+ comparison = result('different', 'future-name-different', { method: 'filesystem-probe' });+ } else {+ comparison = identity;+ }+ }+ } catch (error) {+ comparison = systemFailure('future-name-probe-failed', error, { method: 'filesystem-probe' });+ } finally {+ if (descriptor !== undefined) {+ try {+ fs.closeSync(descriptor);+ } catch (error) {+ cleanupError = error;+ }+ }+ if (probeStat) cleanupError = cleanupError ?? removeOwnedProbe(probePath, probeStat);+ }++ if (cleanupError) {+ return systemFailure('future-name-probe-cleanup-failed', cleanupError, {+ method: 'filesystem-probe',+ ...(comparison ? { comparison: comparison.reason } : {}),+ });+ }+ return comparison;+}++function sidecarCaseKey(component) {+ // The candidate is accepted only after the containing filesystem confirms+ // that the original grapheme and this spelling name the same entry.+ return component.toLocaleUpperCase('en-US').toLocaleLowerCase('en-US');+}++function transformSidecarComponent(directoryPath, component, transform, phase) {+ if (typeof Intl.Segmenter !== 'function') {+ return {+ ok: false,+ failure: unknown('sidecar-unicode-segmentation-unavailable', {+ operation: 'sidecar-namespace-key',+ }),+ };+ }+ const segmenter = new Intl.Segmenter('en-US', { granularity: 'grapheme' });+ const comparisons = new Map();+ const output = [];+ for (const { segment } of segmenter.segment(component)) {+ const candidate = transform(segment);+ if (candidate === segment) {+ output.push(segment);+ continue;+ }+ const cacheKey = `${segment}\0${candidate}`;+ let comparison = comparisons.get(cacheKey);+ if (!comparison) {+ comparison = probeNameAlias(directoryPath, segment, candidate);+ comparisons.set(cacheKey, comparison);+ }+ if (comparison.status === 'unknown') {+ return {+ ok: false,+ failure: unknown(`sidecar-${phase}-semantics-indeterminate`, {+ operation: 'sidecar-namespace-key',+ cause: comparison.reason,+ }),+ };+ }+ output.push(comparison.status === 'match' ? candidate : segment);+ }+ return {+ ok: true,+ component: output.join(''),+ };+}++/**+ * Produce a stable component for a sidecar namespace in one existing+ * directory. The returned string is a collision-domain key, not a canonical+ * path and must never be used to decide whether two filesystem entries match.+ */+export function sidecarNamespaceComponentKey(directoryPath, component) {+ if (typeof component !== 'string' || component.length === 0+ || component === '.' || component === '..'+ || hostPath().basename(component) !== component) {+ return unknown('invalid-sidecar-component', {+ operation: 'sidecar-namespace-key',+ });+ }++ const directory = resolveLocation(directoryPath, 'sidecar-directory');+ if (!directory.ok) return directory.failure;+ if (!directory.existing) {+ return unknown('sidecar-directory-missing', {+ operation: 'sidecar-namespace-key',+ });+ }+ if (!directory.entry.stat.isDirectory()) {+ return unknown('sidecar-parent-not-directory', {+ operation: 'sidecar-namespace-key',+ });+ }++ const normalized = transformSidecarComponent(+ directory.entry.realPath,+ component,+ (segment) => segment.normalize('NFC'),+ 'normalization',+ );+ if (!normalized.ok) return normalized.failure;+ const cased = transformSidecarComponent(+ directory.entry.realPath,+ normalized.component,+ sidecarCaseKey,+ 'case',+ );+ if (!cased.ok) return cased.failure;+ const renormalized = transformSidecarComponent(+ directory.entry.realPath,+ cased.component,+ (segment) => segment.normalize('NFC'),+ 'normalization',+ );+ if (!renormalized.ok) return renormalized.failure;++ return {+ status: 'resolved',+ directoryPath: directory.entry.realPath,+ componentKey: renormalized.component,+ reason: {+ code: 'sidecar-namespace-key',+ method: 'directory-filesystem-probe',+ },+ };+}++function compareUnmaterializedNames(leftName, rightName) {+ if (leftName === rightName) {+ return result('match', 'future-name-exact', { method: 'lexical-exact' });+ }+ const windowsRisk = futureWindowsNameRisk(leftName, rightName);+ if (windowsRisk) return windowsRisk;+ if (!semanticEnvelopesOverlap(leftName, rightName)) {+ return result('different', 'future-name-distinct', { method: 'semantic-envelope' });+ }+ return unknown('future-descendant-semantics-indeterminate', {+ method: 'unmaterialized-directory',+ });+}++function compareFutureLocations(left, right) {+ const ancestor = compareKnownEntries(left.ancestor, right.ancestor, 'future-ancestor');+ if (ancestor.status !== 'match') return ancestor;++ if (left.unresolved.length !== right.unresolved.length) {+ return result('different', 'future-depth-different', {+ operation: 'same-location',+ leftDepth: left.unresolved.length,+ rightDepth: right.unresolved.length,+ });+ }++ let probedSegments = 0;+ for (let index = 0; index < left.unresolved.length; index += 1) {+ const names = index === 0+ ? probeNameAlias(+ left.ancestor.realPath,+ left.unresolved[index],+ right.unresolved[index],+ )+ : compareUnmaterializedNames(left.unresolved[index], right.unresolved[index]);+ if (names.reason.method === 'filesystem-probe') probedSegments += 1;+ if (names.status !== 'match') {+ const { code, ...reasonDetails } = names.reason;+ return result(names.status, code, {+ ...reasonDetails,+ operation: 'same-location',+ segmentIndex: index,+ });+ }+ }++ return result('match', probedSegments > 0 ? 'future-location-alias' : 'future-location-exact', {+ operation: 'same-location',+ method: probedSegments > 0 ? 'filesystem-probe' : 'lexical-exact',+ probedSegments,+ });+}++/**+ * Compare two existing filesystem entries by physical identity.+ * Missing or unidentifiable entries return `unknown`, never `different`.+ */+export function sameEntry(leftPath, rightPath) {+ const left = resolveLocation(leftPath, 'left');+ if (!left.ok) return left.failure;+ const right = resolveLocation(rightPath, 'right');+ if (!right.ok) return right.failure;++ if (!left.existing || !right.existing) {+ return unknown('entry-missing', {+ operation: 'same-entry',+ missing: [+ ...(!left.existing ? ['left'] : []),+ ...(!right.existing ? ['right'] : []),+ ],+ });+ }++ return compareKnownEntries(left.entry, right.entry, 'same-entry');+}++/**+ * Compare two existing or future write targets using the containing filesystem's+ * actual name semantics. Existing hard links and resolved symbolic links match.+ */+export function sameLocation(leftPath, rightPath) {+ const left = resolveLocation(leftPath, 'left');+ if (!left.ok) return left.failure;+ const right = resolveLocation(rightPath, 'right');+ if (!right.ok) return right.failure;++ if (left.existing && right.existing) {+ return compareKnownEntries(left.entry, right.entry, 'same-location');+ }+ if (left.existing !== right.existing) {+ return result('different', 'location-existence-different', {+ operation: 'same-location',+ existing: left.existing ? 'left' : 'right',+ });+ }+ return compareFutureLocations(left, right);+}++/** Compare the physical locations of the two paths' parent directories. */+export function sameParent(leftPath, rightPath) {+ const left = absolutePath(leftPath, 'left');+ if (!left.ok) return left.failure;+ const right = absolutePath(rightPath, 'right');+ if (!right.ok) return right.failure;++ return sameLocation(hostPath().dirname(left.path), hostPath().dirname(right.path));+}++function parentEntry(entry) {+ const parentPath = hostPath().dirname(entry.realPath);+ if (parentPath === entry.realPath) return null;+ try {+ const realPath = fs.realpathSync.native(parentPath);+ return {+ ok: true,+ entry: {+ realPath,+ stat: statBigInt(realPath),+ },+ };+ } catch (error) {+ return {+ ok: false,+ failure: systemFailure('ancestor-resolution-failed', error, {+ operation: 'contained-by',+ }),+ };+ }+}++/**+ * Determine physical containment in an existing directory. The comparison is+ * inclusive and follows links; the target may exist or name a future location.+ */+export function containedBy(directoryPath, targetPath) {+ const directory = resolveLocation(directoryPath, 'directory');+ if (!directory.ok) return directory.failure;+ if (directory.existing && !directory.entry.stat.isDirectory()) {+ return unknown('container-not-directory', { operation: 'contained-by' });+ }++ const target = resolveLocation(targetPath, 'target');+ if (!target.ok) return target.failure;++ if (!directory.existing) {+ if (target.existing) {+ return unknown('container-missing', { operation: 'contained-by' });+ }+ const ancestor = compareKnownEntries(directory.ancestor, target.ancestor, 'contained-by');+ if (ancestor.status !== 'match') return ancestor;+ if (target.unresolved.length < directory.unresolved.length) {+ return result('different', 'future-container-prefix-too-deep', {+ operation: 'contained-by',+ });+ }+ for (let index = 0; index < directory.unresolved.length; index += 1) {+ const segment = index === 0+ ? probeNameAlias(+ directory.ancestor.realPath,+ directory.unresolved[index],+ target.unresolved[index],+ )+ : compareUnmaterializedNames(+ directory.unresolved[index],+ target.unresolved[index],+ );+ if (segment.status === 'match') continue;+ const { code, ...reasonDetails } = segment.reason;+ return result(segment.status, code, {+ ...reasonDetails,+ operation: 'contained-by',+ segmentIndex: index,+ });+ }+ return result('match', 'future-container-prefix-match', {+ operation: 'contained-by',+ target: 'future',+ depth: target.unresolved.length - directory.unresolved.length,+ });+ }++ let current;+ if (!target.existing) {+ current = target.ancestor;+ } else if (target.entry.stat.isDirectory()) {+ current = target.entry;+ } else {+ const parent = parentEntry(target.entry);+ if (!parent?.ok) return parent?.failure ?? unknown('ancestor-resolution-failed', {+ operation: 'contained-by',+ });+ current = parent.entry;+ }++ let depth = 0;+ let identityWasUnknown = false;+ while (current) {+ const comparison = compareKnownEntries(directory.entry, current, 'contained-by');+ if (comparison.status === 'match') {+ return result('match', 'physical-ancestor-match', {+ operation: 'contained-by',+ depth,+ target: target.existing ? 'existing' : 'future',+ });+ }+ if (comparison.status === 'unknown') identityWasUnknown = true;++ const parent = parentEntry(current);+ if (parent === null) break;+ if (!parent.ok) return parent.failure;+ current = parent.entry;+ depth += 1;+ }++ if (identityWasUnknown) {+ return unknown('containment-identity-unavailable', {+ operation: 'contained-by',+ target: target.existing ? 'existing' : 'future',+ });+ }+ return result('different', 'physical-ancestor-not-found', {+ operation: 'contained-by',+ target: target.existing ? 'existing' : 'future',+ });+}diff --git a/archify/renderers/shared/portable-path.mjs b/archify/renderers/shared/portable-path.mjsnew file mode 100644index 00000000..99c63ebb--- /dev/null+++ b/archify/renderers/shared/portable-path.mjs@@ -0,0 +1,406 @@+const PORTABLE_PATH_PROFILES = new Set(['output', 'repo', 'archive']);+const WINDOWS_SAFE_PROFILES = new Set(['output', 'archive']);+const WINDOWS_RESERVED_NAME = /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/iu;+const WINDOWS_SHORT_NAME = /~[1-9][0-9]*(?:\.|$)/iu;+const URI_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/u;+const CONTROL_CHARACTER = /\p{Cc}/u;+const WINDOWS_INVALID_CHARACTER = /[<>"|?*]/u;+const MAX_SEMANTIC_VARIANTS = 32;++export class PortablePathError extends Error {+ constructor(message, {+ code,+ reason,+ value,+ profile,+ segment,+ segmentIndex,+ character,+ index,+ conflictIndex,+ conflictValue,+ collisionKind,+ semantics,+ pathPart,+ conflictPathPart,+ utf8Bytes,+ utf16CodeUnits,+ limit,+ } = {}) {+ super(message);+ this.name = 'PortablePathError';+ this.code = code;+ this.reason = reason;+ this.value = value;+ this.profile = profile;+ if (segment !== undefined) this.segment = segment;+ if (segmentIndex !== undefined) this.segmentIndex = segmentIndex;+ if (character !== undefined) this.character = character;+ if (index !== undefined) this.index = index;+ if (conflictIndex !== undefined) this.conflictIndex = conflictIndex;+ if (conflictValue !== undefined) this.conflictValue = conflictValue;+ if (collisionKind !== undefined) this.collisionKind = collisionKind;+ if (semantics !== undefined) this.semantics = semantics;+ if (pathPart !== undefined) this.pathPart = pathPart;+ if (conflictPathPart !== undefined) this.conflictPathPart = conflictPathPart;+ if (utf8Bytes !== undefined) this.utf8Bytes = utf8Bytes;+ if (utf16CodeUnits !== undefined) this.utf16CodeUnits = utf16CodeUnits;+ if (limit !== undefined) this.limit = limit;+ }+}++function pathError(value, profile, reason, message, details = {}) {+ return new PortablePathError(message, {+ code: `portable-path/${reason}`,+ reason,+ value,+ profile,+ ...details,+ });+}++function assertProfile(profile) {+ if (PORTABLE_PATH_PROFILES.has(profile)) return;+ throw pathError(+ undefined,+ profile,+ 'profile',+ `Portable path profile must be one of: ${[...PORTABLE_PATH_PROFILES].join(', ')}.`,+ );+}++export function validatePortablePath(value, options = {}) {+ const profile = options?.profile;+ assertProfile(profile);++ if (typeof value !== 'string') {+ throw pathError(value, profile, 'type', 'Portable path must be a string.');+ }+ if (value.length === 0) {+ throw pathError(value, profile, 'empty', 'Portable path must not be empty.');+ }+ if (/^[A-Za-z]:[\\/]/u.test(value) || value.startsWith('/') || value.startsWith('\\')) {+ throw pathError(value, profile, 'absolute', 'Portable path must be relative.');+ }+ if (/^[A-Za-z]:/u.test(value)) {+ throw pathError(+ value,+ profile,+ 'drive-relative',+ 'Portable path must not use a drive-relative Windows path.',+ );+ }+ if (URI_SCHEME.test(value)) {+ throw pathError(value, profile, 'uri', 'Portable path must not be a URI.');+ }+ if (value.includes('\\')) {+ throw pathError(+ value,+ profile,+ 'backslash',+ 'Portable path must use forward slashes as separators.',+ );+ }++ const segments = value.split('/');+ for (const [segmentIndex, segment] of segments.entries()) {+ const segmentDetails = { segment, segmentIndex };+ if (segment.length === 0) {+ throw pathError(+ value,+ profile,+ 'empty-segment',+ 'Portable path must not contain empty segments.',+ segmentDetails,+ );+ }+ if (segment === '.' || segment === '..') {+ throw pathError(+ value,+ profile,+ 'dot-segment',+ 'Portable path must not contain dot segments.',+ segmentDetails,+ );+ }+ const controlMatch = segment.match(CONTROL_CHARACTER);+ if (controlMatch) {+ throw pathError(+ value,+ profile,+ 'control',+ 'Portable path must not contain control characters.',+ { ...segmentDetails, character: controlMatch[0] },+ );+ }+ const surrogateMatch = segment.match(/[\uD800-\uDFFF]/u);+ if (surrogateMatch) {+ throw pathError(+ value,+ profile,+ 'unpaired-surrogate',+ 'Portable path must not contain unpaired UTF-16 surrogates.',+ { ...segmentDetails, character: surrogateMatch[0] },+ );+ }++ if (!WINDOWS_SAFE_PROFILES.has(profile)) continue;+ if (segment.includes(':')) {+ throw pathError(+ value,+ profile,+ 'windows-ads',+ 'Portable path must not select a Windows alternate data stream.',+ { ...segmentDetails, character: ':' },+ );+ }+ const invalidMatch = segment.match(WINDOWS_INVALID_CHARACTER);+ if (invalidMatch) {+ throw pathError(+ value,+ profile,+ 'windows-invalid-character',+ 'Portable path contains a character that is invalid in Windows file names.',+ { ...segmentDetails, character: invalidMatch[0] },+ );+ }+ if (/[. ]$/u.test(segment)) {+ throw pathError(+ value,+ profile,+ 'windows-trailing-dot-space',+ 'Portable path segments must not end with a dot or space.',+ segmentDetails,+ );+ }+ if (WINDOWS_RESERVED_NAME.test(segment)) {+ throw pathError(+ value,+ profile,+ 'windows-reserved-name',+ 'Portable path must not use a reserved Windows device name.',+ segmentDetails,+ );+ }+ if (WINDOWS_SHORT_NAME.test(segment)) {+ throw pathError(+ value,+ profile,+ 'windows-short-name',+ 'Portable path must not use a Windows 8.3 short-name shape.',+ segmentDetails,+ );+ }+ const utf8Bytes = Buffer.byteLength(segment, 'utf8');+ const utf16CodeUnits = segment.length;+ if (utf8Bytes > 255 || utf16CodeUnits > 255) {+ throw pathError(+ value,+ profile,+ 'component-too-long',+ 'Portable path segments must fit both UTF-8 and UTF-16 filesystem component limits.',+ {+ ...segmentDetails,+ utf8Bytes,+ utf16CodeUnits,+ limit: 255,+ },+ );+ }+ }++ return value;+}++function collisionError(values, profile, index, conflictIndex, reason, details = {}) {+ return new PortablePathError(+ `Portable paths at indexes ${conflictIndex} and ${index} collide under portable filesystem semantics.`,+ {+ code: 'portable-path/collision',+ reason,+ value: values[index],+ profile,+ index,+ conflictIndex,+ conflictValue: values[conflictIndex],+ ...details,+ },+ );+}++function createSemanticIndex() {+ return new Map();+}++function semanticEnvelope(value, profile, index) {+ const variants = [value];+ const seen = new Set(variants);+ const transforms = [+ (candidate) => candidate.normalize('NFC'),+ (candidate) => candidate.normalize('NFD'),+ (candidate) => candidate.toLocaleLowerCase('en-US'),+ (candidate) => candidate.toLocaleUpperCase('en-US'),+ ];++ for (let cursor = 0; cursor < variants.length; cursor += 1) {+ for (const transform of transforms) {+ const transformed = transform(variants[cursor]);+ if (seen.has(transformed)) continue;+ if (variants.length >= MAX_SEMANTIC_VARIANTS) {+ throw pathError(+ value,+ profile,+ 'semantic-expansion',+ 'Portable path semantic comparison exceeded its bounded Unicode expansion.',+ { index, limit: MAX_SEMANTIC_VARIANTS },+ );+ }+ seen.add(transformed);+ variants.push(transformed);+ }+ }++ return variants;+}++function classifySemanticCollision(value, conflictValue) {+ if (value === conflictValue) return 'exact';+ if (value.normalize('NFC') === conflictValue.normalize('NFC')) return 'normalization';++ const directLowerMatch = value.toLocaleLowerCase('en-US')+ === conflictValue.toLocaleLowerCase('en-US');+ const directUpperMatch = value.toLocaleUpperCase('en-US')+ === conflictValue.toLocaleUpperCase('en-US');+ return directLowerMatch || directUpperMatch ? 'case' : 'case-and-normalization';+}++function findSemanticCollision(semanticIndex, value, profile, sourceIndex) {+ const variants = semanticEnvelope(value, profile, sourceIndex);+ for (const variant of variants) {+ const entry = semanticIndex.get(variant);+ if (entry) {+ return {+ entry,+ variants,+ semantics: classifySemanticCollision(value, entry.value),+ };+ }+ }+ return { entry: null, variants, semantics: null };+}++function rememberSemanticEntry(semanticIndex, entry, variants) {+ for (const variant of variants) {+ if (!semanticIndex.has(variant)) semanticIndex.set(variant, entry);+ }+}++export function validatePortablePathSet(values, options = {}) {+ const profile = options?.profile;+ assertProfile(profile);+ if (!Array.isArray(values)) {+ throw pathError(values, profile, 'set-type', 'Portable path set must be an array.');+ }++ const leafEntries = createSemanticIndex();+ const directoryEntries = createSemanticIndex();++ for (const [index, value] of values.entries()) {+ try {+ validatePortablePath(value, { profile });+ } catch (error) {+ if (error instanceof PortablePathError && error.index === undefined) error.index = index;+ throw error;+ }++ const leafCollision = findSemanticCollision(leafEntries, value, profile, index);+ if (leafCollision.entry) {+ const conflictIndex = leafCollision.entry.index;+ throw collisionError(+ values,+ profile,+ index,+ conflictIndex,+ leafCollision.semantics === 'exact' ? 'duplicate' : leafCollision.semantics,+ {+ collisionKind: 'entry',+ semantics: leafCollision.semantics,+ pathPart: value,+ conflictPathPart: leafCollision.entry.value,+ },+ );+ }++ const segments = value.split('/');+ const prefixes = segments.slice(0, -1).map((_, prefixIndex) => (+ segments.slice(0, prefixIndex + 1).join('/')+ ));+ for (const prefix of prefixes) {+ const directoryCollision = findSemanticCollision(directoryEntries, prefix, profile, index);+ if (directoryCollision.entry && directoryCollision.semantics !== 'exact') {+ throw collisionError(+ values,+ profile,+ index,+ directoryCollision.entry.index,+ `directory-${directoryCollision.semantics}`,+ {+ collisionKind: 'directory-spelling',+ semantics: directoryCollision.semantics,+ pathPart: prefix,+ conflictPathPart: directoryCollision.entry.value,+ },+ );+ }++ const fileCollision = findSemanticCollision(leafEntries, prefix, profile, index);+ if (fileCollision.entry) {+ throw collisionError(+ values,+ profile,+ index,+ fileCollision.entry.index,+ fileCollision.semantics === 'exact'+ ? 'tree-file'+ : `tree-file-${fileCollision.semantics}`,+ {+ collisionKind: 'tree-file',+ semantics: fileCollision.semantics,+ pathPart: prefix,+ conflictPathPart: fileCollision.entry.value,+ },+ );+ }+ }++ const directoryCollision = findSemanticCollision(directoryEntries, value, profile, index);+ if (directoryCollision.entry) {+ throw collisionError(+ values,+ profile,+ index,+ directoryCollision.entry.index,+ directoryCollision.semantics === 'exact'+ ? 'tree-file'+ : `tree-file-${directoryCollision.semantics}`,+ {+ collisionKind: 'tree-file',+ semantics: directoryCollision.semantics,+ pathPart: value,+ conflictPathPart: directoryCollision.entry.value,+ },+ );+ }++ rememberSemanticEntry(leafEntries, { index, value }, leafCollision.variants);+ for (const prefix of prefixes) {+ rememberSemanticEntry(+ directoryEntries,+ { index, value: prefix },+ semanticEnvelope(prefix, profile, index),+ );+ }+ }++ return values;+}diff --git a/archify/renderers/shared/repository-evidence.mjs b/archify/renderers/shared/repository-evidence.mjsindex e5187ee3..ac9399b4 100644--- a/archify/renderers/shared/repository-evidence.mjs+++ b/archify/renderers/shared/repository-evidence.mjs@@ -2,6 +2,7 @@ import { spawnSync } from 'node:child_process';import fs from 'node:fs';import path from 'node:path';import { throwDiagnosticError } from './diagnostics.mjs';+import { sameEntry } from './path-semantics.mjs';import { parseRepositoryRemote, redactRepositoryRemote, repositorySourceHref } from './repository-location.mjs';const FULL_SHA_RE = /^[a-f0-9]{40}$/i;@@ -42,6 +43,7 @@ function gitValue(repoRoot, args, failure) {function verifiedSourcePath(value, where) {const sourcePath = String(value || '');+ // path-contract-allow: git-path -- Git tree entries use repository-relative POSIX syntax.if (!sourcePath || sourcePath.startsWith('/') || sourcePath.includes('\\') || CONTROL_CHARACTER_RE.test(sourcePath)) {evidenceFailure('repository-evidence/path-invalid', `${where} must be a repo-relative POSIX path.`, {subject: { path: where },@@ -146,7 +148,15 @@ export function verifyRepositoryEvidence(diagramType, diagram, repoRootInput) {});}const gitRoot = gitValue(realRoot, ['rev-parse', '--show-toplevel'], `Evidence root "${realRoot}" is not a Git repository.`);- if (fs.realpathSync(gitRoot) !== realRoot) {+ const rootIdentity = sameEntry(realRoot, gitRoot);+ if (rootIdentity.status === 'unknown') {+ evidenceFailure('repository-evidence/root-identity-indeterminate', 'Could not determine whether the evidence root is the Git top-level directory.', {+ subject: { repoRoot: realRoot },+ evidence: { gitTopLevel: gitRoot, relation: rootIdentity.reason },+ supportedFixes: ['pass the readable Git top-level directory using its canonical filesystem path'],+ });+ }+ if (rootIdentity.status === 'different') {evidenceFailure('repository-evidence/root-not-top-level', `Evidence root must be the Git top-level directory: ${gitRoot}`, {subject: { repoRoot: realRoot },evidence: { gitTopLevel: gitRoot },diff --git a/archify/renderers/shared/repository-location.mjs b/archify/renderers/shared/repository-location.mjsindex 32257d62..aa6ee82d 100644--- a/archify/renderers/shared/repository-location.mjs+++ b/archify/renderers/shared/repository-location.mjs@@ -36,6 +36,7 @@ export function parseRepositoryRemote(value, { authored = false } = {}) {const endpoint = provider && ((protocol === 'https:' && port === '443') || (protocol === 'ssh:' && port === '22'))? 'standard' : `${protocol}${port}`;const pathKind = provider ? 'repository' : scp && !scpAbsolute ? 'relative' : 'absolute';+ // path-contract-allow: url-path -- GitHub repository names are case-insensitive URL identities.const identityPath = provider === 'github' ? repositoryPath.toLowerCase() : repositoryPath;const encodedPath = segments.map(encodeURIComponent).join('/');const canonicalUrl = scp ? `git@${hostname}:${scpAbsolute ? '/' : ''}${repositoryPath}`diff --git a/archify/schemas/README.md b/archify/schemas/README.mdindex 2c212262..66c8b0b2 100644--- a/archify/schemas/README.md+++ b/archify/schemas/README.md@@ -139,6 +139,9 @@ The five diagram schemas reference `common.schema.json#/$defs/...`:- `componentType` — `frontend`, `backend`, `database`, `cloud`, `security`,`messagebus`, `external`- `locale` — the bounded renderer locale, `en`, `zh-CN`, or `es`+- `portableOutputPath` — the portable POSIX-relative `.html` path used by+ `meta.output`; see the two output-path boundaries in the+ [delivery contract](../references/delivery-contract.md#output-path-contracts)- `brandMark` — one optional built-in brand ID or explicit HTTP(S) site URL- `variant` — `default`, `emphasis`, `security`, `dashed` (sequence messagesextend this list locally with `return`)@@ -150,6 +153,11 @@ The five diagram schemas reference `common.schema.json#/$defs/...`:Lifecycle state `type` is mode-specific (`start`/`active`/`waiting`/...) andstays in `lifecycle.schema.json`.+The JSON Schema definition is the portable contract's structurally expressible+preflight. The shipped generated validator wrapper and CLI additionally enforce+byte-based component limits and the complete runtime path contract; consumers+that need the same cross-platform acceptance boundary should use that wrapper.+## Runtime validationAt development time, `scripts/generate-validators.mjs` compiles all fivediff --git a/archify/schemas/architecture.schema.json b/archify/schemas/architecture.schema.jsonindex a4826e99..8cd74f8f 100644--- a/archify/schemas/architecture.schema.json+++ b/archify/schemas/architecture.schema.json@@ -16,7 +16,7 @@"title": { "type": "string", "minLength": 1 },"locale": { "$ref": "common.schema.json#/$defs/locale" },"subtitle": { "type": "string" },- "output": { "type": "string" },+ "output": { "$ref": "common.schema.json#/$defs/portableOutputPath" },"animation": { "$ref": "common.schema.json#/$defs/animation" },"visual_preset": { "$ref": "common.schema.json#/$defs/visualPreset" },"quality_profile": { "$ref": "common.schema.json#/$defs/qualityProfile" },diff --git a/archify/schemas/common.schema.json b/archify/schemas/common.schema.jsonindex 871a27cb..e73a2669 100644--- a/archify/schemas/common.schema.json+++ b/archify/schemas/common.schema.json@@ -19,6 +19,30 @@"qualityProfile": {"enum": ["standard", "showcase"]},+ "portableOutputPath": {+ "description": "A portable POSIX-relative HTML output path. It must be safe to interpret identically on every supported host filesystem.",+ "type": "string",+ "minLength": 1,+ "pattern": "^[^/]+(?:/[^/]+)*$",+ "allOf": [+ { "pattern": "(?:^|/)[^/]+[.][Hh][Tt][Mm][Ll]$" },+ { "not": { "pattern": "[\\\\<>:\"|?*\\u0000-\\u001F\\u007F-\\u009F]" } },+ { "not": { "pattern": "[\\uD800-\\uDFFF]" } },+ { "not": { "pattern": "(^|/)[.]{1,2}(/|$)" } },+ { "not": { "pattern": "[. ](/|$)" } },+ { "not": { "pattern": "(^|/)[^/]{256}" } },+ {+ "not": {+ "pattern": "(^|/)(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Nn][Ii][Nn][$]|[Cc][Oo][Nn][Oo][Uu][Tt][$]|[Cc][Oo][Mm][1-9¹²³]|[Ll][Pp][Tt][1-9¹²³])(?:[.]|/|$)"+ }+ },+ {+ "not": {+ "pattern": "(^|/)[^/]*~[1-9][0-9]*(?:[.]|/|$)"+ }+ }+ ]+ },"side": {"enum": ["left", "right", "top", "bottom"]},diff --git a/archify/schemas/dataflow.schema.json b/archify/schemas/dataflow.schema.jsonindex 6654c2ce..1e860685 100644--- a/archify/schemas/dataflow.schema.json+++ b/archify/schemas/dataflow.schema.json@@ -37,7 +37,7 @@"type": "string"},"output": {- "type": "string"+ "$ref": "common.schema.json#/$defs/portableOutputPath"},"animation": {"$ref": "common.schema.json#/$defs/animation"diff --git a/archify/schemas/lifecycle.schema.json b/archify/schemas/lifecycle.schema.jsonindex 7f50a5b6..0226d93d 100644--- a/archify/schemas/lifecycle.schema.json+++ b/archify/schemas/lifecycle.schema.json@@ -37,7 +37,7 @@"type": "string"},"output": {- "type": "string"+ "$ref": "common.schema.json#/$defs/portableOutputPath"},"animation": {"$ref": "common.schema.json#/$defs/animation"diff --git a/archify/schemas/sequence.schema.json b/archify/schemas/sequence.schema.jsonindex 6813ab9d..2c496f4a 100644--- a/archify/schemas/sequence.schema.json+++ b/archify/schemas/sequence.schema.json@@ -36,7 +36,7 @@"type": "string"},"output": {- "type": "string"+ "$ref": "common.schema.json#/$defs/portableOutputPath"},"animation": {"$ref": "common.schema.json#/$defs/animation"diff --git a/archify/schemas/workflow.schema.json b/archify/schemas/workflow.schema.jsonindex 1763a664..479fea27 100644--- a/archify/schemas/workflow.schema.json+++ b/archify/schemas/workflow.schema.json@@ -40,7 +40,7 @@"type": "string"},"output": {- "type": "string"+ "$ref": "common.schema.json#/$defs/portableOutputPath"},"animation": {"enum": [diff --git a/archify/scripts/check-update.mjs b/archify/scripts/check-update.mjsindex dd12e4ba..f7427b30 100644--- a/archify/scripts/check-update.mjs+++ b/archify/scripts/check-update.mjs@@ -19,6 +19,7 @@ import {validateReleaseNotesUrl,validateStableUpdateManifest,} from './update-contract.mjs';+import { sameEntry } from '../renderers/shared/path-semantics.mjs';const OPERATION_STATE_FILE = 'state.json';const OPERATION_OWNER_FILE = 'owner.json';@@ -249,19 +250,35 @@ async function readJsonFile(target, maxBytes, expectedMetadata = null) {function isWithinDirectory(directory, target) {const relative = path.relative(directory, target);return relative === ''+ // path-contract-allow: lexical-capability -- No-follow snapshots bind this mutation boundary.|| (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`));}+function physicalDirectorySuffix(directory, target) {+ const absoluteTarget = path.resolve(target);+ const parsed = path.parse(absoluteTarget);+ const segments = absoluteTarget.slice(parsed.root.length).split(path.sep).filter(Boolean);+ let prefix = parsed.root;+ for (let index = 0; index < segments.length; index += 1) {+ prefix = path.join(prefix, segments[index]);+ const relation = sameEntry(directory, prefix);+ if (relation.status === 'match') return segments.slice(index + 1);+ if (relation.status === 'unknown' && relation.reason.code === 'entry-missing') break;+ }+ return null;+}+async function canonicalizeTrustedDirectoryPrefix(target) {const absoluteTarget = path.resolve(target);const trustedDirectories = [...new Set([os.homedir(), os.tmpdir()].map((directory) => (path.resolve(directory))))].sort((left, right) => right.length - left.length);for (const trustedDirectory of trustedDirectories) {- if (!isWithinDirectory(trustedDirectory, absoluteTarget)) continue;+ const suffix = physicalDirectorySuffix(trustedDirectory, absoluteTarget);+ if (suffix === null) continue;try {const canonicalDirectory = await fs.realpath(trustedDirectory);- return path.resolve(canonicalDirectory, path.relative(trustedDirectory, absoluteTarget));+ return path.resolve(canonicalDirectory, ...suffix);} catch {// Fall back to validating the absolute path from its filesystem root.}@@ -331,7 +348,11 @@ function cacheTokenFor(cacheDirectory) {function resolveCacheTarget(token, target) {const resolved = path.resolve(target);- if (resolved === token.directory || !isWithinDirectory(token.directory, resolved)) {+ const relative = path.relative(token.directory, resolved);+ // This is a lexical capability check, not a physical-containment query. The+ // async lstat snapshots below bind the prepared directory and every mutation+ // parent across awaits; following a link here would weaken that no-link rule.+ if (relative === '' || !isWithinDirectory(token.directory, resolved)) {throw invalidateCacheToken(token, 'cache mutation escaped its prepared directory');}return resolved;@@ -1643,20 +1664,19 @@ async function runCli() {return silent('invalid-arguments');}-async function isMainModule() {- if (!process.argv[1]) return false;+export function isMainModule({+ argvPath = process.argv[1],+ modulePath = fileURLToPath(import.meta.url),+} = {}) {+ if (!argvPath) return false;try {- const [entryPath, modulePath] = await Promise.all([- fs.realpath(path.resolve(process.argv[1])),- fs.realpath(fileURLToPath(import.meta.url)),- ]);- return entryPath === modulePath;+ return sameEntry(argvPath, modulePath).status === 'match';} catch {- return path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));+ return false;}}-if (await isMainModule()) {+if (isMainModule()) {let result;try {result = await runCli();diff --git a/archify/scripts/generate-validators.mjs b/archify/scripts/generate-validators.mjsindex ab205bd1..2820e702 100644--- a/archify/scripts/generate-validators.mjs+++ b/archify/scripts/generate-validators.mjs@@ -48,7 +48,41 @@ validatorCode = validatorCode.replaceAll(ajvUcs2Import, inlineUcs2Length);if (validatorCode.includes('require(')) {throw new Error('AJV standalone output contains an unexpected runtime dependency');}-const generated = `${banner}${validatorCode}\n`;+const schemaValidators = {};+for (const type of diagramTypes) {+ const exportPattern = new RegExp(`export const ${type} = (validate\\d+);`);+ const match = validatorCode.match(exportPattern);+ if (!match) throw new Error(`AJV standalone output no longer exports the ${type} validator as expected`);+ schemaValidators[type] = match[1];+ validatorCode = validatorCode.replace(exportPattern, `const ${type}Schema = ${match[1]};`);+}++const portableOutputWrappers = diagramTypes.map((type) => `export function ${type}(data, context = undefined) {+ if (!${type}Schema(data, context)) {+ ${type}.errors = ${type}Schema.errors;+ return false;+ }+ const output = data?.meta?.output;+ if (typeof output === 'string') {+ try {+ validatePortablePath(output, { profile: 'output' });+ } catch (error) {+ ${type}.errors = [{+ instancePath: \`${'${context?.instancePath || \'\'}'}/meta/output\`,+ schemaPath: 'common.schema.json#/$defs/portableOutputPath',+ keyword: 'portablePath',+ params: { reason: error?.reason || 'invalid' },+ message: 'must satisfy the portable output path contract',+ }];+ return false;+ }+ }+ ${type}.errors = null;+ return true;+}+${type}.evaluated = ${type}Schema.evaluated;`).join('\n');++const generated = `${banner}import { validatePortablePath } from './portable-path.mjs';\n${validatorCode}\n${portableOutputWrappers}\n`;if (process.argv.includes('--check')) {const current = fs.existsSync(output)diff --git a/archify/test/architecture-compare-recovery.test.mjs b/archify/test/architecture-compare-recovery.test.mjsindex 014564e4..4a15c256 100644--- a/archify/test/architecture-compare-recovery.test.mjs+++ b/archify/test/architecture-compare-recovery.test.mjs@@ -18,13 +18,17 @@ const cases = [{ name: 'HTML restore failure retains its old backup', failures: ['commit-receipt', 'restore-html'], retained: ['html'] },{ name: 'receipt restore failure retains its old backup', failures: ['commit-receipt', 'restore-receipt'], retained: ['receipt'] },{ name: 'both restore failures retain both old backups', failures: ['commit-receipt', 'restore-receipt', 'restore-html'], retained: ['html', 'receipt'] },- { name: 'second backup failure restores the first target', failures: ['backup-receipt'] },+ {+ name: 'second backup failure restores the first target',+ failures: ['backup-receipt'],+ diagnostic: 'output/target-indeterminate',+ },{ name: 'second backup and HTML restore failures retain only HTML', failures: ['backup-receipt', 'restore-html'], retained: ['html'] },{ name: 'transient removal failure leaves no backup after successful restoration', failures: ['commit-receipt', 'remove-html'] },];function fixture(t) {- const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-compare-recovery-'));+ const root = fs.realpathSync.native(fs.mkdtempSync(path.join(os.tmpdir(), 'archify-compare-recovery-')));t.after(() => fs.rmSync(root, { recursive: true, force: true }));const targets = { html: path.join(root, 'review.html'), receipt: path.join(root, 'review.receipt.json') };const run = (preload, newHead = head, json = true) => spawnSync(process.execPath, [@@ -68,7 +72,7 @@ function inject(data, failures) {const wanted = new Set(${JSON.stringify(failures)});const fired = new Set();const rename = fs.renameSync;- const remove = fs.rmSync;+ const link = fs.linkSync;const inside = value => typeof value === 'string' && value.startsWith(root + path.sep);const staging = value => inside(value) && path.basename(path.dirname(value)).startsWith('.archify-compare-');function failOnce(action) {@@ -81,21 +85,87 @@ function inject(data, failures) {}fs.renameSync = function(source, target) {if (inside(source) && inside(target)) {- if (source === targets.receipt && staging(target)) failOnce('backup-receipt');- if (staging(source) && target === targets.receipt && path.basename(source) === path.basename(target)) failOnce('commit-receipt');- if (staging(source) && path.basename(source) === '.previous-output' && target === targets.html) failOnce('restore-html');- if (staging(source) && path.basename(source) === '.previous-receipt' && target === targets.receipt) failOnce('restore-receipt');+ if (source === targets.receipt+ && path.basename(path.dirname(target)).startsWith('.archify-remove-')+ && wanted.has('swap-backup-receipt')+ && !fired.has('swap-backup-receipt')) {+ fired.add('swap-backup-receipt');+ fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify('swap-backup-receipt') + '\\n');+ const displaced = path.join(root, '.displaced-receipt');+ rename.call(this, source, displaced);+ fs.unlinkSync(displaced);+ fs.writeFileSync(source, 'third-party receipt claimant', { flag: 'wx' });+ }+ if (source === targets.html+ && path.basename(path.dirname(target)).startsWith('.archify-remove-')+ && fired.has('commit-receipt')) failOnce('remove-html');}return rename.apply(this, arguments);};- fs.rmSync = function(target) {- if (target === targets.html && fired.has('commit-receipt')) failOnce('remove-html');- return remove.apply(this, arguments);+ fs.linkSync = function(source, target) {+ if (source === targets.receipt && staging(target)+ && path.basename(target) === '.previous-receipt') failOnce('backup-receipt');+ if (staging(source) && target === targets.receipt+ && path.basename(source) === path.basename(target)) failOnce('commit-receipt');+ if (staging(source) && path.basename(source) === '.previous-output' && target === targets.html) {+ if (wanted.has('claim-html') && !fired.has('claim-html')) {+ fired.add('claim-html');+ fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify('claim-html') + '\\n');+ fs.writeFileSync(target, 'third-party claimant', { flag: 'wx' });+ }+ failOnce('restore-html');+ }+ if (staging(source) && path.basename(source) === '.previous-receipt' && target === targets.receipt) failOnce('restore-receipt');+ return link.apply(this, arguments);};`);return { preload, log };}+test('compare recovery: a claimant created at the restore boundary is preserved', { timeout: 70000 }, (t) => {+ const data = fixture(t);+ const { preload, log } = inject(data, ['commit-receipt', 'claim-html']);+ const result = data.run(preload);+ assert.ifError(result.error);+ assert.notEqual(result.status, 0);+ assert.deepEqual(+ fs.readFileSync(log, 'utf8').trim().split('\n').map(JSON.parse).sort(),+ ['claim-html', 'commit-receipt'].sort(),+ );+ assert.equal(fs.readFileSync(data.targets.html, 'utf8'), 'third-party claimant');+ assert.deepEqual(fs.readFileSync(data.targets.receipt), data.old.receipt);++ const response = JSON.parse(result.stdout);+ assert.equal(response.diagnostics[0].code, 'delta/commit-rollback-failed');+ const recovery = response.diagnostics[0].evidence.recoveryFiles.find(+ ({ target }) => target === data.targets.html,+ );+ assert.ok(recovery, 'old HTML must remain available as recovery material');+ assert.deepEqual(fs.readFileSync(recovery.backup), data.old.html);+});++test('compare recovery: a claimant swapped at the final backup move is restored and the old receipt remains recoverable', { timeout: 70000 }, (t) => {+ const data = fixture(t);+ const { preload, log } = inject(data, ['swap-backup-receipt']);+ const result = data.run(preload);+ assert.ifError(result.error);+ assert.notEqual(result.status, 0);+ assert.deepEqual(+ fs.readFileSync(log, 'utf8').trim().split('\n').map(JSON.parse),+ ['swap-backup-receipt'],+ );+ assert.deepEqual(fs.readFileSync(data.targets.html), data.old.html);+ assert.equal(fs.readFileSync(data.targets.receipt, 'utf8'), 'third-party receipt claimant');++ const response = JSON.parse(result.stdout);+ assert.equal(response.diagnostics[0].code, 'delta/commit-rollback-failed');+ const recovery = response.diagnostics[0].evidence.recoveryFiles.find(+ ({ target }) => target === data.targets.receipt,+ );+ assert.ok(recovery, 'the old receipt must remain available as recovery material');+ assert.deepEqual(fs.readFileSync(recovery.backup), data.old.receipt);+});+for (const scenario of cases) {test(`compare recovery: ${scenario.name}`, { timeout: 70000 }, (t) => {const data = fixture(t);@@ -122,7 +192,10 @@ for (const scenario of cases) {const retained = scenario.retained || [];const incompleteRollback = retained.length > 0 || scenario.failures.includes('remove-html');const diagnostic = response.diagnostics[0];- assert.equal(diagnostic.code, incompleteRollback ? 'delta/commit-rollback-failed' : 'delta/commit-failed');+ assert.equal(+ diagnostic.code,+ scenario.diagnostic || (incompleteRollback ? 'delta/commit-rollback-failed' : 'delta/commit-failed'),+ );const evidence = diagnostic.evidence;for (const key of ['html', 'receipt'].filter((key) => !retained.includes(key))) {const restored = fs.readFileSync(data.targets[key]);diff --git a/archify/test/architecture-delta.test.mjs b/archify/test/architecture-delta.test.mjsindex ed43dbbb..e064d734 100644--- a/archify/test/architecture-delta.test.mjs+++ b/archify/test/architecture-delta.test.mjs@@ -4,7 +4,7 @@ import { execFileSync, spawnSync } from 'node:child_process';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';-import { fileURLToPath } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';import { createHash } from 'node:crypto';import {ArchitectureDeltaError,@@ -611,6 +611,91 @@ test('compare CLI writes a deterministic three-state artifact and complete sidecassert.deepEqual(validateArchitectureDeltaHtml(firstHtml, receipt), { ok: true, checksPassed: 10, checkCount: 10 });});+test('compare default receipts preserve distinct HTML extension spellings only when the filesystem does', () => {+ const caseRoot = fs.mkdtempSync(path.join(tmp, 'compare-receipt-extension-case-'));+ const lower = path.join(caseRoot, 'delta.html');+ const upper = path.join(caseRoot, 'delta.HTML');+ const lowerResult = run(['compare', 'architecture', baseFixture, headFixture, lower, '--json']);+ assert.equal(lowerResult.status, 0, lowerResult.stderr);+ const aliases = fs.existsSync(upper);+ const upperResult = run(['compare', 'architecture', baseFixture, headFixture, upper, '--json']);+ assert.equal(upperResult.status, 0, upperResult.stderr);++ const receipts = fs.readdirSync(caseRoot).filter((name) => name.endsWith('.receipt.json'));+ if (aliases) {+ assert.deepEqual(receipts, ['delta.receipt.json']);+ } else {+ assert.equal(receipts.length, 2);+ assert.ok(receipts.includes('delta.receipt.json'));+ assert.match(+ receipts.find((name) => name !== 'delta.receipt.json'),+ /^delta\.HTML\.~archify-[0-9a-f]{64}\.receipt\.json$/u,+ );+ }+});++test('compare prepares a missing nested parent before deriving its default receipt', () => {+ const caseRoot = fs.mkdtempSync(path.join(tmp, 'compare-receipt-nested-parent-'));+ const output = path.join(caseRoot, 'nested', 'delta.html');+ const result = run(['compare', 'architecture', baseFixture, headFixture, output, '--json']);++ assert.equal(result.status, 0, result.stderr || result.stdout);+ assert.equal(fs.existsSync(output), true);+ assert.equal(fs.existsSync(path.join(path.dirname(output), 'delta.receipt.json')), true);+});++test('compare validates an explicit receipt directory before preparing a missing output parent', () => {+ const caseRoot = fs.mkdtempSync(path.join(tmp, 'compare-explicit-receipt-parent-'));+ const outputDirectory = path.join(caseRoot, 'artifact');+ const receiptDirectory = path.join(caseRoot, 'receipt');+ const output = path.join(outputDirectory, 'delta.html');+ const receiptPath = path.join(receiptDirectory, 'delta.json');+ const result = run([+ 'compare', 'architecture', baseFixture, headFixture, output,+ '--receipt', receiptPath, '--json',+ ]);++ assert.equal(result.status, 1, result.stderr || result.stdout);+ assert.equal(JSON.parse(result.stdout).diagnostics[0].code, 'delta/receipt-directory');+ assert.equal(fs.existsSync(outputDirectory), false);+ assert.equal(fs.existsSync(receiptDirectory), false);+});++test('compare rejects an indeterminate default receipt namespace before creating outputs', () => {+ const caseRoot = fs.mkdtempSync(path.join(tmp, 'compare-receipt-unknown-'));+ const outputDirectory = path.join(caseRoot, 'nested');+ const output = path.join(outputDirectory, `${'A'.repeat(225)}.html`);+ const wrapper = path.join(caseRoot, 'deny-sidecar-probe.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+import { syncBuiltinESMExports } from 'node:module';+const openSync = fs.openSync;+fs.openSync = (file, ...args) => {+ if (path.basename(String(file)).startsWith('.archify-path-semantics-')) {+ const error = new Error('synthetic sidecar probe denial');+ error.code = 'EACCES';+ throw error;+ }+ return openSync(file, ...args);+};+syncBuiltinESMExports();+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'compare', 'architecture', ${JSON.stringify(baseFixture)}, ${JSON.stringify(headFixture)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const rejected = spawnSync(process.execPath, [wrapper], { cwd: caseRoot, encoding: 'utf8' });+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ const receipt = JSON.parse(rejected.stdout);+ assert.equal(receipt.diagnostics[0].code, 'delta/receipt-namespace-indeterminate');+ assert.equal(+ receipt.diagnostics[0].evidence.pathIdentity.code,+ 'sidecar-case-semantics-indeterminate',+ );+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(fs.readdirSync(outputDirectory), []);+});+test('checked-in Checkout compare artifact is reproducible from its authoritative inputs', () => {const artifact = path.join(tmp, 'checked-artifact.html');const receipt = path.join(tmp, 'checked-artifact.receipt.json');@@ -785,7 +870,7 @@ test('compare validates raw snapshots before canonicalization can discard invaliassert.equal(receipt.diagnostics[0].evidence.additionalProperty, 'unknown_top_level_fact');});-test('compare commit preflights both targets before replacing a trusted pair', () => {+test('compare rejects either unsupported target before staging a trusted pair', () => {const caseRoot = fs.mkdtempSync(path.join(tmp, 'pair-target-'));const output = path.join(caseRoot, 'review.html');const receiptPath = path.join(caseRoot, 'review.receipt.json');@@ -801,9 +886,10 @@ test('compare commit preflights both targets before replacing a trusted pair', (assert.equal(fs.readFileSync(output, 'utf8'), 'trusted html');assert.equal(fs.statSync(receiptPath).isDirectory(), true);const failure = JSON.parse(result.stdout);- assert.equal(failure.stage, 'commit');- assert.equal(failure.diagnostics[0].code, 'delta/commit-target');- assert.equal(failure.diagnostics[0].evidence.targetType, 'directory');+ assert.equal(failure.stage, 'prepare');+ assert.equal(failure.diagnostics[0].code, 'output/target-not-regular-file');+ assert.equal(failure.diagnostics[0].evidence.atomicOutput.code, 'target-not-regular-file');+ assert.equal(failure.diagnostics[0].evidence.atomicOutput.entryType, 'directory');});for (const side of ['base', 'head']) {diff --git a/archify/test/clean-skill-staging.test.mjs b/archify/test/clean-skill-staging.test.mjsindex b27a6b09..af836348 100644--- a/archify/test/clean-skill-staging.test.mjs+++ b/archify/test/clean-skill-staging.test.mjs@@ -6,7 +6,7 @@ import path from 'node:path';import test from 'node:test';import { fileURLToPath } from 'node:url';-import { stageCleanSkill } from '../../scripts/stage-clean-skill.mjs';+import { isMainModule, stageCleanSkill } from '../../scripts/stage-clean-skill.mjs';const stagerPath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../scripts/stage-clean-skill.mjs');const canonicalNotices = fs.readFileSync(@@ -42,12 +42,35 @@ function repositoryFixture() {write(root, 'archify/scripts/check-update.mjs', 'export {};\n');write(root, 'archify/scripts/update-contract.mjs', 'export {};\n');write(root, 'archify/renderers/shared/generated-validators.mjs', 'export {};\n');+ write(root, 'archify/renderers/shared/path-semantics.mjs', 'export {};\n');+ write(root, 'archify/renderers/shared/portable-path.mjs', 'export {};\n');write(root, 'archify/test/repository-only.test.mjs', 'throw new Error();\n');git(root, ['init']);git(root, ['add', 'THIRD_PARTY_NOTICES.md']);return root;}+test('clean staging entry detection accepts a physical alias and fails closed when identity is unknown', (t) => {+ const aliasRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-stage-entry-alias-'));+ t.after(() => fs.rmSync(aliasRoot, { recursive: true, force: true }));+ const aliasPath = path.join(aliasRoot, 'stage-clean-alias.mjs');+ try {+ fs.linkSync(stagerPath, aliasPath);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error?.code)) {+ t.skip(`hard-link aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }++ assert.equal(isMainModule({ argvPath: aliasPath, modulePath: stagerPath }), true);+ assert.equal(isMainModule({+ argvPath: path.join(aliasRoot, 'missing-entry.mjs'),+ modulePath: stagerPath,+ }), false);+});+test('clean staging rejects a packaged notice that diverges from the repository notice', () => {const root = repositoryFixture();const destination = path.join(root, 'staged-skill');@@ -68,6 +91,27 @@ test('clean staging rejects a packaged notice that diverges from the repository}});+test('clean staging requires shared path runtimes only when packaged code imports them', () => {+ const root = repositoryFixture();+ const destination = path.join(root, 'staged-skill');+ try {+ fs.writeFileSync(+ path.join(root, 'archify', 'renderers', 'shared', 'generated-validators.mjs'),+ "const runtime = import /* keep release dependencies complete */ (`./portable-path.mjs`);\nexport { runtime };\n",+ );+ git(root, ['add', '.']);+ git(root, ['rm', '--cached', '-f', 'archify/renderers/shared/portable-path.mjs']);++ assert.throws(+ () => stageCleanSkill({ repoRoot: root, destination }),+ /required package input is not tracked by Git: archify\/renderers\/shared\/portable-path[.]mjs/,+ );+ assert.equal(fs.existsSync(destination), false);+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});+test('clean staging rejects byte-identical but incomplete repository and packaged notices', () => {const root = repositoryFixture();const destination = path.join(root, 'staged-skill');diff --git a/archify/test/cli-output-types.test.mjs b/archify/test/cli-output-types.test.mjsindex 2676c479..d52dda11 100644--- a/archify/test/cli-output-types.test.mjs+++ b/archify/test/cli-output-types.test.mjs@@ -2,7 +2,7 @@ import { spawnSync } from 'node:child_process';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';-import { fileURLToPath } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';import test from 'node:test';import assert from 'node:assert/strict';import { startPreview } from '../bin/preview.mjs';@@ -199,3 +199,116 @@ test('compare rejects a JSON receipt symlink to a non-JSON target', t => {assert.equal(fs.readFileSync(target, 'utf8'), marker);assert.equal(fs.existsSync(output), false);});++test('compare accepts artifact and receipt parents that are aliases of the same directory', t => {+ const cwd = workspace(t);+ const outputDirectory = path.join(cwd, 'physical-output');+ const directoryAlias = path.join(cwd, 'output-alias');+ fs.mkdirSync(outputDirectory);+ try {+ fs.symlinkSync(outputDirectory, directoryAlias, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error.code)) {+ t.skip('directory aliases require permission');+ return;+ }+ throw error;+ }++ const output = path.join(outputDirectory, 'delta.html');+ const receipt = path.join(directoryAlias, 'delta.receipt.json');+ const result = run([+ 'compare', 'architecture', base, head, output,+ '--receipt', receipt, '--json',+ ], cwd);++ assert.equal(result.status, 0, result.stderr || result.stdout);+ assert.equal(JSON.parse(result.stdout).ok, true);+ assert.equal(fs.existsSync(output), true);+ assert.equal(JSON.parse(fs.readFileSync(receipt, 'utf8')).ok, true);+});++test('compare fails closed when artifact and receipt parent identity is indeterminate', t => {+ const cwd = workspace(t);+ const outputDirectory = path.join(cwd, 'output');+ fs.mkdirSync(outputDirectory);+ const output = path.join(outputDirectory, 'delta.html');+ const receipt = path.join(outputDirectory, 'delta.receipt.json');+ const wrapper = path.join(cwd, 'compare-parent-identity-wrapper.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const originalReadFileSync = fs.readFileSync;+const originalRealpathSyncNative = fs.realpathSync.native;+const blockedDirectory = originalRealpathSyncNative(${JSON.stringify(outputDirectory)});+let inputsRead = false;+fs.readFileSync = (file, ...args) => {+ const contents = originalReadFileSync(file, ...args);+ if (path.resolve(String(file)) === ${JSON.stringify(path.resolve(head))}) inputsRead = true;+ return contents;+};+fs.realpathSync.native = (file, ...args) => {+ if (inputsRead && path.resolve(String(file)) === path.resolve(blockedDirectory)) {+ throw Object.assign(new Error('injected parent identity failure'), { code: 'EACCES' });+ }+ return originalRealpathSyncNative(file, ...args);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'compare', 'architecture', ${JSON.stringify(base)}, ${JSON.stringify(head)}, ${JSON.stringify(output)}, '--receipt', ${JSON.stringify(receipt)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const result = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(result.status, 1, result.stderr || result.stdout);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.diagnostics[0].code, 'delta/receipt-directory-identity-indeterminate');+ assert.equal(failure.diagnostics[0].evidence.pathIdentity.systemCode, 'EACCES');+ assert.equal(fs.existsSync(output), false);+ assert.equal(fs.existsSync(receipt), false);+});++test('delivery provenance accepts an artifact reached through a directory alias', t => {+ const cwd = workspace(t);+ const outputDirectory = path.join(cwd, 'physical-output');+ const directoryAlias = path.join(cwd, 'output-alias');+ fs.mkdirSync(outputDirectory);+ try {+ fs.symlinkSync(outputDirectory, directoryAlias, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error.code)) {+ t.skip('directory aliases require permission');+ return;+ }+ throw error;+ }++ const output = path.join(outputDirectory, 'delivered.html');+ const alias = path.join(directoryAlias, 'delivered.html');+ const delivered = run(['deliver', 'workflow', workflow, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);++ const checked = run(['check', alias, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+});++test('delivery provenance fails closed when recorded output identity is indeterminate', t => {+ const cwd = workspace(t);+ const output = path.join(cwd, 'delivered.html');+ const delivered = run(['deliver', 'workflow', workflow, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ const artifactBefore = fs.readFileSync(output);+ const provenancePath = output.replace(/\.html$/i, '.delivery.json');+ const provenance = JSON.parse(fs.readFileSync(provenancePath, 'utf8'));+ provenance.output = path.join(cwd, 'missing-recorded-output.html');+ fs.writeFileSync(provenancePath, `${JSON.stringify(provenance, null, 2)}\n`);++ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 1, checked.stderr || checked.stdout);+ const failure = JSON.parse(checked.stdout);+ assert.equal(failure.diagnostics[0].code, 'delivery/provenance-output-indeterminate');+ assert.equal(failure.diagnostics[0].subject.recordedOutput, provenance.output);+ assert.equal(failure.diagnostics[0].evidence.pathIdentity.code, 'entry-missing');+ assert.deepEqual(failure.diagnostics[0].evidence.pathIdentity.missing, ['left']);+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.equal(JSON.parse(fs.readFileSync(provenancePath, 'utf8')).output, provenance.output);+});diff --git a/archify/test/cli.test.mjs b/archify/test/cli.test.mjsindex c4f64f9a..2dbcbd43 100644--- a/archify/test/cli.test.mjs+++ b/archify/test/cli.test.mjs@@ -13,6 +13,10 @@ const skillRoot = path.resolve(__dirname, '..');const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-cli-'));const cli = path.join(skillRoot, 'bin/archify.mjs');+test.afterEach(() => {+ fs.rmSync(path.join(tmp, '.archify-delivery-lock.json'), { force: true });+});+function run(args, options = {}) {return spawnSync(process.execPath, [cli, ...args], {cwd: options.cwd || skillRoot,@@ -25,8 +29,55 @@ function sha256(file) {return createHash('sha256').update(fs.readFileSync(file)).digest('hex');}+function deliverySidecarPath(file, suffix) {+ let artifact = path.resolve(file);+ try {+ artifact = fs.realpathSync.native(artifact);+ } catch (error) {+ if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') throw error;+ try {+ artifact = path.join(fs.realpathSync.native(path.dirname(artifact)), path.basename(artifact));+ } catch (directoryError) {+ if (directoryError.code !== 'ENOENT' && directoryError.code !== 'ENOTDIR') throw directoryError;+ }+ }+ return artifact.replace(/\.html?$/i, suffix);+}++function deliveryProvenancePath(file) {+ return deliverySidecarPath(file, '.delivery.json');+}+function deliveryPendingPath(file) {- return file.replace(/\.html?$/i, '.delivery-pending.json');+ return deliverySidecarPath(file, '.delivery-pending.json');+}++function deliveryLockPath(file) {+ const artifact = path.resolve(file);+ let directory;+ try {+ directory = path.dirname(fs.realpathSync.native(artifact));+ } catch (error) {+ if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') throw error;+ try {+ directory = fs.realpathSync.native(path.dirname(artifact));+ } catch (directoryError) {+ if (directoryError.code !== 'ENOENT' && directoryError.code !== 'ENOTDIR') throw directoryError;+ directory = path.dirname(artifact);+ }+ }+ return path.join(directory, '.archify-delivery-lock.json');+}++function legacyDeliveryLockPath(file) {+ return path.resolve(file).replace(/\.html?$/i, '.delivery-lock.json');+}++function deliveryStagingEntries(directory) {+ return fs.readdirSync(directory, { withFileTypes: true })+ .filter((entry) => entry.isDirectory() && entry.name.startsWith('.archify-delivery-'))+ .map((entry) => entry.name)+ .sort();}function successorDeliveryState({ receiptId, input, output, pid = process.pid }) {@@ -143,6 +194,7 @@ test('cli: doctor reports a complete installation is ready', () => {assert.match(result.stdout, /\[ok\] Core template/);assert.match(result.stdout, /\[ok\] Example renderer/);assert.match(result.stdout, /\[ok\] Live preview runtime/);+ assert.match(result.stdout, /\[ok\] Atomic output safety runtime/);assert.match(result.stdout, /\[ok\] Scenario recipe guide/);assert.match(result.stdout, /\[ok\] Progressive authoring references/);assert.match(result.stdout, /\[ok\] Architecture compare runtime and proof fixtures/);@@ -387,6 +439,41 @@ test('cli: visual-check --out-dir redirects failed provenance evidence', () => {assert.equal(fs.existsSync(out.replace(/\.html$/, '.visual-check.json')), false);});+test('cli: visual-check rejects an invalid raw --out-dir before filesystem mutation', () => {+ const workingDirectory = path.join(tmp, 'visual-check-invalid-raw-outdir');+ fs.mkdirSync(workingDirectory);+ const out = path.join(workingDirectory, 'artifact.html');+ fs.writeFileSync(out, '<!doctype html><html><body>delivered</body></html>');+ const before = fs.readdirSync(workingDirectory).sort();+ const invalidOutDir = process.platform === 'win32'+ ? `${path.parse(workingDirectory).root.slice(0, 2)}evidence`+ : path.join(workingDirectory, 'x'.repeat(256));+ const normalizedMutation = process.platform === 'win32'+ ? path.join(workingDirectory, 'evidence')+ : invalidOutDir;+ const missingChrome = path.join(workingDirectory, 'missing-chrome');++ const result = run([+ 'visual-check', out, '--json', '--out-dir', invalidOutDir,+ ], {+ cwd: workingDirectory,+ env: { ...process.env, ARCHIFY_CHROME: missingChrome },+ });++ assert.equal(result.status, 1, result.stderr || result.stdout);+ const receipt = JSON.parse(result.stdout);+ assert.equal(receipt.ok, false);+ assert.equal(receipt.command, 'visual-check');+ assert.equal(receipt.diagnostics[0].code, 'output/native-path-syntax');+ assert.equal(receipt.diagnostics[0].subject.output, invalidOutDir);+ assert.deepEqual(fs.readdirSync(workingDirectory).sort(), before);+ assert.equal(fs.existsSync(normalizedMutation), false);+ const evidence = visualEvidencePaths(out);+ assert.equal(fs.existsSync(evidence.receipt), false);+ assert.equal(fs.existsSync(evidence.contactSheet), false);+ assert.equal(evidence.screenshots.every((file) => !fs.existsSync(file)), true);+});+test('cli: visual-check rejects --out-dir with no value', () => {const out = path.join(tmp, 'visual-check-outdir-missing-value.html');fs.writeFileSync(out, '<!doctype html><html><body>delivered</body></html>');@@ -434,7 +521,7 @@ test('cli: deliver atomically writes a checked artifact and structured receipt',assert.equal(receipt.command, 'deliver');assert.equal(receipt.type, 'workflow');assert.equal(receipt.input, input);- assert.equal(receipt.output, out);+ assert.equal(receipt.output, fs.realpathSync.native(out));assert.deepEqual(receipt.specification, {sha256: sha256(input),bytes: fs.statSync(input).size,@@ -463,16 +550,17 @@ test('cli: deliver --open launches only the committed absolute artifact as one aassert.equal(result.status, 0, result.stderr);const receipt = JSON.parse(result.stdout);+ const physicalOut = fs.realpathSync.native(out);assert.deepEqual(receipt.open, {requested: true,status: 'opened',- target: out,+ target: physicalOut,method: process.platform === 'darwin' ? 'open' : 'xdg-open',});const invocation = JSON.parse(fs.readFileSync(fake.log, 'utf8'));assert.equal(invocation.existed, true, 'the opener must run after the atomic commit');- assert.deepEqual(invocation.argv, [out]);- assert.equal(invocation.target, out);+ assert.deepEqual(invocation.argv, [physicalOut]);+ assert.equal(invocation.target, physicalOut);assert.equal(fs.existsSync(out), true);});@@ -488,7 +576,7 @@ test('cli: opener failure does not invalidate a verified delivery or pollute jsoconst receipt = JSON.parse(result.stdout);assert.equal(receipt.ok, true);assert.equal(receipt.open.status, 'failed');- assert.equal(receipt.open.target, out);+ assert.equal(receipt.open.target, fs.realpathSync.native(out));assert.match(result.stderr, /Could not open the verified artifact/);assert.match(result.stderr, new RegExp(out.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));assert.equal(fs.existsSync(out), true);@@ -529,7 +617,7 @@ test('cli: a missing optional opener module preserves verified delivery with a fassert.deepEqual(receipt.open, {requested: true,status: 'unsupported',- target: out,+ target: fs.realpathSync.native(out),method: null,});assert.match(result.stderr, /Open it manually/);@@ -699,7 +787,7 @@ test('cli: deliver reports renderer failure as json and preserves the previous aassert.equal(failure.stage, 'render');assert.match(failure.error, /schema validation failed/i);assert.deepEqual(fs.readFileSync(out), trustedPriorArtifact);- const provenance = JSON.parse(fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8'));+ const provenance = JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8'));assert.equal(provenance.status, 'failed');assert.equal(provenance.stage, 'render');assert.equal(provenance.artifact.sha256, sha256(out));@@ -722,12 +810,12 @@ test('cli: a later successful delivery replaces stale provenance with an artifacconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-provenance-recovers.html');fs.writeFileSync(out, '<!doctype html><title>old artifact</title>\n');- fs.writeFileSync(out.replace(/\.html$/, '.delivery.json'), JSON.stringify({ status: 'failed' }));+ fs.writeFileSync(deliveryProvenancePath(out), JSON.stringify({ status: 'failed' }));const delivered = run(['deliver', 'workflow', input, out, '--json']);assert.equal(delivered.status, 0, delivered.stderr);const receipt = JSON.parse(delivered.stdout);- const provenance = JSON.parse(fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8'));+ const provenance = JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8'));assert.equal(provenance.status, 'current');assert.match(receipt.receiptId, /^[0-9a-f-]{36}$/i);assert.equal(provenance.receiptId, receipt.receiptId);@@ -749,7 +837,7 @@ test('cli: a later successful delivery replaces stale provenance with an artifactest('cli: delivery pair rollback restores the previous HTML and marks it stale', () => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-pair-rollback.html');- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const initial = run(['deliver', 'workflow', input, out, '--json']);assert.equal(initial.status, 0, initial.stderr);const priorArtifact = fs.readFileSync(out);@@ -757,14 +845,14 @@ test('cli: delivery pair rollback restores the previous HTML and marks it stale'const wrapper = path.join(tmp, 'fail-provenance-commit.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const renameSync = fs.renameSync;-fs.renameSync = (source, target) => {+const linkSync = fs.linkSync;+fs.linkSync = (source, target) => {if (String(source).endsWith('delivery-provenance.json')) {- const error = new Error('injected provenance rename failure');+ const error = new Error('injected provenance link failure');error.code = 'EACCES';throw error;}- return renameSync(source, target);+ return linkSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -791,23 +879,35 @@ for (const failureMode of ['journal-read', 'journal-unlink', 'journal-unlink-andconst wrapper = path.join(tmp, `${failureMode}.mjs`);fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;+const lstatSync = fs.lstatSync;const renameSync = fs.renameSync;let pairCommitted = false;-fs.renameSync = (source, target) => {- if (${JSON.stringify(failureMode)} === 'journal-unlink-and-restore' && String(source).endsWith('.previous-output')) {+fs.linkSync = (source, target) => {+ if (${JSON.stringify(failureMode)} === 'journal-unlink-and-restore'+ && String(source).endsWith('.previous-output')) {throw Object.assign(new Error('injected restore failure'), { code: 'EACCES' });}- const result = renameSync(source, target);+ const result = linkSync(source, target);if (String(source).endsWith('delivery-provenance.json')) pairCommitted = true;return result;};-const method = ${JSON.stringify(failureMode)} === 'journal-read' ? 'readFileSync' : 'unlinkSync';-const original = fs[method];-fs[method] = (file, ...args) => {- if (pairCommitted && String(file) === ${JSON.stringify(deliveryPendingPath(out))}) {+fs.lstatSync = (file, ...args) => {+ if (${JSON.stringify(failureMode)} === 'journal-read'+ && pairCommitted && String(file) === ${JSON.stringify(deliveryPendingPath(out))}) {throw Object.assign(new Error('injected journal finalization failure'), { code: 'EACCES' });}- return original(file, ...args);+ return lstatSync(file, ...args);+};+fs.renameSync = (source, target) => {+ if (${JSON.stringify(failureMode)} !== 'journal-read'+ && pairCommitted+ && String(source) === ${JSON.stringify(deliveryPendingPath(out))}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ throw Object.assign(new Error('injected journal finalization failure'), { code: 'EACCES' });+ }+ return renameSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(replacement)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -816,15 +916,27 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(result.status, 1, result.stderr || result.stdout);const receipt = JSON.parse(result.stdout);assert.equal(receipt.stage, 'commit');- assert.equal(receipt.diagnostics[0].code, 'delivery/commit');assert.equal(fs.existsSync(deliveryPendingPath(out)), true);- if (failureMode === 'journal-unlink-and-restore') {- const evidence = receipt.diagnostics[0].evidence;+ if (failureMode !== 'journal-unlink') {+ assert.equal(+ receipt.diagnostics[0].code,+ failureMode === 'journal-read'+ ? 'delivery/ownership-lost'+ : 'delivery/commit-recovery-required',+ );+ const recoveryDiagnostic = receipt.diagnostics.find(+ ({ code }) => code === 'delivery/commit-recovery-required',+ );+ assert.ok(recoveryDiagnostic);+ const evidence = recoveryDiagnostic.evidence;assert.equal(evidence.recoveryRequired, true);const backup = evidence.recoverableBackups.find((entry) => entry.label === 'HTML artifact');assert.ok(backup);assert.equal(sha256(backup.path), previousHash);+ assert.equal(run(['check', out, '--require-provenance']).status, 1);+ return;} else {+ assert.equal(receipt.diagnostics[0].code, 'delivery/commit');assert.equal(sha256(out), previousHash);assert.equal(run(['check', out, '--require-provenance']).status, 1);}@@ -838,24 +950,25 @@ test('cli: delivery pair rollback retains recoverable backups when restoration fconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-pair-recovery-required.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);+ const physicalOut = fs.realpathSync.native(out);const priorArtifact = fs.readFileSync(out);const wrapper = path.join(tmp, 'fail-delivery-rollback-restore.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const renameSync = fs.renameSync;-fs.renameSync = (source, target) => {+const linkSync = fs.linkSync;+fs.linkSync = (source, target) => {if (String(source).endsWith('delivery-provenance.json')) {- const error = new Error('injected provenance rename failure');+ const error = new Error('injected provenance link failure');error.code = 'EACCES';throw error;}- if (String(source).endsWith('.previous-output') && String(target) === ${JSON.stringify(out)}) {+ if (String(source).endsWith('.previous-output') && String(target) === ${JSON.stringify(physicalOut)}) {const error = new Error('injected output restore failure');error.code = 'EACCES';throw error;}- return renameSync(source, target);+ return linkSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -868,7 +981,10 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(evidence.recoveryRequired, true);assert.match(result.stderr, /Recovery required: delivery backups were retained/);assert.equal(fs.existsSync(evidence.recoveryDirectory), true);- const outputBackup = evidence.recoverableBackups.find((entry) => entry.label === 'HTML artifact');+ const outputBackup = evidence.recoverableBackups.find((entry) => (+ entry.label === 'HTML artifact'+ || entry.label === 'unverified preserved backup entry for HTML artifact'+ ));assert.ok(outputBackup);assert.deepEqual(fs.readFileSync(outputBackup.path), priorArtifact);});@@ -877,30 +993,26 @@ test('cli: delivery pair rollback retains backups when recovery-path inspectionconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-pair-recovery-inspection-failure.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);+ const physicalOut = fs.realpathSync.native(out);const priorArtifact = fs.readFileSync(out);const wrapper = path.join(tmp, 'fail-delivery-recovery-inspection.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const renameSync = fs.renameSync;+const linkSync = fs.linkSync;const lstatSync = fs.lstatSync;-let outputRestoreFailed = false;-fs.renameSync = (source, target) => {+let provenanceCommitFailed = false;+fs.linkSync = (source, target) => {if (String(source).endsWith('delivery-provenance.json')) {- const error = new Error('injected provenance rename failure');+ provenanceCommitFailed = true;+ const error = new Error('injected provenance link failure');error.code = 'EACCES';throw error;}- if (String(source).endsWith('.previous-output') && String(target) === ${JSON.stringify(out)}) {- outputRestoreFailed = true;- const error = new Error('injected output restore failure');- error.code = 'EACCES';- throw error;- }- return renameSync(source, target);+ return linkSync(source, target);};fs.lstatSync = (target, options) => {- if (outputRestoreFailed && String(target).endsWith('.previous-output')) {+ if (provenanceCommitFailed && String(target).endsWith('.previous-output')) {const error = new Error('injected recovery inspection failure');error.code = 'EACCES';throw error;@@ -918,7 +1030,10 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(evidence.recoveryRequired, true);assert.match(result.stderr, /Recovery required: delivery backups were retained/);assert.equal(fs.existsSync(evidence.recoveryDirectory), true);- const outputBackup = evidence.recoverableBackups.find((entry) => entry.label === 'HTML artifact');+ const outputBackup = evidence.recoverableBackups.find((entry) => (+ entry.label === 'HTML artifact'+ || entry.label === 'unverified preserved backup entry for HTML artifact'+ ));assert.ok(outputBackup);assert.deepEqual(fs.readFileSync(outputBackup.path), priorArtifact);});@@ -929,14 +1044,17 @@ test('cli: portable delivery lock: a process exit requires explicit stale-lock rconst out = path.join(tmp, 'interrupted-delivery-pair.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);const initialSha256 = sha256(out);+ const pendingPath = deliveryPendingPath(out);- const wrapper = path.join(tmp, 'interrupt-after-html-commit.mjs');+ const wrapper = path.join(tmp, 'interrupt-after-journal.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const renameSync = fs.renameSync;-fs.renameSync = (source, target) => {- const result = renameSync(source, target);- if (String(target) === ${JSON.stringify(out)} && String(source).includes('.archify-delivery-')) {+import path from 'node:path';+const unlinkSync = fs.unlinkSync;+fs.unlinkSync = (target, ...args) => {+ const result = unlinkSync(target, ...args);+ if (path.basename(String(target)) === ${JSON.stringify(path.basename(pendingPath))}+ && path.basename(path.dirname(String(target))).startsWith('.archify-provenance-')) {process.exit(86);}return result;@@ -947,11 +1065,12 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});const interrupted = spawnSync(process.execPath, [wrapper], { cwd: skillRoot, encoding: 'utf8' });assert.equal(interrupted.status, 86);- assert.notEqual(sha256(out), initialSha256);- const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ assert.equal(sha256(out), initialSha256);+ const lockPath = deliveryLockPath(out);+ const legacyLockPath = legacyDeliveryLockPath(out);+ const provenancePath = deliveryProvenancePath(out);assert.equal(fs.existsSync(pendingPath), true);+ assert.equal(fs.existsSync(legacyLockPath), true);for (const args of [['check', out],['check', out, '--require-provenance'],@@ -980,8 +1099,15 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});if (provenanceExisted) assert.deepEqual(fs.readFileSync(provenancePath), provenanceBeforeRecovery);// Manual recovery is deliberately outside the delivery protocol: after- // confirming the recorded PID exited, remove only the reported stale lock.+ // confirming the recorded PID exited, remove each reported stale lock.fs.unlinkSync(lockPath);+ const legacyRejected = run(['deliver', 'workflow', replacementInput, out, '--json']);+ assert.equal(legacyRejected.status, 1, legacyRejected.stderr || legacyRejected.stdout);+ assert.equal(JSON.parse(legacyRejected.stdout).diagnostics[0].code, 'delivery/lock-stale');+ assert.equal(JSON.parse(legacyRejected.stdout).diagnostics[0].subject.lock, legacyLockPath);+ assert.equal(fs.existsSync(provenancePath), provenanceExisted);+ if (provenanceExisted) assert.deepEqual(fs.readFileSync(provenancePath), provenanceBeforeRecovery);+ fs.unlinkSync(legacyLockPath);const recovered = run(['deliver', 'workflow', replacementInput, out, '--json']);assert.equal(recovered.status, 0, recovered.stderr || recovered.stdout);assert.equal(fs.existsSync(deliveryPendingPath(out)), false);@@ -1045,10 +1171,10 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});const activeExit = await activeExitPromise;assert.deepEqual(activeExit, { code: 0, signal: null }, activeStderr);const activeReceipt = JSON.parse(activeStdout);- const provenance = JSON.parse(fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8'));+ const provenance = JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8'));assert.equal(provenance.status, 'current');assert.equal(provenance.receiptId, activeReceipt.receiptId);- assert.equal(fs.existsSync(out.replace(/\.html$/, '.delivery-lock.json')), false);+ assert.equal(fs.existsSync(deliveryLockPath(out)), false);});test('cli: a pre-lock failure cannot replace an active delivery attempt', async (t) => {@@ -1056,7 +1182,7 @@ test('cli: a pre-lock failure cannot replace an active delivery attempt', asyncconst replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'concurrent-pre-lock-failure.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);- const initialProvenance = fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8');+ const initialProvenance = fs.readFileSync(deliveryProvenancePath(out), 'utf8');const ready = path.join(tmp, 'concurrent-pre-lock-failure.ready');const release = path.join(tmp, 'concurrent-pre-lock-failure.release');const activeWrapper = path.join(tmp, 'hold-active-pre-lock-delivery.mjs');@@ -1111,7 +1237,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});const rejected = spawnSync(process.execPath, [failingWrapper], { cwd: skillRoot, encoding: 'utf8' });const rejection = JSON.parse(rejected.stdout);const pendingAfterRejection = fs.readFileSync(deliveryPendingPath(out), 'utf8');- const provenanceAfterRejection = fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8');+ const provenanceAfterRejection = fs.readFileSync(deliveryProvenancePath(out), 'utf8');fs.writeFileSync(release, 'release');const activeExit = await activeExitPromise;@@ -1130,11 +1256,10 @@ test('cli: portable delivery lock: a stale entry is preserved when a pre-lock faconst out = path.join(tmp, 'stale-lock-pre-lock-failure.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const artifactBefore = fs.readFileSync(out);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const provenanceBefore = fs.readFileSync(provenancePath);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const stagingBefore = fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-')).sort();+ const lockPath = deliveryLockPath(out);+ const stagingBefore = deliveryStagingEntries(path.dirname(out));const exited = spawnSync(process.execPath, ['-e', '']);assert.equal(exited.status, 0);const staleLock = `${JSON.stringify({@@ -1165,7 +1290,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});const receipt = JSON.parse(failed.stdout);assert.equal(receipt.diagnostics[0].code, 'delivery/lock-stale');assert.equal('provenance' in receipt, false);- assert.equal(receipt.diagnostics[0].subject.output, path.resolve(out));+ assert.equal(receipt.diagnostics[0].subject.output, fs.realpathSync.native(out));assert.equal(receipt.diagnostics[0].subject.lock, lockPath);assert.equal(receipt.diagnostics[0].evidence.pid, exited.pid);assert.equal(receipt.diagnostics[0].evidence.receiptId, '00000000-0000-4000-8000-000000000000');@@ -1176,7 +1301,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(fs.existsSync(deliveryPendingPath(out)), false);assert.equal(fs.readFileSync(lockPath, 'utf8'), staleLock);assert.deepEqual(- fs.readdirSync(path.dirname(out)).filter((entry) => entry.startsWith('.archify-delivery-')).sort(),+ deliveryStagingEntries(path.dirname(out)),stagingBefore,);});@@ -1186,11 +1311,10 @@ test('cli: portable delivery lock: simultaneous stale-lock contenders both failconst out = path.join(tmp, 'simultaneous-stale-lock-contenders.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const artifactBefore = fs.readFileSync(out);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const provenanceBefore = fs.readFileSync(provenancePath);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const stagingBefore = fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-')).sort();+ const lockPath = deliveryLockPath(out);+ const stagingBefore = deliveryStagingEntries(path.dirname(out));const exited = spawnSync(process.execPath, ['-e', '']);assert.equal(exited.status, 0);const staleLock = `${JSON.stringify({@@ -1256,7 +1380,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(fs.existsSync(deliveryPendingPath(out)), false);assert.equal(fs.readFileSync(lockPath, 'utf8'), staleLock);assert.deepEqual(- fs.readdirSync(path.dirname(out)).filter((entry) => entry.startsWith('.archify-delivery-')).sort(),+ deliveryStagingEntries(path.dirname(out)),stagingBefore,);});@@ -1270,24 +1394,16 @@ test('cli: portable delivery lock: lost ownership prevents failure provenance wrconst out = path.join(tmp, 'lost-delivery-ownership.html');assert.equal(run(['deliver', 'workflow', validInput, out, '--json']).status, 0);const artifactBefore = fs.readFileSync(out);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const provenanceBefore = fs.readFileSync(provenancePath);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successorReceiptId = '11111111-1111-4111-8111-111111111111';const successorLock = `${JSON.stringify({schemaVersion: 1,receiptId: successorReceiptId,pid: process.pid,})}\n`;- const successorPending = `${JSON.stringify({- schemaVersion: 1,- command: 'deliver',- status: 'pending',- receiptId: successorReceiptId,- input: path.resolve(validInput),- output: path.resolve(out),- }, null, 2)}\n`;const successorProvenance = `${JSON.stringify({schemaVersion: 1,receiptId: successorReceiptId,@@ -1301,16 +1417,18 @@ test('cli: portable delivery lock: lost ownership prevents failure provenance wrconst wrapper = path.join(tmp, 'lose-delivery-ownership.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;const renameSync = fs.renameSync;const writeFileSync = fs.writeFileSync;let replaced = false;-fs.renameSync = (source, target) => {- const result = renameSync(source, target);- if (!replaced && String(target) === ${JSON.stringify(pendingPath)} && String(source).includes('.archify-provenance-')) {+fs.linkSync = (source, target) => {+ const result = linkSync(source, target);+ if (!replaced && String(target) === ${JSON.stringify(pendingPath)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {replaced = true;renameSync(${JSON.stringify(lockPath)}, ${JSON.stringify(`${lockPath}.lost-owner`)});writeFileSync(${JSON.stringify(lockPath)}, ${JSON.stringify(successorLock)});- writeFileSync(${JSON.stringify(pendingPath)}, ${JSON.stringify(successorPending)});writeFileSync(${JSON.stringify(provenancePath)}, ${JSON.stringify(successorProvenance)});}return result;@@ -1329,7 +1447,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.deepEqual(fs.readFileSync(out), artifactBefore);assert.equal(fs.readFileSync(provenancePath, 'utf8'), successorProvenance);assert.equal(fs.readFileSync(lockPath, 'utf8'), successorLock);- assert.equal(fs.readFileSync(pendingPath, 'utf8'), successorPending);+ assert.equal(JSON.parse(fs.readFileSync(pendingPath, 'utf8')).receiptId, receipt.receiptId);});test('cli: portable delivery lock: failure provenance ownership loss reports retained recovery state', () => {@@ -1340,9 +1458,9 @@ test('cli: portable delivery lock: failure provenance ownership loss reports retfs.writeFileSync(invalidInput, JSON.stringify(invalid));const out = path.join(tmp, 'failure-provenance-ownership-loss.html');assert.equal(run(['deliver', 'workflow', validInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '15151515-1515-4515-8515-151515151515',input: validInput,@@ -1393,9 +1511,9 @@ test('cli: portable delivery lock: journal creation cannot overwrite a successorconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'lost-ownership-before-journal-rename.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '12121212-1212-4212-8212-121212121212',input,@@ -1437,15 +1555,145 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(fs.readFileSync(pendingPath, 'utf8'), successor.pending);});-test('cli: portable delivery lock: an unverifiable new journal loses ownership', () => {+test('cli: portable delivery lock: journal publish preserves a final-window claimant', () => {+ const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const out = path.join(tmp, 'journal-final-window-claimant.html');+ assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);+ const artifactBefore = fs.readFileSync(out);+ const provenancePath = deliveryProvenancePath(out);+ const provenanceBefore = fs.readFileSync(provenancePath);+ const pendingPath = deliveryPendingPath(out);+ const lockPath = deliveryLockPath(out);+ const claimant = '{"claimant":"journal-final-window"}\n';+ const identityFile = path.join(tmp, 'journal-final-window-identity.json');+ const priorJournalStaging = fs.readdirSync(path.dirname(out))+ .filter((name) => name.startsWith('.archify-provenance-'))+ .sort();+ const wrapper = path.join(tmp, 'journal-final-window-claimant.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;+let injected = false;+fs.linkSync = (source, target) => {+ if (!injected && String(target) === ${JSON.stringify(pendingPath)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {+ injected = true;+ fs.writeFileSync(target, ${JSON.stringify(claimant)}, { flag: 'wx' });+ const identity = fs.lstatSync(target, { bigint: true });+ fs.writeFileSync(${JSON.stringify(identityFile)}, JSON.stringify({ dev: String(identity.dev), ino: String(identity.ino) }));+ }+ return linkSync(source, target);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd: skillRoot, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(receipt.diagnostics[0].code, 'delivery/journal-recovery-required');+ assert.equal(receipt.diagnostics[0].evidence.recoveryRequired, true);+ assert.match(receipt.diagnostics[0].evidence.reason, /target-claimed-during-publish/);+ assert.equal('recoveryDirectory' in receipt.diagnostics[0].evidence, false);+ assert.equal('recoveryFiles' in receipt.diagnostics[0].evidence, false);+ assert.ok(!('provenance' in receipt) || receipt.provenance === 'unrecorded');+ assert.equal(fs.readFileSync(pendingPath, 'utf8'), claimant);+ const currentIdentity = fs.lstatSync(pendingPath, { bigint: true });+ assert.deepEqual(+ { dev: String(currentIdentity.dev), ino: String(currentIdentity.ino) },+ JSON.parse(fs.readFileSync(identityFile, 'utf8')),+ );+ assert.deepEqual(fs.readFileSync(out), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.equal(fs.existsSync(lockPath), true);+ assert.deepEqual(+ fs.readdirSync(path.dirname(out))+ .filter((name) => name.startsWith('.archify-provenance-'))+ .sort(),+ priorJournalStaging,+ );+});++test('cli: portable delivery lock: failed journal restore retains the previous journal and claimant', () => {+ const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const out = path.join(tmp, 'journal-restore-claimant.html');+ assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);+ const artifactBefore = fs.readFileSync(out);+ const provenancePath = deliveryProvenancePath(out);+ const provenanceBefore = fs.readFileSync(provenancePath);+ const pendingPath = deliveryPendingPath(out);+ const lockPath = deliveryLockPath(out);+ const previousJournal = '{"previous":"delivery journal"}\n';+ fs.writeFileSync(pendingPath, previousJournal, { flag: 'wx' });+ const previousIdentity = fs.lstatSync(pendingPath, { bigint: true });+ const claimant = '{"claimant":"blocks journal restore"}\n';+ const claimantIdentityFile = path.join(tmp, 'journal-restore-claimant-identity.json');+ const wrapper = path.join(tmp, 'journal-restore-claimant.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;+let injected = false;+fs.linkSync = (source, target) => {+ if (!injected && String(target) === ${JSON.stringify(pendingPath)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {+ injected = true;+ fs.writeFileSync(target, ${JSON.stringify(claimant)}, { flag: 'wx' });+ const identity = fs.lstatSync(target, { bigint: true });+ fs.writeFileSync(${JSON.stringify(claimantIdentityFile)}, JSON.stringify({ dev: String(identity.dev), ino: String(identity.ino) }));+ }+ return linkSync(source, target);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd: skillRoot, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ const recovery = receipt.diagnostics[0];+ assert.equal(recovery.code, 'delivery/journal-recovery-required');+ assert.equal(recovery.evidence.recoveryRequired, true);+ assert.match(recovery.evidence.rollbackErrors.join('\n'), /previous journal restore failed/);+ assert.match(recovery.evidence.rollbackErrors.join('\n'), /claimant prevents restoring/);+ assert.equal(fs.existsSync(recovery.evidence.recoveryDirectory), true);+ assert.equal(recovery.evidence.recoveryFiles.length, 1);+ const [previous] = recovery.evidence.recoveryFiles;+ assert.equal(previous.label, 'previous delivery journal');+ assert.equal(previous.target, pendingPath);+ assert.equal(fs.readFileSync(previous.path, 'utf8'), previousJournal);+ const retainedIdentity = fs.lstatSync(previous.path, { bigint: true });+ assert.deepEqual(+ { dev: retainedIdentity.dev, ino: retainedIdentity.ino },+ { dev: previousIdentity.dev, ino: previousIdentity.ino },+ );+ assert.deepEqual(fs.readdirSync(recovery.evidence.recoveryDirectory), ['.previous-journal']);+ assert.equal(fs.readFileSync(pendingPath, 'utf8'), claimant);+ const claimantIdentity = fs.lstatSync(pendingPath, { bigint: true });+ assert.deepEqual(+ { dev: String(claimantIdentity.dev), ino: String(claimantIdentity.ino) },+ JSON.parse(fs.readFileSync(claimantIdentityFile, 'utf8')),+ );+ assert.deepEqual(fs.readFileSync(out), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.equal(fs.existsSync(lockPath), true);+ const retry = run(['deliver', 'workflow', input, out, '--json']);+ assert.equal(retry.status, 1, retry.stderr || retry.stdout);+ assert.equal(JSON.parse(retry.stdout).diagnostics[0].code, 'delivery/lock-stale');+ assert.equal(fs.readFileSync(pendingPath, 'utf8'), claimant);+ assert.equal(fs.readFileSync(previous.path, 'utf8'), previousJournal);+});++test('cli: portable delivery lock: an unverifiable new journal fails safely', () => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'unverifiable-new-journal.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const artifactBefore = fs.readFileSync(out);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const provenanceBefore = fs.readFileSync(provenancePath);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const wrapper = path.join(tmp, 'unverifiable-new-journal.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';@@ -1466,15 +1714,75 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(failed.status, 1, failed.stderr || failed.stdout);const receipt = JSON.parse(failed.stdout);- assert.equal(receipt.diagnostics[0].code, 'delivery/ownership-lost');- assert.equal(receipt.diagnostics[0].evidence.systemCode, 'EACCES');- assert.equal('provenance' in receipt, false);+ assert.equal(receipt.diagnostics[0].code, 'delivery/journal-write');+ assert.match(+ receipt.diagnostics[0].evidence.reason,+ /delivery-journal-candidate-handle-verification-failed/,+ );+ assert.equal(receipt.provenance, 'failed');assert.deepEqual(fs.readFileSync(out), artifactBefore);- assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.notDeepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.equal(JSON.parse(fs.readFileSync(provenancePath, 'utf8')).status, 'failed');assert.equal(fs.existsSync(pendingPath), true);- assert.equal(fs.existsSync(lockPath), true);+ assert.equal(fs.existsSync(lockPath), false);});+for (const removalRole of ['journal', 'lock']) {+ test(`cli: delivery preserves a ${removalRole} successor swapped at final public removal`, () => {+ const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const out = path.join(tmp, `final-remove-${removalRole}.html`);+ assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);+ const publicPath = removalRole === 'journal' ? deliveryPendingPath(out) : deliveryLockPath(out);+ const displacedOwner = path.join(tmp, `final-remove-${removalRole}-owner`);+ const successor = `${JSON.stringify({+ schemaVersion: 1,+ receiptId: '56565656-5656-4656-8656-565656565656',+ pid: process.pid,+ role: removalRole,+ })}\n`;+ const identityFile = path.join(tmp, `final-remove-${removalRole}-identity.json`);+ const wrapper = path.join(tmp, `final-remove-${removalRole}.mjs`);+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const renameSync = fs.renameSync;+let injected = false;+fs.renameSync = (source, target) => {+ if (!injected && String(source) === ${JSON.stringify(publicPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ injected = true;+ renameSync(source, ${JSON.stringify(displacedOwner)});+ fs.writeFileSync(source, ${JSON.stringify(successor)}, { flag: 'wx' });+ const identity = fs.lstatSync(source, { bigint: true });+ fs.writeFileSync(${JSON.stringify(identityFile)}, JSON.stringify({ dev: String(identity.dev), ino: String(identity.ino) }));+ }+ return renameSync(source, target);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd: skillRoot, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(+ receipt.diagnostics.some((entry) => entry.code === (+ removalRole === 'journal'+ ? 'delivery/commit-recovery-required'+ : 'delivery/ownership-lost'+ )),+ true,+ );+ assert.equal(fs.readFileSync(publicPath, 'utf8'), successor);+ const current = fs.lstatSync(publicPath, { bigint: true });+ assert.deepEqual(+ { dev: String(current.dev), ino: String(current.ino) },+ JSON.parse(fs.readFileSync(identityFile, 'utf8')),+ );+ assert.equal(fs.existsSync(displacedOwner), true);+ });+}+test('cli: portable delivery lock: release loss cannot claim failed provenance', () => {const validInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const invalidInput = path.join(tmp, 'release-loss-after-failure.workflow.json');@@ -1483,9 +1791,9 @@ test('cli: portable delivery lock: release loss cannot claim failed provenance',fs.writeFileSync(invalidInput, JSON.stringify(invalid));const out = path.join(tmp, 'release-loss-after-failure.html');assert.equal(run(['deliver', 'workflow', validInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '13131313-1313-4313-8313-131313131313',input: validInput,@@ -1494,17 +1802,20 @@ test('cli: portable delivery lock: release loss cannot claim failed provenance',const wrapper = path.join(tmp, 'lose-ownership-after-failure-provenance.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';const writeFileSync = fs.writeFileSync;const renameSync = fs.renameSync;+const linkSync = fs.linkSync;let replaced = false;-fs.renameSync = (source, target) => {- const result = renameSync(source, target);+fs.linkSync = (source, target) => {+ const result = linkSync(source, target);if (!replaced && String(target) === ${JSON.stringify(provenancePath)}- && String(source).includes('.archify-provenance-')) {+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {replaced = true;renameSync(${JSON.stringify(lockPath)}, ${JSON.stringify(`${lockPath}.owner-a`)});writeFileSync(${JSON.stringify(lockPath)}, ${JSON.stringify(successor.lock)}, { flag: 'wx' });writeFileSync(${JSON.stringify(pendingPath)}, ${JSON.stringify(successor.pending)});+ renameSync(target, String(target) + '.owner-a');writeFileSync(${JSON.stringify(provenancePath)}, ${JSON.stringify(successor.provenance)});writeFileSync(${JSON.stringify(out)}, ${JSON.stringify(successor.artifact)});}@@ -1518,7 +1829,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(failed.status, 1, failed.stderr || failed.stdout);const receipt = JSON.parse(failed.stdout);- assert.equal(receipt.diagnostics[0].code, 'delivery/ownership-lost');+ assert.equal(receipt.diagnostics[0].code, 'delivery/provenance-recovery-required');assert.ok(!('provenance' in receipt) || receipt.provenance === 'unrecorded');assert.equal(receipt.diagnostics[0].evidence.recoveryRequired, true);assert.equal(fs.existsSync(receipt.diagnostics[0].evidence.recoveryDirectory), true);@@ -1533,9 +1844,9 @@ test('cli: portable delivery lock: commit entry preserves a successor owner', ()const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'lost-ownership-before-commit.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '22222222-2222-4222-8222-222222222222',input: replacementInput,@@ -1585,11 +1896,11 @@ test('cli: portable delivery lock: rollback stops after ownership is lost', () =const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'lost-ownership-before-rollback.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const priorArtifact = fs.readFileSync(out);const priorProvenance = fs.readFileSync(provenancePath);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '33333333-3333-4333-8333-333333333333',input: replacementInput,@@ -1601,8 +1912,9 @@ import fs from 'node:fs';import path from 'node:path';const writeFileSync = fs.writeFileSync;const renameSync = fs.renameSync;+const linkSync = fs.linkSync;let replaced = false;-fs.renameSync = (source, target) => {+fs.linkSync = (source, target) => {if (!replaced && path.basename(String(source)) === 'delivery-provenance.json'&& path.basename(path.dirname(String(source))).startsWith('.archify-delivery-')) {replaced = true;@@ -1613,7 +1925,7 @@ fs.renameSync = (source, target) => {writeFileSync(${JSON.stringify(out)}, ${JSON.stringify(successor.artifact)});throw Object.assign(new Error('injected provenance commit failure'), { code: 'EACCES' });}- return renameSync(source, target);+ return linkSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(replacementInput)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -1646,11 +1958,11 @@ test('cli: portable delivery lock: finalization preserves a successor owner', ()const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'lost-ownership-before-finalization.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const priorArtifact = fs.readFileSync(out);const priorProvenance = fs.readFileSync(provenancePath);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '44444444-4444-4444-8444-444444444444',input: replacementInput,@@ -1662,9 +1974,10 @@ import fs from 'node:fs';import path from 'node:path';const writeFileSync = fs.writeFileSync;const renameSync = fs.renameSync;+const linkSync = fs.linkSync;let replaced = false;-fs.renameSync = (source, target) => {- const result = renameSync(source, target);+fs.linkSync = (source, target) => {+ const result = linkSync(source, target);if (!replaced && path.basename(String(source)) === 'delivery-provenance.json'&& path.basename(path.dirname(String(source))).startsWith('.archify-delivery-')) {replaced = true;@@ -1704,11 +2017,11 @@ test('cli: portable delivery lock: release preserves a successor owner', () => {const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'lost-ownership-before-release.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const priorArtifact = fs.readFileSync(out);const priorProvenance = fs.readFileSync(provenancePath);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '55555555-5555-4555-8555-555555555555',input: replacementInput,@@ -1717,15 +2030,18 @@ test('cli: portable delivery lock: release preserves a successor owner', () => {const wrapper = path.join(tmp, 'lose-ownership-before-release.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';const writeFileSync = fs.writeFileSync;const renameSync = fs.renameSync;-const unlinkSync = fs.unlinkSync;const lstatSync = fs.lstatSync;let journalFinalized = false;let replaced = false;-fs.unlinkSync = (file, ...args) => {- const result = unlinkSync(file, ...args);- if (String(file) === ${JSON.stringify(pendingPath)}) journalFinalized = true;+fs.renameSync = (source, target) => {+ const result = renameSync(source, target);+ if (String(source) === ${JSON.stringify(pendingPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ journalFinalized = true;+ }return result;};fs.lstatSync = (file, ...args) => {@@ -1773,7 +2089,7 @@ test('cli: portable delivery lock: release rejects a recreated journal', () => {const out = path.join(tmp, 'recreated-journal-before-release.html');assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '66666666-6666-4666-8666-666666666666',input: replacementInput,@@ -1782,15 +2098,19 @@ test('cli: portable delivery lock: release rejects a recreated journal', () => {const wrapper = path.join(tmp, 'recreate-journal-before-release.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';const writeFileSync = fs.writeFileSync;-const unlinkSync = fs.unlinkSync;+const renameSync = fs.renameSync;const lstatSync = fs.lstatSync;let journalFinalized = false;let postFinalizeLockChecks = 0;let journalRecreated = false;-fs.unlinkSync = (file, ...args) => {- const result = unlinkSync(file, ...args);- if (String(file) === ${JSON.stringify(pendingPath)}) journalFinalized = true;+fs.renameSync = (source, target) => {+ const result = renameSync(source, target);+ if (String(source) === ${JSON.stringify(pendingPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ journalFinalized = true;+ }return result;};fs.lstatSync = (file, ...args) => {@@ -1814,7 +2134,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(failed.status, 1, failed.stderr || failed.stdout);const receipt = JSON.parse(failed.stdout);- assert.equal(receipt.stage, 'release');+ assert.equal(receipt.stage, 'commit');assert.equal(receipt.diagnostics[0].code, 'delivery/ownership-lost');assert.equal(receipt.diagnostics[0].evidence.recoveryRequired, true);assert.ok(receipt.diagnostics[0].evidence.recoverableBackups.length >= 1);@@ -1831,20 +2151,19 @@ test('cli: portable delivery lock: release failure cannot claim delivery successconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-lock-release-failure.html');const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const lockPath = deliveryLockPath(out);+ const provenancePath = deliveryProvenancePath(out);const wrapper = path.join(tmp, 'delivery-lock-release-failure.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const unlinkSync = fs.unlinkSync;-let journalFinalized = false;-fs.unlinkSync = (file, ...args) => {- if (String(file) === ${JSON.stringify(lockPath)} && journalFinalized) {+import path from 'node:path';+const renameSync = fs.renameSync;+fs.renameSync = (source, target) => {+ if (String(source) === ${JSON.stringify(lockPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {throw Object.assign(new Error('injected lock release failure'), { code: 'EACCES' });}- const result = unlinkSync(file, ...args);- if (String(file) === ${JSON.stringify(pendingPath)}) journalFinalized = true;- return result;+ return renameSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -1871,14 +2190,15 @@ test('cli: portable delivery lock: failure-path release errors override the rendconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-failure-lock-release.html');const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const lockPath = deliveryLockPath(out);+ const provenancePath = deliveryProvenancePath(out);assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const previousHash = sha256(out);const wrapper = path.join(tmp, 'delivery-failure-lock-release.mjs');fs.writeFileSync(wrapper, `import childProcess from 'node:child_process';import fs from 'node:fs';+import path from 'node:path';import { syncBuiltinESMExports } from 'node:module';const spawnSync = childProcess.spawnSync;let rendererFailed = false;@@ -1890,12 +2210,13 @@ childProcess.spawnSync = (executable, args, options) => {return spawnSync(executable, args, options);};syncBuiltinESMExports();-const unlinkSync = fs.unlinkSync;-fs.unlinkSync = (file, ...args) => {- if (String(file) === ${JSON.stringify(lockPath)}) {+const renameSync = fs.renameSync;+fs.renameSync = (source, target) => {+ if (String(source) === ${JSON.stringify(lockPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {throw Object.assign(new Error('injected failure-path lock release error'), { code: 'EACCES' });}- return unlinkSync(file, ...args);+ return renameSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -1921,14 +2242,13 @@ test('cli: portable delivery lock: final cleanup preserves an unexpected primaryconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-unexpected-release-failure.html');const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const wrapper = path.join(tmp, 'delivery-unexpected-release-failure.mjs');- const stagingBefore = fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-'))- .sort();+ const stagingBefore = deliveryStagingEntries(path.dirname(out));fs.writeFileSync(wrapper, `import childProcess from 'node:child_process';import fs from 'node:fs';+import path from 'node:path';import { syncBuiltinESMExports } from 'node:module';const spawnSync = childProcess.spawnSync;childProcess.spawnSync = (executable, args, options) => {@@ -1938,12 +2258,13 @@ childProcess.spawnSync = (executable, args, options) => {return spawnSync(executable, args, options);};syncBuiltinESMExports();-const unlinkSync = fs.unlinkSync;-fs.unlinkSync = (file, ...args) => {- if (String(file) === ${JSON.stringify(lockPath)}) {+const renameSync = fs.renameSync;+fs.renameSync = (source, target) => {+ if (String(source) === ${JSON.stringify(lockPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {throw Object.assign(new Error('injected final lock release failure'), { code: 'EACCES' });}- return unlinkSync(file, ...args);+ return renameSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -1958,9 +2279,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(fs.existsSync(lockPath), true);assert.equal(fs.existsSync(pendingPath), true);assert.deepEqual(- fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-'))- .sort(),+ deliveryStagingEntries(path.dirname(out)),stagingBefore,);});@@ -1969,16 +2288,15 @@ test('cli: portable delivery lock: final cleanup preserves successor state afterconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-unexpected-ownership-loss.html');const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const lockPath = deliveryLockPath(out);+ const provenancePath = deliveryProvenancePath(out);const successor = successorDeliveryState({receiptId: '16161616-1616-4616-8616-161616161616',input,output: out,});const wrapper = path.join(tmp, 'delivery-unexpected-ownership-loss.mjs');- const stagingBefore = new Set(fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-')));+ const stagingBefore = new Set(deliveryStagingEntries(path.dirname(out)));fs.writeFileSync(wrapper, `import childProcess from 'node:child_process';import fs from 'node:fs';@@ -2012,8 +2330,8 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(fs.readFileSync(lockPath, 'utf8'), successor.lock);assert.equal(fs.readFileSync(pendingPath, 'utf8'), successor.pending);assert.equal(fs.readFileSync(provenancePath, 'utf8'), successor.provenance);- const recoveryDirectories = fs.readdirSync(path.dirname(out))- .filter((entry) => entry.startsWith('.archify-delivery-') && !stagingBefore.has(entry));+ const recoveryDirectories = deliveryStagingEntries(path.dirname(out))+ .filter((entry) => !stagingBefore.has(entry));assert.equal(recoveryDirectories.length, 1);assert.equal(fs.existsSync(path.join(path.dirname(out), recoveryDirectories[0], 'specification.snapshot.json')), true);});@@ -2026,20 +2344,19 @@ test('cli: lock release failure does not invoke the requested opener', (t) => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'delivery-lock-release-no-open.html');const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const fake = makeFakeOpeners('delivery-lock-release-no-open');const wrapper = path.join(tmp, 'delivery-lock-release-no-open.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const unlinkSync = fs.unlinkSync;-let journalFinalized = false;-fs.unlinkSync = (file, ...args) => {- if (String(file) === ${JSON.stringify(lockPath)} && journalFinalized) {+import path from 'node:path';+const renameSync = fs.renameSync;+fs.renameSync = (source, target) => {+ if (String(source) === ${JSON.stringify(lockPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {throw Object.assign(new Error('injected lock release failure'), { code: 'EACCES' });}- const result = unlinkSync(file, ...args);- if (String(file) === ${JSON.stringify(pendingPath)}) journalFinalized = true;- return result;+ return renameSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(out)}, '--json', '--open'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -2062,10 +2379,11 @@ for (const failureMode of ['empty-write', 'partial-write', 'close', 'replacementconst out = path.join(tmp, `lock-init-${failureMode}.html`);assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const previousHash = sha256(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const wrapper = path.join(tmp, `lock-init-${failureMode}.mjs`);fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';const openSync = fs.openSync;let lockDescriptor;fs.openSync = (file, ...args) => {@@ -2091,10 +2409,13 @@ if (mode === 'zero-identity-replacement') {};}if (mode === 'cleanup-failure') {- const unlinkSync = fs.unlinkSync;- fs.unlinkSync = (file, ...args) => {- if (String(file) === ${JSON.stringify(lockPath)}) throw Object.assign(new Error('injected lock cleanup failure'), { code: 'EACCES' });- return unlinkSync(file, ...args);+ const renameSync = fs.renameSync;+ fs.renameSync = (source, target) => {+ if (String(source) === ${JSON.stringify(lockPath)}+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ throw Object.assign(new Error('injected lock cleanup failure'), { code: 'EACCES' });+ }+ return renameSync(source, target);};}let injected = false;@@ -2164,9 +2485,9 @@ test('cli: portable delivery lock: initialization ownership loss cannot claim faconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'lock-init-ownership-loss.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);- const provenancePath = out.replace(/\.html$/, '.delivery.json');+ const provenancePath = deliveryProvenancePath(out);const pendingPath = deliveryPendingPath(out);- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);const successor = successorDeliveryState({receiptId: '14141414-1414-4414-8414-141414141414',input,@@ -2175,9 +2496,11 @@ test('cli: portable delivery lock: initialization ownership loss cannot claim faconst wrapper = path.join(tmp, 'lock-init-ownership-loss.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';+import path from 'node:path';const openSync = fs.openSync;const writeFileSync = fs.writeFileSync;const renameSync = fs.renameSync;+const linkSync = fs.linkSync;let lockDescriptor;let initializationFailed = false;let successorInstalled = false;@@ -2193,15 +2516,16 @@ fs.writeFileSync = (file, ...args) => {}return writeFileSync(file, ...args);};-fs.renameSync = (source, target) => {- const result = renameSync(source, target);+fs.linkSync = (source, target) => {+ const result = linkSync(source, target);if (!successorInstalled && initializationFailed&& String(target) === ${JSON.stringify(provenancePath)}- && String(source).includes('.archify-provenance-')) {+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {successorInstalled = true;renameSync(${JSON.stringify(lockPath)}, ${JSON.stringify(`${lockPath}.owner-a`)});writeFileSync(${JSON.stringify(lockPath)}, ${JSON.stringify(successor.lock)}, { flag: 'wx' });writeFileSync(${JSON.stringify(pendingPath)}, ${JSON.stringify(successor.pending)});+ renameSync(target, String(target) + '.owner-a');writeFileSync(${JSON.stringify(provenancePath)}, ${JSON.stringify(successor.provenance)});writeFileSync(${JSON.stringify(out)}, ${JSON.stringify(successor.artifact)});}@@ -2215,9 +2539,11 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assert.equal(failed.status, 1, failed.stderr || failed.stdout);const receipt = JSON.parse(failed.stdout);- assert.equal(receipt.diagnostics[0].code, 'delivery/ownership-lost');+ assert.equal(receipt.diagnostics[0].code, 'delivery/provenance-recovery-required');assert.ok(!('provenance' in receipt) || receipt.provenance === 'unrecorded');- assert.equal(receipt.diagnostics[0].evidence.initializationSystemCode, 'ENOSPC');+ assert.equal(receipt.diagnostics[0].evidence.recoveryRequired, true);+ const initialization = receipt.diagnostics.find(({ code }) => code === 'delivery/lock-acquire');+ assert.equal(initialization.evidence.systemCode, 'ENOSPC');assert.equal(fs.readFileSync(out, 'utf8'), successor.artifact);assert.equal(fs.readFileSync(provenancePath, 'utf8'), successor.provenance);assert.equal(fs.readFileSync(lockPath, 'utf8'), successor.lock);@@ -2241,10 +2567,10 @@ test('cli: portable delivery lock: a raw acquisition error does not obscure the});test('cli: delivery lock cannot replace its input specification', () => {- const input = path.join(tmp, 'lock-input-alias.delivery-lock.json');+ const input = path.join(tmp, '.archify-delivery-lock.json');const source = fs.readFileSync(path.join(skillRoot, 'examples/agent-tool-call.workflow.json'));fs.writeFileSync(input, source);- const out = input.replace(/\.delivery-lock\.json$/, '.html');+ const out = path.join(tmp, 'lock-input-alias.html');const result = run(['deliver', 'workflow', input, out, '--json']);assert.equal(result.status, 1);assert.deepEqual(fs.readFileSync(input), source);@@ -2256,7 +2582,7 @@ test('cli: delivery lock cannot replace its input specification', () => {test('cli: portable delivery lock: a symlink lock is invalid even when it targets the input', (t) => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'symlink-lock-to-input.html');- const lockPath = out.replace(/\.html$/, '.delivery-lock.json');+ const lockPath = deliveryLockPath(out);try {fs.symlinkSync(input, lockPath, 'file');} catch (error) {@@ -2280,7 +2606,7 @@ test('cli: an unrecognized delivery lock preserves user data and invalidates theconst initialInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');const out = path.join(tmp, 'unrecognized-lock.html');- const lock = out.replace(/\.html$/, '.delivery-lock.json');+ const lock = deliveryLockPath(out);const bytes = Buffer.from(JSON.stringify({ schemaVersion: 1, sentinel: 'user data' }));assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);const previousHash = sha256(out);@@ -2310,6 +2636,222 @@ test('cli: an unrecognized delivery lock preserves user data and invalidates the}});+test('cli: a legacy per-artifact delivery lock remains a fail-closed migration barrier', () => {+ const initialInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');+ const out = path.join(tmp, 'legacy-lock-migration.html');+ assert.equal(run(['deliver', 'workflow', initialInput, out, '--json']).status, 0);+ const artifactBefore = fs.readFileSync(out);+ const provenancePath = deliveryProvenancePath(out);+ const provenanceBefore = fs.readFileSync(provenancePath);+ const legacyLock = legacyDeliveryLockPath(out);+ const exited = spawnSync(process.execPath, ['-e', '']);+ assert.equal(exited.status, 0);+ fs.writeFileSync(legacyLock, `${JSON.stringify({+ schemaVersion: 1,+ receiptId: '17171717-1717-4717-8717-171717171717',+ pid: exited.pid,+ })}\n`);++ const failed = run(['deliver', 'workflow', replacementInput, out, '--json']);++ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const failure = JSON.parse(failed.stdout);+ assert.equal(failure.diagnostics[0].code, 'delivery/lock-stale');+ assert.equal(failure.diagnostics[0].subject.lock, legacyLock);+ assert.deepEqual(fs.readFileSync(out), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.equal(fs.existsSync(deliveryLockPath(out)), false);+ assert.equal(fs.existsSync(legacyLock), true);++ const checked = run(['check', out, '--require-provenance']);+ assert.equal(checked.status, 1, checked.stderr || checked.stdout);+ const checkFailure = JSON.parse(checked.stdout);+ assert.equal(checkFailure.provenance, 'locked');+ assert.equal(checkFailure.diagnostics[0].subject.lock, legacyLock);+});++test('cli: a legacy lock beside a symlinked artifact target remains a migration barrier', (t) => {+ const initialInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');+ const root = path.join(tmp, 'legacy-target-lock-symlink');+ const realDirectory = path.join(root, 'real');+ const aliasDirectory = path.join(root, 'alias');+ fs.mkdirSync(realDirectory, { recursive: true });+ fs.mkdirSync(aliasDirectory, { recursive: true });+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ const realOutput = path.join(realDirectory, 'diagram.html');+ const aliasOutput = path.join(aliasDirectory, 'alias.html');+ assert.equal(run(['deliver', 'workflow', initialInput, realOutput, '--json']).status, 0);+ const artifactBefore = fs.readFileSync(realOutput);+ const provenancePath = deliveryProvenancePath(realOutput);+ const provenanceBefore = fs.readFileSync(provenancePath);+ try {+ fs.symlinkSync(realOutput, aliasOutput, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }+ const targetLegacyLock = legacyDeliveryLockPath(fs.realpathSync.native(realOutput));+ const exited = spawnSync(process.execPath, ['-e', '']);+ assert.equal(exited.status, 0);+ fs.writeFileSync(targetLegacyLock, `${JSON.stringify({+ schemaVersion: 1,+ receiptId: '19191919-1919-4919-8919-191919191919',+ pid: exited.pid,+ })}\n`);++ const failed = run(['deliver', 'workflow', replacementInput, aliasOutput, '--json']);++ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const failure = JSON.parse(failed.stdout);+ assert.equal(failure.diagnostics[0].code, 'delivery/lock-stale');+ assert.equal(failure.diagnostics[0].subject.lock, targetLegacyLock);+ assert.equal(fs.lstatSync(aliasOutput).isSymbolicLink(), true);+ assert.deepEqual(fs.readFileSync(realOutput), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+ assert.equal(fs.existsSync(deliveryLockPath(aliasOutput)), false);++ const checked = run(['check', aliasOutput, '--require-provenance']);+ assert.equal(checked.status, 1, checked.stderr || checked.stdout);+ const checkFailure = JSON.parse(checked.stdout);+ assert.equal(checkFailure.provenance, 'locked');+ assert.equal(checkFailure.diagnostics[0].subject.lock, targetLegacyLock);+});++test('cli: an active delivery fences old binaries at both lexical and physical artifact paths', async (t) => {+ const initialInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');+ const root = path.join(tmp, 'dual-lock-active-symlink');+ const realDirectory = path.join(root, 'real');+ const aliasDirectory = path.join(root, 'alias');+ fs.mkdirSync(realDirectory, { recursive: true });+ fs.mkdirSync(aliasDirectory, { recursive: true });+ const realOutput = path.join(realDirectory, 'diagram.html');+ const aliasOutput = path.join(aliasDirectory, 'alias.html');+ assert.equal(run(['deliver', 'workflow', initialInput, realOutput, '--json']).status, 0);+ try {+ fs.symlinkSync(realOutput, aliasOutput, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }+ const lexicalLegacyLock = legacyDeliveryLockPath(aliasOutput);+ const physicalLegacyLock = legacyDeliveryLockPath(fs.realpathSync.native(realOutput));+ const globalLock = deliveryLockPath(aliasOutput);+ const ready = path.join(root, 'active.ready');+ const release = path.join(root, 'active.release');+ const wrapper = path.join(root, 'hold-active.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+const writeFileSync = fs.writeFileSync;+fs.writeFileSync = (file, value, options) => {+ const result = writeFileSync(file, value, options);+ if (String(file).endsWith('specification.snapshot.json')) {+ writeFileSync(${JSON.stringify(ready)}, 'ready');+ while (!fs.existsSync(${JSON.stringify(release)})) {+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);+ }+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(replacementInput)}, ${JSON.stringify(aliasOutput)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);+ const active = spawn(process.execPath, [wrapper], { cwd: skillRoot, stdio: ['ignore', 'pipe', 'pipe'] });+ let stdout = '';+ let stderr = '';+ active.stdout.on('data', (chunk) => { stdout += chunk; });+ active.stderr.on('data', (chunk) => { stderr += chunk; });+ const activeExit = new Promise((resolve) => {+ active.once('close', (code, signal) => resolve({ code, signal }));+ });+ t.after(() => {+ if (!fs.existsSync(release)) fs.writeFileSync(release, 'release');+ if (active.exitCode === null && active.signalCode === null) active.kill();+ fs.rmSync(root, { recursive: true, force: true });+ });+ const deadline = Date.now() + 5000;+ while (!fs.existsSync(ready) && Date.now() < deadline) {+ await new Promise((resolve) => setTimeout(resolve, 20));+ }+ assert.equal(fs.existsSync(ready), true, stderr || stdout);+ assert.equal(fs.existsSync(globalLock), true);+ assert.equal(fs.existsSync(lexicalLegacyLock), true);+ assert.equal(fs.existsSync(physicalLegacyLock), true);+ for (const oldLockPath of [lexicalLegacyLock, physicalLegacyLock]) {+ assert.throws(+ () => fs.openSync(oldLockPath, 'wx', 0o600),+ (error) => error?.code === 'EEXIST',+ );+ }++ fs.writeFileSync(release, 'release');+ assert.deepEqual(await activeExit, { code: 0, signal: null }, stderr || stdout);+ assert.equal(fs.existsSync(globalLock), false);+ assert.equal(fs.existsSync(lexicalLegacyLock), false);+ assert.equal(fs.existsSync(physicalLegacyLock), false);+});++test('cli: a legacy-fence acquisition failure cleans every lock created by the new attempt', (t) => {+ const initialInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');+ const replacementInput = path.join(skillRoot, 'examples/incident-response.workflow.json');+ const root = path.join(tmp, 'dual-lock-acquire-cleanup');+ const realDirectory = path.join(root, 'real');+ const aliasDirectory = path.join(root, 'alias');+ fs.mkdirSync(realDirectory, { recursive: true });+ fs.mkdirSync(aliasDirectory, { recursive: true });+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ const realOutput = path.join(realDirectory, 'diagram.html');+ const aliasOutput = path.join(aliasDirectory, 'alias.html');+ assert.equal(run(['deliver', 'workflow', initialInput, realOutput, '--json']).status, 0);+ const artifactBefore = fs.readFileSync(realOutput);+ const provenancePath = deliveryProvenancePath(realOutput);+ const provenanceBefore = fs.readFileSync(provenancePath);+ try {+ fs.symlinkSync(realOutput, aliasOutput, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }+ const lexicalLegacyLock = legacyDeliveryLockPath(aliasOutput);+ const physicalLegacyLock = legacyDeliveryLockPath(fs.realpathSync.native(realOutput));+ const globalLock = deliveryLockPath(aliasOutput);+ const wrapper = path.join(root, 'fail-physical-legacy-fence.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+const openSync = fs.openSync;+fs.openSync = (file, ...args) => {+ if (String(file) === ${JSON.stringify(physicalLegacyLock)}) {+ throw Object.assign(new Error('injected legacy fence acquisition failure'), { code: 'EACCES' });+ }+ return openSync(file, ...args);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(replacementInput)}, ${JSON.stringify(aliasOutput)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd: skillRoot, encoding: 'utf8' });++ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ assert.equal(JSON.parse(failed.stdout).diagnostics[0].code, 'delivery/lock-acquire');+ assert.equal(fs.existsSync(globalLock), false);+ assert.equal(fs.existsSync(lexicalLegacyLock), false);+ assert.equal(fs.existsSync(physicalLegacyLock), false);+ assert.equal(fs.lstatSync(aliasOutput).isSymbolicLink(), true);+ assert.deepEqual(fs.readFileSync(realOutput), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenancePath), provenanceBefore);+});+test('cli: delivery provenance cannot replace its input specification', () => {const input = path.join(tmp, 'provenance-input-alias.delivery.json');const source = fs.readFileSync(path.join(skillRoot, 'examples/agent-tool-call.workflow.json'));@@ -2346,7 +2888,7 @@ test('cli: rejected authored output does not write provenance outside the workinassert.equal(result.status, 1);const failure = JSON.parse(result.stdout);- assert.equal(failure.diagnostics[0].code, 'output/meta-outside-cwd');+ assert.equal(failure.diagnostics[0].code, 'output/meta-path-syntax');assert.deepEqual(fs.readFileSync(victim), artifactBytes);assert.deepEqual(fs.readFileSync(sidecar), sidecarBytes);assert.equal(fs.existsSync(pending), false);@@ -2360,31 +2902,24 @@ test('cli: a failed provenance marker write and invalidation still leave a fail-invalid.nodes[0].unexpected = true;fs.writeFileSync(invalidInput, JSON.stringify(invalid));const out = path.join(tmp, 'marker-write-failure.html');- const provenancePath = out.replace(/\.html$/, '.delivery.json');- const pendingPath = deliveryPendingPath(out);assert.equal(run(['deliver', 'workflow', validInput, out, '--json']).status, 0);+ const provenancePath = deliveryProvenancePath(out);+ const pendingPath = deliveryPendingPath(out);const priorProvenance = fs.readFileSync(provenancePath);const wrapper = path.join(tmp, 'fail-marker-write.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const renameSync = fs.renameSync;-const rmSync = fs.rmSync;-fs.renameSync = (source, target) => {- if (String(source).includes('.archify-provenance-') && String(target) === ${JSON.stringify(provenancePath)}) {- const error = new Error('injected failure marker rename error');+const linkSync = fs.linkSync;+fs.linkSync = (source, target) => {+ if (String(source).includes('.archify-provenance-')+ && !String(source).endsWith('.previous-provenance')+ && String(target) === ${JSON.stringify(provenancePath)}) {+ const error = new Error('injected failure marker publish error');error.code = 'EACCES';throw error;}- return renameSync(source, target);-};-fs.rmSync = (target, options) => {- if (String(target) === ${JSON.stringify(provenancePath)}) {- const error = new Error('injected current provenance removal error');- error.code = 'EACCES';- throw error;- }- return rmSync(target, options);+ return linkSync(source, target);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(invalidInput)}, ${JSON.stringify(out)}, '--json'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -2417,7 +2952,7 @@ test('cli: using the existing receipt as input preserves it and invalidates theconst input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'receipt-as-input.html');assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);- const sidecar = out.replace(/\.html$/, '.delivery.json');+ const sidecar = deliveryProvenancePath(out);const prior = fs.readFileSync(sidecar);const failed = run(['deliver', 'workflow', sidecar, out, '--json']);assert.equal(failed.status, 1);@@ -2432,22 +2967,29 @@ test('cli: using the existing receipt as input preserves it and invalidates theassert.equal(run(['check', out, '--require-provenance']).status, 0);});-test('cli: visual-check input errors identify the artifact rather than Chrome', () => {+test('cli: visual-check input errors identify the artifact and preserve unowned evidence', () => {for (const input of [path.join(tmp, 'missing-visual.html'), path.join(tmp, 'wrong-visual.txt')]) {if (input.endsWith('.txt')) fs.writeFileSync(input, '<html></html>');const base = input.replace(/\.html?$/i, '') + '.visual-check';- fs.writeFileSync(`${base}.json`, JSON.stringify({ ok: true, status: 'pass' }));- fs.writeFileSync(`${base}.html`, 'old contact sheet');- fs.writeFileSync(`${base}.1440x900.light.png`, 'old screenshot');+ const staleReceipt = JSON.stringify({ ok: true, status: 'pass' });+ const staleContactSheet = 'old contact sheet';+ const staleScreenshot = 'old screenshot';+ fs.writeFileSync(`${base}.json`, staleReceipt);+ fs.writeFileSync(`${base}.html`, staleContactSheet);+ fs.writeFileSync(`${base}.1440x900.light.png`, staleScreenshot);const result = run(['visual-check', input, '--json']);assert.equal(result.status, 1);const receipt = JSON.parse(result.stdout);assert.equal(receipt.diagnostics[0].code, input.endsWith('.txt') ? 'viewer/visual-check-input' : 'input/artifact-unreadable');assert.equal(receipt.diagnostics[0].subject.artifact, input);assert.match(receipt.diagnostics[0].supportedFixes[0], /readable.*html/);- assert.equal(JSON.parse(fs.readFileSync(`${base}.json`)).status, 'fail');- assert.equal(fs.existsSync(`${base}.html`), false);- assert.equal(fs.existsSync(`${base}.1440x900.light.png`), false);+ assert.equal(+ receipt.diagnostics.some((entry) => entry.code === 'viewer/evidence-path-conflict'),+ !input.endsWith('.txt'),+ );+ assert.equal(fs.readFileSync(`${base}.json`, 'utf8'), staleReceipt);+ assert.equal(fs.readFileSync(`${base}.html`, 'utf8'), staleContactSheet);+ assert.equal(fs.readFileSync(`${base}.1440x900.light.png`, 'utf8'), staleScreenshot);}});@@ -2509,7 +3051,7 @@ test('cli: provenance strictness distinguishes lower-level render output from detest('cli: strict provenance rejects null, incomplete current, and unsupported-schema sidecars', () => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'malformed-current-provenance.html');- const sidecar = out.replace(/\.html$/, '.delivery.json');+ const sidecar = deliveryProvenancePath(out);assert.equal(run(['deliver', 'workflow', input, out, '--json']).status, 0);const valid = JSON.parse(fs.readFileSync(sidecar, 'utf8'));const incompleteCurrent = { ...valid };@@ -2535,7 +3077,7 @@ test('cli: strict provenance rejects null, incomplete current, and unsupported-stest('cli: a dangling delivery sidecar is invalid rather than absent', t => {const input = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const out = path.join(tmp, 'dangling-provenance.html');- const sidecar = out.replace(/\.html$/, '.delivery.json');+ const sidecar = deliveryProvenancePath(out);assert.equal(run(['render', 'workflow', input, out]).status, 0);try {fs.symlinkSync(path.join(tmp, 'missing-provenance-target.json'), sidecar, 'file');@@ -2574,15 +3116,17 @@ test('cli: strict check cannot attach prior provenance after the artifact changeconst wrapper = path.join(tmp, 'provenance-check-race-wrapper.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const readFileSync = fs.readFileSync;+const openSync = fs.openSync;+const artifactPath = fs.realpathSync.native(${JSON.stringify(out)});+let artifactOpens = 0;let replaced = false;-fs.readFileSync = (file, ...args) => {- const value = readFileSync(file, ...args);- if (!replaced && String(file) === ${JSON.stringify(out)}) {+fs.openSync = (file, ...args) => {+ if (String(file) === artifactPath) artifactOpens += 1;+ if (!replaced && String(file) === artifactPath && artifactOpens === 2) {replaced = true;- fs.copyFileSync(${JSON.stringify(replacement)}, ${JSON.stringify(out)});+ fs.copyFileSync(${JSON.stringify(replacement)}, artifactPath);}- return value;+ return openSync(file, ...args);};process.argv = [process.execPath, ${JSON.stringify(cli)}, 'check', ${JSON.stringify(out)}, '--require-provenance'];await import(${JSON.stringify(pathToFileURL(cli).href)});@@ -2594,11 +3138,11 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});assertCheckFailureReceipt(JSON.parse(checked.stdout),out,- /^delivery\/(?:provenance-mismatch|artifact-changed)$/,+ /^(?:delivery\/(?:provenance-mismatch|artifact-changed)|input\/artifact-unreadable)$/,);});-test('cli: failed visual provenance preflight replaces stale evidence with a persisted failure receipt', () => {+test('cli: failed visual provenance preflight preserves unowned stale evidence', () => {const validInput = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');const invalidInput = path.join(tmp, 'visual-preflight-failure.workflow.json');const invalid = JSON.parse(fs.readFileSync(validInput, 'utf8'));@@ -2609,9 +3153,12 @@ test('cli: failed visual provenance preflight replaces stale evidence with a perassert.equal(run(['deliver', 'workflow', invalidInput, out, '--json']).status, 1);const evidence = visualEvidencePaths(out);- fs.writeFileSync(evidence.receipt, '{"sentinel":"stale receipt"}\n');- fs.writeFileSync(evidence.contactSheet, '<!doctype html><title>stale contact sheet</title>\n');- for (const screenshot of evidence.screenshots) fs.writeFileSync(screenshot, 'stale screenshot');+ const staleReceipt = '{"sentinel":"stale receipt"}\n';+ const staleContactSheet = '<!doctype html><title>stale contact sheet</title>\n';+ const staleScreenshot = 'stale screenshot';+ fs.writeFileSync(evidence.receipt, staleReceipt);+ fs.writeFileSync(evidence.contactSheet, staleContactSheet);+ for (const screenshot of evidence.screenshots) fs.writeFileSync(screenshot, staleScreenshot);const visual = run(['visual-check', out, '--json', '--require-provenance']);@@ -2622,13 +3169,12 @@ test('cli: failed visual provenance preflight replaces stale evidence with a perassert.equal(receipt.status, 'fail');assert.equal(receipt.artifact.path, path.resolve(out));assert.match(receipt.diagnostics[0].code, /^delivery\/provenance-failed$/);- assert.equal(fs.existsSync(evidence.contactSheet), false);- assert.equal(evidence.screenshots.every((file) => !fs.existsSync(file)), true);- const persisted = JSON.parse(fs.readFileSync(evidence.receipt, 'utf8'));- assert.equal(persisted.command, 'visual-check');- assert.equal(persisted.status, 'fail');- assert.equal(persisted.artifact.path, path.resolve(out));- assert.equal(persisted.diagnostics[0].code, receipt.diagnostics[0].code);+ assert.ok(receipt.diagnostics.some((entry) => entry.code === 'viewer/evidence-path-conflict'));+ assert.equal(fs.readFileSync(evidence.receipt, 'utf8'), staleReceipt);+ assert.equal(fs.readFileSync(evidence.contactSheet, 'utf8'), staleContactSheet);+ assert.equal(evidence.screenshots.every(+ (file) => fs.readFileSync(file, 'utf8') === staleScreenshot,+ ), true);});test('cli: provenance writes cannot follow the former predictable temporary symlink', t => {@@ -2645,7 +3191,7 @@ test('cli: provenance writes cannot follow the former predictable temporary symlconst wrapper = path.join(tmp, 'provenance-symlink-wrapper.mjs');fs.writeFileSync(wrapper, `import fs from 'node:fs';-const sidecar = ${JSON.stringify(out.replace(/\.html$/, '.delivery.json'))};+const sidecar = ${JSON.stringify(deliveryProvenancePath(out))};try {fs.symlinkSync(${JSON.stringify(sentinel)}, sidecar + '.tmp-' + process.pid, 'file');} catch (error) {@@ -2662,7 +3208,7 @@ await import(${JSON.stringify(pathToFileURL(cli).href)});}assert.equal(result.status, 1);assert.equal(fs.readFileSync(sentinel, 'utf8'), sentinelContents);- assert.equal(JSON.parse(fs.readFileSync(out.replace(/\.html$/, '.delivery.json'), 'utf8')).status, 'failed');+ assert.equal(JSON.parse(fs.readFileSync(deliveryProvenancePath(out), 'utf8')).status, 'failed');});test('cli: deliver reports unreadable input as json without touching the target', () => {@@ -2700,7 +3246,7 @@ test('cli: invalid source output metadata still fails inside the renderer', () =assert.equal(fs.readFileSync(out, 'utf8'), trustedPriorArtifact);});-test('cli: deliver reports commit failure without a false success receipt', () => {+test('cli: deliver rejects a non-regular target before commit without a false success receipt', () => {const input = path.join(skillRoot, 'examples/web-app.architecture.json');const outputDirectory = path.join(tmp, 'commit-target-is-a-directory.html');fs.mkdirSync(outputDirectory, { recursive: true });@@ -2709,8 +3255,9 @@ test('cli: deliver reports commit failure without a false success receipt', () =assert.equal(result.status, 1);const failure = JSON.parse(result.stdout);assert.equal(failure.ok, false);- assert.equal(failure.stage, 'commit');- assert.match(failure.error, /Could not commit verified delivery/);+ assert.equal(failure.stage, 'prepare');+ assert.equal(failure.diagnostics[0].code, 'output/target-not-regular-file');+ assert.match(failure.error, /HTML artifact target is not a regular file/);assert.equal(fs.statSync(outputDirectory).isDirectory(), true);assert.equal(fs.readdirSync(outputDirectory).length, 0);});@@ -2726,7 +3273,8 @@ test('cli: deliver reports preparation failure as json without touching the blocconst failure = JSON.parse(result.stdout);assert.equal(failure.ok, false);assert.equal(failure.stage, 'prepare');- assert.match(failure.error, /Could not create delivery directory/);+ assert.equal(failure.diagnostics[0].code, 'output/path-resolution-indeterminate');+ assert.match(failure.error, /Output path could not be resolved safely/);assert.equal(fs.readFileSync(blockingFile, 'utf8'), 'do not replace me');});diff --git a/archify/test/copy-site-assets.test.mjs b/archify/test/copy-site-assets.test.mjsnew file mode 100644index 00000000..a5de166e--- /dev/null+++ b/archify/test/copy-site-assets.test.mjs@@ -0,0 +1,325 @@+import assert from 'node:assert/strict';+import { spawnSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import test from 'node:test';+import { fileURLToPath } from 'node:url';++import { copySiteAssets } from '../../scripts/copy-site-assets.mjs';++const testDirectory = path.dirname(fileURLToPath(import.meta.url));+const repoRoot = path.resolve(testDirectory, '../..');+const canonicalAssets = path.join(repoRoot, 'docs', 'assets');++function workspace(t, prefix) {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), prefix));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ return directory;+}++function assertThrowsWithCauseCode(action, expectedCode) {+ assert.throws(action, (error) => {+ assert.equal(error?.cause?.code, expectedCode);+ return true;+ });+}++function createDirectorySymlink(t, target, alias) {+ try {+ fs.symlinkSync(target, alias, process.platform === 'win32' ? 'junction' : 'dir');+ return true;+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip(`directory symlinks unavailable: ${error.code}`);+ return false;+ }+ throw error;+ }+}++function createFileSymlink(t, target, alias) {+ try {+ fs.symlinkSync(target, alias, process.platform === 'win32' ? 'file' : undefined);+ return true;+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip(`file symlinks unavailable: ${error.code}`);+ return false;+ }+ throw error;+ }+}++test('copySiteAssets rejects an assets-directory symlink without modifying its external target', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-directory-link-');+ const outputParent = path.join(root, 'site');+ const external = path.join(root, 'external');+ fs.mkdirSync(outputParent);+ fs.mkdirSync(external);+ const sentinel = path.join(external, 'sentinel.txt');+ fs.writeFileSync(sentinel, 'external-owned\n');+ const assets = path.join(outputParent, 'assets');+ if (!createDirectorySymlink(t, external, assets)) return;++ assert.throws(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ /must be a physical directory, not a symbolic link or special entry/i,+ );+ assert.equal(fs.lstatSync(assets).isSymbolicLink(), true);+ assert.deepEqual(fs.readdirSync(external), ['sentinel.txt']);+ assert.equal(fs.readFileSync(sentinel, 'utf8'), 'external-owned\n');+});++test('copySiteAssets rejects existing and dangling asset symlinks without following them', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-leaf-link-');+ for (const kind of ['existing', 'dangling']) {+ const outputParent = path.join(root, kind, 'site');+ const assets = path.join(outputParent, 'assets');+ const external = path.join(root, kind, 'external', 'site-language.js');+ fs.mkdirSync(assets, { recursive: true });+ fs.mkdirSync(path.dirname(external), { recursive: true });+ if (kind === 'existing') fs.writeFileSync(external, 'external-owned\n');+ const target = path.join(assets, 'site-language.js');+ if (!createFileSymlink(t, external, target)) return;++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'requested-entry-symbolic-link',+ );+ assert.equal(fs.lstatSync(target).isSymbolicLink(), true);+ if (kind === 'existing') {+ assert.equal(fs.readFileSync(external, 'utf8'), 'external-owned\n');+ } else {+ assert.equal(fs.existsSync(external), false);+ }+ assert.equal(fs.existsSync(path.join(assets, 'site-navigation.css')), false);+ }+});++test('copySiteAssets preflights both asset targets before publishing either one', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-two-target-preflight-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const first = path.join(assets, 'site-language.js');+ const second = path.join(assets, 'site-navigation.css');+ const external = path.join(root, 'external-navigation.css');+ fs.mkdirSync(assets, { recursive: true });+ fs.writeFileSync(first, 'first asset remains unchanged\n');+ fs.writeFileSync(external, 'external navigation remains unchanged\n');+ if (!createFileSymlink(t, external, second)) return;++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'requested-entry-symbolic-link',+ );+ assert.equal(fs.readFileSync(first, 'utf8'), 'first asset remains unchanged\n');+ assert.equal(fs.lstatSync(second).isSymbolicLink(), true);+ assert.equal(fs.readFileSync(external, 'utf8'), 'external navigation remains unchanged\n');+});++test('copySiteAssets preserves a target introduced after capture and before publication', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-target-swap-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const target = path.join(assets, 'site-language.js');+ fs.mkdirSync(assets, { recursive: true });++ const copyFileSync = fs.copyFileSync.bind(fs);+ const writeFileSync = fs.writeFileSync.bind(fs);+ let swapped = false;+ t.mock.method(fs, 'copyFileSync', (source, destination, mode) => {+ if (!swapped && path.basename(source) === 'site-language.js'+ && path.basename(destination) === 'site-language.js') {+ fs.writeFileSync(target, 'late claimant\n', { flag: 'wx' });+ swapped = true;+ }+ const result = copyFileSync(source, destination, mode);+ if (!swapped && path.basename(source) === 'site-language.js') {+ fs.writeFileSync(target, 'late claimant\n', { flag: 'wx' });+ swapped = true;+ }+ return result;+ });+ t.mock.method(fs, 'writeFileSync', (file, data, options) => {+ const result = writeFileSync(file, data, options);+ if (!swapped && typeof file === 'number') {+ writeFileSync(target, 'late claimant\n', { flag: 'wx' });+ swapped = true;+ }+ return result;+ });++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'requested-entry-changed',+ );+ assert.equal(swapped, true, 'the race fixture must replace the captured absent target');+ assert.equal(fs.readFileSync(target, 'utf8'), 'late claimant\n');+ assert.deepEqual(fs.readdirSync(assets), ['site-language.js']);+});++test('copySiteAssets rejects a candidate modified while the final target state is checked', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-candidate-mutation-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const target = path.join(assets, 'site-language.js');+ fs.mkdirSync(assets, { recursive: true });+ fs.writeFileSync(target, 'original public asset\n');++ const lstatSync = fs.lstatSync.bind(fs);+ const writeFileSync = fs.writeFileSync.bind(fs);+ let candidatePath;+ let candidateInspections = 0;+ let armed = false;+ let injected = false;+ t.mock.method(fs, 'lstatSync', (file, options) => {+ const metadata = lstatSync(file, options);+ const basename = path.basename(String(file));+ if (basename.startsWith('.site-language.js.archify-') && basename.endsWith('.tmp')) {+ candidatePath = String(file);+ candidateInspections += 1;+ if (candidateInspections === 3) armed = true;+ } else if (armed && !injected && basename === 'site-language.js') {+ writeFileSync(candidatePath, 'mutated candidate\n');+ injected = true;+ }+ return metadata;+ });++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'site-asset-candidate-content-changed',+ );+ assert.equal(injected, true, 'the race fixture must mutate the staged candidate');+ assert.equal(fs.readFileSync(target, 'utf8'), 'original public asset\n');+ assert.deepEqual(fs.readdirSync(assets), ['site-language.js']);+});++test('copySiteAssets preserves a successor that replaces the random candidate during target verification', (t) => {+ if (process.platform === 'win32') {+ t.skip('Replacing an open candidate is not portable to Windows.');+ return;+ }+ const root = workspace(t, 'archify-copy-site-assets-candidate-successor-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const target = path.join(assets, 'site-language.js');+ const displaced = path.join(assets, 'displaced-owned-candidate');+ fs.mkdirSync(assets, { recursive: true });+ fs.writeFileSync(target, 'original public asset\n');++ const lstatSync = fs.lstatSync.bind(fs);+ const writeFileSync = fs.writeFileSync.bind(fs);+ let candidatePath;+ let candidateInspections = 0;+ let armed = false;+ let injected = false;+ t.mock.method(fs, 'lstatSync', (file, options) => {+ const metadata = lstatSync(file, options);+ const basename = path.basename(String(file));+ if (basename.startsWith('.site-language.js.archify-') && basename.endsWith('.tmp')) {+ candidatePath = String(file);+ candidateInspections += 1;+ if (candidateInspections === 3) armed = true;+ } else if (armed && !injected && basename === 'site-language.js') {+ fs.renameSync(candidatePath, displaced);+ writeFileSync(candidatePath, 'candidate successor\n', { flag: 'wx' });+ injected = true;+ }+ return metadata;+ });++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'site-asset-candidate-identity-changed',+ );+ assert.equal(injected, true, 'the race fixture must replace the staged candidate');+ assert.match(path.basename(candidatePath), /^\.site-language\.js\.archify-[a-f\d]{32}\.tmp$/);+ assert.equal(fs.readFileSync(target, 'utf8'), 'original public asset\n');+ assert.equal(fs.readFileSync(candidatePath, 'utf8'), 'candidate successor\n');+ assert.deepEqual(fs.readFileSync(displaced), fs.readFileSync(path.join(canonicalAssets, 'site-language.js')));+});++test('copySiteAssets rejects a hardlinked asset without modifying either name', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-hardlink-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const external = path.join(root, 'external.js');+ const target = path.join(assets, 'site-language.js');+ fs.mkdirSync(assets, { recursive: true });+ fs.writeFileSync(external, 'external-owned\n');+ try {+ fs.linkSync(external, target);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error?.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'requested-entry-hardlinked',+ );+ assert.equal(fs.readFileSync(target, 'utf8'), 'external-owned\n');+ assert.equal(fs.readFileSync(external, 'utf8'), 'external-owned\n');+ assert.equal(fs.lstatSync(target, { bigint: true }).ino, fs.lstatSync(external, { bigint: true }).ino);+ assert.deepEqual(fs.readdirSync(assets), ['site-language.js']);+});++test('copySiteAssets rejects a special asset entry without replacing it', (t) => {+ if (process.platform === 'win32') {+ t.skip('FIFO fixture is POSIX-only.');+ return;+ }+ const root = workspace(t, 'archify-copy-site-assets-special-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ const target = path.join(assets, 'site-language.js');+ fs.mkdirSync(assets, { recursive: true });+ const created = spawnSync('mkfifo', [target], { encoding: 'utf8' });+ if (created.status !== 0) {+ t.skip(`mkfifo unavailable: ${created.stderr || created.error?.message || created.status}`);+ return;+ }++ assertThrowsWithCauseCode(+ () => copySiteAssets(path.join(outputParent, 'index.html')),+ 'requested-entry-not-regular-file',+ );+ assert.equal(fs.lstatSync(target).isFIFO(), true);+ assert.deepEqual(fs.readdirSync(assets), ['site-language.js']);+});++test('copySiteAssets atomically refreshes regular assets and leaves no temporary entries', (t) => {+ const root = workspace(t, 'archify-copy-site-assets-success-');+ const outputParent = path.join(root, 'site');+ const assets = path.join(outputParent, 'assets');+ fs.mkdirSync(assets, { recursive: true });+ const existing = path.join(assets, 'site-language.js');+ fs.writeFileSync(existing, 'stale\n');+ let previousUmask;+ if (process.platform !== 'win32') {+ fs.chmodSync(existing, 0o666);+ previousUmask = process.umask(0o077);+ }++ try {+ copySiteAssets(path.join(outputParent, 'index.html'));+ } finally {+ if (previousUmask !== undefined) process.umask(previousUmask);+ }++ for (const asset of ['site-language.js', 'site-navigation.css']) {+ assert.deepEqual(+ fs.readFileSync(path.join(assets, asset)),+ fs.readFileSync(path.join(canonicalAssets, asset)),+ );+ }+ if (process.platform !== 'win32') {+ assert.equal(fs.statSync(existing).mode & 0o777, 0o666);+ }+ assert.deepEqual(fs.readdirSync(assets).sort(), ['site-language.js', 'site-navigation.css']);+});diff --git a/archify/test/delivery-contract.test.mjs b/archify/test/delivery-contract.test.mjsindex a273f32d..511f5bf5 100644--- a/archify/test/delivery-contract.test.mjs+++ b/archify/test/delivery-contract.test.mjs@@ -7,6 +7,27 @@ import assert from 'node:assert/strict';const here = path.dirname(fileURLToPath(import.meta.url));const skill = readFileSync(path.join(here, '..', 'SKILL.md'), 'utf8');const delivery = readFileSync(path.join(here, '..', 'references', 'delivery-contract.md'), 'utf8');+const schemaReadme = readFileSync(path.join(here, '..', 'schemas', 'README.md'), 'utf8');++test('delivery contract separates portable authored outputs from native CLI outputs', () => {+ assert.match(delivery, /Authored `meta\.output` is a portable POSIX-relative path/i);+ assert.match(delivery, /Explicit CLI output arguments use the active host's native syntax/i);+ assert.match(delivery, /explicit CLI output does not hide\s+an invalid durable `meta\.output`/i);+ assert.match(delivery, /Windows 8\.3 short-name shape[\s\S]*repo\/Git POSIX paths[\s\S]*exempt/i);+ assert.match(delivery, /system-resolved 8\.3 spelling[\s\S]*physical identity[\s\S]*does\s+not relax the durable output\/archive profile/i);+ assert.match(schemaReadme, /portableOutputPath[\s\S]*delivery-contract\.md#output-path-contracts/);+});++test('delivery contract describes the directory-wide physical delivery lock', () => {+ assert.match(delivery, /directory-wide `\.archify-delivery-lock\.json`/i);+ assert.match(delivery, /same physical output directory/i);+ assert.match(delivery, /deliveries to different artifact names in one directory also run serially/i);+ assert.match(delivery, /legacy\s+`<output-stem>\.delivery-lock\.json`[\s\S]*fail-closed recovery barrier/i);+ assert.match(delivery, /temporary legacy-format fences[\s\S]*requested\s+spelling[\s\S]*existing artifact's physical target spelling/i);+ assert.match(delivery, /acquires the\s+directory lock first[\s\S]*compatibility fences before writing a\s+journal or artifact/i);+ assert.match(delivery, /removes the directory lock before those fences during\s+release/i);+ assert.match(delivery, /pre-namespace raw pending journal[\s\S]*independent\s+fail-closed barrier[\s\S]*encoded pending\s+journal also exists/i);+});test('skill requires a bounded and truthful perceptual delivery receipt', () => {assert.match(delivery, /browser_evidence: passed\|failed\|skipped/);@@ -66,6 +87,21 @@ test('handoff browser evidence mirrors only the automated visual-check outcome',assert.match(delivery, /manual browser record[\s\S]*never changes `browser_evidence`/i);});+test('visual evidence replacement is ownership-bound and fails closed on slot changes', () => {+ assert.match(delivery, /receipt, contact sheet, and four PNGs form one owned evidence\s+set/i);+ assert.match(delivery, /random,\s+private staging directory beneath the physical evidence directory/i);+ assert.match(delivery, /staged candidate must have exactly one hard-link name[\s\S]*link count of two[\s\S]*link count of one/i);+ assert.match(delivery, /unexpected external hard\s+link fails closed and its alias is never removed/i);+ assert.match(delivery, /Immediately before committing anything[\s\S]*complete six-path set/i);+ assert.match(delivery, /absent-path claimant[\s\S]*existing-path replacement[\s\S]*dangling-link retarget/i);+ assert.match(delivery, /fails closed with `viewer\/evidence-path-conflict`/i);+ assert.match(delivery, /claimant and every other final evidence path remain untouched/i);+ assert.match(delivery, /receipt proves ownership[\s\S]*byte count and SHA-256 digest/i);+ assert.match(delivery, /missing, malformed, unknown, mismatched,[\s\S]*never authorizes deletion/i);+ assert.match(delivery, /Chrome is unavailable or provenance fails[\s\S]*neither path may blindly delete/i);+ assert.match(delivery, /Cleanup removes\s+only this run's staged or published entries after rechecking their captured\s+identities/i);+});+test('skill uses recoverable verified delivery for the final artifact', () => {assert.match(delivery, /archify\.mjs deliver <type>/);assert.match(delivery, /same-directory candidate/i);@@ -74,6 +110,17 @@ test('skill uses recoverable verified delivery for the final artifact', () => {assert.match(delivery, /never claim that the deterministic receipt includes visual review/i);});+test('atomic publishers freeze the write slot and reject hardlinked write targets', () => {+ assert.match(delivery, /Every atomic HTML publisher \(`render`, `deliver`, `compare`, and `preview`\)/i);+ assert.match(delivery, /requested directory entry, canonical write slot, physical parent/i);+ assert.match(delivery, /target type, device\/inode identity, and mode[\s\S]*revalidates/i);+ assert.match(delivery, /multiple hard-link names fails closed with `output\/target-hardlinked`/i);+ assert.match(delivery, /provenance directory\s+entry itself must be a single-link regular file[\s\S]*`delivery\/provenance-hardlink-unsupported`/i);+ assert.match(delivery, /Hard links remain supported for[\s\S]*read identity[\s\S]*unsupported only as\s+write targets/i);+ assert.match(delivery, /symbolic link to a single-link regular file remains supported/i);+ assert.match(delivery, /preserves the symbolic-link entry[\s\S]*resolved target/i);+});+test('skill keeps optional opening behind the verified commit and outside automation', () => {assert.match(delivery, /Add `--open` only when the user wants an immediate local preview/);assert.match(delivery, /runs after[\s\S]*verified pair commit[\s\S]*journal has been\s+removed/);diff --git a/archify/test/delivery-sidecar-path.test.mjs b/archify/test/delivery-sidecar-path.test.mjsnew file mode 100644index 00000000..1141ebb3--- /dev/null+++ b/archify/test/delivery-sidecar-path.test.mjs@@ -0,0 +1,1072 @@+import { spawn, spawnSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';+import test from 'node:test';+import assert from 'node:assert/strict';++const skillRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const cli = path.join(skillRoot, 'bin', 'archify.mjs');+const input = path.join(skillRoot, 'examples', 'agent-tool-call.workflow.json');++function run(args, cwd) {+ return spawnSync(process.execPath, [cli, ...args], { cwd, encoding: 'utf8' });+}++function windowsShortPath(targetPath) {+ if (process.platform !== 'win32') return null;+ const result = spawnSync(+ process.env.ComSpec || 'cmd.exe',+ ['/d', '/s', '/c', '"for %I in ("%ARCHIFY_SHORT_PATH_TARGET%") do @echo %~sI"'],+ {+ encoding: 'utf8',+ env: { ...process.env, ARCHIFY_SHORT_PATH_TARGET: targetPath },+ windowsHide: true,+ windowsVerbatimArguments: true,+ },+ );+ if (result.error) throw new Error(`Could not query a Windows 8.3 path: ${result.error.message}`);+ if (result.status !== 0) {+ throw new Error(`Could not query a Windows 8.3 path: ${result.stderr.trim() || `exit ${result.status}`}`);+ }+ const shortPath = result.stdout.trim();+ if (!shortPath) throw new Error('Windows returned an empty 8.3 path');+ if (path.resolve(shortPath).toLowerCase() === path.resolve(targetPath).toLowerCase()) return null;+ if (fs.realpathSync.native(shortPath).toLowerCase() !== fs.realpathSync.native(targetPath).toLowerCase()) {+ throw new Error('Windows returned an 8.3 path for a different filesystem entry');+ }+ return shortPath;+}++function controlledWindowsShortRoot(required) {+ const root = process.env.ARCHIFY_WINDOWS_8DOT3_ROOT;+ const shortRoot = process.env.ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT;+ if (!root && !shortRoot) {+ if (required) {+ assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires the controlled long and short roots');+ }+ return null;+ }+ assert.ok(root && shortRoot, 'the controlled Windows 8.3 roots must be configured together');+ assert.match(+ path.win32.basename(shortRoot),+ /~/u,+ 'the controlled short root must use an explicit 8.3 alias',+ );+ assert.equal(+ fs.realpathSync.native(root).toLowerCase(),+ fs.realpathSync.native(shortRoot).toLowerCase(),+ 'the controlled long and short roots must identify the same directory',+ );+ return { root, shortRoot };+}++test('delivery keeps every derived sidecar component within portable limits', () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-long-sidecars-'));+ const output = path.join(cwd, `${'x'.repeat(245)}.html`);+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);++ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ const names = fs.readdirSync(cwd);+ const provenance = names.find((name) => name.endsWith('.delivery.json'));+ assert.ok(provenance, 'delivery provenance must be present');+ assert.match(provenance, /\.~archify-[0-9a-f]{64}\.delivery\.json$/);+ assert.equal(names.every((name) => (+ name.length <= 255 && Buffer.byteLength(name, 'utf8') <= 255+ )), true);+ assert.equal(names.some((name) => name.endsWith('.delivery-lock.json')), false);+ assert.equal(names.some((name) => name.endsWith('.delivery-pending.json')), false);++ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+});++test('delivery rejects an illegal output extension before preparing its missing parent', () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-illegal-output-parent-'));+ const parent = path.join(cwd, 'must-remain-absent');+ const output = path.join(parent, 'diagram.txt');+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);++ assert.equal(delivered.status, 1, delivered.stderr || delivered.stdout);+ const receipt = JSON.parse(delivered.stdout);+ assert.equal(receipt.stage, 'prepare');+ assert.equal(receipt.diagnostics[0].code, 'output/cli-extension');+ assert.equal(fs.existsSync(parent), false);+});++test('delivery rejects an indeterminate sidecar namespace before creating output state', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-unknown-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, `${'A'.repeat(225)}.html`);+ const wrapper = path.join(cwd, 'deny-sidecar-probe.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+import { syncBuiltinESMExports } from 'node:module';+const openSync = fs.openSync;+fs.openSync = (file, ...args) => {+ if (path.basename(String(file)).startsWith('.archify-path-semantics-')) {+ const error = new Error('synthetic sidecar probe denial');+ error.code = 'EACCES';+ throw error;+ }+ return openSync(file, ...args);+};+syncBuiltinESMExports();+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const rejected = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ const receipt = JSON.parse(rejected.stdout);+ assert.equal(receipt.stage, 'prepare');+ assert.equal(receipt.diagnostics[0].code, 'output/path-resolution');+ assert.equal(+ receipt.diagnostics[0].evidence.systemCode,+ 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE',+ );+ assert.match(receipt.error, /sidecar-case-semantics-indeterminate/u);+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(+ fs.readdirSync(cwd).filter((name) => name !== path.basename(wrapper)),+ [],+ );+});++test('strict provenance finds a long-stem sidecar through a case-only artifact alias', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-long-sidecar-alias-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const upperOutput = path.join(cwd, `${'A'.repeat(234)}.html`);+ const lowerOutput = path.join(cwd, `${'a'.repeat(234)}.html`);+ const delivered = run(['deliver', 'workflow', input, upperOutput, '--json'], cwd);++ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ if (!fs.existsSync(lowerOutput)) {+ t.skip('the test filesystem is case-sensitive');+ return;+ }++ const checked = run(['check', lowerOutput, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');++ const redelivered = run(['deliver', 'workflow', input, lowerOutput, '--json'], cwd);+ assert.equal(redelivered.status, 0, redelivered.stderr || redelivered.stdout);+ for (const alias of [upperOutput, lowerOutput]) {+ const rechecked = run(['check', alias, '--require-provenance'], cwd);+ assert.equal(rechecked.status, 0, rechecked.stderr || rechecked.stdout);+ assert.equal(JSON.parse(rechecked.stdout).provenance, 'current');+ }+});++test('delivery sidecars preserve distinct HTML extension spellings only when the filesystem does', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-extension-case-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const lower = path.join(cwd, 'diagram.html');+ const upper = path.join(cwd, 'diagram.HTML');+ const lowerDelivery = run(['deliver', 'workflow', input, lower, '--json'], cwd);+ assert.equal(lowerDelivery.status, 0, lowerDelivery.stderr || lowerDelivery.stdout);+ const aliases = fs.existsSync(upper);+ const upperDelivery = run(['deliver', 'workflow', input, upper, '--json'], cwd);+ assert.equal(upperDelivery.status, 0, upperDelivery.stderr || upperDelivery.stdout);++ const receipts = fs.readdirSync(cwd).filter((name) => name.endsWith('.delivery.json'));+ if (aliases) {+ assert.deepEqual(receipts, ['diagram.delivery.json']);+ } else {+ assert.equal(receipts.length, 2);+ assert.ok(receipts.includes('diagram.delivery.json'));+ assert.match(+ receipts.find((name) => name !== 'diagram.delivery.json'),+ /^diagram\.HTML\.~archify-[0-9a-f]{64}\.delivery\.json$/u,+ );+ }+ for (const artifactPath of [lower, upper]) {+ const checked = run(['check', artifactPath, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ }+});++test('different long artifact names retain distinct delivery provenance', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-long-sidecar-distinct-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const shared = 'x'.repeat(233);+ const outputs = ['a', 'b'].map((suffix) => path.join(cwd, `${shared}${suffix}.html`));++ for (const output of outputs) {+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ }++ const receipts = fs.readdirSync(cwd).filter((name) => name.endsWith('.delivery.json'));+ assert.equal(receipts.length, 2);+ assert.notEqual(receipts[0], receipts[1]);+});++test('a crafted bounded stem cannot replace another artifact delivery provenance', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-namespace-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const longOutput = path.join(cwd, `${'x'.repeat(245)}.html`);+ const first = run(['deliver', 'workflow', input, longOutput, '--json'], cwd);+ assert.equal(first.status, 0, first.stderr || first.stdout);++ const firstProvenance = fs.readdirSync(cwd).find((name) => name.endsWith('.delivery.json'));+ assert.ok(firstProvenance);+ const encodedStem = firstProvenance.replace(/\.delivery\.json$/u, '');+ const craftedOutput = path.join(cwd, `${encodedStem}.html`);+ const second = run(['deliver', 'workflow', input, craftedOutput, '--json'], cwd);+ assert.equal(second.status, 0, second.stderr || second.stdout);++ const receipts = fs.readdirSync(cwd).filter((name) => name.endsWith('.delivery.json'));+ assert.equal(receipts.length, 2);+ assert.equal(new Set(receipts).size, 2);+ for (const output of [longOutput, craftedOutput]) {+ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+ }+});++test('a pre-namespace raw sidecar remains readable and its pending journal blocks redelivery', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-migration-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const reservedStem = `legacy.~archify-${'a'.repeat(64)}`;+ const output = path.join(cwd, `${reservedStem}.html`);+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);++ const encodedProvenance = fs.readdirSync(cwd)+ .find((name) => name.endsWith('.delivery.json'));+ assert.ok(encodedProvenance);+ const rawProvenance = path.join(cwd, `${reservedStem}.delivery.json`);+ assert.notEqual(path.join(cwd, encodedProvenance), rawProvenance);+ fs.renameSync(path.join(cwd, encodedProvenance), rawProvenance);++ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');++ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(rawProvenance);+ const rawPending = path.join(cwd, `${reservedStem}.delivery-pending.json`);+ const pendingBefore = '{"legacyPending":true}\n';+ fs.writeFileSync(rawPending, pendingBefore);+ const rejected = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ const receipt = JSON.parse(rejected.stdout);+ assert.equal(receipt.diagnostics[0].code, 'delivery/legacy-pending');+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(rawProvenance), provenanceBefore);+ assert.equal(fs.readFileSync(rawPending, 'utf8'), pendingBefore);+ assert.equal(fs.readdirSync(cwd).filter((name) => name.endsWith('.delivery.json')).length, 1);+});++test('a raw legacy pending journal remains the barrier when an encoded journal also exists', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-migration-coexistence-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const reservedStem = `legacy.~archify-${'a'.repeat(64)}`;+ const output = path.join(cwd, `${reservedStem}.html`);+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);++ const encodedProvenance = fs.readdirSync(cwd)+ .find((name) => name.endsWith('.delivery.json'));+ assert.ok(encodedProvenance);+ const rawProvenance = path.join(cwd, `${reservedStem}.delivery.json`);+ assert.notEqual(path.join(cwd, encodedProvenance), rawProvenance);+ fs.renameSync(path.join(cwd, encodedProvenance), rawProvenance);++ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(rawProvenance);+ const rawPending = path.join(cwd, `${reservedStem}.delivery-pending.json`);+ const pendingBefore = '{"legacyPending":true}\n';+ fs.writeFileSync(rawPending, pendingBefore);+ const encodedPending = path.join(+ cwd,+ encodedProvenance.replace(/\.delivery\.json$/u, '.delivery-pending.json'),+ );+ const encodedPendingBefore = '{"currentPending":true}\n';+ fs.writeFileSync(encodedPending, encodedPendingBefore);++ const rejected = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ const receipt = JSON.parse(rejected.stdout);+ assert.equal(receipt.diagnostics[0].code, 'delivery/legacy-pending');+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(rawProvenance), provenanceBefore);+ assert.equal(fs.readFileSync(rawPending, 'utf8'), pendingBefore);+ assert.equal(fs.readFileSync(encodedPending, 'utf8'), encodedPendingBefore);+});++test('strict provenance follows an artifact symlink into another directory', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-file-symlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const realDirectory = path.join(cwd, 'real');+ const aliasDirectory = path.join(cwd, 'alias');+ fs.mkdirSync(realDirectory);+ fs.mkdirSync(aliasDirectory);+ const output = path.join(realDirectory, `${'x'.repeat(234)}.html`);+ const alias = path.join(aliasDirectory, 'diagram.html');++ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ try {+ fs.symlinkSync(output, alias, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error?.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }++ const checked = run(['check', alias, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+});++test('delivery follows a dangling artifact symlink without replacing the link', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-dangling-symlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const targetDirectory = path.join(cwd, 'target');+ const aliasDirectory = path.join(cwd, 'alias');+ fs.mkdirSync(targetDirectory);+ fs.mkdirSync(aliasDirectory);+ const target = path.join(targetDirectory, 'diagram.html');+ const alias = path.join(aliasDirectory, 'diagram.html');+ try {+ fs.symlinkSync(target, alias, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error?.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }++ const delivered = run(['deliver', 'workflow', input, alias, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ assert.equal(fs.lstatSync(alias).isSymbolicLink(), true);+ assert.equal(fs.lstatSync(target).isFile(), true);++ for (const artifactPath of [alias, target]) {+ const checked = run(['check', artifactPath, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+ }+});++test('delivery and strict checks reject a hard-linked artifact without changing its pair', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-sidecar-hardlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const alias = path.join(cwd, 'diagram-hardlink.html');+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ const provenance = path.join(cwd, 'diagram.delivery.json');+ try {+ fs.linkSync(output, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error?.code)) {+ t.skip(`hard links are unavailable (${error.code})`);+ return;+ }+ throw error;+ }+ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(provenance);++ for (const artifactPath of [output, alias]) {+ const checked = run(['check', artifactPath, '--require-provenance'], cwd);+ assert.equal(checked.status, 1, checked.stderr || checked.stdout);+ assert.equal(+ JSON.parse(checked.stdout).diagnostics[0].code,+ 'output/target-hardlinked',+ );+ }++ const rejected = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ assert.equal(+ JSON.parse(rejected.stdout).diagnostics[0].code,+ 'output/target-hardlinked',+ );+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(alias), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenance), provenanceBefore);++ fs.unlinkSync(alias);+ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+});++test('delivery and strict check reject hard-linked provenance without changing the pair', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-provenance-hardlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const alias = path.join(cwd, 'provenance-alias.json');+ const delivered = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(delivered.status, 0, delivered.stderr || delivered.stdout);+ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(provenance);+ try {+ fs.linkSync(provenance, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error?.code)) {+ t.skip(`hard links are unavailable (${error.code})`);+ return;+ }+ throw error;+ }++ const checked = run(['check', output, '--require-provenance'], cwd);+ assert.equal(checked.status, 1, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).diagnostics[0].code, 'delivery/provenance-hardlink-unsupported');++ const rejected = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(rejected.status, 1, rejected.stderr || rejected.stdout);+ assert.equal(+ JSON.parse(rejected.stdout).diagnostics.some((entry) => entry.code === 'delivery/provenance-hardlink-unsupported'),+ true,+ );+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenance), provenanceBefore);+ assert.deepEqual(fs.readFileSync(alias), provenanceBefore);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), false);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), false);++ fs.unlinkSync(alias);+ const recovered = run(['check', output, '--require-provenance'], cwd);+ assert.equal(recovered.status, 0, recovered.stderr || recovered.stdout);+});++test('delivery refuses existing and dangling provenance symlinks without touching their targets', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-provenance-symlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));++ for (const kind of ['existing', 'dangling']) {+ const directory = path.join(cwd, kind);+ fs.mkdirSync(directory);+ const output = path.join(directory, 'diagram.html');+ const first = run(['deliver', 'workflow', input, output, '--json'], directory);+ assert.equal(first.status, 0, first.stderr || first.stdout);+ const provenance = path.join(directory, 'diagram.delivery.json');+ const preservedReceipt = fs.readFileSync(provenance);+ const target = path.join(directory, 'owned.json');+ fs.unlinkSync(provenance);+ if (kind === 'existing') fs.writeFileSync(target, preservedReceipt);+ try {+ fs.symlinkSync(target, provenance, 'file');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(error?.code)) {+ t.skip(`file symlink creation requires Windows permission (${error.code})`);+ return;+ }+ throw error;+ }+ const artifactBefore = fs.readFileSync(output);+ const targetBefore = kind === 'existing' ? fs.readFileSync(target) : undefined;++ const rejected = run(['deliver', 'workflow', input, output, '--json'], directory);+ assert.equal(rejected.status, 1, rejected.stderr || rejected.stdout);+ assert.equal(JSON.parse(rejected.stdout).diagnostics[0].code, 'output/target-not-regular-file');+ assert.equal(fs.lstatSync(provenance).isSymbolicLink(), true);+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ if (kind === 'existing') assert.deepEqual(fs.readFileSync(target), targetBefore);+ else assert.equal(fs.existsSync(target), false);+ assert.equal(fs.existsSync(path.join(directory, 'diagram.delivery-pending.json')), false);+ assert.equal(fs.readdirSync(directory).some((name) => name.includes('delivery-lock')), false);+ }+});++test('a missing-input failure cannot replace hard-linked delivery provenance', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-failure-provenance-hardlink-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const provenanceAlias = path.join(cwd, 'receipt-alias.json');+ const first = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(first.status, 0, first.stderr || first.stdout);+ try {+ fs.linkSync(provenance, provenanceAlias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error?.code)) {+ t.skip(`hard links are unavailable (${error.code})`);+ return;+ }+ throw error;+ }+ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(provenance);++ const rejected = run([+ 'deliver',+ 'workflow',+ path.join(cwd, 'missing-input.json'),+ output,+ '--json',+ ], cwd);+ assert.equal(rejected.status, 1, rejected.stderr || rejected.stdout);+ const failure = JSON.parse(rejected.stdout);+ assert.equal(+ failure.diagnostics.some((entry) => entry.code === 'delivery/provenance-hardlink-unsupported'),+ true,+ );+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenance), provenanceBefore);+ assert.deepEqual(fs.readFileSync(provenanceAlias), provenanceBefore);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), false);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), false);+});++test('failed-delivery provenance preserves a replacement that appears after its snapshot', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-failure-provenance-race-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const displaced = path.join(cwd, 'previous.delivery.json');+ const first = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(first.status, 0, first.stderr || first.stdout);+ const artifactBefore = fs.readFileSync(output);+ const claimant = '{"claimant":"do-not-replace"}\n';+ const wrapper = path.join(cwd, 'replace-failure-provenance.mjs');+ fs.writeFileSync(wrapper, `+import childProcess from 'node:child_process';+import fs from 'node:fs';+import path from 'node:path';+import { syncBuiltinESMExports } from 'node:module';+const spawnSync = childProcess.spawnSync;+childProcess.spawnSync = (executable, args, options) => {+ if (String(args?.[0]).includes('render-workflow.mjs')) {+ return { status: 7, stdout: '', stderr: '' };+ }+ return spawnSync(executable, args, options);+};+syncBuiltinESMExports();+const writeFileSync = fs.writeFileSync;+let replaced = false;+fs.writeFileSync = (file, value, options) => {+ const result = writeFileSync(file, value, options);+ if (!replaced+ && path.basename(String(file)) === ${JSON.stringify(path.basename(provenance))}+ && path.basename(path.dirname(String(file))).startsWith('.archify-provenance-')) {+ replaced = true;+ fs.renameSync(${JSON.stringify(provenance)}, ${JSON.stringify(displaced)});+ writeFileSync(${JSON.stringify(provenance)}, ${JSON.stringify(claimant)}, { flag: 'wx' });+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const rejected = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.notEqual(rejected.status, 0, rejected.stderr || rejected.stdout);+ const failure = JSON.parse(rejected.stdout);+ assert.equal(failure.provenance, 'unrecorded');+ assert.equal(failure.diagnostics.some((entry) => entry.code === 'output/target-changed'), true);+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.equal(fs.readFileSync(provenance, 'utf8'), claimant);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), false);+});++test('failed-delivery provenance cannot overwrite a claimant in the final publish window', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-failure-provenance-claimant-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const provenanceName = path.basename(provenance);+ assert.equal(run(['deliver', 'workflow', input, output, '--json'], cwd).status, 0);+ const artifactBefore = fs.readFileSync(output);+ const claimant = '{"claimant":"final-window"}\n';+ const wrapper = path.join(cwd, 'claim-failure-provenance.mjs');+ fs.writeFileSync(wrapper, `+import childProcess from 'node:child_process';+import fs from 'node:fs';+import path from 'node:path';+import { syncBuiltinESMExports } from 'node:module';+const spawnSync = childProcess.spawnSync;+childProcess.spawnSync = (executable, args, options) => {+ if (String(args?.[0]).includes('render-workflow.mjs')) return { status: 7, stdout: '', stderr: '' };+ return spawnSync(executable, args, options);+};+syncBuiltinESMExports();+const linkSync = fs.linkSync;+const writeFileSync = fs.writeFileSync;+let claimed = false;+fs.linkSync = (source, target) => {+ if (!claimed+ && path.basename(String(target)) === ${JSON.stringify(provenanceName)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-provenance-')) {+ claimed = true;+ writeFileSync(target, ${JSON.stringify(claimant)}, { flag: 'wx' });+ }+ return linkSync(source, target);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.notEqual(failed.status, 0, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(receipt.provenance, 'unrecorded');+ assert.equal(fs.readFileSync(provenance, 'utf8'), claimant, failed.stderr || failed.stdout);+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), true);+ assert.equal(+ receipt.diagnostics.some((entry) => entry.code === 'delivery/provenance-recovery-required'),+ true,+ );+});++for (const candidateRole of ['artifact', 'provenance']) {+ test(`delivery rejects a hard-linked staged ${candidateRole} candidate`, (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-${candidateRole}-candidate-hardlink-`));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const externalAlias = path.join(cwd, `${candidateRole}-candidate-alias`);+ assert.equal(run(['deliver', 'workflow', input, output, '--json'], cwd).status, 0);+ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(provenance);+ const wrapper = path.join(cwd, `hardlink-${candidateRole}-candidate.mjs`);+ const candidateName = candidateRole === 'artifact' ? path.basename(output) : 'delivery-provenance.json';+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const lstatSync = fs.lstatSync;+const linkSync = fs.linkSync;+let linked = false;+fs.lstatSync = (file, options) => {+ if (!linked+ && path.basename(String(file)) === ${JSON.stringify(candidateName)}+ && path.basename(path.dirname(String(file))).startsWith('.archify-delivery-')) {+ linked = true;+ linkSync(file, ${JSON.stringify(externalAlias)});+ }+ return lstatSync(file, options);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(+ receipt.diagnostics.some((entry) => entry.code === (+ candidateRole === 'artifact'+ ? 'output/target-hardlinked'+ : 'delivery/provenance-hardlink-unsupported'+ )),+ true,+ );+ assert.deepEqual(fs.readFileSync(output), artifactBefore);+ assert.deepEqual(fs.readFileSync(provenance), provenanceBefore);+ assert.equal(fs.existsSync(externalAlias), true);+ assert.equal(fs.statSync(externalAlias).nlink, 1);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), false);+ });+}++for (const candidateRole of ['artifact', 'provenance']) {+ test(`delivery preserves a published ${candidateRole} claimant and its old backup after an external hard link`, (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-${candidateRole}-publish-hardlink-`));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ const externalAlias = path.join(cwd, `${candidateRole}-published-alias`);+ assert.equal(run(['deliver', 'workflow', input, output, '--json'], cwd).status, 0);+ const artifactBefore = fs.readFileSync(output);+ const provenanceBefore = fs.readFileSync(provenance);+ const wrapper = path.join(cwd, `hardlink-published-${candidateRole}.mjs`);+ const candidateName = candidateRole === 'artifact' ? path.basename(output) : 'delivery-provenance.json';+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;+let linked = false;+fs.linkSync = (source, target) => {+ const result = linkSync(source, target);+ if (!linked+ && path.basename(String(source)) === ${JSON.stringify(candidateName)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-delivery-')) {+ linked = true;+ linkSync(source, ${JSON.stringify(externalAlias)});+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(+ receipt.diagnostics.some((entry) => entry.code === (+ candidateRole === 'artifact'+ ? 'output/target-hardlinked'+ : 'delivery/provenance-hardlink-unsupported'+ )),+ true,+ );+ const recovery = receipt.diagnostics.find(+ (entry) => entry.code === 'delivery/commit-recovery-required',+ );+ assert.ok(recovery, failed.stderr || failed.stdout);+ assert.equal(recovery.evidence.recoveryRequired, true);+ const affectedTarget = candidateRole === 'artifact' ? output : provenance;+ const affectedBefore = candidateRole === 'artifact' ? artifactBefore : provenanceBefore;+ const unaffectedTarget = candidateRole === 'artifact' ? provenance : output;+ const unaffectedBefore = candidateRole === 'artifact' ? provenanceBefore : artifactBefore;+ assert.deepEqual(fs.readFileSync(unaffectedTarget), unaffectedBefore);+ assert.equal(fs.existsSync(externalAlias), true);+ assert.equal(fs.statSync(externalAlias).ino, fs.statSync(affectedTarget).ino);+ assert.ok(fs.statSync(externalAlias).nlink >= 2);+ const backup = recovery.evidence.recoverableBackups.find(({ label }) => label === (+ candidateRole === 'artifact' ? 'HTML artifact' : 'delivery provenance'+ ));+ assert.ok(backup, 'the displaced previous file must remain recoverable');+ assert.deepEqual(fs.readFileSync(backup.path), affectedBefore);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.existsSync(path.join(cwd, '.archify-delivery-lock.json')), true);+ });+}++for (const targetRole of ['artifact', 'provenance']) {+ test(`delivery preserves the ${targetRole} claimant that replaces the just-published candidate`, (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-${targetRole}-post-link-claimant-`));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ assert.equal(run(['deliver', 'workflow', input, output, '--json'], cwd).status, 0);+ const before = new Map([[output, fs.readFileSync(output)], [provenance, fs.readFileSync(provenance)]]);+ const physicalDirectory = fs.realpathSync.native(cwd);+ const target = targetRole === 'artifact'+ ? path.join(physicalDirectory, path.basename(output))+ : path.join(physicalDirectory, path.basename(provenance));+ const other = targetRole === 'artifact' ? provenance : output;+ const candidateName = targetRole === 'artifact' ? path.basename(output) : 'delivery-provenance.json';+ const claimant = targetRole === 'artifact'+ ? '<!doctype html><title>post-link claimant</title>\n'+ : '{"claimant":"post-link"}\n';+ const claimantIdentityFile = path.join(cwd, `${targetRole}-post-link-identity.json`);+ const displacedCandidate = path.join(cwd, `${targetRole}-displaced-candidate`);+ const wrapper = path.join(cwd, `replace-published-${targetRole}.mjs`);+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const linkSync = fs.linkSync;+const lstatSync = fs.lstatSync;+let armedTarget;+let replaced = false;+fs.linkSync = (source, finalPath) => {+ const result = linkSync(source, finalPath);+ if (!replaced+ && path.basename(String(source)) === ${JSON.stringify(candidateName)}+ && path.basename(path.dirname(String(source))).startsWith('.archify-delivery-')) {+ armedTarget = String(finalPath);+ }+ return result;+};+fs.lstatSync = (file, options) => {+ if (!replaced && armedTarget && String(file) === armedTarget) {+ replaced = true;+ fs.renameSync(file, ${JSON.stringify(displacedCandidate)});+ fs.writeFileSync(file, ${JSON.stringify(claimant)}, { flag: 'wx' });+ const stat = lstatSync(file, { bigint: true });+ fs.writeFileSync(${JSON.stringify(claimantIdentityFile)}, JSON.stringify({ dev: String(stat.dev), ino: String(stat.ino) }));+ }+ return lstatSync(file, options);+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(receipt.diagnostics[0].code, 'output/target-changed');+ const recovery = receipt.diagnostics.find(+ (entry) => entry.code === 'delivery/commit-recovery-required',+ );+ assert.ok(recovery, failed.stderr || failed.stdout);+ assert.equal(fs.readFileSync(target, 'utf8'), claimant);+ const claimantIdentity = fs.lstatSync(target, { bigint: true });+ assert.deepEqual(+ { dev: String(claimantIdentity.dev), ino: String(claimantIdentity.ino) },+ JSON.parse(fs.readFileSync(claimantIdentityFile, 'utf8')),+ );+ assert.deepEqual(fs.readFileSync(other), before.get(other));+ assert.equal(fs.existsSync(displacedCandidate), true);+ const backup = recovery.evidence.recoverableBackups.find(({ label }) => label === (+ targetRole === 'artifact' ? 'HTML artifact' : 'delivery provenance'+ ));+ assert.ok(backup, 'the prior target must remain recoverable beside the preserved claimant');+ assert.deepEqual(+ fs.readFileSync(backup.path),+ before.get(targetRole === 'artifact' ? output : provenance),+ );+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.existsSync(path.join(cwd, '.archify-delivery-lock.json')), true);+ });+}++for (const initiallyExisting of [false, true]) {+ for (const targetRole of ['artifact', 'provenance']) {+ test(`delivery preserves an ${initiallyExisting ? 'existing replacement' : 'absent-slot claimant'} for the ${targetRole}`, (t) => {+ const cwd = fs.mkdtempSync(path.join(+ os.tmpdir(),+ `archify-${initiallyExisting ? 'replacement' : 'claimant'}-${targetRole}-`,+ ));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const output = path.join(cwd, 'diagram.html');+ const provenance = path.join(cwd, 'diagram.delivery.json');+ if (initiallyExisting) {+ const first = run(['deliver', 'workflow', input, output, '--json'], cwd);+ assert.equal(first.status, 0, first.stderr || first.stdout);+ }+ const before = new Map([+ [output, fs.existsSync(output) ? fs.readFileSync(output) : null],+ [provenance, fs.existsSync(provenance) ? fs.readFileSync(provenance) : null],+ ]);+ const physicalDirectory = fs.realpathSync.native(cwd);+ const target = targetRole === 'artifact'+ ? path.join(physicalDirectory, path.basename(output))+ : path.join(physicalDirectory, path.basename(provenance));+ const other = targetRole === 'artifact' ? provenance : output;+ const claimant = targetRole === 'artifact'+ ? '<!doctype html><title>claimant</title>\n'+ : '{"claimant":true}\n';+ const identityFile = path.join(cwd, `${targetRole}-claimant-identity.json`);+ const displaced = path.join(cwd, `${targetRole}-displaced`);+ const wrapper = path.join(cwd, `claim-${targetRole}.mjs`);+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+import path from 'node:path';+const writeFileSync = fs.writeFileSync;+let injected = false;+fs.writeFileSync = (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!injected+ && path.basename(String(file)) === 'delivery-provenance.json'+ && path.basename(path.dirname(String(file))).startsWith('.archify-delivery-')) {+ injected = true;+ if (fs.existsSync(${JSON.stringify(target)})) fs.renameSync(${JSON.stringify(target)}, ${JSON.stringify(displaced)});+ writeFileSync(${JSON.stringify(target)}, ${JSON.stringify(claimant)}, { flag: 'wx' });+ const stat = fs.lstatSync(${JSON.stringify(target)}, { bigint: true });+ writeFileSync(${JSON.stringify(identityFile)}, JSON.stringify({ dev: String(stat.dev), ino: String(stat.ino) }));+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(output)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(receipt.diagnostics[0].code, 'output/target-changed');+ assert.equal(fs.readFileSync(target, 'utf8'), claimant);+ const expectedIdentity = JSON.parse(fs.readFileSync(identityFile, 'utf8'));+ const actualIdentity = fs.lstatSync(target, { bigint: true });+ assert.deepEqual(+ { dev: String(actualIdentity.dev), ino: String(actualIdentity.ino) },+ expectedIdentity,+ );+ const otherBefore = before.get(other);+ if (otherBefore === null) assert.equal(fs.existsSync(other), false);+ else assert.deepEqual(fs.readFileSync(other), otherBefore);+ assert.equal(fs.existsSync(path.join(cwd, 'diagram.delivery-pending.json')), true);+ assert.equal(fs.readdirSync(cwd).some((name) => name.includes('delivery-lock')), false);+ });+ }+}++test('delivery rejects a nested directory alias retarget before taking its write-slot snapshot', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-nested-alias-retarget-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const route = path.join(cwd, 'route');+ const outer = path.join(cwd, 'outer');+ const first = path.join(cwd, 'first-target');+ const second = path.join(cwd, 'second-target');+ const inner = path.join(route, 'inner');+ for (const directory of [route, first, second]) fs.mkdirSync(directory);+ try {+ fs.symlinkSync(route, outer, process.platform === 'win32' ? 'junction' : 'dir');+ fs.symlinkSync(first, inner, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (process.platform === 'win32' && ['EPERM', 'EACCES', 'UNKNOWN'].includes(error?.code)) {+ t.skip('directory alias creation is unavailable on this Windows host');+ return;+ }+ throw error;+ }+ const requestedOutput = path.join(outer, 'inner', 'diagram.html');+ const firstOutput = path.join(first, 'diagram.html');+ const secondOutput = path.join(second, 'diagram.html');+ const firstPhysical = fs.realpathSync.native(first);+ const wrapper = path.join(cwd, 'retarget-nested-alias.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+const mkdirSync = fs.mkdirSync;+let retargeted = false;+fs.mkdirSync = (directory, options) => {+ const result = mkdirSync(directory, options);+ if (!retargeted && String(directory) === ${JSON.stringify(firstPhysical)}) {+ retargeted = true;+ fs.unlinkSync(${JSON.stringify(inner)});+ fs.symlinkSync(${JSON.stringify(second)}, ${JSON.stringify(inner)}, ${JSON.stringify(process.platform === 'win32' ? 'junction' : 'dir')});+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(requestedOutput)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ const failed = spawnSync(process.execPath, [wrapper], { cwd, encoding: 'utf8' });+ assert.equal(failed.status, 1, failed.stderr || failed.stdout);+ const receipt = JSON.parse(failed.stdout);+ assert.equal(receipt.diagnostics[0].code, 'output/target-changed');+ assert.equal(receipt.diagnostics[0].evidence.targetState.code, 'write-slot-changed-before-snapshot');+ for (const target of [firstOutput, secondOutput]) {+ assert.equal(fs.existsSync(target), false);+ assert.equal(fs.existsSync(target.replace(/\.html$/u, '.delivery.json')), false);+ }+ assert.equal(+ [...fs.readdirSync(first), ...fs.readdirSync(second)]+ .some((name) => name.includes('archify-delivery') || name.includes('delivery-lock')),+ false,+ );+});++test('Windows delivery accepts an existing 8.3 artifact alias and keeps strict provenance', (t) => {+ const requiresWindows8dot3 = process.env.ARCHIFY_REQUIRE_WINDOWS_8DOT3 === '1';+ if (process.platform !== 'win32') {+ if (requiresWindows8dot3) assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires Windows');+ t.skip('Windows-only 8.3 delivery regression');+ return;+ }+ const controlledRoot = controlledWindowsShortRoot(requiresWindows8dot3);+ const cwd = controlledRoot+ ? fs.mkdtempSync(path.join(controlledRoot.root, 'delivery-'))+ : fs.mkdtempSync(path.join(os.tmpdir(), 'archify-delivery-eight-dot-three-'));+ t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));+ const shortCwd = controlledRoot+ ? path.win32.join(controlledRoot.shortRoot, path.basename(cwd))+ : null;+ const directory = path.join(cwd, 'directory name requiring short alias');+ fs.mkdirSync(directory);+ const output = path.join(directory, 'diagram artifact with long name.html');+ assert.equal(run(['deliver', 'workflow', input, output, '--json'], cwd).status, 0);+ const shortOutput = shortCwd+ ? path.win32.join(shortCwd, path.basename(directory), path.basename(output))+ : windowsShortPath(output);+ if (!shortOutput) {+ t.skip('the Windows volume does not expose a distinct 8.3 artifact alias');+ return;+ }+ assert.equal(+ fs.realpathSync.native(shortOutput).toLowerCase(),+ fs.realpathSync.native(output).toLowerCase(),+ 'the artifact path must resolve through the controlled explicit 8.3 alias',+ );++ const redelivered = run(['deliver', 'workflow', input, shortOutput, '--json'], cwd);+ assert.equal(redelivered.status, 0, redelivered.stderr || redelivered.stdout);+ for (const artifact of [output, shortOutput]) {+ const checked = run(['check', artifact, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');+ }+});++test('normalization aliases contend for one future long-stem delivery lock', async (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-normalized-sidecar-alias-'));+ let active;+ t.after(() => {+ if (active && !fs.existsSync(release)) fs.writeFileSync(release, 'release');+ if (active?.exitCode === null && active.signalCode === null) active.kill();+ fs.rmSync(cwd, { recursive: true, force: true });+ });+ const probeNfc = path.join(cwd, '\u00e9-probe');+ const probeNfd = path.join(cwd, 'e\u0301-probe');+ fs.writeFileSync(probeNfc, 'probe');+ const aliasesNormalization = fs.existsSync(probeNfd);+ fs.unlinkSync(probeNfc);+ if (!aliasesNormalization) {+ t.skip('the test filesystem is normalization-sensitive');+ return;+ }++ const nfcStem = '\u00e9'.repeat(80);+ const nfdStem = nfcStem.normalize('NFD');+ const nfcOutput = path.join(cwd, `${nfcStem}.html`);+ const nfdOutput = path.join(cwd, `${nfdStem}.html`);+ const ready = path.join(cwd, 'active-delivery.ready');+ const release = path.join(cwd, 'active-delivery.release');+ const wrapper = path.join(cwd, 'hold-active-delivery.mjs');+ fs.writeFileSync(wrapper, `+import fs from 'node:fs';+const writeFileSync = fs.writeFileSync;+fs.writeFileSync = (file, value, options) => {+ const result = writeFileSync(file, value, options);+ if (String(file).endsWith('specification.snapshot.json')) {+ writeFileSync(${JSON.stringify(ready)}, 'ready');+ while (!fs.existsSync(${JSON.stringify(release)})) {+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 20);+ }+ }+ return result;+};+process.argv = [process.execPath, ${JSON.stringify(cli)}, 'deliver', 'workflow', ${JSON.stringify(input)}, ${JSON.stringify(nfdOutput)}, '--json'];+await import(${JSON.stringify(pathToFileURL(cli).href)});+`);++ active = spawn(process.execPath, [wrapper], {+ cwd,+ stdio: ['ignore', 'pipe', 'pipe'],+ });+ let activeStdout = '';+ let activeStderr = '';+ active.stdout.on('data', (chunk) => { activeStdout += chunk; });+ active.stderr.on('data', (chunk) => { activeStderr += chunk; });+ const activeExit = new Promise((resolve) => {+ active.once('close', (code, signal) => resolve({ code, signal }));+ });+ const deadline = Date.now() + 5000;+ while (!fs.existsSync(ready) && Date.now() < deadline) {+ await new Promise((resolve) => setTimeout(resolve, 20));+ }+ assert.equal(fs.existsSync(ready), true, `active delivery did not acquire its lock: ${activeStderr}`);++ const contender = run(['deliver', 'workflow', input, nfcOutput, '--json'], cwd);+ assert.equal(contender.status, 1, contender.stderr || contender.stdout);+ assert.equal(JSON.parse(contender.stdout).diagnostics[0].code, 'delivery/concurrent-attempt');++ fs.writeFileSync(release, 'release');+ assert.deepEqual(await activeExit, { code: 0, signal: null }, activeStderr || activeStdout);++ const checked = run(['check', nfcOutput, '--require-provenance'], cwd);+ assert.equal(checked.status, 0, checked.stderr || checked.stdout);+ assert.equal(JSON.parse(checked.stdout).provenance, 'current');++ const redelivered = run(['deliver', 'workflow', input, nfcOutput, '--json'], cwd);+ assert.equal(redelivered.status, 0, redelivered.stderr || redelivered.stdout);+ for (const alias of [nfcOutput, nfdOutput]) {+ const rechecked = run(['check', alias, '--require-provenance'], cwd);+ assert.equal(rechecked.status, 0, rechecked.stderr || rechecked.stdout);+ assert.equal(JSON.parse(rechecked.stdout).provenance, 'current');+ }+});diff --git a/archify/test/generate-validators.test.mjs b/archify/test/generate-validators.test.mjsindex 3d5df070..858c1a8f 100644--- a/archify/test/generate-validators.test.mjs+++ b/archify/test/generate-validators.test.mjs@@ -4,10 +4,17 @@ import { spawnSync } from 'node:child_process';import fs from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';-import { workflow as validateWorkflow } from '../renderers/shared/generated-validators.mjs';+import Ajv2020 from 'ajv/dist/2020.js';+import * as generatedValidators from '../renderers/shared/generated-validators.mjs';const __dirname = path.dirname(fileURLToPath(import.meta.url));const skillRoot = path.resolve(__dirname, '..');+const validateWorkflow = generatedValidators.workflow;+const commonSchema = JSON.parse(+ fs.readFileSync(path.join(skillRoot, 'schemas', 'common.schema.json'), 'utf8'),+);+const validatePortableOutputSchema = new Ajv2020({ strict: true })+ .compile(commonSchema.$defs.portableOutputPath);function workflowDocument(schemaVersion) {return {@@ -21,12 +28,91 @@ function workflowDocument(schemaVersion) {}test('generated workflow validator accepts schema versions 1 and 2 only', () => {+ assert.equal(validateWorkflow.length, 1, 'the generated wrapper preserves the AJV call arity');assert.equal(validateWorkflow(workflowDocument(1)), true, JSON.stringify(validateWorkflow.errors));assert.equal(validateWorkflow(workflowDocument(2)), true, JSON.stringify(validateWorkflow.errors));assert.equal(validateWorkflow(workflowDocument(3)), false);assert.deepEqual(validateWorkflow.errors?.[0]?.params.allowedValues, [1, 2]);});+test('portable output diagnostics preserve a caller-provided instance path', () => {+ const document = workflowDocument(1);+ document.meta.output = `${'é'.repeat(128)}.html`;+ assert.equal(validateWorkflow(document, { instancePath: '/payload' }), false);+ assert.equal(validateWorkflow.errors?.[0]?.instancePath, '/payload/meta/output');+});++test('portable output schema rejects empty basenames, unpaired surrogates, and 8.3 aliases', () => {+ for (const output of [+ '.html',+ 'reports/.html',+ '\ud800.html',+ 'reports/\udfff.html',+ 'PROGRA~1/diagram.html',+ 'reports/DIAGRA~12.HTML',+ ]) {+ assert.equal(+ validatePortableOutputSchema(output),+ false,+ `schema accepted ${JSON.stringify(output)}`,+ );+ }+ assert.equal(validatePortableOutputSchema('reports/😀.html'), true);+});++test('generated validators share one portable authored output contract', () => {+ const examples = {+ architecture: 'web-app.architecture.json',+ workflow: 'agent-tool-call.workflow.json',+ sequence: 'cache-miss-request.sequence.json',+ dataflow: 'product-analytics.dataflow.json',+ lifecycle: 'agent-run.lifecycle.json',+ };+ const invalidOutputs = [+ '',+ '/absolute/diagram.html',+ 'reports\\diagram.html',+ 'C:diagram.html',+ 'file:///tmp/diagram.html',+ 'reports//diagram.html',+ 'reports/./diagram.html',+ 'reports/../diagram.html',+ 'reports./diagram.html',+ 'reports/NUL.html',+ 'reports/CONIN$.html',+ 'reports/COM¹.snapshot.html',+ 'PROGRA~1/diagram.html',+ 'reports/DIAGRA~12.HTML',+ 'reports/diagram?.html',+ 'reports/diagram.txt',+ '.html',+ 'reports/.html',+ '\ud800.html',+ 'reports/\udfff.html',+ `${'a'.repeat(251)}.html`,+ `${'é'.repeat(128)}.html`,+ ];++ for (const [type, example] of Object.entries(examples)) {+ const document = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples', example), 'utf8'));+ document.meta.output = 'reports/diagram.HTML';+ assert.equal(+ generatedValidators[type](document),+ true,+ `${type} rejected a portable HTML output: ${JSON.stringify(generatedValidators[type].errors)}`,+ );++ for (const output of invalidOutputs) {+ document.meta.output = output;+ assert.equal(+ generatedValidators[type](document),+ false,+ `${type} accepted non-portable meta.output ${JSON.stringify(output)}`,+ );+ }+ }+});+test('validator freshness check accepts CRLF checkouts', () => {const scratch = fs.mkdtempSync(path.join(skillRoot, '.validator-check-'));try {diff --git a/archify/test/meta-output-contract.test.mjs b/archify/test/meta-output-contract.test.mjsnew file mode 100644index 00000000..2c0364da--- /dev/null+++ b/archify/test/meta-output-contract.test.mjs@@ -0,0 +1,146 @@+import { spawnSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import test from 'node:test';+import assert from 'node:assert/strict';+import { fileURLToPath } from 'node:url';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const skillRoot = path.resolve(__dirname, '..');+const cli = path.join(skillRoot, 'bin', 'archify.mjs');+const architectureExample = path.join(skillRoot, 'examples', 'web-app.architecture.json');+const workflowFixture = path.join(+ __dirname,+ 'fixtures',+ 'v1-workflow-explicit-coordinates.workflow.json',+);++function workspace(t) {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-meta-output-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ return directory;+}++function writeDocument(directory, name, source, output) {+ const document = JSON.parse(fs.readFileSync(source, 'utf8'));+ document.meta.output = output;+ const target = path.join(directory, name);+ fs.writeFileSync(target, `${JSON.stringify(document, null, 2)}\n`);+ return target;+}++function run(args, cwd) {+ return spawnSync(process.execPath, [cli, ...args], { cwd, encoding: 'utf8' });+}++function jsonOutput(result) {+ assert.doesNotThrow(+ () => JSON.parse(result.stdout),+ `expected JSON stdout, received:\n${result.stdout}\nstderr:\n${result.stderr}`,+ );+ return JSON.parse(result.stdout);+}++test('validate checks authored output even though its verification artifact uses a staging path', t => {+ const directory = workspace(t);+ const invalidOutputs = [+ { output: '', code: 'output/meta-path-syntax' },+ { output: '/absolute/diagram.html', code: 'output/meta-absolute' },+ { output: 'reports\\diagram.html', code: 'output/meta-path-syntax' },+ { output: 'C:diagram.html', code: 'output/meta-path-syntax' },+ { output: 'file:///tmp/diagram.html', code: 'output/meta-path-syntax' },+ ];++ for (const [index, { output, code }] of invalidOutputs.entries()) {+ const input = writeDocument(directory, `invalid-${index}.architecture.json`, architectureExample, output);+ const result = run(['validate', 'architecture', input, '--json'], directory);+ assert.equal(result.status, 1, result.stderr || result.stdout);+ const failure = jsonOutput(result);+ assert.equal(failure.ok, false);+ assert.equal(failure.command, 'validate');+ assert.equal(failure.diagnostics.length, 1, result.stdout);+ assert.equal(failure.diagnostics[0].code, code);+ assert.equal(failure.diagnostics[0].subject.path, '/meta/output');+ }++ const valid = writeDocument(+ directory,+ 'valid.architecture.json',+ architectureExample,+ 'reports/diagram.html',+ );+ const result = run(['validate', 'architecture', valid, '--json'], directory);+ assert.equal(result.status, 0, result.stderr || result.stdout);+ assert.equal(jsonOutput(result).ok, true);+ assert.equal(fs.existsSync(path.join(directory, 'reports')), false);+});++test('an explicit CLI output does not hide an invalid durable authored output', t => {+ const directory = workspace(t);+ const input = writeDocument(+ directory,+ 'invalid-override.architecture.json',+ architectureExample,+ 'reports\\diagram.html',+ );+ const override = path.join(directory, 'override.html');++ const result = run(['render', 'architecture', input, override], directory);++ assert.equal(result.status, 1, result.stderr || result.stdout);+ assert.match(result.stderr, /output\/meta-path-syntax/);+ assert.equal(fs.existsSync(override), false);+});++test('migration rejects a non-portable authored output without mutating its destination', t => {+ const directory = workspace(t);+ const source = writeDocument(+ directory,+ 'invalid.workflow.json',+ workflowFixture,+ 'reports\\diagram.html',+ );+ const sourceBytes = fs.readFileSync(source);+ const destination = path.join(directory, 'destination.workflow.json');+ const sentinel = Buffer.from('destination sentinel\n');+ fs.writeFileSync(destination, sentinel);++ const result = run([+ 'migrate', 'workflow', source, destination, '--to-schema', '2', '--json',+ ], directory);++ assert.equal(result.status, 1, result.stderr || result.stdout);+ assert.deepEqual(fs.readFileSync(source), sourceBytes);+ assert.deepEqual(fs.readFileSync(destination), sentinel);+ const failure = jsonOutput(result);+ assert.equal(failure.ok, false);+ assert.equal(failure.command, 'migrate');+ assert.equal(failure.diagnostics.length, 1, result.stdout);+ assert.equal(failure.diagnostics[0].code, 'output/meta-path-syntax');+ assert.equal(failure.diagnostics[0].subject.path, '/meta/output');+});++test('migration preserves a portable authored output and remains byte-idempotent', t => {+ const directory = workspace(t);+ const source = writeDocument(+ directory,+ 'valid.workflow.json',+ workflowFixture,+ 'reports/diagram.html',+ );+ const firstDestination = path.join(directory, 'first.workflow.json');+ const secondDestination = path.join(directory, 'second.workflow.json');++ const first = run([+ 'migrate', 'workflow', source, firstDestination, '--to-schema', '2', '--json',+ ], directory);+ assert.equal(first.status, 0, first.stderr || first.stdout);+ assert.equal(JSON.parse(fs.readFileSync(firstDestination, 'utf8')).meta.output, 'reports/diagram.html');++ const second = run([+ 'migrate', 'workflow', firstDestination, secondDestination, '--to-schema', '2', '--json',+ ], directory);+ assert.equal(second.status, 0, second.stderr || second.stdout);+ assert.deepEqual(fs.readFileSync(secondDestination), fs.readFileSync(firstDestination));+});diff --git a/archify/test/native-output-path.test.mjs b/archify/test/native-output-path.test.mjsnew file mode 100644index 00000000..0252b166--- /dev/null+++ b/archify/test/native-output-path.test.mjs@@ -0,0 +1,205 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import path from 'node:path';++import {+ resolveNativeOutputDirectory,+ resolveOutputPath,+ validateNativeOutputPath,+} from '../renderers/shared/output-path.mjs';++function nativeFailure(value, options) {+ assert.throws(+ () => validateNativeOutputPath(value, options),+ (error) => error?.archifyDiagnostics?.[0]?.code === 'output/native-path-syntax',+ );+}++test('Windows CLI outputs retain native absolute, UNC, extended, and relative forms', () => {+ for (const value of [+ String.raw`C:\reports\diagram.html`,+ String.raw`\\server\share\reports\diagram.html`,+ '//server/share/reports/diagram.html',+ String.raw`\\?\C:\reports\diagram.html`,+ String.raw`\\?\UNC\server\share\reports\diagram.html`,+ String.raw`reports\diagram.html`,+ String.raw`..\diagram.html`,+ String.raw`.\reports\..\diagram.html`,+ String.raw`C:\reports\..\diagram.html`,+ String.raw`\\server\share\reports\..\diagram.html`,+ String.raw`C:\ARCHIF~1\diagram.html`,+ `C:\\reports\\${'界'.repeat(100)}.html`,+ `\\\\?\\C:\\reports\\${'界'.repeat(100)}.html`,+ ]) {+ assert.equal(validateNativeOutputPath(value, { platform: 'win32' }), value);+ }+});++test('Windows CLI outputs reject ambiguous or special namespace forms', () => {+ for (const value of [+ String.raw`C:`,+ String.raw`C:diagram.html`,+ String.raw`C:\reports\diagram.html:payload`,+ String.raw`\\.\NUL`,+ '//./NUL/diagram.html',+ String.raw`\\?\GLOBALROOT\Device\HarddiskVolume1\diagram.html`,+ '//?/GLOBALROOT/Device/HarddiskVolume1/diagram.html',+ String.raw`\\?/GLOBALROOT\Device\HarddiskVolume1\diagram.html`,+ String.raw`\\?\\C:diagram.html`,+ String.raw`\\?\foo.html`,+ String.raw`\\ser?ver\share\file.html`,+ String.raw`\reports\diagram.html`,+ String.raw`C:\reports\CON.html`,+ String.raw`C:\reports\diagram .html `,+ String.raw`C:\reports\bad?.html`,+ ]) nativeFailure(value, { platform: 'win32' });+});++test('Windows native output directories validate raw spelling before resolution', () => {+ const cwd = String.raw`C:\workspace\project`;+ const invalid = [+ [String.raw`C:evidence`, 'drive-relative'],+ [String.raw`\evidence`, 'current-drive-rooted'],+ [String.raw`\\.\NUL`, 'windows-device-namespace'],+ [String.raw`C:\reports\evidence:stream`, 'windows-ads'],+ [String.raw`C:\reports\CON`, 'windows-reserved-name'],+ [String.raw`C:\reports\evidence.`, 'windows-trailing-dot-space'],+ [String.raw`C:\reports\evidence `, 'windows-trailing-dot-space'],+ ];+ for (const [value, reason] of invalid) {+ assert.throws(+ () => resolveNativeOutputDirectory(value, { platform: 'win32', cwd }),+ (error) => {+ const diagnostic = error?.archifyDiagnostics?.[0];+ return diagnostic?.code === 'output/native-path-syntax'+ && diagnostic?.subject?.output === value+ && diagnostic?.evidence?.reason === reason;+ },+ value,+ );+ }++ assert.equal(+ resolveNativeOutputDirectory('evidence', { platform: 'win32', cwd }),+ String.raw`C:\workspace\project\evidence`,+ );+ assert.equal(+ resolveNativeOutputDirectory(String.raw`D:\evidence`, { platform: 'win32', cwd }),+ String.raw`D:\evidence`,+ );+});++test('native file outputs reject a trailing separator before normalization', (t) => {+ const normalize = path.win32.normalize.bind(path.win32);+ let normalizeCalls = 0;+ t.mock.method(path.win32, 'normalize', (...args) => {+ normalizeCalls += 1;+ return normalize(...args);+ });++ for (const value of [+ 'C:\\reports\\diagram.html\\',+ '\\\\server\\share\\diagram.html\\',+ '\\\\?\\C:\\reports\\diagram.html\\',+ '\\\\?\\UNC\\server\\share\\diagram.html\\',+ ]) {+ assert.throws(+ () => validateNativeOutputPath(value, { platform: 'win32' }),+ (error) => error?.archifyDiagnostics?.[0]?.evidence?.reason === 'trailing-separator',+ value,+ );+ }+ assert.equal(normalizeCalls, 0);+ nativeFailure('/tmp/archive.zip/', { platform: 'linux' });+});++test('native output directories retain one trailing separator', () => {+ const cwd = String.raw`C:\workspace\project`;+ for (const [value, expected] of [+ ['C:\\reports\\', String.raw`C:\reports`],+ ['\\\\server\\share\\reports\\', String.raw`\\server\share\reports`],+ ['\\\\?\\C:\\reports\\', String.raw`\\?\C:\reports`],+ ['\\\\?\\UNC\\server\\share\\reports\\', String.raw`\\?\UNC\server\share\reports`],+ ]) {+ assert.equal(+ validateNativeOutputPath(value, { platform: 'win32', kind: 'directory' }),+ value,+ );+ assert.equal(resolveNativeOutputDirectory(value, { platform: 'win32', cwd }), expected);+ }+ assert.equal(+ validateNativeOutputPath('/tmp/evidence/', { platform: 'linux', kind: 'directory' }),+ '/tmp/evidence/',+ );+});++test('Windows CLI outputs reject malformed raw UNC roots before normalization', () => {+ for (const value of [+ String.raw`\\server\\share\report.html`,+ '//server//share/report.html',+ String.raw`\\server\/share\report.html`,+ String.raw`\\server/share\report.html`,+ String.raw`//server\share/report.html`,+ ]) {+ assert.throws(+ () => validateNativeOutputPath(value, { platform: 'win32' }),+ (error) => error?.archifyDiagnostics?.[0]?.evidence?.reason === 'windows-unc-root',+ );+ }+});++test('Windows extended paths preserve raw namespace semantics', () => {+ for (const value of [+ String.raw`\\?\C:\reports\..\diagram.html`,+ String.raw`\\?\C:\reports\.\diagram.html`,+ String.raw`\\?\C:\reports\\diagram.html`,+ String.raw`\\?\UNC\server\share\..\other\diagram.html`,+ String.raw`\\?\UNC\server\share\.\diagram.html`,+ String.raw`\\?\UNC\server\share\reports\\diagram.html`,+ String.raw`\\?\C:/reports/diagram.html`,+ String.raw`\\?\UNC/server/share/diagram.html`,+ '//?/C:/reports/diagram.html',+ String.raw`\\?\C:diagram.html`,+ String.raw`\\?\UNC\server`,+ String.raw`\\?\UNC\\share\diagram.html`,+ String.raw`\\?\Device\HarddiskVolume1\diagram.html`,+ String.raw`\\?\Volume{01234567-89AB-CDEF-0123-456789ABCDEF}\reports\diagram.html`,+ ]) nativeFailure(value, { platform: 'win32' });+});++test('native outputs reject unpaired UTF-16 surrogates without rejecting valid pairs', () => {+ for (const platform of ['darwin', 'linux', 'win32']) {+ for (const surrogate of ['\ud800', '\udfff']) {+ assert.throws(+ () => validateNativeOutputPath(`reports/${surrogate}.html`, { platform }),+ (error) => error?.archifyDiagnostics?.[0]?.evidence?.reason === 'unpaired-surrogate',+ );+ }+ const emojiOutput = 'reports/\ud83d\ude00.html';+ assert.equal(validateNativeOutputPath(emojiOutput, { platform }), emojiOutput);+ }+});++test('native output validation rejects components that cannot host derived files', () => {+ nativeFailure(`/tmp/${'é'.repeat(128)}.html`, { platform: 'linux' });+ nativeFailure(`C:\\reports\\${'x'.repeat(256)}.html`, { platform: 'win32' });+ nativeFailure(`C:\\reports\\${'x'.repeat(256)}~1.html`, { platform: 'win32' });+});++test('resolveOutputPath applies Windows native validation to explicit outputs before resolution', () => {+ assert.throws(+ () => resolveOutputPath({+ requestedOutput: String.raw`C:\reports\NUL.html`,+ defaultOutput: 'diagram.html',+ platform: 'win32',+ }),+ (error) => error?.archifyDiagnostics?.[0]?.evidence?.reason === 'windows-reserved-name',+ );+});++test('POSIX CLI outputs are not forced through Windows spelling rules', () => {+ for (const value of ['reports/CON.html', 'reports/name:stream.html', 'reports/name .html']) {+ assert.equal(validateNativeOutputPath(value, { platform: 'linux' }), value);+ }+ nativeFailure('reports/diagram\0.html', { platform: 'linux' });+});diff --git a/archify/test/output-path.test.mjs b/archify/test/output-path.test.mjsindex 28eea13a..6702ce7e 100644--- a/archify/test/output-path.test.mjs+++ b/archify/test/output-path.test.mjs@@ -170,7 +170,7 @@ test('render rejects an absolute meta.output when no CLI output is provided', ()assert.equal(fs.existsSync(output), false);});-test('render rejects a relative meta.output that escapes the working directory', () => {+test('render rejects a parent segment in portable meta.output before filesystem containment', () => {const parent = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-meta-parent-'));const cwd = path.join(parent, 'work');fs.mkdirSync(cwd);@@ -183,7 +183,8 @@ test('render rejects a relative meta.output that escapes the working directory',const result = run(['render', 'workflow', input], cwd);assert.equal(result.status, 1);- assert.match(result.stderr, /meta\.output must stay inside the current working directory/i);+ assert.match(result.stderr, /output\/meta-path-syntax/);+ assert.match(result.stderr, /portable POSIX-relative path/i);assert.equal(fs.existsSync(output), false);});@@ -276,6 +277,18 @@ test('deliver rechecks aliases immediately before committing a verified candidatpath.join(skillRoot, 'renderers/shared/output-path.mjs'),path.join(installedShared, 'output-path.mjs'),);+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/path-semantics.mjs'),+ path.join(installedShared, 'path-semantics.mjs'),+ );+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/portable-path.mjs'),+ path.join(installedShared, 'portable-path.mjs'),+ );+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/atomic-output.mjs'),+ path.join(installedShared, 'atomic-output.mjs'),+ );fs.writeFileSync(path.join(installedRenderer, 'render-workflow.mjs'), `import fs from 'node:fs';const [, output] = process.argv.slice(2);@@ -403,6 +416,481 @@ test('compare rejects a dangling receipt symlink to the future artifact path', (assert.equal(fs.existsSync(output), false);});+test('compare preserves dangling output symlinks and commits to their physical targets', () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-compare-links-'));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const outputTarget = path.join(cwd, 'rendered.html');+ const receiptTarget = path.join(cwd, 'rendered.receipt.json');+ fs.symlinkSync(path.basename(outputTarget), output, 'file');+ fs.symlinkSync(path.basename(receiptTarget), receiptPath, 'file');++ const result = run([+ 'compare', 'architecture', baseFixture, headFixture, output,+ '--receipt', receiptPath, '--json',+ ], cwd);++ assert.equal(result.status, 0, result.stdout + result.stderr);+ const receipt = JSON.parse(result.stdout);+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.lstatSync(receiptPath).isSymbolicLink(), true);+ assert.equal(fs.readlinkSync(output), path.basename(outputTarget));+ assert.equal(fs.readlinkSync(receiptPath), path.basename(receiptTarget));+ assert.match(fs.readFileSync(outputTarget, 'utf8'), /<!doctype html>/i);+ assert.deepEqual(JSON.parse(fs.readFileSync(receiptTarget, 'utf8')), receipt);+});++for (const slot of ['artifact', 'receipt']) {+ for (const initialState of ['absent', 'existing']) {+ test(`compare does not overwrite an ${initialState} ${slot} slot changed after staging`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-${slot}-${initialState}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const changedPath = slot === 'artifact' ? output : receiptPath;+ const stablePath = slot === 'artifact' ? receiptPath : output;+ const changedBytes = slot === 'artifact'+ ? '<!doctype html><title>concurrent artifact owner</title>\n'+ : '{"owner":"concurrent receipt owner"}\n';+ const stableBytes = slot === 'artifact'+ ? '{"owner":"trusted receipt owner"}\n'+ : '<!doctype html><title>trusted artifact owner</title>\n';+ const detachedPath = path.join(cwd, `detached-${path.basename(changedPath)}`);+ fs.writeFileSync(stablePath, stableBytes);+ if (initialState === 'existing') fs.writeFileSync(changedPath, 'original target bytes\n');++ const preload = path.join(cwd, 'change-compare-slot.cjs');+ const replaceExisting = initialState === 'existing'+ ? `fs.renameSync(changedPath, ${JSON.stringify(detachedPath)});`+ : '';+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalWrite = fs.writeFileSync;+ const changedPath = ${JSON.stringify(changedPath)};+ let changed = false;+ fs.writeFileSync = function(file, ...args) {+ const result = originalWrite.call(this, file, ...args);+ if (!changed+ && path.basename(String(file)) === ${JSON.stringify(path.basename(receiptPath))}+ && path.basename(path.dirname(String(file))).startsWith('.archify-compare-')) {+ changed = true;+ ${replaceExisting}+ originalWrite.call(fs, changedPath, ${JSON.stringify(changedBytes)});+ }+ return result;+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'output/target-changed');+ assert.equal(fs.readFileSync(changedPath, 'utf8'), changedBytes);+ assert.equal(fs.readFileSync(stablePath, 'utf8'), stableBytes);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+ });+ }+}++for (const slot of ['artifact', 'receipt']) {+ test(`compare preserves a concurrent ${slot} replacement made after final verification`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-backup-race-${slot}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const changedPath = slot === 'artifact' ? output : receiptPath;+ const physicalChangedPath = path.join(fs.realpathSync.native(cwd), path.basename(changedPath));+ const stablePath = slot === 'artifact' ? receiptPath : output;+ const changedBytes = slot === 'artifact'+ ? '<!doctype html><title>replacement artifact owner</title>\n'+ : '{"owner":"replacement receipt owner"}\n';+ const stableBytes = slot === 'artifact'+ ? '{"owner":"trusted receipt owner"}\n'+ : '<!doctype html><title>trusted artifact owner</title>\n';+ const detachedPath = path.join(cwd, `detached-${path.basename(changedPath)}`);+ fs.writeFileSync(changedPath, 'original target bytes\n');+ fs.writeFileSync(stablePath, stableBytes);++ const preload = path.join(cwd, 'replace-before-backup.cjs');+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalRename = fs.renameSync.bind(fs);+ const originalWrite = fs.writeFileSync.bind(fs);+ const changedPath = ${JSON.stringify(physicalChangedPath)};+ let changed = false;+ fs.renameSync = function(source, target, ...args) {+ if (!changed+ && String(source) === changedPath+ && path.basename(path.dirname(String(target))).startsWith('.archify-remove-')) {+ changed = true;+ originalRename(changedPath, ${JSON.stringify(detachedPath)});+ originalWrite(changedPath, ${JSON.stringify(changedBytes)});+ }+ return originalRename(source, target, ...args);+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'delta/commit-rollback-failed');+ const recovery = failure.diagnostics[0].evidence;+ const retained = recovery.recoveryFiles.find(({ target }) => target === physicalChangedPath);+ assert.ok(retained, JSON.stringify(recovery.recoveryFiles));+ assert.equal(fs.readFileSync(retained.backup, 'utf8'), 'original target bytes\n');+ assert.equal(fs.readFileSync(changedPath, 'utf8'), changedBytes);+ assert.equal(fs.readFileSync(stablePath, 'utf8'), stableBytes);+ assert.equal(path.dirname(retained.backup), recovery.recoveryDirectory);+ });+}++for (const slot of ['artifact', 'receipt']) {+ test(`compare preserves an absent ${slot} slot claimant made during publish`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-publish-race-${slot}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const changedPath = slot === 'artifact' ? output : receiptPath;+ const physicalChangedPath = path.join(fs.realpathSync.native(cwd), path.basename(changedPath));+ const stablePath = slot === 'artifact' ? receiptPath : output;+ const changedBytes = slot === 'artifact'+ ? '<!doctype html><title>claimant artifact owner</title>\n'+ : '{"owner":"claimant receipt owner"}\n';+ const stableBytes = slot === 'artifact'+ ? '{"owner":"trusted receipt owner"}\n'+ : '<!doctype html><title>trusted artifact owner</title>\n';+ fs.writeFileSync(stablePath, stableBytes);++ const preload = path.join(cwd, 'claim-before-publish.cjs');+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalLink = fs.linkSync.bind(fs);+ const originalWrite = fs.writeFileSync.bind(fs);+ const changedPath = ${JSON.stringify(physicalChangedPath)};+ let changed = false;+ fs.linkSync = function(source, target, ...args) {+ if (!changed+ && String(target) === changedPath+ && path.basename(path.dirname(String(source))).startsWith('.archify-compare-')) {+ changed = true;+ originalWrite(changedPath, ${JSON.stringify(changedBytes)});+ }+ return originalLink(source, target, ...args);+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'output/target-changed');+ assert.equal(+ failure.diagnostics[0].evidence.atomicOutput.code,+ 'target-claimed-during-publish',+ );+ assert.equal(fs.readFileSync(changedPath, 'utf8'), changedBytes);+ assert.equal(fs.readFileSync(stablePath, 'utf8'), stableBytes);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+ });+}++for (const slot of ['artifact', 'receipt']) {+ test(`compare rejects a same-inode ${slot} candidate byte mutation before publish and restores the old pair`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-candidate-bytes-${slot}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const physicalOutput = path.join(fs.realpathSync.native(cwd), path.basename(output));+ const outputBytes = '<!doctype html><title>trusted artifact owner</title>\n';+ const receiptBytes = '{"owner":"trusted receipt owner"}\n';+ const candidateName = slot === 'artifact' ? path.basename(output) : path.basename(receiptPath);+ fs.writeFileSync(output, outputBytes);+ fs.writeFileSync(receiptPath, receiptBytes);++ const preload = path.join(cwd, 'mutate-compare-candidate-bytes.cjs');+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalLink = fs.linkSync.bind(fs);+ const originalAppend = fs.appendFileSync.bind(fs);+ const physicalOutput = ${JSON.stringify(physicalOutput)};+ const candidateName = ${JSON.stringify(candidateName)};+ let mutated = false;+ fs.linkSync = function(source, target, ...args) {+ const result = originalLink(source, target, ...args);+ if (!mutated+ && String(source) === physicalOutput+ && path.basename(String(target)) === '.previous-output'+ && path.basename(path.dirname(String(target))).startsWith('.archify-compare-')) {+ mutated = true;+ originalAppend(path.join(path.dirname(String(target)), candidateName), '\\nexternally mutated candidate bytes\\n');+ }+ return result;+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'output/target-changed');+ assert.equal(+ failure.diagnostics[0].evidence.atomicOutput.code,+ 'compare-candidate-content-changed',+ );+ assert.equal(fs.readFileSync(output, 'utf8'), outputBytes);+ assert.equal(fs.readFileSync(receiptPath, 'utf8'), receiptBytes);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+ });+}++test('compare preserves a same-inode edit to the first published member when the second publish fails', () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-compare-published-edit-'));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const physicalDirectory = fs.realpathSync.native(cwd);+ const physicalOutput = path.join(physicalDirectory, path.basename(output));+ const physicalReceipt = path.join(physicalDirectory, path.basename(receiptPath));+ const outputBytes = '<!doctype html><title>trusted artifact owner</title>\n';+ const receiptBytes = '{"owner":"trusted receipt owner"}\n';+ const claimantSuffix = '\nexternally edited published artifact\n';+ fs.writeFileSync(output, outputBytes);+ fs.writeFileSync(receiptPath, receiptBytes);++ const preload = path.join(cwd, 'edit-first-published-member.cjs');+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalLink = fs.linkSync.bind(fs);+ const originalAppend = fs.appendFileSync.bind(fs);+ const physicalOutput = ${JSON.stringify(physicalOutput)};+ const physicalReceipt = ${JSON.stringify(physicalReceipt)};+ let artifactPublished = false;+ fs.linkSync = function(source, target, ...args) {+ const inCompareStaging = path.basename(path.dirname(String(source))).startsWith('.archify-compare-');+ if (inCompareStaging && String(target) === physicalOutput) {+ const result = originalLink(source, target, ...args);+ artifactPublished = true;+ return result;+ }+ if (artifactPublished+ && inCompareStaging+ && path.basename(String(source)) === ${JSON.stringify(path.basename(receiptPath))}+ && String(target) === physicalReceipt) {+ originalAppend(physicalOutput, ${JSON.stringify(claimantSuffix)});+ const error = new Error('injected second member publish failure');+ error.code = 'EACCES';+ throw error;+ }+ return originalLink(source, target, ...args);+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ const recovery = failure.diagnostics[0].evidence;+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'delta/commit-rollback-failed');+ assert.match(recovery.reason, /injected second member publish failure/);+ assert.ok(recovery.rollbackErrors.some((entry) => /HTML artifact/u.test(entry)));+ assert.equal(typeof recovery.recoveryDirectory, 'string');+ const artifactRecovery = recovery.recoveryFiles.find(({ target }) => target === physicalOutput);+ assert.ok(artifactRecovery, JSON.stringify(recovery.recoveryFiles));+ assert.equal(artifactRecovery.backup, path.join(recovery.recoveryDirectory, '.previous-output'));+ assert.equal(fs.readFileSync(artifactRecovery.backup, 'utf8'), outputBytes);+ assert.equal(fs.readFileSync(output, 'utf8').endsWith(claimantSuffix), true);+ assert.equal(fs.readFileSync(receiptPath, 'utf8'), receiptBytes);+ assert.equal(fs.existsSync(path.join(recovery.recoveryDirectory, '.previous-receipt')), false);+});++for (const slot of ['artifact', 'receipt']) {+ test(`compare rejects a same-inode ${slot} candidate mode mutation before publish`, { skip: process.platform === 'win32' }, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-candidate-mode-${slot}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const physicalOutput = path.join(fs.realpathSync.native(cwd), path.basename(output));+ const outputBytes = '<!doctype html><title>trusted artifact owner</title>\n';+ const receiptBytes = '{"owner":"trusted receipt owner"}\n';+ const candidateName = slot === 'artifact' ? path.basename(output) : path.basename(receiptPath);+ fs.writeFileSync(output, outputBytes);+ fs.writeFileSync(receiptPath, receiptBytes);+ fs.chmodSync(output, 0o640);+ fs.chmodSync(receiptPath, 0o640);++ const preload = path.join(cwd, 'mutate-compare-candidate-mode.cjs');+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalLink = fs.linkSync.bind(fs);+ const originalChmod = fs.chmodSync.bind(fs);+ const physicalOutput = ${JSON.stringify(physicalOutput)};+ const candidateName = ${JSON.stringify(candidateName)};+ let mutated = false;+ fs.linkSync = function(source, target, ...args) {+ const result = originalLink(source, target, ...args);+ if (!mutated+ && String(source) === physicalOutput+ && path.basename(String(target)) === '.previous-output'+ && path.basename(path.dirname(String(target))).startsWith('.archify-compare-')) {+ mutated = true;+ originalChmod(path.join(path.dirname(String(target)), candidateName), 0o600);+ }+ return result;+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'output/target-changed');+ assert.equal(+ failure.diagnostics[0].evidence.atomicOutput.code,+ 'compare-candidate-mode-changed',+ );+ assert.equal(fs.readFileSync(output, 'utf8'), outputBytes);+ assert.equal(fs.readFileSync(receiptPath, 'utf8'), receiptBytes);+ assert.equal(fs.statSync(output).mode & 0o777, 0o640);+ assert.equal(fs.statSync(receiptPath).mode & 0o777, 0o640);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+ });+}++for (const slot of ['artifact', 'receipt']) {+ test(`compare rolls back both targets when the staged ${slot} link cannot be released`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), `archify-output-compare-unlink-${slot}-`));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const outputBytes = '<!doctype html><title>trusted artifact owner</title>\n';+ const receiptBytes = '{"owner":"trusted receipt owner"}\n';+ fs.writeFileSync(output, outputBytes);+ fs.writeFileSync(receiptPath, receiptBytes);++ const preload = path.join(cwd, 'reject-candidate-unlink.cjs');+ const candidateName = slot === 'artifact' ? path.basename(output) : path.basename(receiptPath);+ fs.writeFileSync(preload, `+ const fs = require('node:fs');+ const path = require('node:path');+ const originalUnlink = fs.unlinkSync.bind(fs);+ let rejected = false;+ fs.unlinkSync = function(file, ...args) {+ if (!rejected+ && path.basename(String(file)) === ${JSON.stringify(candidateName)}+ && path.basename(path.dirname(String(file))).startsWith('.archify-compare-')) {+ rejected = true;+ const error = new Error('injected candidate unlink failure');+ error.code = 'EACCES';+ throw error;+ }+ return originalUnlink(file, ...args);+ };+ `);++ const result = spawnSync(process.execPath, [+ '--require', preload, cli, 'compare', 'architecture',+ baseFixture, headFixture, output, '--receipt', receiptPath, '--json',+ ], { cwd, encoding: 'utf8', timeout: 30000 });++ assert.ifError(result.error);+ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'commit');+ assert.equal(failure.diagnostics[0].code, 'delta/commit-failed');+ assert.match(failure.diagnostics[0].evidence.reason, /injected candidate unlink failure/);+ assert.equal(fs.readFileSync(output, 'utf8'), outputBytes);+ assert.equal(fs.readFileSync(receiptPath, 'utf8'), receiptBytes);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+ });+}++test('compare preserves the modes of both existing pair targets', { skip: process.platform === 'win32' }, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-compare-modes-'));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ fs.writeFileSync(output, 'trusted artifact bytes\n');+ fs.writeFileSync(receiptPath, 'trusted receipt bytes\n');+ fs.chmodSync(output, 0o640);+ fs.chmodSync(receiptPath, 0o600);++ const result = run([+ 'compare', 'architecture', baseFixture, headFixture, output,+ '--receipt', receiptPath, '--json',+ ], cwd);++ assert.equal(result.status, 0, result.stdout + result.stderr);+ assert.equal(fs.statSync(output).mode & 0o777, 0o640);+ assert.equal(fs.statSync(receiptPath).mode & 0o777, 0o600);+ assert.equal(fs.statSync(output).nlink, 1);+ assert.equal(fs.statSync(receiptPath).nlink, 1);+});++test('compare rejects a hard-linked pair target before staging either output', (t) => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-compare-hardlink-'));+ const output = path.join(cwd, 'delta.html');+ const receiptPath = path.join(cwd, 'delta.receipt.json');+ const receiptAlias = path.join(cwd, 'receipt-owner.json');+ const outputBytes = '<!doctype html><title>trusted artifact owner</title>\n';+ const receiptBytes = '{"owner":"trusted receipt owner"}\n';+ fs.writeFileSync(output, outputBytes);+ fs.writeFileSync(receiptPath, receiptBytes);+ try {+ fs.linkSync(receiptPath, receiptAlias);+ } catch (error) {+ if (error?.code === 'EPERM' || error?.code === 'EACCES' || error?.code === 'ENOTSUP') {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }++ const result = run([+ 'compare', 'architecture', baseFixture, headFixture, output,+ '--receipt', receiptPath, '--json',+ ], cwd);++ assert.equal(result.status, 1, result.stdout + result.stderr);+ const failure = JSON.parse(result.stdout);+ assert.equal(failure.stage, 'prepare');+ assert.equal(failure.diagnostics[0].code, 'output/target-hardlinked');+ assert.equal(failure.diagnostics[0].evidence.atomicOutput.code, 'target-hardlinked');+ assert.equal(fs.readFileSync(output, 'utf8'), outputBytes);+ assert.equal(fs.readFileSync(receiptPath, 'utf8'), receiptBytes);+ assert.equal(fs.readFileSync(receiptAlias, 'utf8'), receiptBytes);+ assert.equal(fs.readdirSync(cwd).some((name) => name.startsWith('.archify-compare-')), false);+});+test('preview applies the meta.output relative-path boundary before starting a server', async () => {const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-preview-meta-'));const input = path.join(cwd, 'diagram.workflow.json');@@ -479,6 +967,18 @@ test('compare rechecks every target immediately before committing the artifact ppath.join(skillRoot, 'renderers/shared/output-path.mjs'),path.join(installedShared, 'output-path.mjs'),);+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/path-semantics.mjs'),+ path.join(installedShared, 'path-semantics.mjs'),+ );+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/portable-path.mjs'),+ path.join(installedShared, 'portable-path.mjs'),+ );+ fs.copyFileSync(+ path.join(skillRoot, 'renderers/shared/atomic-output.mjs'),+ path.join(installedShared, 'atomic-output.mjs'),+ );fs.writeFileSync(path.join(installedRenderer, 'render-architecture.mjs'), `import fs from 'node:fs';import path from 'node:path';@@ -586,3 +1086,24 @@ test('doctor reports a missing output-path safety runtime in an installed skill'assert.equal(result.status, 1);assert.match(result.stdout, /\[missing\] Output path safety runtime/);});++for (const [relative, label] of [+ ['renderers/shared/path-semantics.mjs', 'Physical path semantics runtime'],+ ['renderers/shared/portable-path.mjs', 'Portable path contract runtime'],+]) {+ test(`doctor reports a missing ${path.basename(relative)} runtime without crashing`, () => {+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-output-doctor-dependency-'));+ const installedRoot = path.join(cwd, 'skill');+ copyInstalledSkill(installedRoot);+ fs.rmSync(path.join(installedRoot, relative));++ const result = spawnSync(process.execPath, [path.join(installedRoot, 'bin/archify.mjs'), 'doctor'], {+ cwd: installedRoot,+ encoding: 'utf8',+ });++ assert.equal(result.status, 1);+ assert.match(result.stdout, new RegExp(`\\[missing\\] ${label}`));+ assert.doesNotMatch(result.stderr, /ERR_MODULE_NOT_FOUND/);+ });+}diff --git a/archify/test/path-boundary-contract.test.mjs b/archify/test/path-boundary-contract.test.mjsnew file mode 100644index 00000000..76ad7696--- /dev/null+++ b/archify/test/path-boundary-contract.test.mjs@@ -0,0 +1,133 @@+import assert from 'node:assert/strict';+import fs from 'node:fs';+import path from 'node:path';+import test from 'node:test';+import { fileURLToPath } from 'node:url';++const here = path.dirname(fileURLToPath(import.meta.url));+const repositoryRoot = path.resolve(here, '../..');+const productionSourceRoots = [+ 'archify/bin',+ 'archify/delta',+ 'archify/migrations',+ 'archify/recipes',+ 'archify/renderers',+ 'archify/scripts',+ 'integrations/deepseek-harness/lib',+ 'integrations/deepseek-harness/scripts',+ 'scripts',+];++function productionSources(relativeRoot) {+ const absoluteRoot = path.join(repositoryRoot, relativeRoot);+ if (!fs.existsSync(absoluteRoot)) return [];+ return fs.readdirSync(absoluteRoot, { withFileTypes: true }).flatMap((entry) => {+ const relativePath = path.posix.join(relativeRoot, entry.name);+ if (entry.isDirectory()) return productionSources(relativePath);+ return entry.isFile() && /[.](?:mjs|js)$/u.test(entry.name) ? [relativePath] : [];+ });+}++const protectedCallers = productionSourceRoots.flatMap(productionSources).sort();++const exemption = /path-contract-allow:\s*(?:git-path|portable-logical-path|url-path|lexical-capability)\s+--\s+\S/u;+const exemptionMarker = /path-contract-allow:/u;+const pathIdentifier = String.raw`(?:[$A-Z_a-z][$\w]*(?:Path|Root|Directory|Dir|File|Canonical|Location)|path|root|directory|dir|file|output|input|target|destination|artifact|receipt|relative|resolved|canonical)`;+const pathProperty = String.raw`(?:[$A-Z_a-z][$\w.]*\.(?:path|root|directory|dir|file|output|input|target|source|destination|artifact|receipt))`;+const pathOperand = String.raw`(?:${pathIdentifier}|${pathProperty})`;+const rawPathEquality = new RegExp(String.raw`\b${pathOperand}\s*(?:===|!==)\s*${pathOperand}\b`, 'u');+const nativePathCall = String.raw`(?:path\.(?:resolve|normalize|dirname|relative|basename)|fs\.realpathSync(?:\.native)?)\s*\(`;+const directNativeEquality = new RegExp(+ String.raw`(?:${nativePathCall}[^;\n]*?\)\s*(?:===|!==)|(?:===|!==)\s*${nativePathCall})`,+ 'u',+);+const caseFoldPathKey = new RegExp(+ String.raw`(?:\b${pathIdentifier}|${nativePathCall}[^;\n]*)\.to(?:Locale)?(?:Lower|Upper)Case\s*\(`,+ 'u',+);+const pathContainmentCall = new RegExp(String.raw`\b${pathIdentifier}\.(?:startsWith|includes)\s*\(([^)]*)\)`, 'u');+const directNativeContainmentCall = new RegExp(+ String.raw`${nativePathCall}[^;\n]*\.(?:startsWith|includes)\s*\(`,+ 'u',+);++function hasValidExemption(lines, index) {+ for (let candidate = index; candidate >= Math.max(0, index - 1); candidate -= 1) {+ if (exemption.test(lines[candidate])) return true;+ }+ return false;+}++function inspectPathBoundarySource(source, file = '<fixture>') {+ const lines = source.split(/\r?\n/u);+ const violations = [];+ for (let index = 0; index < lines.length; index += 1) {+ const line = lines[index];+ const trimmed = line.trim();+ if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('*')) continue;++ const validExemption = hasValidExemption(lines, index);+ if (exemptionMarker.test(line) && !exemption.test(line)) {+ violations.push({ file, line: index + 1, rule: 'invalid-exemption' });+ continue;+ }++ if (!validExemption && (rawPathEquality.test(line) || directNativeEquality.test(line))) {+ violations.push({ file, line: index + 1, rule: 'native-path-raw-equality' });+ }+ if (!validExemption && caseFoldPathKey.test(line)) {+ violations.push({ file, line: index + 1, rule: 'native-path-case-fold-key' });+ }++ const containment = pathContainmentCall.exec(line);+ const optionPrefix = containment && line.includes('.startsWith') && /^\s*['"]--/u.test(containment[1]);+ if (!validExemption && ((containment && !optionPrefix) || directNativeContainmentCall.test(line))) {+ violations.push({ file, line: index + 1, rule: 'native-path-string-prefix-containment' });+ }+ }+ return violations;+}++test('path-boundary detector rejects the three native-path regression patterns', () => {+ const violations = inspectPathBoundarySource([+ 'if (path.resolve(receipt.output) !== path.resolve(artifactPath)) fail();',+ 'const outputKey = outputPath.toLowerCase();',+ "const lockKey = path.basename(outputPath).normalize('NFC').toLocaleUpperCase();",+ 'if (targetPath.startsWith(`${rootPath}${path.sep}`)) accept();',+ 'if (targetPath.includes(`${path.sep}trusted${path.sep}`)) accept();',+ ].join('\n'));++ assert.deepEqual(violations.map(({ rule }) => rule), [+ 'native-path-raw-equality',+ 'native-path-case-fold-key',+ 'native-path-case-fold-key',+ 'native-path-string-prefix-containment',+ 'native-path-string-prefix-containment',+ ]);+});++test('path-boundary detector permits explicit logical-path and lexical-capability exemptions', () => {+ const violations = inspectPathBoundarySource([+ '// path-contract-allow: git-path -- Git tree entries use repository-relative POSIX syntax.',+ "if (sourcePath.startsWith('/')) reject();",+ '// path-contract-allow: lexical-capability -- No-follow snapshots enforce this mutation boundary.',+ 'if (relative.startsWith(`..${path.sep}`)) reject();',+ ].join('\n'));++ assert.deepEqual(violations, []);+});++test('production callers do not implement native path identity or containment with strings', () => {+ const violations = protectedCallers.flatMap((relativePath) => {+ const source = fs.readFileSync(path.join(repositoryRoot, relativePath), 'utf8');+ return inspectPathBoundarySource(source, relativePath);+ });++ assert.deepEqual(+ violations,+ [],+ `Path-boundary regressions must delegate to path-semantics.mjs:\n${violations+ .map(({ file, line, rule }) => `- ${file}:${line} ${rule}`)+ .join('\n')}`,+ );+});diff --git a/archify/test/path-semantics.test.mjs b/archify/test/path-semantics.test.mjsnew file mode 100644index 00000000..2154e7a0--- /dev/null+++ b/archify/test/path-semantics.test.mjs@@ -0,0 +1,821 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import test from 'node:test';+import assert from 'node:assert/strict';+import {+ containedBy,+ resolvePhysicalLocation,+ sameEntry,+ sameLocation,+ sameParent,+} from '../renderers/shared/path-semantics.mjs';++function scratchDirectory(t) {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-path-semantics-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ return directory;+}++function expectResult(value, expectedStatus) {+ assert.equal(value.status, expectedStatus);+ assert.equal(typeof value.reason?.code, 'string');+ assert.ok(value.reason.code.length > 0);+ assert.deepEqual(Object.keys(value).sort(), ['reason', 'status']);+}++function mockWindowsFilesystem(t, {+ entriesExist = true,+ preserveExtendedRealpaths = false,+ symbolicLinks = [],+} = {}) {+ const platform = Object.getOwnPropertyDescriptor(process, 'platform');+ Object.defineProperty(process, 'platform', { ...platform, value: 'win32' });+ t.after(() => Object.defineProperty(process, 'platform', platform));++ const realpathCalls = [];+ const identities = new Map();+ let nextIdentity = 1n;+ const canonicalPath = (targetPath) => {+ const input = String(targetPath);+ let canonical;+ if (/^\\\\\?\\UNC\\[^\\]+\\[^\\]+(?:\\|$)/iu.test(input)) {+ canonical = input.replace(/^\\\\\?\\UNC\\/iu, '\\\\');+ } else if (/^\\\\\?\\[A-Za-z]:\\/u.test(input)) {+ canonical = input.slice(4);+ } else if (/^\\\\[^\\]+\\[^\\]+(?:\\|$)/u.test(input) || /^[A-Za-z]:\\/u.test(input)) {+ canonical = input;+ } else {+ const error = new Error(`virtual Windows path is not rooted at a drive or share: ${input}`);+ error.code = 'EINVAL';+ throw error;+ }+ return path.win32.normalize(canonical);+ };+ const statFor = (targetPath) => {+ const key = canonicalPath(targetPath).toLocaleLowerCase('en-US');+ if (!identities.has(key)) {+ identities.set(key, nextIdentity);+ nextIdentity += 1n;+ }+ return {+ dev: 1n,+ ino: identities.get(key),+ isDirectory: () => true,+ isSymbolicLink: () => false,+ };+ };+ const linkTargets = new Map(symbolicLinks.map(({ link, target }) => (+ [canonicalPath(link).toLocaleLowerCase('en-US'), target]+ )));++ t.mock.method(fs.realpathSync, 'native', (targetPath) => {+ realpathCalls.push(String(targetPath));+ return preserveExtendedRealpaths+ ? path.win32.normalize(String(targetPath))+ : canonicalPath(targetPath);+ });+ t.mock.method(fs, 'statSync', statFor);+ t.mock.method(fs, 'lstatSync', (targetPath) => {+ if (entriesExist) {+ const stat = statFor(targetPath);+ const key = canonicalPath(targetPath).toLocaleLowerCase('en-US');+ if (!linkTargets.has(key)) return stat;+ return {+ ...stat,+ isDirectory: () => false,+ isSymbolicLink: () => true,+ };+ }+ const error = new Error(`virtual Windows entry does not exist: ${targetPath}`);+ error.code = 'ENOENT';+ throw error;+ });+ t.mock.method(fs, 'readlinkSync', (targetPath) => {+ const key = canonicalPath(targetPath).toLocaleLowerCase('en-US');+ if (linkTargets.has(key)) return linkTargets.get(key);+ const error = new Error(`virtual Windows entry is not a symbolic link: ${targetPath}`);+ error.code = 'EINVAL';+ throw error;+ });+ return { realpathCalls };+}++test('Windows drive and share roots reach native resolution as complete filesystem roots', (t) => {+ const { realpathCalls } = mockWindowsFilesystem(t);+ const ordinaryUnc = String.raw`\\server\share\reports\diagram.html`;+ const extendedUnc = String.raw`\\?\UNC\server\share\reports\diagram.html`;+ const ordinaryDrive = String.raw`C:\reports\diagram.html`;+ const extendedDrive = String.raw`\\?\C:\reports\diagram.html`;++ expectResult(sameLocation(ordinaryUnc, extendedUnc), 'match');+ expectResult(+ sameLocation(String.raw`\\server\share`, String.raw`\\?\UNC\server\share`),+ 'match',+ );+ expectResult(sameLocation(ordinaryDrive, extendedDrive), 'match');+ expectResult(sameLocation('C:\\', `${String.raw`\\?\C:`}\\`), 'match');+ assert.ok(realpathCalls.includes(`${String.raw`\\server\share`}\\`));+ assert.ok(realpathCalls.includes(`${String.raw`\\?\UNC\server\share`}\\`));+ assert.ok(realpathCalls.includes('C:\\'));+ assert.ok(realpathCalls.includes(`${String.raw`\\?\C:`}\\`));+});++test('Windows device and malformed extended namespaces fail closed before filesystem access', (t) => {+ const { realpathCalls } = mockWindowsFilesystem(t);+ for (const [targetPath, reason] of [+ [String.raw`\\.\NUL`, 'windows-namespace-unsupported'],+ ['//./NUL', 'windows-namespace-unsupported'],+ [String.raw`\\?\GLOBALROOT\Device\HarddiskVolume1\diagram.html`, 'windows-namespace-unsupported'],+ ['//?/GLOBALROOT/Device/HarddiskVolume1/diagram.html', 'windows-namespace-unsupported'],+ [String.raw`\\?\Volume{01234567-89AB-CDEF-0123-456789ABCDEF}\diagram.html`, 'windows-namespace-unsupported'],+ [String.raw`\\?\UNC\server`, 'windows-root-invalid'],+ [String.raw`\\?\other\diagram.html`, 'windows-root-invalid'],+ [String.raw`\\server`, 'windows-root-invalid'],+ [String.raw`\reports\diagram.html`, 'windows-root-invalid'],+ [String.raw`C:reports\diagram.html`, 'drive-relative-path'],+ ]) {+ const comparison = sameLocation(targetPath, targetPath);+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, reason);+ }+ assert.deepEqual(realpathCalls, []);+});++test('Windows extended dot segments fail closed before filesystem access', (t) => {+ const { realpathCalls } = mockWindowsFilesystem(t);+ for (const targetPath of [+ String.raw`\\?\C:\reports\.\diagram.html`,+ String.raw`\\?\C:\reports\..\diagram.html`,+ String.raw`\\?\UNC\server\share\reports\.\diagram.html`,+ String.raw`\\?\UNC\server\share\reports\..\diagram.html`,+ ]) {+ const comparison = sameLocation(targetPath, targetPath);+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'windows-root-invalid');+ }+ assert.deepEqual(realpathCalls, []);+});++test('Windows extended repeated separators fail closed before filesystem access', (t) => {+ const { realpathCalls } = mockWindowsFilesystem(t);+ for (const targetPath of [+ String.raw`\\?\C:\reports\\diagram.html`,+ String.raw`\\?\UNC\server\share\reports\\diagram.html`,+ ]) {+ const comparison = sameLocation(targetPath, targetPath);+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'windows-root-invalid');+ }+ assert.deepEqual(realpathCalls, []);+});++test('relative symbolic-link navigation remains physical through an extended path', (t) => {+ const link = String.raw`\\?\C:\container\link.html`;+ mockWindowsFilesystem(t, {+ preserveExtendedRealpaths: true,+ symbolicLinks: [{ link, target: String.raw`..\\target.html` }],+ });++ expectResult(sameEntry(link, String.raw`C:\target.html`), 'match');+});++test('sameEntry uses physical identity for files, symbolic links, and hard links', (t) => {+ const root = scratchDirectory(t);+ const original = path.join(root, 'original.txt');+ const hard = path.join(root, 'hard.txt');+ const other = path.join(root, 'other.txt');+ const realDirectory = path.join(root, 'real-directory');+ const linkedDirectory = path.join(root, 'linked-directory');+ fs.writeFileSync(original, 'original');+ fs.writeFileSync(other, 'other');+ fs.linkSync(original, hard);+ fs.mkdirSync(realDirectory);+ fs.symlinkSync(realDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');++ expectResult(sameEntry(realDirectory, linkedDirectory), 'match');+ expectResult(sameEntry(original, hard), 'match');+ expectResult(sameEntry(original, other), 'different');+ expectResult(sameEntry(original, path.join(root, 'missing.txt')), 'unknown');+});++test('sameLocation follows directory links for future targets', (t) => {+ const root = scratchDirectory(t);+ const realDirectory = path.join(root, 'real');+ const linkedDirectory = path.join(root, 'linked');+ fs.mkdirSync(realDirectory);+ fs.symlinkSync(realDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');++ expectResult(+ sameLocation(+ path.join(realDirectory, 'future', 'diagram.html'),+ path.join(linkedDirectory, 'future', 'diagram.html'),+ ),+ 'match',+ );+});++test('physical traversal resolves dot-dot after following a directory alias', (t) => {+ const root = scratchDirectory(t);+ const container = path.join(root, 'container');+ const physical = path.join(root, 'physical');+ const nested = path.join(physical, 'nested');+ const escape = path.join(physical, 'escape.html');+ fs.mkdirSync(container);+ fs.mkdirSync(nested, { recursive: true });+ fs.writeFileSync(escape, 'physical target');+ fs.symlinkSync(nested, path.join(container, 'jump'), process.platform === 'win32' ? 'junction' : 'dir');++ const authored = `${container}${path.sep}jump${path.sep}..${path.sep}escape.html`;+ expectResult(sameEntry(authored, escape), 'match');+ expectResult(containedBy(container, authored), 'different');+ const resolved = resolvePhysicalLocation(authored);+ assert.equal(resolved.status, 'resolved');+ assert.deepEqual(resolved.location, {+ kind: 'existing',+ path: fs.realpathSync.native(escape),+ });+});++test('a missing segment before dot-dot is not lexically collapsed into an existing entry', (t) => {+ const root = scratchDirectory(t);+ const target = path.join(root, 'target.html');+ fs.writeFileSync(target, 'target');++ const authored = `${root}${path.sep}missing${path.sep}..${path.sep}target.html`;+ const comparison = sameEntry(authored, target);+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-parent-traversal-indeterminate');+});++test('physical resolution preserves dot-dot inside a symbolic-link target', (t) => {+ const root = scratchDirectory(t);+ const container = path.join(root, 'container');+ const authoredParent = path.join(root, 'authored');+ const physical = path.join(root, 'physical');+ const nested = path.join(physical, 'nested');+ const target = path.join(physical, 'target.html');+ fs.mkdirSync(container);+ fs.mkdirSync(authoredParent);+ fs.mkdirSync(nested, { recursive: true });+ fs.writeFileSync(target, 'physical target');+ fs.symlinkSync(nested, path.join(authoredParent, 'jump'), process.platform === 'win32' ? 'junction' : 'dir');+ const authoredTarget = `..${path.sep}authored${path.sep}jump${path.sep}..${path.sep}target.html`;+ const link = path.join(container, 'link.html');+ try {+ fs.symlinkSync(authoredTarget, link, 'file');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip('file symbolic links are unavailable');+ return;+ }+ throw error;+ }++ const resolved = resolvePhysicalLocation(link);+ assert.equal(resolved.status, 'resolved');+ assert.deepEqual(resolved.location, {+ kind: 'existing',+ path: fs.realpathSync.native(target),+ });+ expectResult(sameEntry(link, target), 'match');+});++test('symbolic-link targets cannot erase a missing segment or a cycle with dot-dot', (t) => {+ const root = scratchDirectory(t);+ const target = path.join(root, 'target.html');+ const missingLink = path.join(root, 'missing-link.html');+ const loop = path.join(root, 'loop');+ fs.writeFileSync(target, 'target');+ try {+ fs.symlinkSync(`missing${path.sep}..${path.sep}target.html`, missingLink, 'file');+ fs.symlinkSync(`loop${path.sep}..`, loop, 'file');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip('file symbolic links are unavailable');+ return;+ }+ throw error;+ }++ const missing = sameEntry(missingLink, target);+ expectResult(missing, 'unknown');+ assert.equal(missing.reason.code, 'future-parent-traversal-indeterminate');+ const cyclic = sameEntry(loop, root);+ expectResult(cyclic, 'unknown');+ assert.equal(cyclic.reason.code, 'symlink-cycle');+});++test('physical resolution returns a real ancestor and unresolved future segments', (t) => {+ const root = scratchDirectory(t);+ const physical = path.join(root, 'physical');+ const nested = path.join(physical, 'nested');+ const alias = path.join(root, 'alias');+ fs.mkdirSync(nested, { recursive: true });+ fs.symlinkSync(nested, alias, process.platform === 'win32' ? 'junction' : 'dir');+ const authored = `${alias}${path.sep}..${path.sep}future${path.sep}diagram.html`;++ const resolved = resolvePhysicalLocation(authored);+ assert.equal(resolved.status, 'resolved');+ assert.deepEqual(resolved.location, {+ kind: 'future',+ ancestorPath: fs.realpathSync.native(physical),+ unresolved: ['future', 'diagram.html'],+ });+});++test('sameLocation asks the containing filesystem about case-only future names', (t) => {+ const root = scratchDirectory(t);+ const authoredProbe = path.join(root, 'ArchifyCaseProbe');+ const lookupProbe = path.join(root, 'archifycaseprobe');+ fs.writeFileSync(authoredProbe, 'probe');+ const aliasesCase = fs.existsSync(lookupProbe)+ && fs.statSync(authoredProbe, { bigint: true }).ino === fs.statSync(lookupProbe, { bigint: true }).ino;+ fs.unlinkSync(authoredProbe);++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ expectResult(comparison, aliasesCase ? 'match' : 'different');+});++test('sameLocation does not project ancestor semantics through a future directory', (t) => {+ const root = scratchDirectory(t);+ const openSync = fs.openSync.bind(fs);+ let probeCount = 0;+ t.mock.method(fs, 'openSync', (targetPath, ...args) => {+ if (path.basename(targetPath).startsWith('.archify-path-semantics-')) probeCount += 1;+ return openSync(targetPath, ...args);+ });++ const caseOverlap = sameLocation(+ path.join(root, 'future-parent', 'Diagram.HTML'),+ path.join(root, 'future-parent', 'diagram.html'),+ );+ const normalizationOverlap = sameLocation(+ path.join(root, 'future-parent', 'Caf\u00e9.html'),+ path.join(root, 'future-parent', 'Cafe\u0301.html'),+ );+ const distinct = sameLocation(+ path.join(root, 'future-parent', 'diagram.html'),+ path.join(root, 'future-parent', 'receipt.json'),+ );+ t.mock.restoreAll();++ for (const comparison of [caseOverlap, normalizationOverlap]) {+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-descendant-semantics-indeterminate');+ assert.equal(comparison.reason.segmentIndex, 1);+ }+ expectResult(distinct, 'different');+ assert.equal(distinct.reason.code, 'future-name-distinct');+ assert.equal(probeCount, 0);+});++test('sameLocation probes an existing intermediate directory using its own semantics', (t) => {+ const root = scratchDirectory(t);+ const intermediate = path.join(root, 'existing-parent');+ fs.mkdirSync(intermediate);+ const authoredProbe = path.join(intermediate, 'ArchifyCaseProbe');+ const lookupProbe = path.join(intermediate, 'archifycaseprobe');+ fs.writeFileSync(authoredProbe, 'probe');+ const aliasesCase = fs.existsSync(lookupProbe)+ && fs.statSync(authoredProbe, { bigint: true }).ino === fs.statSync(lookupProbe, { bigint: true }).ino;+ fs.unlinkSync(authoredProbe);++ const comparison = sameLocation(+ path.join(intermediate, 'Diagram.HTML'),+ path.join(intermediate, 'diagram.html'),+ );+ expectResult(comparison, aliasesCase ? 'match' : 'different');+});++test('sameLocation distinguishes different existing entries and future depths', (t) => {+ const root = scratchDirectory(t);+ const left = path.join(root, 'left.txt');+ const right = path.join(root, 'right.txt');+ fs.writeFileSync(left, 'left');+ fs.writeFileSync(right, 'right');++ expectResult(sameLocation(left, right), 'different');+ expectResult(+ sameLocation(path.join(root, 'future.txt'), path.join(root, 'nested', 'future.txt')),+ 'different',+ );+ const invalidDescendant = sameLocation(+ path.join(left, 'future.txt'),+ path.join(left, 'future.txt'),+ );+ expectResult(invalidDescendant, 'unknown');+ assert.equal(invalidDescendant.reason.code, 'ancestor-not-directory');+});++test('sameLocation reports probe cleanup failures as unknown', (t) => {+ const root = scratchDirectory(t);+ const unlinkSync = fs.unlinkSync.bind(fs);+ t.mock.method(fs, 'unlinkSync', (targetPath, ...args) => {+ if (path.basename(targetPath).startsWith('.archify-path-semantics-cleanup-')) {+ unlinkSync(targetPath, ...args);+ const error = new Error('simulated probe cleanup failure');+ error.code = 'EIO';+ throw error;+ }+ return unlinkSync(targetPath, ...args);+ });++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-cleanup-failed');+ assert.equal(comparison.reason.systemCode, 'EIO');+ assert.equal(typeof comparison.reason.comparison?.code, 'string');+});++test('sameLocation does not recursively probe its own watcher events', (t) => {+ const root = scratchDirectory(t);+ const openSync = fs.openSync.bind(fs);+ let probeName;+ t.mock.method(fs, 'openSync', (targetPath, ...args) => {+ if (path.basename(targetPath).startsWith('.archify-path-semantics-')) {+ probeName = path.basename(targetPath);+ }+ return openSync(targetPath, ...args);+ });++ sameLocation(path.join(root, 'Future.HTML'), path.join(root, 'future.html'));+ t.mock.restoreAll();+ assert.equal(typeof probeName, 'string');++ const watcherComparison = sameLocation(+ path.join(root, probeName),+ path.join(root, 'future.html'),+ );+ expectResult(watcherComparison, 'different');+ assert.equal(watcherComparison.reason.code, 'internal-probe-name');+});++test('sameLocation proves distinct safe-ASCII names without writing to the directory', (t) => {+ const root = scratchDirectory(t);+ t.mock.method(fs, 'openSync', () => {+ const error = new Error('the directory is read-only');+ error.code = 'EACCES';+ throw error;+ });++ const comparison = sameLocation(+ path.join(root, 'diagram.workflow.json'),+ path.join(root, 'diagram.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'different');+ assert.equal(comparison.reason.code, 'future-name-distinct');+ assert.equal(comparison.reason.method, 'semantic-envelope');+});++test('sameLocation proves a long Unicode artifact distinct from a bounded hash sidecar', (t) => {+ const root = scratchDirectory(t);+ const longNfd = `${'e\u0301'.repeat(100)}-architecture.html`;+ const hashSidecar = '.archify-delivery-a3f5712c9e19.json';+ t.mock.method(fs, 'openSync', () => {+ throw new Error('a distinct-name proof must not write a probe');+ });++ const comparison = sameLocation(+ path.join(root, longNfd),+ path.join(root, hashSidecar),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'different');+ assert.equal(comparison.reason.code, 'future-name-distinct');+ assert.equal(comparison.reason.method, 'semantic-envelope');+});++test('sameLocation never unlinks a probe path it did not create', (t) => {+ const root = scratchDirectory(t);+ let unlinkCalls = 0;+ t.mock.method(fs, 'openSync', () => {+ const error = new Error('probe creation denied');+ error.code = 'EACCES';+ throw error;+ });+ t.mock.method(fs, 'unlinkSync', () => {+ unlinkCalls += 1;+ });++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-failed');+ assert.equal(comparison.reason.systemCode, 'EACCES');+ assert.equal(unlinkCalls, 0);+});++test('sameLocation fails closed when a direct probe would exceed the component limit', (t) => {+ const root = scratchDirectory(t);+ const upper = `${'a'.repeat(220)}A.html`;+ const lower = upper.toLowerCase();+ const shortUpper = path.join(root, 'CaseProbeA');+ const shortLower = path.join(root, 'caseprobea');+ fs.writeFileSync(shortUpper, 'probe');+ const aliasesCase = fs.existsSync(shortLower)+ && fs.statSync(shortUpper, { bigint: true }).ino === fs.statSync(shortLower, { bigint: true }).ino;+ fs.unlinkSync(shortUpper);++ const comparison = sameLocation(path.join(root, upper), path.join(root, lower));+ if (aliasesCase) {+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-unrepresentable');+ } else {+ // A case-sensitive directory can prove the names different without+ // manufacturing either long target name.+ assert.ok(['different', 'unknown'].includes(comparison.status));+ }+});++test('probe cleanup never deletes a replacement entry', (t) => {+ const root = scratchDirectory(t);+ const openSync = fs.openSync.bind(fs);+ const closeSync = fs.closeSync.bind(fs);+ let probePath;+ let replaced = false;+ t.mock.method(fs, 'openSync', (targetPath, ...args) => {+ const descriptor = openSync(targetPath, ...args);+ if (path.basename(targetPath).startsWith('.archify-path-semantics-')) {+ probePath = targetPath;+ }+ return descriptor;+ });+ t.mock.method(fs, 'closeSync', (descriptor) => {+ closeSync(descriptor);+ if (probePath && !replaced) {+ replaced = true;+ fs.unlinkSync(probePath);+ fs.writeFileSync(probePath, 'replacement sentinel');+ }+ });++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-cleanup-failed');+ assert.equal(comparison.reason.systemCode, 'ARCHIFY_PROBE_IDENTITY_CHANGED');+ assert.equal(fs.readFileSync(probePath, 'utf8'), 'replacement sentinel');+});++test('probe cleanup preserves a replacement introduced after its identity check', (t) => {+ const root = scratchDirectory(t);+ const lstatSync = fs.lstatSync.bind(fs);+ const unlinkSync = fs.unlinkSync.bind(fs);+ let probePath;+ let replaced = false;+ t.mock.method(fs, 'lstatSync', (targetPath, ...args) => {+ const stat = lstatSync(targetPath, ...args);+ if (+ !replaced+ && (+ path.basename(targetPath).startsWith('.archify-path-semantics-')+ || path.basename(path.dirname(targetPath)).startsWith('.archify-path-semantics-')+ )+ && !stat.isDirectory()+ ) {+ probePath = targetPath;+ replaced = true;+ unlinkSync(targetPath);+ fs.writeFileSync(targetPath, 'replacement after identity check');+ }+ return stat;+ });++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-cleanup-failed');+ assert.equal(comparison.reason.systemCode, 'ARCHIFY_PROBE_IDENTITY_CHANGED');+ assert.equal(comparison.reason.restoredAtTarget, true);+ assert.equal(typeof comparison.reason.recoveryPath, 'string');+ assert.equal(fs.readFileSync(probePath, 'utf8'), 'replacement after identity check');+ assert.equal(+ fs.readFileSync(comparison.reason.recoveryPath, 'utf8'),+ 'replacement after identity check',+ );+ assert.equal(+ fs.statSync(probePath, { bigint: true }).ino,+ fs.statSync(comparison.reason.recoveryPath, { bigint: true }).ino,+ );+});++test('probe cleanup exposes the quarantine path when target restoration fails', (t) => {+ const root = scratchDirectory(t);+ const lstatSync = fs.lstatSync.bind(fs);+ const unlinkSync = fs.unlinkSync.bind(fs);+ let probePath;+ let replaced = false;+ t.mock.method(fs, 'lstatSync', (targetPath, ...args) => {+ const stat = lstatSync(targetPath, ...args);+ if (+ !replaced+ && path.basename(targetPath).startsWith('.archify-path-semantics-')+ && !stat.isDirectory()+ ) {+ probePath = targetPath;+ replaced = true;+ unlinkSync(targetPath);+ fs.writeFileSync(targetPath, 'quarantined replacement');+ }+ return stat;+ });+ t.mock.method(fs, 'linkSync', () => {+ const error = new Error('simulated target restoration failure');+ error.code = 'EACCES';+ throw error;+ });++ const comparison = sameLocation(+ path.join(root, 'Future.HTML'),+ path.join(root, 'future.html'),+ );+ t.mock.restoreAll();++ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-name-probe-cleanup-failed');+ assert.equal(comparison.reason.systemCode, 'ARCHIFY_PROBE_IDENTITY_CHANGED');+ assert.equal(comparison.reason.restoredAtTarget, false);+ assert.equal(typeof comparison.reason.recoveryPath, 'string');+ assert.equal(fs.existsSync(probePath), false);+ assert.equal(+ fs.readFileSync(comparison.reason.recoveryPath, 'utf8'),+ 'quarantined replacement',+ );+});++test('successful probe cleanup leaves no quarantine entry', (t) => {+ const root = scratchDirectory(t);+ sameLocation(path.join(root, 'Future.HTML'), path.join(root, 'future.html'));+ assert.deepEqual(+ fs.readdirSync(root).filter((entry) => entry.startsWith('.archify-path-semantics-')),+ [],+ );+});++test('future name probes run in the directory whose semantics are being queried', (t) => {+ const root = scratchDirectory(t);+ const openSync = fs.openSync.bind(fs);+ let probeParent;+ t.mock.method(fs, 'openSync', (targetPath, ...args) => {+ if (+ path.basename(targetPath).startsWith('.archify-path-semantics-')+ || path.basename(path.dirname(targetPath)).startsWith('.archify-path-semantics-')+ ) {+ probeParent = path.dirname(targetPath);+ }+ return openSync(targetPath, ...args);+ });++ sameLocation(path.join(root, 'Future.HTML'), path.join(root, 'future.html'));+ t.mock.restoreAll();+ assert.equal(probeParent, fs.realpathSync.native(root));+});++test('future Windows short-name shapes fail closed before creation', (t) => {+ const root = scratchDirectory(t);+ const comparison = sameLocation(+ path.join(root, 'PROGRA~1', 'diagram.html'),+ path.join(root, 'Program Files', 'diagram.html'),+ );+ expectResult(comparison, process.platform === 'win32' ? 'unknown' : 'different');+ if (process.platform === 'win32') {+ assert.equal(comparison.reason.code, 'future-short-name-indeterminate');+ }+});++test('future Windows device names fail closed across the portable reserved set', (t) => {+ mockWindowsFilesystem(t, { entriesExist: false });+ for (const reserved of ['CONIN$.txt', 'CONOUT$.json', 'COM¹.html', 'COM²', 'LPT³.log']) {+ const comparison = sameLocation(+ `C:\\${reserved}`,+ String.raw`C:\ordinary-output.html`,+ );+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-device-name-indeterminate');+ }+});++test('sameParent compares the parent location through directory aliases', (t) => {+ const root = scratchDirectory(t);+ const realDirectory = path.join(root, 'real');+ const linkedDirectory = path.join(root, 'linked');+ const otherDirectory = path.join(root, 'other');+ fs.mkdirSync(realDirectory);+ fs.mkdirSync(otherDirectory);+ fs.symlinkSync(realDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');++ expectResult(+ sameParent(path.join(realDirectory, 'left.html'), path.join(linkedDirectory, 'right.json')),+ 'match',+ );+ expectResult(+ sameParent(path.join(realDirectory, 'left.html'), path.join(otherDirectory, 'right.json')),+ 'different',+ );+});++test('containedBy handles existing and future descendants and rejects link escapes', (t) => {+ const root = scratchDirectory(t);+ const container = path.join(root, 'container');+ const nested = path.join(container, 'nested');+ const outside = path.join(root, 'outside');+ fs.mkdirSync(nested, { recursive: true });+ fs.mkdirSync(outside);+ const file = path.join(nested, 'diagram.html');+ fs.writeFileSync(file, 'diagram');+ const escape = path.join(container, 'escape');+ fs.symlinkSync(outside, escape, process.platform === 'win32' ? 'junction' : 'dir');++ expectResult(containedBy(container, container), 'match');+ expectResult(containedBy(container, file), 'match');+ expectResult(containedBy(container, path.join(nested, 'future.html')), 'match');+ expectResult(containedBy(container, path.join(escape, 'future.html')), 'different');+ expectResult(containedBy(container, path.join(outside, 'future.html')), 'different');+ expectResult(containedBy(path.join(root, 'missing'), file), 'unknown');+});++test('containedBy does not fold case-distinct sibling directories', (t) => {+ const root = scratchDirectory(t);+ const upper = path.join(root, 'CaseRoot');+ const lower = path.join(root, 'caseroot');+ fs.mkdirSync(upper);++ let sibling = lower;+ try {+ fs.mkdirSync(lower);+ } catch (error) {+ if (error?.code !== 'EEXIST') throw error;+ sibling = path.join(root, 'different-root');+ fs.mkdirSync(sibling);+ }++ const upperStat = fs.statSync(upper, { bigint: true });+ const siblingStat = fs.statSync(sibling, { bigint: true });+ assert.notEqual(`${upperStat.dev}:${upperStat.ino}`, `${siblingStat.dev}:${siblingStat.ino}`);+ expectResult(containedBy(upper, path.join(sibling, 'future.html')), 'different');+});++test('containedBy resolves physical aliases for a future container prefix', (t) => {+ const root = scratchDirectory(t);+ const physical = path.join(root, 'physical');+ const alias = path.join(root, 'alias');+ fs.mkdirSync(physical);+ try {+ fs.symlinkSync(physical, alias, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip('directory aliases are unavailable');+ return;+ }+ throw error;+ }++ const relation = containedBy(+ path.join(alias, 'future-stage'),+ path.join(physical, 'future-stage', 'modes.json'),+ );+ expectResult(relation, 'match');+ assert.equal(relation.reason.code, 'future-container-prefix-match');+ expectResult(+ containedBy(+ path.join(alias, 'other-stage'),+ path.join(physical, 'future-stage', 'modes.json'),+ ),+ 'different',+ );+});++test('containedBy does not project ancestor semantics through a future container', (t) => {+ const root = scratchDirectory(t);+ const comparison = containedBy(+ path.join(root, 'future-parent', 'Diagram'),+ path.join(root, 'future-parent', 'diagram', 'artifact.html'),+ );+ expectResult(comparison, 'unknown');+ assert.equal(comparison.reason.code, 'future-descendant-semantics-indeterminate');+ assert.equal(comparison.reason.segmentIndex, 1);+});diff --git a/archify/test/portable-path.test.mjs b/archify/test/portable-path.test.mjsnew file mode 100644index 00000000..79ec3082--- /dev/null+++ b/archify/test/portable-path.test.mjs@@ -0,0 +1,437 @@+import assert from 'node:assert/strict';+import test from 'node:test';+import {+ PortablePathError,+ validatePortablePath,+ validatePortablePathSet,+} from '../renderers/shared/portable-path.mjs';++function assertPathError(run, { code, reason, profile, segment, index, conflictIndex } = {}) {+ assert.throws(run, (error) => {+ assert.ok(error instanceof PortablePathError);+ if (code !== undefined) assert.equal(error.code, code);+ if (reason !== undefined) assert.equal(error.reason, reason);+ if (profile !== undefined) assert.equal(error.profile, profile);+ if (segment !== undefined) assert.equal(error.segment, segment);+ if (index !== undefined) assert.equal(error.index, index);+ if (conflictIndex !== undefined) assert.equal(error.conflictIndex, conflictIndex);+ return true;+ });+}++test('portable path profiles accept non-empty POSIX-relative paths without rewriting them', () => {+ for (const profile of ['output', 'repo', 'archive']) {+ const value = 'reports/Architecture Café 2026.html';+ assert.equal(validatePortablePath(value, { profile }), value);+ }++ assert.equal(+ validatePortablePath('source/NUL.txt', { profile: 'repo' }),+ 'source/NUL.txt',+ 'repository paths remain able to describe names that cannot be checked out on Windows',+ );+ assert.equal(validatePortablePath('source/name:variant', { profile: 'repo' }), 'source/name:variant');+});++test('portable paths require a declared profile and string value', () => {+ assertPathError(+ () => validatePortablePath('report.html'),+ { code: 'portable-path/profile', reason: 'profile' },+ );+ assertPathError(+ () => validatePortablePath('report.html', { profile: 'unknown' }),+ { code: 'portable-path/profile', reason: 'profile' },+ );+ assertPathError(+ () => validatePortablePath(42, { profile: 'output' }),+ { code: 'portable-path/type', reason: 'type', profile: 'output' },+ );+ assertPathError(+ () => validatePortablePath('', { profile: 'output' }),+ { code: 'portable-path/empty', reason: 'empty', profile: 'output' },+ );+});++test('portable paths reject absolute, drive-relative, URI, and backslash forms', () => {+ const cases = [+ ['/report.html', 'portable-path/absolute', 'absolute'],+ ['C:/report.html', 'portable-path/absolute', 'absolute'],+ ['C:\\report.html', 'portable-path/absolute', 'absolute'],+ ['\\\\server\\share\\report.html', 'portable-path/absolute', 'absolute'],+ ['\\report.html', 'portable-path/absolute', 'absolute'],+ ['C:report.html', 'portable-path/drive-relative', 'drive-relative'],+ ['https://example.test/report.html', 'portable-path/uri', 'uri'],+ ['docs\\report.html', 'portable-path/backslash', 'backslash'],+ ];++ for (const [value, code, reason] of cases) {+ assertPathError(+ () => validatePortablePath(value, { profile: 'repo' }),+ { code, reason, profile: 'repo' },+ );+ }+});++test('portable paths reject empty, dot, and control-bearing segments', () => {+ const cases = [+ ['reports//diagram.html', 'portable-path/empty-segment', 'empty-segment', ''],+ ['reports/', 'portable-path/empty-segment', 'empty-segment', ''],+ ['./diagram.html', 'portable-path/dot-segment', 'dot-segment', '.'],+ ['reports/../diagram.html', 'portable-path/dot-segment', 'dot-segment', '..'],+ ['reports/line\nfeed.html', 'portable-path/control', 'control', 'line\nfeed.html'],+ ['reports/delete\u007f.html', 'portable-path/control', 'control', 'delete\u007f.html'],+ ];++ for (const [value, code, reason, segment] of cases) {+ assertPathError(+ () => validatePortablePath(value, { profile: 'repo' }),+ { code, reason, profile: 'repo', segment },+ );+ }+});++test('portable paths reject unpaired UTF-16 surrogates without rejecting valid pairs', () => {+ for (const profile of ['output', 'repo', 'archive']) {+ for (const surrogate of ['\ud800', '\udfff']) {+ assertPathError(+ () => validatePortablePath(`reports/${surrogate}.html`, { profile }),+ {+ code: 'portable-path/unpaired-surrogate',+ reason: 'unpaired-surrogate',+ profile,+ segment: `${surrogate}.html`,+ },+ );+ }++ assert.equal(+ validatePortablePath('reports/😀.html', { profile }),+ 'reports/😀.html',+ );+ }+});++test('output and archive profiles reject Windows-invalid segment names', () => {+ for (const profile of ['output', 'archive']) {+ assertPathError(+ () => validatePortablePath('reports/diagram:stream.html', { profile }),+ {+ code: 'portable-path/windows-ads',+ reason: 'windows-ads',+ profile,+ segment: 'diagram:stream.html',+ },+ );++ for (const character of ['<', '>', '"', '|', '?', '*']) {+ const segment = `diagram${character}.html`;+ assertPathError(+ () => validatePortablePath(`reports/${segment}`, { profile }),+ {+ code: 'portable-path/windows-invalid-character',+ reason: 'windows-invalid-character',+ profile,+ segment,+ },+ );+ }++ for (const segment of ['diagram.', 'diagram ', 'folder.']) {+ assertPathError(+ () => validatePortablePath(`reports/${segment}`, { profile }),+ {+ code: 'portable-path/windows-trailing-dot-space',+ reason: 'windows-trailing-dot-space',+ profile,+ segment,+ },+ );+ }+ }+});++test('output and archive profiles reject DOS device names including superscript forms', () => {+ const reserved = [+ 'CON', 'prn.txt', 'Aux.json', 'nul.html', 'CONIN$', 'conout$.txt',+ 'COM1', 'com9.log', 'LPT1', 'lpt9.txt',+ 'COM¹', 'com².txt', 'COM³.log',+ 'LPT¹', 'lpt².txt', 'LPT³.log',+ ];++ for (const profile of ['output', 'archive']) {+ for (const segment of reserved) {+ assertPathError(+ () => validatePortablePath(`reports/${segment}`, { profile }),+ {+ code: 'portable-path/windows-reserved-name',+ reason: 'windows-reserved-name',+ profile,+ segment,+ },+ );+ }++ for (const segment of ['console.html', 'COM0', 'COM10', 'COM¹x', 'LPT0.txt']) {+ assert.equal(validatePortablePath(`reports/${segment}`, { profile }), `reports/${segment}`);+ }+ }+});++test('output and archive profiles reject Windows 8.3 short-name shapes', () => {+ for (const profile of ['output', 'archive']) {+ for (const segment of ['PROGRA~1', 'longfi~9.html', 'REPORT~12.json']) {+ assertPathError(+ () => validatePortablePath(`reports/${segment}`, { profile }),+ {+ code: 'portable-path/windows-short-name',+ reason: 'windows-short-name',+ profile,+ segment,+ },+ );+ }++ for (const segment of ['tilde~0', 'tilde~x', 'name~1suffix']) {+ assert.equal(validatePortablePath(`reports/${segment}`, { profile }), `reports/${segment}`);+ }+ }++ assert.equal(+ validatePortablePath('fixtures/PROGRA~1/source.json', { profile: 'repo' }),+ 'fixtures/PROGRA~1/source.json',+ 'Git paths retain POSIX spelling semantics even when a segment resembles an 8.3 alias',+ );+});++test('output and archive profiles conservatively enforce portable component sizes', () => {+ const maxAscii = 'a'.repeat(255);+ const maxMultibyte = `${'é'.repeat(127)}a`;+ for (const profile of ['output', 'archive']) {+ assert.equal(validatePortablePath(maxAscii, { profile }), maxAscii);+ assert.equal(validatePortablePath(maxMultibyte, { profile }), maxMultibyte);++ for (const segment of ['a'.repeat(256), 'é'.repeat(128)]) {+ assert.throws(+ () => validatePortablePath(segment, { profile }),+ (error) => {+ assert.ok(error instanceof PortablePathError);+ assert.equal(error.code, 'portable-path/component-too-long');+ assert.equal(error.reason, 'component-too-long');+ assert.equal(error.profile, profile);+ assert.equal(error.segment, segment);+ assert.ok(error.utf8Bytes > 255 || error.utf16CodeUnits > 255);+ assert.equal(error.limit, 255);+ return true;+ },+ );+ }+ }++ const descriptiveRepoPath = `sources/${'a'.repeat(256)}`;+ assert.equal(+ validatePortablePath(descriptiveRepoPath, { profile: 'repo' }),+ descriptiveRepoPath,+ );+});++test('portable path sets return the source array when all entries remain distinct', () => {+ const values = ['docs/Architecture.md', 'docs/architecture-v2.md', 'assets/logo.svg'];+ assert.equal(validatePortablePathSet(values, { profile: 'archive' }), values);+});++test('portable path sets preserve the invalid Windows short-name entry index', () => {+ assertPathError(+ () => validatePortablePathSet(+ ['docs/readme.md', 'fixtures/PROGRA~1/report.html'],+ { profile: 'archive' },+ ),+ {+ code: 'portable-path/windows-short-name',+ reason: 'windows-short-name',+ profile: 'archive',+ index: 1,+ },+ );+});++test('portable path sets reject exact duplicates with both source positions', () => {+ assertPathError(+ () => validatePortablePathSet(['docs/readme.md', 'docs/readme.md'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'duplicate',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets conservatively reject case collisions', () => {+ assertPathError(+ () => validatePortablePathSet(['Docs/Readme.md', 'docs/readme.md'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'case',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets reject case collisions found only by uppercase folding', () => {+ assertPathError(+ () => validatePortablePathSet(['docs/σ.md', 'docs/ς.md'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'case',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets reject case-aliased directory prefixes', () => {+ assert.throws(+ () => validatePortablePathSet(['Docs/one.txt', 'docs/two.txt'], { profile: 'archive' }),+ (error) => {+ assert.ok(error instanceof PortablePathError);+ assert.equal(error.code, 'portable-path/collision');+ assert.equal(error.reason, 'directory-case');+ assert.equal(error.collisionKind, 'directory-spelling');+ assert.equal(error.semantics, 'case');+ assert.equal(error.index, 1);+ assert.equal(error.conflictIndex, 0);+ assert.equal(error.pathPart, 'docs');+ assert.equal(error.conflictPathPart, 'Docs');+ return true;+ },+ );+});++test('portable path sets reject normalization-aliased directory prefixes', () => {+ assertPathError(+ () => validatePortablePathSet(['café/one.txt', 'cafe\u0301/two.txt'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'directory-normalization',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets allow exact shared directory prefixes', () => {+ const values = ['docs/one.txt', 'docs/nested/two.txt', 'docs/nested/three.txt'];+ assert.equal(validatePortablePathSet(values, { profile: 'archive' }), values);+});++test('portable path sets reject file and directory tree conflicts in either order', () => {+ for (const values of [+ ['docs', 'DOCS/a.txt'],+ ['DOCS/a.txt', 'docs'],+ ]) {+ assert.throws(+ () => validatePortablePathSet(values, { profile: 'archive' }),+ (error) => {+ assert.ok(error instanceof PortablePathError);+ assert.equal(error.code, 'portable-path/collision');+ assert.equal(error.reason, 'tree-file-case');+ assert.equal(error.collisionKind, 'tree-file');+ assert.equal(error.semantics, 'case');+ assert.equal(error.index, 1);+ assert.equal(error.conflictIndex, 0);+ return true;+ },+ );+ }++ assertPathError(+ () => validatePortablePathSet(['docs', 'docs/a.txt'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'tree-file',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets conservatively reject canonical Unicode normalization collisions', () => {+ assertPathError(+ () => validatePortablePathSet(['docs/café.md', 'docs/cafe\u0301.md'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'normalization',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets report collisions that require both case folding and normalization', () => {+ assertPathError(+ () => validatePortablePathSet(['docs/Résumé.md', 'docs/re\u0301sume\u0301.md'], { profile: 'archive' }),+ {+ code: 'portable-path/collision',+ reason: 'case-and-normalization',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets close Unicode normalization and case transforms to a fixed point', () => {+ assertPathError(+ () => validatePortablePathSet(+ ['docs/\u0390.md', 'docs/\u0399\u0308\u0301.md'],+ { profile: 'archive' },+ ),+ {+ code: 'portable-path/collision',+ reason: 'case',+ profile: 'archive',+ index: 1,+ conflictIndex: 0,+ },+ );+});++test('portable path sets close Unicode directory-prefix transforms to a fixed point', () => {+ assert.throws(+ () => validatePortablePathSet(+ ['root/\u0390/one.txt', 'root/\u0399\u0308\u0301/two.txt'],+ { profile: 'archive' },+ ),+ (error) => {+ assert.ok(error instanceof PortablePathError);+ assert.equal(error.code, 'portable-path/collision');+ assert.equal(error.reason, 'directory-case');+ assert.equal(error.collisionKind, 'directory-spelling');+ assert.equal(error.semantics, 'case');+ assert.equal(error.index, 1);+ assert.equal(error.conflictIndex, 0);+ assert.equal(error.pathPart, 'root/\u0399\u0308\u0301');+ assert.equal(error.conflictPathPart, 'root/\u0390');+ return true;+ },+ );+});++test('portable path set errors preserve the invalid entry index', () => {+ assertPathError(+ () => validatePortablePathSet(['docs/readme.md', '../escape.md'], { profile: 'archive' }),+ {+ code: 'portable-path/dot-segment',+ reason: 'dot-segment',+ profile: 'archive',+ index: 1,+ },+ );+});diff --git a/archify/test/preview.test.mjs b/archify/test/preview.test.mjsindex 07961f50..43801146 100644--- a/archify/test/preview.test.mjs+++ b/archify/test/preview.test.mjs@@ -47,6 +47,29 @@ function windowsShortPath(targetPath) {return shortPath;}+function controlledWindowsShortRoot(required) {+ const root = process.env.ARCHIFY_WINDOWS_8DOT3_ROOT;+ const shortRoot = process.env.ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT;+ if (!root && !shortRoot) {+ if (required) {+ assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires the controlled long and short roots');+ }+ return null;+ }+ assert.ok(root && shortRoot, 'the controlled Windows 8.3 roots must be configured together');+ assert.match(+ path.win32.basename(shortRoot),+ /~/u,+ 'the controlled short root must use an explicit 8.3 alias',+ );+ assert.equal(+ fs.realpathSync.native(root).toLowerCase(),+ fs.realpathSync.native(shortRoot).toLowerCase(),+ 'the controlled long and short roots must identify the same directory',+ );+ return { root, shortRoot };+}+async function stateAt(url) {const response = await fetch(new URL('/state', url));assert.equal(response.status, 200);@@ -84,6 +107,31 @@ function rawRequest(url, { method = 'GET', pathname = '/', hostHeader } = {}) {});}+async function waitForPath(target, message, timeoutMs = 3000) {+ const started = Date.now();+ while (!fs.existsSync(target) && Date.now() - started < timeoutMs) {+ await new Promise((resolve) => setTimeout(resolve, 20));+ }+ assert.ok(fs.existsSync(target), message);+}++function writeDelayedDeliveryCli(deliveryCli, marker, title) {+ fs.writeFileSync(deliveryCli, `+import { createHash } from 'node:crypto';+import fs from 'node:fs';+const [, , , output] = process.argv.slice(2);+fs.writeFileSync(${JSON.stringify(marker)}, 'ready');+await new Promise((resolve) => setTimeout(resolve, 220));+const artifact = Buffer.from(${JSON.stringify(`<!doctype html><title>${title}</title><svg></svg>`)});+fs.writeFileSync(output, artifact);+console.log(JSON.stringify({+ ok: true,+ artifact: { sha256: createHash('sha256').update(artifact).digest('hex'), bytes: artifact.byteLength },+ validation: { checksPassed: 1, checkCount: 1, compositionProfile: 'showcase', compositionStatus: 'pass' }+}));+`);+}+test('preview: rejects destructive or unsupported startup targets before watching', async () => {const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-startup-'));const input = path.join(tmp, 'diagram.json');@@ -394,6 +442,518 @@ console.log(JSON.stringify({}});+test('preview: an in-place content change to the staged commit candidate is not published', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-candidate-content-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ fs.writeFileSync(input, '{}');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Candidate content binding');++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ const writeFileSync = fs.writeFileSync;+ let candidatePath;+ let modified = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-preview-commit-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!modified && candidatePath && path.resolve(target) === output) {+ const before = fs.statSync(candidatePath, { bigint: true });+ writeFileSync(candidatePath, '<!doctype html><title>same inode claimant</title>');+ const after = fs.statSync(candidatePath, { bigint: true });+ assert.equal(after.dev, before.dev);+ assert.equal(after.ino, before.ino);+ modified = true;+ }+ return lstatSync(target, ...args);+ });++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'candidate content change did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.equal(state.failure.evidence.relation.code, 'candidate-content-changed');+ assert.equal(modified, true);+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(fs.readdirSync(tmp).filter((name) => name.startsWith('.archify-preview-commit-')), []);+ } finally {+ await preview.stop();+ }+});++test('preview: an in-place mode change to the staged commit candidate is not published', { timeout: 10000 }, async (t) => {+ if (process.platform === 'win32') {+ t.skip('POSIX candidate mode regression');+ return;+ }+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-candidate-mode-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ fs.writeFileSync(input, '{}');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Candidate mode binding');++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ let candidatePath;+ let modified = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-preview-commit-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!modified && candidatePath && path.resolve(target) === output) {+ const before = fs.statSync(candidatePath, { bigint: true });+ fs.chmodSync(candidatePath, Number(before.mode & 0o777n) ^ 0o111);+ const after = fs.statSync(candidatePath, { bigint: true });+ assert.equal(after.dev, before.dev);+ assert.equal(after.ino, before.ino);+ assert.notEqual(after.mode & 0o777n, before.mode & 0o777n);+ modified = true;+ }+ return lstatSync(target, ...args);+ });++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'candidate mode change did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.equal(state.failure.evidence.relation.code, 'candidate-mode-changed');+ assert.equal(modified, true);+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(fs.readdirSync(tmp).filter((name) => name.startsWith('.archify-preview-commit-')), []);+ } finally {+ await preview.stop();+ }+});++test('preview: replacing the staged commit candidate preserves the claimant', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-candidate-replacement-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const detachedCandidate = path.join(tmp, 'detached-preview-candidate.html');+ const sentinel = '<!doctype html><title>preview claimant must survive</title>';+ fs.writeFileSync(input, '{}');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Candidate identity binding');++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ const writeFileSync = fs.writeFileSync;+ let candidatePath;+ let replaced = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-preview-commit-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!replaced && candidatePath && path.resolve(target) === output) {+ fs.renameSync(candidatePath, detachedCandidate);+ writeFileSync(candidatePath, sentinel);+ replaced = true;+ }+ return lstatSync(target, ...args);+ });++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'candidate replacement did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.equal(state.failure.evidence.relation.code, 'candidate-identity-changed');+ assert.equal(replaced, true);+ assert.equal(fs.existsSync(output), false);+ assert.equal(fs.readFileSync(candidatePath, 'utf8'), sentinel);+ assert.equal(fs.existsSync(detachedCandidate), true);+ } finally {+ await preview.stop();+ }+});++test('preview: a delivery candidate replaced by a symlink is rejected without following it', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-source-symlink-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const claimant = path.join(tmp, 'claimant.html');+ const probe = path.join(tmp, 'symlink-probe');+ const sentinel = '<!doctype html><title>external symlink claimant</title>';+ fs.writeFileSync(input, '{}');+ fs.writeFileSync(claimant, sentinel);+ try {+ fs.symlinkSync(claimant, probe, process.platform === 'win32' ? 'file' : undefined);+ fs.unlinkSync(probe);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip(`file aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not follow replacement');++ const lstatSync = fs.lstatSync;+ let replaced = false;+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!replaced+ && path.basename(target) === 'generation-1.html'+ && fs.existsSync(target)) {+ fs.renameSync(target, `${target}.detached`);+ fs.symlinkSync(claimant, target, process.platform === 'win32' ? 'file' : undefined);+ replaced = true;+ }+ return lstatSync(target, ...args);+ });++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'symlink delivery candidate did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-not-regular-file');+ assert.equal(state.failure.evidence.relation.code, 'candidate-not-regular-file');+ assert.equal(state.failure.evidence.relation.entryType, 'symbolic-link');+ assert.equal(replaced, true);+ assert.equal(fs.existsSync(output), false);+ } finally {+ await preview.stop();+ }+ assert.equal(fs.readFileSync(claimant, 'utf8'), sentinel);+});++test('preview: a delivery candidate replaced by a FIFO is rejected without blocking', { timeout: 10000 }, async (t) => {+ if (process.platform === 'win32') {+ t.skip('FIFO files are unavailable on Windows');+ return;+ }+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-source-fifo-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ fs.writeFileSync(input, '{}');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not read FIFO replacement');++ const lstatSync = fs.lstatSync;+ let replaced = false;+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!replaced+ && path.basename(target) === 'generation-1.html'+ && fs.existsSync(target)) {+ fs.renameSync(target, `${target}.detached`);+ const created = spawnSync('mkfifo', [target], { encoding: 'utf8' });+ assert.equal(created.status, 0, created.stderr || created.error?.message);+ replaced = true;+ }+ return lstatSync(target, ...args);+ });++ const startedAt = Date.now();+ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'FIFO delivery candidate did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-not-regular-file');+ assert.equal(state.failure.evidence.relation.code, 'candidate-not-regular-file');+ assert.equal(state.failure.evidence.relation.entryType, 'fifo');+ assert.equal(replaced, true);+ assert.ok(Date.now() - startedAt < 5000, 'preview blocked while inspecting a FIFO replacement');+ assert.equal(fs.existsSync(output), false);+ } finally {+ await preview.stop();+ }+});++test('preview: publishing through an existing output symlink preserves the link and updates its target', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-symlink-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const target = path.join(tmp, 'target.html');+ const output = path.join(tmp, 'linked.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ fs.writeFileSync(input, '{}');+ fs.writeFileSync(target, '<!doctype html><title>Previous target</title>');+ try {+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`file aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ writeDelayedDeliveryCli(deliveryCli, marker, 'Published through symlink');+ const physicalTarget = fs.realpathSync.native(target);+ const renameSync = fs.renameSync;+ let commits = 0;+ t.mock.method(fs, 'renameSync', (source, destination) => {+ if (path.resolve(destination) === physicalTarget) {+ commits += 1;+ assert.equal(path.dirname(source), path.dirname(physicalTarget));+ assert.match(path.basename(source), /^\.archify-preview-commit-/);+ }+ return renameSync(source, destination);+ });++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ await waitForState(preview.url, (state) => state.status === 'verified', 'symlinked preview did not verify');+ assert.equal(commits, 1);+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.match(fs.readFileSync(target, 'utf8'), /Published through symlink/);+ } finally {+ await preview.stop();+ }+});++test('preview: cleanup stays bound to the physical output parent after a directory alias is redirected', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-cleanup-alias-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const first = path.join(tmp, 'first');+ const second = path.join(tmp, 'second');+ const alias = path.join(tmp, 'output-alias');+ const input = path.join(tmp, 'diagram.json');+ fs.mkdirSync(first);+ fs.mkdirSync(second);+ fs.writeFileSync(input, '{}');+ try {+ fs.symlinkSync(first, alias, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip(`directory aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }++ const preview = await startPreview({+ type: 'architecture', input, output: path.join(alias, 'diagram.html'), open: false, watch: false, pollMs: 60_000,+ });+ const stagingName = fs.readdirSync(first).find((name) => name.startsWith('.archify-preview-'));+ assert.ok(stagingName, 'preview did not create its private staging directory');+ const originalStaging = path.join(first, stagingName);+ const decoyStaging = path.join(second, stagingName);+ const sentinel = path.join(decoyStaging, 'claimant.txt');+ try {+ fs.unlinkSync(alias);+ fs.symlinkSync(second, alias, process.platform === 'win32' ? 'junction' : 'dir');+ fs.mkdirSync(decoyStaging);+ fs.writeFileSync(sentinel, 'preserve claimant');+ } finally {+ await preview.stop();+ }++ assert.equal(fs.existsSync(originalStaging), false, 'owned physical staging directory was not removed');+ assert.equal(fs.readFileSync(sentinel, 'utf8'), 'preserve claimant');+});++test('preview: publishing through a dangling output symlink creates its target without replacing the link', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-dangling-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const target = path.join(tmp, 'future-target.html');+ const output = path.join(tmp, 'linked.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ fs.writeFileSync(input, '{}');+ try {+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`file aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ writeDelayedDeliveryCli(deliveryCli, marker, 'Published through dangling symlink');++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ await waitForState(preview.url, (state) => state.status === 'verified', 'dangling symlink preview did not verify');+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.match(fs.readFileSync(target, 'utf8'), /Published through dangling symlink/);+ } finally {+ await preview.stop();+ }+});++test('preview: recreating an output symlink to the same target fails the commit', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-recreated-symlink-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const target = path.join(tmp, 'target.html');+ const output = path.join(tmp, 'linked.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const previous = '<!doctype html><title>Previous target</title>';+ fs.writeFileSync(input, '{}');+ fs.writeFileSync(target, previous);+ try {+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`file aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not publish');++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ await waitForPath(marker, 'fake delivery did not start');+ fs.unlinkSync(output);+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'recreated symlink did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.equal(state.failure.evidence.relation.code, 'requested-entry-changed');+ assert.match(state.failure.message, /requested-entry-changed/);+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.readFileSync(target, 'utf8'), previous);+ } finally {+ await preview.stop();+ }+});++test('preview: a concurrently claimed absent output is preserved and fails the commit', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-claim-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const claimant = '<!doctype html><title>Concurrent claimant</title>';+ fs.writeFileSync(input, '{}');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not publish');++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ await waitForPath(marker, 'fake delivery did not start');+ fs.writeFileSync(output, claimant);+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'output claim did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.match(state.failure.message, /requested-entry-changed|target-existence-changed|write-slot-changed/);+ assert.equal(fs.readFileSync(output, 'utf8'), claimant);+ } finally {+ await preview.stop();+ }+});++test('preview: a concurrent replacement of an existing output is preserved and fails the commit', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-replacement-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const detached = path.join(tmp, 'detached-original.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const replacement = '<!doctype html><title>Concurrent replacement</title>';+ fs.writeFileSync(input, '{}');+ fs.writeFileSync(output, '<!doctype html><title>Original output</title>');+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not publish');++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ await waitForPath(marker, 'fake delivery did not start');+ fs.renameSync(output, detached);+ fs.writeFileSync(output, replacement);+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'output replacement did not fail preview');+ assert.equal(state.failure.stage, 'commit');+ assert.equal(state.failure.code, 'output/target-changed');+ assert.match(state.failure.message, /requested-entry-changed|target-identity-changed/);+ assert.equal(fs.readFileSync(output, 'utf8'), replacement);+ } finally {+ await preview.stop();+ }+});++test('preview: a hardlinked existing output is unsupported before delivery starts', { timeout: 10000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-output-hardlink-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.json');+ const output = path.join(tmp, 'diagram.html');+ const alias = path.join(tmp, 'diagram-alias.html');+ const deliveryCli = path.join(tmp, 'delivery.mjs');+ const marker = path.join(tmp, 'delivery-started');+ const previous = '<!doctype html><title>Hardlinked output</title>';+ fs.writeFileSync(input, '{}');+ fs.writeFileSync(output, previous);+ try {+ fs.linkSync(output, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ writeDelayedDeliveryCli(deliveryCli, marker, 'Must not publish');++ const preview = await startPreview({+ type: 'architecture', input, output, open: false, watch: false, pollMs: 60_000, debounceMs: 10, deliveryCli,+ });+ try {+ const state = await waitForState(preview.url, (candidate) => candidate.status === 'needs-fix', 'hardlinked output was not rejected');+ assert.equal(state.failure.stage, 'prepare');+ assert.equal(state.failure.code, 'output/target-hardlinked');+ assert.equal(state.failure.evidence.relation.code, 'target-hardlinked');+ assert.match(state.failure.message, /multiple hard-link names/);+ assert.equal(fs.existsSync(marker), false);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.readFileSync(alias, 'utf8'), previous);+ } finally {+ await preview.stop();+ }+});+test('preview: stopping drains an active delivery without publishing it', { timeout: 30000 }, async () => {const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-stop-'));const input = path.join(tmp, 'diagram.json');@@ -558,6 +1118,126 @@ test('preview: polling continues after an asynchronous watcher error', { timeoutawait assert.rejects(fetch(preview.url));});+test('preview: watcher accepts an existing file alias with a different basename', { timeout: 30000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-watch-file-alias-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const input = path.join(tmp, 'diagram.architecture.json');+ const alias = path.join(tmp, 'DIAGRAM~1.JSON');+ const output = path.join(tmp, 'diagram.html');+ const source = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples/web-app.architecture.json'), 'utf8'));+ source.meta.title = 'Watched through original basename';+ fs.writeFileSync(input, JSON.stringify(source));+ fs.linkSync(input, alias);++ const watcher = new EventEmitter();+ watcher.close = () => {};+ let observeWatchEvent;+ t.mock.method(fs, 'watch', (target, listener) => {+ assert.equal(target, fs.realpathSync.native(tmp));+ observeWatchEvent = listener;+ return watcher;+ });++ const preview = await startPreview({+ type: 'architecture',+ input,+ output,+ open: false,+ debounceMs: 20,+ pollMs: 60_000,+ });+ try {+ await waitForState(preview.url, (state) => state.status === 'verified' && state.revision === 1, 'initial artifact did not verify');+ source.meta.title = 'Watcher accepted file alias';+ fs.writeFileSync(alias, JSON.stringify(source));+ observeWatchEvent('change', Buffer.from(path.basename(alias)));+ await waitForState(+ preview.url,+ (state) => state.status === 'verified' && state.revision === 2,+ 'watcher ignored an event for the same file through another basename',+ 5000,+ );+ const artifact = await (await fetch(new URL('/artifact.html', preview.url))).text();+ assert.match(artifact, /Watcher accepted file alias/);++ source.meta.title = 'Watcher accepted unnamed event';+ fs.writeFileSync(input, JSON.stringify(source));+ observeWatchEvent('change', null);+ await waitForState(+ preview.url,+ (state) => state.status === 'verified' && state.revision === 3,+ 'watcher ignored an event without a filename',+ 5000,+ );+ const unnamedArtifact = await (await fetch(new URL('/artifact.html', preview.url))).text();+ assert.match(unnamedArtifact, /Watcher accepted unnamed event/);+ } finally {+ await preview.stop();+ }+});++test('preview: watcher accepts case-variant basenames on a case-insensitive filesystem', { timeout: 30000 }, async (t) => {+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-watch-case-alias-'));+ t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const inputBasename = 'Diagram.Architecture.JSON';+ const eventBasename = inputBasename.toLowerCase();+ const input = path.join(tmp, inputBasename);+ const eventTarget = path.join(tmp, eventBasename);+ const output = path.join(tmp, 'diagram.html');+ const source = JSON.parse(fs.readFileSync(path.join(skillRoot, 'examples/web-app.architecture.json'), 'utf8'));+ source.meta.title = 'Watched with authored case';+ fs.writeFileSync(input, JSON.stringify(source));++ let inputStat;+ let eventStat;+ try {+ inputStat = fs.statSync(input, { bigint: true });+ eventStat = fs.statSync(eventTarget, { bigint: true });+ } catch {+ t.skip('the test volume is case-sensitive');+ return;+ }+ const preservesCase = path.basename(fs.realpathSync.native(input)) === inputBasename;+ if (!preservesCase || inputStat.dev !== eventStat.dev || inputStat.ino !== eventStat.ino) {+ t.skip('the test volume is not case-preserving and case-insensitive');+ return;+ }++ const watcher = new EventEmitter();+ watcher.close = () => {};+ let observeWatchEvent;+ t.mock.method(fs, 'watch', (target, listener) => {+ assert.equal(target, fs.realpathSync.native(tmp));+ observeWatchEvent = listener;+ return watcher;+ });++ const preview = await startPreview({+ type: 'architecture',+ input,+ output,+ open: false,+ debounceMs: 20,+ pollMs: 60_000,+ });+ try {+ await waitForState(preview.url, (state) => state.status === 'verified' && state.revision === 1, 'initial artifact did not verify');+ source.meta.title = 'Watcher accepted case alias';+ fs.writeFileSync(input, JSON.stringify(source));+ observeWatchEvent('change', eventBasename);+ await waitForState(+ preview.url,+ (state) => state.status === 'verified' && state.revision === 2,+ 'watcher ignored a case-variant event for the same file',+ 5000,+ );+ const artifact = await (await fetch(new URL('/artifact.html', preview.url))).text();+ assert.match(artifact, /Watcher accepted case alias/);+ } finally {+ await preview.stop();+ }+});+test('preview: canonical watch target observes edits through a directory alias', { timeout: 30000 }, async (t) => {const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-watch-alias-'));t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));@@ -602,20 +1282,37 @@ test('preview: canonical watch target observes edits through a directory alias',});test('preview: Windows 8.3 short path observes edits through the canonical watcher', { timeout: 30000 }, async (t) => {+ const requiresWindows8dot3 = process.env.ARCHIFY_REQUIRE_WINDOWS_8DOT3 === '1';if (process.platform !== 'win32') {+ if (requiresWindows8dot3) {+ assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires a Windows test lane');+ }t.skip('Windows-only 8.3 path regression');return;}- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-eight-dot-three-'));+ const controlledRoot = controlledWindowsShortRoot(requiresWindows8dot3);+ const tmp = controlledRoot+ ? fs.mkdtempSync(path.join(controlledRoot.root, 'preview-'))+ : fs.mkdtempSync(path.join(os.tmpdir(), 'archify-preview-eight-dot-three-'));t.after(() => fs.rmSync(tmp, { recursive: true, force: true }));+ const shortTmp = controlledRoot+ ? path.win32.join(controlledRoot.shortRoot, path.basename(tmp))+ : null;const realDirectory = path.join(tmp, 'directory name requiring short alias');fs.mkdirSync(realDirectory);- const shortDirectory = windowsShortPath(realDirectory);+ const shortDirectory = shortTmp+ ? path.win32.join(shortTmp, path.basename(realDirectory))+ : windowsShortPath(realDirectory);if (!shortDirectory) {t.skip('the Windows volume does not expose a distinct 8.3 short path');return;}+ assert.equal(+ fs.realpathSync.native(shortDirectory).toLowerCase(),+ fs.realpathSync.native(realDirectory).toLowerCase(),+ 'the 8.3 input directory must resolve through the controlled explicit alias',+ );const realInput = path.join(realDirectory, 'diagram.architecture.json');const shortInput = path.join(shortDirectory, 'diagram.architecture.json');diff --git a/archify/test/readme-showcase.test.mjs b/archify/test/readme-showcase.test.mjsindex 82676f4a..8a23d327 100644--- a/archify/test/readme-showcase.test.mjs+++ b/archify/test/readme-showcase.test.mjs@@ -91,6 +91,7 @@ function inspectGif(buffer) {test('README motion proof is compact, looping, and backed by current gallery artifacts', () => {const builder = fs.readFileSync(path.join(repoRoot, 'scripts', 'build-readme-showcase.mjs'), 'utf8');assert.match(builder, /\?embed=1&play=1&theme=dark#view=/);+ assert.match(builder, /path\.relative\(from, to\)\.split\(path\.sep\)\.join\('\/'\)/);const buffer = fs.readFileSync(assetPath);const receipt = JSON.parse(fs.readFileSync(receiptPath, 'utf8'));const inspected = inspectGif(buffer);diff --git a/archify/test/release-package-gates.test.mjs b/archify/test/release-package-gates.test.mjsindex e1d7d24a..71cd9937 100644--- a/archify/test/release-package-gates.test.mjs+++ b/archify/test/release-package-gates.test.mjs@@ -4,7 +4,7 @@ import { spawnSync } from 'node:child_process';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';-import { fileURLToPath } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';import { stageCleanSkill } from '../../scripts/stage-clean-skill.mjs';@@ -36,6 +36,27 @@ function spawnBuildZip(outputPath, options = {}) {return spawnSync(script, [outputPath], { cwd, encoding: 'utf8', ...rest });}+function preparePackageIndex(indexPath, extraPaths) {+ const env = { ...process.env, GIT_INDEX_FILE: indexPath };+ let result = spawnSync('git', ['read-tree', 'HEAD'], { cwd: repoRoot, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.stderr);+ result = spawnSync('git', ['rev-parse', 'HEAD:archify/LICENSE'], {+ cwd: repoRoot,+ encoding: 'utf8',+ });+ assert.equal(result.status, 0, result.stderr);+ const blob = result.stdout.trim();+ for (const relative of extraPaths) {+ result = spawnSync('git', [+ '-c', 'core.protectNTFS=false',+ '-c', 'core.protectHFS=false',+ 'update-index', '--add', '--cacheinfo', '100644', blob, relative,+ ], { cwd: repoRoot, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.stderr);+ }+ return env;+}+function workflowStep(workflow, name) {const marker = ` - name: ${name}`;const start = workflow.indexOf(marker);@@ -390,6 +411,10 @@ test('archive build refuses to silently omit required release files', () => {assert.match(stageSource, /archify\/LICENSE/);assert.match(stageSource, /archify\/THIRD_PARTY_NOTICES\.md/);assert.match(stageSource, /archify\/skill-release\.json/);+ assert.match(stageSource, /archify\/renderers\/shared\/path-semantics\.mjs/);+ assert.match(stageSource, /archify\/renderers\/shared\/portable-path\.mjs/);+ assert.match(stageSource, /archify\/renderers\/shared\/output-path\.mjs/);+ assert.match(stageSource, /archify\/renderers\/shared\/atomic-output\.mjs/);assert.match(stageSource, /archify\/scripts\/check-update\.mjs/);assert.match(stageSource, /archify\/scripts\/update-contract\.mjs/);assert.match(stageSource, /git', \['ls-files', '--stage', '-z'/);@@ -397,6 +422,167 @@ test('archive build refuses to silently omit required release files', () => {assert.match(stageSource, /required repository input is not tracked by Git/);});+test('clean package staging rejects non-portable tracked names and entry collisions before copying', () => {+ const cases = [+ {+ paths: ['archify/portable-gate/CON.txt'],+ code: 'portable-path/windows-reserved-name',+ },+ {+ paths: ['archify/portable-gate/Docs/one.txt', 'archify/portable-gate/docs/two.txt'],+ code: 'portable-path/collision',+ },+ {+ paths: [`archify/portable-gate/${'a'.repeat(256)}`],+ code: 'portable-path/component-too-long',+ },+ ];++ for (const { paths, code } of cases) {+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-package-portable-index-'));+ const destination = path.join(fixture, 'staged');+ const env = preparePackageIndex(path.join(fixture, 'index'), paths);+ const previousIndex = process.env.GIT_INDEX_FILE;+ try {+ process.env.GIT_INDEX_FILE = env.GIT_INDEX_FILE;+ assert.throws(+ () => stageCleanSkill({ repoRoot, destination }),+ (error) => error?.code === code,+ );+ assert.equal(fs.existsSync(destination), false, 'portable-name rejection must precede staging writes');+ } finally {+ if (previousIndex === undefined) delete process.env.GIT_INDEX_FILE;+ else process.env.GIT_INDEX_FILE = previousIndex;+ fs.rmSync(fixture, { recursive: true, force: true });+ }+ }+});++test('archive build rejects unsafe native output paths before creating files', () => {+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-package-output-path-'));+ try {+ const cases = [+ ['C:drive-relative.zip', /\(drive-relative\)/],+ ['\\current-drive-rooted.zip', /\(current-drive-rooted\)/],+ [String.raw`\\.\C:\device.zip`, /\(windows-device-namespace\)/],+ [String.raw`//./C:/device.zip`, /\((?:current-drive-rooted|windows-device-namespace)\)/],+ [String.raw`\\?\GLOBALROOT\Device\HarddiskVolume1\archive.zip`, /\(windows-device-namespace\)/],+ [String.raw`//?/GLOBALROOT/Device/HarddiskVolume1/archive.zip`, /\((?:current-drive-rooted|windows-extended-root)\)/],+ [String.raw`\\?\Device\HarddiskVolume1\archive.zip`, /\(windows-device-namespace\)/],+ [String.raw`\\?\PIPE\archive.zip`, /\(windows-extended-root\)/],+ [String.raw`\\?\foo.zip`, /\(windows-extended-root\)/],+ [String.raw`\\?\Volume{00000000-0000-0000-0000-000000000000}\archive.zip`, /\(windows-extended-root\)/],+ [String.raw`\\?\UNC\server`, /\(windows-extended-root\)/],+ [String.raw`\\?\C:/archive.zip`, /\(windows-extended-separator\)/],+ [String.raw`\\?\C:\folder\..\archive.zip`, /\(dot-segment\)/],+ [String.raw`\\server.zip`, /\(windows-unc-root\)/],+ [String.raw`\\`, /\(trailing-separator\)/],+ [String.raw`\\\share\archive.zip`, /\(windows-unc-root\)/],+ [String.raw`\\server\\archive.zip`, /\(windows-unc-root\)/],+ [String.raw`\\server/share/archive.zip`, /\(windows-unc-root\)/],+ [String.raw`archive.zip:stream`, /\(windows-ads\)/],+ [String.raw`folder\safe.zip:stream`, /\(windows-ads\)/],+ [String.raw`folder\CON.zip`, /\(windows-reserved-name\)/],+ [String.raw`folder\NUL.zip`, /\(windows-reserved-name\)/],+ [String.raw`folder.\archive.zip`, /\(windows-trailing-dot-space\)/],+ [String.raw`folder \archive.zip`, /\(windows-trailing-dot-space\)/],+ [String.raw`archive.zip/`, /\(trailing-separator\)/],+ ['folder\\archive.zip\\', /\(trailing-separator\)/],+ [String.raw`bad<name.zip`, /\(windows-invalid-character\)/],+ [String.raw`bad|name.zip`, /\(windows-invalid-character\)/],+ [`folder\\${'x'.repeat(256)}.zip`, /\(component-too-long\)/],+ ];+ for (const [output, expectedReason] of cases) {+ const build = spawnBuildZip(output, { cwd: fixture });+ assert.equal(build.status, 2, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /archive output is not a valid native filesystem path/);+ assert.match(build.stderr, expectedReason);+ assert.deepEqual(fs.readdirSync(fixture), [], 'a rejected output spelling must not create files');+ }+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive output grammar is owned by the shared native-path validator', () => {+ const buildSource = fs.readFileSync(path.join(repoRoot, 'scripts', 'build-zip.sh'), 'utf8');+ const writerSource = fs.readFileSync(+ path.join(repoRoot, 'scripts', 'write-deterministic-zip.mjs'),+ 'utf8',+ );+ assert.doesNotMatch(buildSource, /windows_(?:drive|current|device|extended|dot|unc)/);+ assert.match(writerSource, /import \{ validateNativeOutputPath \} from/);+ assert.equal(writerSource.match(/kind: 'file'/gu)?.length, 2);+ assert.ok(+ writerSource.indexOf('validateNativeOutputPath(') < writerSource.indexOf('path.resolve(outputArg)'),+ 'the raw output spelling must be validated before it is normalized or any archive write begins',+ );+ const validationOnly = buildSource.indexOf('--validate-output "$out"');+ const nodeMajorGate = buildSource.indexOf('node_version=');+ assert.notEqual(validationOnly, -1, 'the archive build must invoke the writer path-only validation mode');+ assert.notEqual(nodeMajorGate, -1, 'the archive build must retain its canonical Node-major gate');+ assert.ok(+ validationOnly < nodeMajorGate,+ 'raw output validation must run before the canonical Node-major gate',+ );+});++test('archive build keeps unsafe-path diagnostics ahead of the canonical Node gate', {+ skip: process.platform === 'win32' ? 'the POSIX node shim is unnecessary on the real Windows Node 24 lane' : false,+}, () => {+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-package-node-gate-order-'));+ const shimDirectory = path.join(fixture, 'bin');+ const nodeShim = path.join(shimDirectory, 'node');+ fs.mkdirSync(shimDirectory);+ fs.writeFileSync(nodeShim, `#!/usr/bin/env bash+if [[ "$1" == "-p" && "$2" == "process.versions.node" ]]; then+ printf '%s\\n' '24.0.0'+ exit 0+fi+exec "$ARCHIFY_REAL_NODE" "$@"+`);+ fs.chmodSync(nodeShim, 0o755);+ const env = {+ ...process.env,+ ARCHIFY_REAL_NODE: process.execPath,+ PATH: `${shimDirectory}${path.delimiter}${process.env.PATH || ''}`,+ };+ try {+ const unsafe = spawnBuildZip('C:drive-relative.zip', { cwd: fixture, env });+ assert.equal(unsafe.status, 2, `${unsafe.stdout}\n${unsafe.stderr}`);+ assert.match(unsafe.stderr, /archive output is not a valid native filesystem path \(drive-relative\)/);++ const safeParent = path.join(fixture, 'missing-parent');+ const safeOutput = path.join(safeParent, 'safe.zip');+ const safe = spawnBuildZip(safeOutput, { cwd: fixture, env });+ assert.equal(safe.status, 1, `${safe.stdout}\n${safe.stderr}`);+ assert.match(safe.stderr, /canonical archify[.]zip builds require Node 22 \(current: 24[.]0[.]0\)/);+ assert.equal(fs.existsSync(safeOutput), false);+ assert.equal(fs.existsSync(safeParent), false, 'path-only validation must not create output parents');+ assert.deepEqual(fs.readdirSync(fixture).sort(), ['bin']);+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive output rejection preserves an existing unsafe target byte-for-byte', {+ skip: process.platform === 'win32' ? 'Windows cannot create the reserved-name fixture' : false,+}, () => {+ const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-package-output-preserve-'));+ const output = path.join(fixture, 'CON.zip');+ const sentinel = Buffer.from('existing archive sentinel\n');+ try {+ fs.writeFileSync(output, sentinel);+ const build = spawnBuildZip(output, { cwd: fixture });+ assert.equal(build.status, 2, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /archive output is not a valid native filesystem path/);+ assert.ok(fs.readFileSync(output).equals(sentinel));+ assert.deepEqual(fs.readdirSync(fixture), ['CON.zip']);+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});+canonicalZipTest('package smoke rejects every dependency metadata field in a built package', () => {const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-built-package-gate-'));try {@@ -450,6 +636,7 @@ canonicalZipTest('built archives contain the embedded notifier runtime', () => {assert.ok(entries.has('archify/skill-release.json'));assert.ok(entries.has('archify/scripts/check-update.mjs'));assert.ok(entries.has('archify/scripts/update-contract.mjs'));+ assert.ok(entries.has('archify/renderers/shared/atomic-output.mjs'));} finally {fs.rmSync(fixture, { recursive: true, force: true });}@@ -513,6 +700,22 @@ canonicalZipTest('archive build rejects an unmerged index and preserves an existpath.join(repoRoot, 'scripts', 'third-party-notices-contract.mjs'),path.join(scripts, 'third-party-notices-contract.mjs'),);+ fs.copyFileSync(+ path.join(repoRoot, 'archify', 'renderers', 'shared', 'portable-path.mjs'),+ path.join(skill, 'renderers', 'shared', 'portable-path.mjs'),+ );+ fs.copyFileSync(+ path.join(repoRoot, 'archify', 'renderers', 'shared', 'path-semantics.mjs'),+ path.join(skill, 'renderers', 'shared', 'path-semantics.mjs'),+ );+ fs.copyFileSync(+ path.join(repoRoot, 'archify', 'renderers', 'shared', 'output-path.mjs'),+ path.join(skill, 'renderers', 'shared', 'output-path.mjs'),+ );+ fs.copyFileSync(+ path.join(repoRoot, 'archify', 'renderers', 'shared', 'atomic-output.mjs'),+ path.join(skill, 'renderers', 'shared', 'atomic-output.mjs'),+ );fs.writeFileSync(path.join(skill, 'renderers', 'shared', 'generated-validators.mjs'), 'export default {};\n');fs.writeFileSync(path.join(skill, 'scripts', 'check-update.mjs'), 'export {};\n');fs.writeFileSync(path.join(skill, 'scripts', 'update-contract.mjs'), 'export {};\n');@@ -611,21 +814,15 @@ test('archive build accepts Windows-style absolute output paths', {const outputRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-package-windows-path-'));const backslashArchive = path.win32.join(outputRoot, 'backslash.zip');const slashArchive = path.win32.join(outputRoot, 'slash.zip').replace(/\\/g, '/');- // The \\.\ device-namespace form is a \\-prefixed absolute path like a UNC- // share: MSYS passes it to bash unchanged from a native parent and Node- // resolves it natively. A real network share cannot be assumed in the suite,- // and the \\?\ extended-length prefix is stripped by MSYS's command-line- // parsing when bash is started from a native process.- const deviceArchive = `\\\\.\\${path.win32.join(outputRoot, 'device.zip')}`;try {- for (const archive of [backslashArchive, slashArchive, deviceArchive]) {+ for (const archive of [backslashArchive, slashArchive]) {const build = spawnBuildZip(archive);assert.equal(build.status, 0, `${build.stdout}\n${build.stderr}`);assert.ok(fs.existsSync(archive), `archive must be written to the requested path: ${archive}`);}const reference = fs.readFileSync(backslashArchive);- for (const archive of [slashArchive, deviceArchive]) {+ for (const archive of [slashArchive]) {assert.ok(reference.equals(fs.readFileSync(archive)),`every Windows path form must produce identical archive bytes: ${archive}`,@@ -633,7 +830,7 @@ test('archive build accepts Windows-style absolute output paths', {}assert.deepEqual(fs.readdirSync(outputRoot).sort(),- ['backslash.zip', 'device.zip', 'slash.zip'],+ ['backslash.zip', 'slash.zip'],'successful archive publication must not leave temporary files behind',);} finally {@@ -660,10 +857,10 @@ function centralDirectoryModes(archive) {return modes;}-function writeArchive(stagedRoot, archive, modeManifest) {+function writeArchive(stagedRoot, archive, modeManifest, options = {}) {const args = [path.join(repoRoot, 'scripts', 'write-deterministic-zip.mjs'), stagedRoot, archive];if (modeManifest !== null) args.push('--mode-manifest', modeManifest);- return spawnSync(process.execPath, args, { encoding: 'utf8' });+ return spawnSync(process.execPath, args, { encoding: 'utf8', ...options });}function stagedFixture(files) {@@ -744,6 +941,371 @@ test('archive writer fails closed when the mode manifest and the staged tree dis}});+test('archive writer rejects existing and dangling output symlinks without mutation', (t) => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ try {+ const external = path.join(fixture, 'external.zip');+ const sentinel = Buffer.from('external sentinel\n');+ fs.writeFileSync(external, sentinel);++ const linked = path.join(fixture, 'linked.zip');+ try {+ fs.symlinkSync(external, linked, process.platform === 'win32' ? 'file' : undefined);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ t.skip(`file symlinks unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ let build = writeArchive(staged, linked, manifest);+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /requested-entry-symbolic-link/);+ assert.equal(fs.lstatSync(linked).isSymbolicLink(), true);+ assert.ok(fs.readFileSync(external).equals(sentinel));++ const dangling = path.join(fixture, 'dangling.zip');+ const missing = path.join(fixture, 'missing.zip');+ fs.symlinkSync(missing, dangling, process.platform === 'win32' ? 'file' : undefined);+ build = writeArchive(staged, dangling, manifest);+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /requested-entry-symbolic-link/);+ assert.equal(fs.lstatSync(dangling).isSymbolicLink(), true);+ assert.equal(fs.existsSync(missing), false);++ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'rejected output symlinks must not leave temporary files behind',+ );+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer rejects a special output entry without replacing it', {+ skip: process.platform === 'win32' ? 'the FIFO fixture is POSIX-only' : false,+}, () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const fifo = path.join(fixture, 'special.zip');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ try {+ const mkfifo = spawnSync('mkfifo', [fifo], { encoding: 'utf8' });+ assert.equal(mkfifo.status, 0, mkfifo.stderr);+ const build = writeArchive(staged, fifo, manifest);+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /requested-entry-not-regular-file/);+ assert.equal(fs.lstatSync(fifo).isFIFO(), true);+ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'special-entry rejection must happen before a temporary archive is created',+ );+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer rejects a hard-linked output without changing either name', () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const external = path.join(fixture, 'external.zip');+ const archive = path.join(fixture, 'archive.zip');+ const sentinel = Buffer.from('shared archive sentinel\n');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ fs.writeFileSync(external, sentinel);+ fs.linkSync(external, archive);+ try {+ const before = fs.statSync(archive, { bigint: true });+ const build = writeArchive(staged, archive, manifest);+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /requested-entry-hardlinked/);+ assert.ok(fs.readFileSync(archive).equals(sentinel));+ assert.ok(fs.readFileSync(external).equals(sentinel));+ const after = fs.statSync(archive, { bigint: true });+ assert.equal(after.dev, before.dev);+ assert.equal(after.ino, before.ino);+ assert.equal(after.nlink, 2n);+ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'hard-link rejection must happen before a temporary archive is created',+ );+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer verifies the output binding immediately before rename', () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const archive = path.join(fixture, 'archive.zip');+ const replacement = path.join(fixture, 'replacement.zip');+ const preload = path.join(fixture, 'swap-before-rename.cjs');+ const original = Buffer.from('original archive\n');+ const claimant = Buffer.from('replacement claimant\n');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ fs.writeFileSync(archive, original);+ fs.writeFileSync(replacement, claimant);+ fs.writeFileSync(preload, String.raw`+const fs = require('node:fs');+const path = require('node:path');+const output = process.env.ARCHIFY_TEST_SWAP_OUTPUT;+const replacement = process.env.ARCHIFY_TEST_SWAP_REPLACEMENT;+const originalOpen = fs.openSync;+const originalClose = fs.closeSync;+let temporaryDescriptor;+let swapped = false;+fs.openSync = function patchedOpen(file, ...args) {+ const descriptor = originalOpen.call(this, file, ...args);+ if (typeof file === 'string'+ && path.basename(file).startsWith('.' + path.basename(output) + '.')+ && file.endsWith('.tmp')) {+ temporaryDescriptor = descriptor;+ }+ return descriptor;+};+fs.closeSync = function patchedClose(descriptor) {+ const result = originalClose.call(this, descriptor);+ if (!swapped && descriptor === temporaryDescriptor) {+ swapped = true;+ fs.unlinkSync(output);+ fs.renameSync(replacement, output);+ }+ return result;+};+require('node:module').syncBuiltinESMExports();+`);+ try {+ const build = writeArchive(staged, archive, manifest, {+ env: {+ ...process.env,+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ''}--import=${pathToFileURL(preload).href}`,+ ARCHIFY_TEST_SWAP_OUTPUT: archive,+ ARCHIFY_TEST_SWAP_REPLACEMENT: replacement,+ },+ });+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /(?:requested-entry-changed|target-identity-changed)/);+ assert.ok(fs.readFileSync(archive).equals(claimant), 'the replacement claimant must not be overwritten');+ assert.equal(fs.existsSync(replacement), false, 'the fixture must actually move the claimant into place');+ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'a failed pre-rename verification must remove the unpublished temporary archive',+ );+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer rejects a candidate changed while the final output state is checked', () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const archive = path.join(fixture, 'archive.zip');+ const preload = path.join(fixture, 'mutate-archive-candidate.cjs');+ const original = Buffer.from('original archive\n');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ fs.writeFileSync(archive, original);+ fs.writeFileSync(preload, String.raw`+const fs = require('node:fs');+const path = require('node:path');+const output = process.env.ARCHIFY_TEST_ARCHIVE_OUTPUT;+const originalOpen = fs.openSync;+const originalLstat = fs.lstatSync;+const originalWriteFile = fs.writeFileSync;+let candidatePath;+let candidateOpens = 0;+let mutated = false;+fs.openSync = function patchedOpen(file, ...args) {+ const descriptor = originalOpen.call(this, file, ...args);+ if (typeof file === 'string'+ && path.basename(file).startsWith('.' + path.basename(output) + '.')+ && file.endsWith('.tmp')) {+ candidatePath = file;+ candidateOpens += 1;+ }+ return descriptor;+};+fs.lstatSync = function patchedLstat(file, ...args) {+ if (!mutated && candidateOpens >= 2 && path.resolve(file) === path.resolve(output)) {+ mutated = true;+ originalWriteFile(candidatePath, 'mutated candidate bytes\n');+ }+ return originalLstat.call(this, file, ...args);+};+require('node:module').syncBuiltinESMExports();+`);+ try {+ const build = writeArchive(staged, archive, manifest, {+ env: {+ ...process.env,+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ''}--import=${pathToFileURL(preload).href}`,+ ARCHIFY_TEST_ARCHIVE_OUTPUT: archive,+ },+ });+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /archive-candidate-content-changed/);+ assert.ok(fs.readFileSync(archive).equals(original));+ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'an in-place candidate mutation must be rejected and cleaned up by identity',+ );+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer preserves a successor that replaces its temporary candidate', {+ skip: process.platform === 'win32'+ ? 'Windows does not unlink an archive candidate while its verification handle is open'+ : false,+}, () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const archive = path.join(fixture, 'archive.zip');+ const preload = path.join(fixture, 'replace-archive-candidate.cjs');+ const original = Buffer.from('original archive\n');+ const successor = Buffer.from('candidate successor claimant\n');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ fs.writeFileSync(archive, original);+ fs.writeFileSync(preload, String.raw`+const fs = require('node:fs');+const path = require('node:path');+const output = process.env.ARCHIFY_TEST_ARCHIVE_OUTPUT;+const successor = process.env.ARCHIFY_TEST_ARCHIVE_SUCCESSOR;+const originalOpen = fs.openSync;+const originalLstat = fs.lstatSync;+const originalUnlink = fs.unlinkSync;+const originalWriteFile = fs.writeFileSync;+let candidatePath;+let candidateOpens = 0;+let swapped = false;+fs.openSync = function patchedOpen(file, ...args) {+ const descriptor = originalOpen.call(this, file, ...args);+ if (typeof file === 'string'+ && path.basename(file).startsWith('.' + path.basename(output) + '.')+ && file.endsWith('.tmp')) {+ candidatePath = file;+ candidateOpens += 1;+ }+ return descriptor;+};+fs.lstatSync = function patchedLstat(file, ...args) {+ if (!swapped && candidateOpens >= 2 && path.resolve(file) === path.resolve(output)) {+ swapped = true;+ originalUnlink(candidatePath);+ originalWriteFile(candidatePath, successor, { flag: 'wx' });+ }+ return originalLstat.call(this, file, ...args);+};+require('node:module').syncBuiltinESMExports();+`);+ try {+ const build = writeArchive(staged, archive, manifest, {+ env: {+ ...process.env,+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ''}--import=${pathToFileURL(preload).href}`,+ ARCHIFY_TEST_ARCHIVE_OUTPUT: archive,+ ARCHIFY_TEST_ARCHIVE_SUCCESSOR: successor.toString('utf8'),+ },+ });+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, /archive-candidate-identity-changed/);+ assert.ok(fs.readFileSync(archive).equals(original));+ const candidates = fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp'));+ assert.equal(candidates.length, 1, 'the replacement claimant must remain named');+ assert.ok(fs.readFileSync(path.join(fixture, candidates[0])).equals(successor));+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer preserves an existing regular output mode despite a restrictive umask', {+ skip: process.platform === 'win32' ? 'Windows does not expose POSIX creation modes' : false,+}, () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const manifest = path.join(fixture, 'modes.json');+ const archive = path.join(fixture, 'archive.zip');+ const fresh = path.join(fixture, 'fresh.zip');+ const preload = path.join(fixture, 'restrict-umask.cjs');+ fs.writeFileSync(manifest, JSON.stringify({ 'safe.txt': '100644' }));+ fs.writeFileSync(archive, 'existing archive\n');+ fs.chmodSync(archive, 0o664);+ fs.writeFileSync(preload, 'process.umask(0o077);\n');+ const options = {+ env: {+ ...process.env,+ NODE_OPTIONS: `${process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ` : ''}--import=${pathToFileURL(preload).href}`,+ },+ };+ try {+ let build = writeArchive(staged, archive, manifest, options);+ assert.equal(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.equal(fs.statSync(archive).mode & 0o777, 0o664);++ build = writeArchive(staged, fresh, manifest, options);+ assert.equal(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.equal(fs.statSync(fresh).mode & 0o777, 0o600);+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});++test('archive writer rejects non-portable manifest entries and collisions before publication', () => {+ const { fixture, staged } = stagedFixture({+ 'safe.txt': { content: 'safe\n', mode: 0o644 },+ });+ const archive = path.join(fixture, 'trusted.zip');+ const trusted = Buffer.from('trusted archive bytes');+ const manifest = path.join(fixture, 'modes.json');+ try {+ const cases = [+ [+ { 'safe.txt': '100644', 'CON.txt': '100644' },+ /Portable path must not use a reserved Windows device name/,+ ],+ [+ { 'safe.txt': '100644', 'Docs/one.txt': '100644', 'docs/two.txt': '100644' },+ /collide under portable filesystem semantics/,+ ],+ ];+ for (const [contents, expected] of cases) {+ fs.writeFileSync(archive, trusted);+ fs.writeFileSync(manifest, JSON.stringify(contents));+ const build = writeArchive(staged, archive, manifest);+ assert.notEqual(build.status, 0, `${build.stdout}\n${build.stderr}`);+ assert.match(build.stderr, expected);+ assert.ok(fs.readFileSync(archive).equals(trusted), 'portable-name rejection must preserve the prior archive');+ assert.deepEqual(+ fs.readdirSync(fixture).filter((name) => name.endsWith('.tmp')),+ [],+ 'portable-name rejection must not leave temporary files behind',+ );+ }+ } finally {+ fs.rmSync(fixture, { recursive: true, force: true });+ }+});+test('archive build hands the recorded Git index modes from the stager to the writer', () => {const buildSource = fs.readFileSync(path.join(repoRoot, 'scripts', 'build-zip.sh'), 'utf8');assert.match(buildSource, /stage-clean-skill\.mjs[\s\S]*?--mode-manifest "\$stage\/modes\.json"/);@@ -768,3 +1330,134 @@ test('CI tests the declared Node floor plus every maintained current lane', () =assert.match(packageSmokeJob, /os:\s*\[ubuntu-latest, macos-latest, windows-latest\]/);assert.match(packageSmokeJob, /node-version:\s*22/);});++test('CI and tagged releases share the maintained Windows path contract on Node 22 and 24', () => {+ const runnerPath = path.join(repoRoot, 'scripts', 'run-windows-path-tests.mjs');+ const runner = fs.readFileSync(runnerPath, 'utf8');+ const fullSuites = [+ 'test/release-package-gates.test.mjs',+ 'test/copy-site-assets.test.mjs',+ 'test/path-boundary-contract.test.mjs',+ 'test/path-semantics.test.mjs',+ 'test/portable-path.test.mjs',+ 'test/native-output-path.test.mjs',+ 'test/meta-output-contract.test.mjs',+ 'test/output-path.test.mjs',+ 'test/cli-output-types.test.mjs',+ 'test/delivery-sidecar-path.test.mjs',+ 'test/sidecar-path-length.test.mjs',+ 'test/open-artifact.test.mjs',+ 'test/repository-evidence.test.mjs',+ 'test/renderer-atomic-write.test.mjs',+ ];+ for (const suite of fullSuites) {+ assert.ok(runner.includes(`'${suite}'`), `shared runner must execute ${suite}`);+ }+ for (const fixture of [+ 'test/checkout-line-endings.test.mjs',+ 'test/clean-skill-staging.test.mjs',+ 'test/workflow-migration.test.mjs',+ 'test/cli.test.mjs',+ 'test/preview.test.mjs',+ 'test/update-notifier.test.mjs',+ 'test/visual-check.test.mjs',+ ]) {+ assert.ok(runner.includes(`'${fixture}'`), `shared runner must execute ${fixture}`);+ }+ assert.match(runner, /canonical watch target/);+ assert.match(runner, /entry detection/);+ assert.match(runner, /workflow migration rejects a dangling destination symlink/);+ assert.match(runner, /workflow migration preserves a destination claimant created before final verification/);+ assert.match(runner, /workflow migration preserves an existing destination replaced during candidate mode finalization/);+ assert.match(runner, /Windows 8\.3 short path/);+ assert.match(runner, /preview: publishing through an existing output symlink/);+ assert.match(runner, /preview: a hardlinked existing output/);+ assert.match(runner, /'visual-check'/);+ assert.match(runner, /updater rejects a case-only alias/);+ assert.match(runner, /symlink cache root/);+ assert.match(runner, /symlink cache ancestor/);+ assert.match(runner, /trusted cache prefix switched/);+ assert.match(runner, /preview runs from an installed skill/);+ assert.match(runner, /watcher accepts/);+ assert.match(runner, /findChrome/);+ assert.match(runner, /doctor identifies an incomplete installation/);+ assert.match(runner, /ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS/);+ assert.match(runner, /ARCHIFY_WINDOWS_CASE_SENSITIVE_ROOT/);+ assert.match(runner, /ARCHIFY_WINDOWS_UNC_ROOT/);+ assert.match(runner, /ARCHIFY_WINDOWS_EXTENDED_UNC_ROOT/);+ assert.match(runner, /ARCHIFY_WINDOWS_8DOT3_ROOT/);+ assert.match(runner, /ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT/);+ assert.match(runner, /sameLocation\(uncRoot, extendedUncRoot\)\.status, 'match'/);+ assert.doesNotMatch(runner, /extendedUncRoot\.toLocaleLowerCase/);+ assert.doesNotMatch(runner, /controlled real-path fixture belongs to the canonical Node 22 lane/);+ assert.match(runner, /driveLetterCaseAlias/);+ assert.match(runner, /strict check through drive-letter case alias/);+ assert.match(runner, /fs\.symlinkSync\(junctionTarget, junctionAlias, 'junction'\)/);+ assert.match(runner, /fs\.symlinkSync\(fileTarget, fileSymlink, 'file'\)/);+ assert.match(runner, /fs\.linkSync\(fileTarget, hardlink\)/);+ assert.match(runner, /runCli\(\[\s*'visual-check'/);+ assert.match(runner, /--require-provenance/);+ assert.match(runner, /build-zip[.]sh/);++ const previewSuite = fs.readFileSync(path.join(repoRoot, 'archify', 'test', 'preview.test.mjs'), 'utf8');+ assert.match(previewSuite, /process\.env\.ARCHIFY_REQUIRE_WINDOWS_8DOT3 === '1'/);+ assert.match(previewSuite, /process\.env\.ARCHIFY_WINDOWS_8DOT3_ROOT/);+ assert.match(previewSuite, /process\.env\.ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT/);+ const deliverySuite = fs.readFileSync(+ path.join(repoRoot, 'archify', 'test', 'delivery-sidecar-path.test.mjs'),+ 'utf8',+ );+ assert.match(deliverySuite, /process\.env\.ARCHIFY_WINDOWS_8DOT3_ROOT/);+ assert.match(deliverySuite, /process\.env\.ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT/);++ const workflows = [+ ['CI', fs.readFileSync(path.join(repoRoot, '.github', 'workflows', 'ci.yml'), 'utf8')],+ ['release', fs.readFileSync(path.join(repoRoot, '.github', 'workflows', 'release.yml'), 'utf8')],+ ];+ for (const [label, workflow] of workflows) {+ const job = workflowJob(workflow, 'windows-test-portability');+ assert.match(job, /runs-on:\s*windows-latest/);+ assert.match(job, /node-version:\s*\[22, 24\]/);+ assert.match(job, /node-version:\s*\$\{\{ matrix\.node-version \}\}/);+ assert.match(job, /npm ci --ignore-scripts/);+ assert.match(job, /node scripts\/run-windows-path-tests\.mjs/);+ assert.match(job, /name: Provision controlled Windows path fixtures\n\s+shell: pwsh/);+ assert.match(job, /node\$\{\{ matrix\.node-version \}\}/);+ assert.match(job, /fsutil[.]exe file setCaseSensitiveInfo/);+ assert.match(job, /New-SmbShare[^\n]*-Temporary[^\n]*-ChangeAccess \$identity/);+ assert.match(job, /\\\\localhost\\/);+ assert.match(job, /\\\\[?]\\UNC\\localhost\\/);+ assert.match(job, /ARCHIFY_WINDOWS_CASE_SENSITIVE_ROOT/);+ assert.match(job, /ARCHIFY_WINDOWS_UNC_ROOT/);+ assert.match(job, /ARCHIFY_WINDOWS_EXTENDED_UNC_ROOT/);+ assert.match(job, /fsutil[.]exe file setshortname/);+ assert.match(job, /ARCHIFY_WINDOWS_8DOT3_ROOT/);+ assert.match(job, /ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT/);+ assert.match(+ job,+ /name: Clean up controlled Windows path fixtures\n\s+if: \$\{\{ always\(\) \}\}/,+ );+ assert.match(job, /Remove-SmbShare/);+ assert.match(+ job,+ /ARCHIFY_REQUIRE_WINDOWS_8DOT3:\s*\$\{\{ matrix\.node-version == 22 && '1' \|\| '0' \}\}/,+ `${label} must require real 8.3 watcher coverage on its controlled Node 22 lane`,+ );+ assert.match(+ job,+ /ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS:\s*'1'/,+ `${label} must require controlled UNC and case-sensitive NTFS coverage on every lane`,+ );+ for (const suite of fullSuites) {+ assert.equal(job.includes(suite), false, `${label} must get ${suite} from the shared runner`);+ }+ }++ const ci = workflows[0][1];+ const deploy = workflowJob(ci, 'deploy-pages');+ assert.match(deploy, /needs: \[[^\]]*windows-test-portability[^\]]*\]/);++ const releaseWorkflow = workflows[1][1];+ const release = workflowJob(releaseWorkflow, 'release');+ assert.match(release, /needs:\s*windows-test-portability/);+});diff --git a/archify/test/render-failure-diagnostics.test.mjs b/archify/test/render-failure-diagnostics.test.mjsindex 3cea378f..1ca8aff9 100644--- a/archify/test/render-failure-diagnostics.test.mjs+++ b/archify/test/render-failure-diagnostics.test.mjs@@ -57,21 +57,25 @@ for (const [type, example] of Object.entries(examples)) {// Directory targets fail on both POSIX and Windows without relying on// permission bits (which a privileged test process may bypass).fs.mkdirSync(output);- assertHumanFailure(run([cli, 'render', type, input, output], cwd), 'output/write');+ assertHumanFailure(run([cli, 'render', type, input, output], cwd), 'output/target-not-regular-file');const renderer = path.join(skillRoot, 'renderers', type, `render-${type}.mjs`);const machine = run([renderer, input, output], cwd, true);assert.equal(machine.status, 1);assert.equal(machine.stdout, '');const failure = JSON.parse(machine.stderr);- assert.equal(failure.diagnostics[0].code, 'output/write');+ assert.equal(failure.diagnostics[0].code, 'output/target-not-regular-file');assert.deepEqual(failure.diagnostics[0].subject, { output });- assert.ok(failure.diagnostics[0].evidence.systemCode);+ assert.equal(failure.diagnostics[0].evidence.relation.code, 'target-not-regular-file');+ assert.equal(failure.diagnostics[0].evidence.relation.entryType, 'directory');assert.ok(failure.diagnostics[0].supportedFixes.length);assert.deepEqual(fs.readdirSync(output), []);const blockedParent = path.join(cwd, 'parent');fs.writeFileSync(blockedParent, 'preserved');- assertHumanFailure(run([renderer, input, path.join(blockedParent, 'diagram.html')], cwd), 'output/write');+ assertHumanFailure(+ run([renderer, input, path.join(blockedParent, 'diagram.html')], cwd),+ 'output/path-resolution-indeterminate',+ );assert.equal(fs.readFileSync(blockedParent, 'utf8'), 'preserved');});diff --git a/archify/test/renderer-atomic-write.test.mjs b/archify/test/renderer-atomic-write.test.mjsnew file mode 100644index 00000000..d45ae36a--- /dev/null+++ b/archify/test/renderer-atomic-write.test.mjs@@ -0,0 +1,1313 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { spawnSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import test from 'node:test';+import assert from 'node:assert/strict';+import {+ backupPublicRegularFileBinding,+ captureAtomicOutput,+ captureRegularFileBinding,+ quarantineRemoveRegularFileBinding,+ releaseRegularFileBinding,+} from '../renderers/shared/atomic-output.mjs';+import { loadDiagram, writeDiagram } from '../renderers/shared/cli.mjs';++const here = path.dirname(fileURLToPath(import.meta.url));+const skillRoot = path.resolve(here, '..');+const workflowFixture = path.join(skillRoot, 'examples/agent-tool-call.workflow.json');++function workspace(t, prefix) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), prefix));+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ return root;+}++function loadWorkflow(input, output) {+ return loadDiagram({+ rendererDir: path.join(skillRoot, 'renderers/workflow'),+ diagramType: 'workflow',+ defaultExample: 'agent-tool-call.workflow.json',+ argv: ['node', 'render-workflow.mjs', input, output],+ });+}++function writeWorkflow(loaded) {+ writeDiagram({+ outPath: loaded.outPath,+ template: loaded.template,+ diagramType: 'workflow',+ meta: loaded.diagram.meta,+ svg: '<svg role="img"></svg>',+ cards: [],+ });+}++function renderCandidates(directory) {+ return fs.readdirSync(directory).filter((entry) => entry.startsWith('.archify-render-'));+}++function createFifo(target) {+ const created = spawnSync('mkfifo', [target], { encoding: 'utf8' });+ if (created.error?.code === 'ENOENT') return false;+ assert.equal(created.status, 0, created.stderr || created.error?.message);+ return true;+}++function fileSymlinksAvailable(t, root) {+ const target = path.join(root, 'symlink-capability-target');+ const link = path.join(root, 'symlink-capability-link');+ try {+ fs.symlinkSync(target, link, process.platform === 'win32' ? 'file' : undefined);+ fs.unlinkSync(link);+ return true;+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`file aliases unavailable: ${error.code}`);+ return false;+ }+ throw error;+ }+}++test('a partial candidate write preserves the previous artifact and removes the candidate', (t) => {+ const root = workspace(t, 'archify-render-atomic-partial-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const previous = '<!doctype html><title>trusted previous artifact</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, previous);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let injected = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ if (!injected) {+ injected = true;+ writeFileSync(file, 'partial artifact');+ throw Object.assign(new Error('injected partial render write'), {+ code: 'ENOSPC',+ errno: -28,+ syscall: 'write',+ });+ }+ return writeFileSync(file, ...args);+ });++ assert.throws(() => writeWorkflow(loaded), /Output could not be written/);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('an existing output directory is rejected before a render candidate is written', (t) => {+ const root = workspace(t, 'archify-render-atomic-directory-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.mkdirSync(output);+ const loaded = loadWorkflow(input, output);+ let writes = 0;+ const writeFileSync = fs.writeFileSync;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-not-regular-file'+ && error.archifyDiagnostics[0].evidence.relation.entryType === 'directory',+ );+ assert.equal(writes, 0);+ assert.equal(fs.statSync(output).isDirectory(), true);+ assert.deepEqual(renderCandidates(root), []);+});++test('an existing output FIFO is rejected before a render candidate is written', (t) => {+ if (process.platform === 'win32') {+ t.skip('FIFO files are unavailable on Windows');+ return;+ }+ const root = workspace(t, 'archify-render-atomic-fifo-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ if (!createFifo(output)) {+ t.skip('mkfifo is unavailable');+ return;+ }+ const loaded = loadWorkflow(input, output);+ let writes = 0;+ const writeFileSync = fs.writeFileSync;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-not-regular-file'+ && error.archifyDiagnostics[0].evidence.relation.entryType === 'fifo',+ );+ assert.equal(writes, 0);+ assert.equal(fs.statSync(output).isFIFO(), true);+ assert.deepEqual(renderCandidates(root), []);+});++test('a no-follow atomic output policy rejects symlinks, including dangling aliases', (t) => {+ const root = workspace(t, 'archify-render-atomic-no-follow-alias-');+ if (!fileSymlinksAvailable(t, root)) return;+ const target = path.join(root, 'target.html');+ const existingAlias = path.join(root, 'existing.delivery.json');+ const danglingAlias = path.join(root, 'dangling.delivery.json');+ fs.writeFileSync(target, 'target\n');+ fs.symlinkSync(target, existingAlias, process.platform === 'win32' ? 'file' : undefined);+ fs.symlinkSync(+ path.join(root, 'missing-target.html'),+ danglingAlias,+ process.platform === 'win32' ? 'file' : undefined,+ );++ for (const output of [existingAlias, danglingAlias]) {+ const captured = captureAtomicOutput(output, { requestedEntryPolicy: 'regular-or-absent' });+ assert.equal(captured.status, 'unsupported');+ assert.equal(captured.reason.code, 'requested-entry-symbolic-link');+ assert.equal(captured.reason.entryType, 'symbolic-link');+ }+ assert.equal(fs.lstatSync(existingAlias).isSymbolicLink(), true);+ assert.equal(fs.lstatSync(danglingAlias).isSymbolicLink(), true);+});++test('a no-follow atomic output policy rejects special and hardlinked requested entries', (t) => {+ const root = workspace(t, 'archify-render-atomic-no-follow-entry-');+ const output = path.join(root, 'receipt.delivery.json');+ const alias = path.join(root, 'receipt-alias.delivery.json');++ if (process.platform !== 'win32' && createFifo(output)) {+ const fifo = captureAtomicOutput(output, { requestedEntryPolicy: 'regular-or-absent' });+ assert.equal(fifo.status, 'unsupported');+ assert.equal(fifo.reason.code, 'requested-entry-not-regular-file');+ assert.equal(fifo.reason.entryType, 'fifo');+ fs.unlinkSync(output);+ }++ fs.writeFileSync(output, 'owned\n');+ try {+ fs.linkSync(output, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const hardlinked = captureAtomicOutput(output, { requestedEntryPolicy: 'regular-or-absent' });+ assert.equal(hardlinked.status, 'unsupported');+ assert.equal(hardlinked.reason.code, 'requested-entry-hardlinked');+ assert.equal(fs.readFileSync(output, 'utf8'), 'owned\n');+ assert.equal(fs.readFileSync(alias, 'utf8'), 'owned\n');+});++test('an existing output with no stable file identity fails closed before staging', (t) => {+ const root = workspace(t, 'archify-render-atomic-zero-inode-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>original</title>\n');+ const loaded = loadWorkflow(input, output);+ const physicalOutput = fs.realpathSync.native(output);++ const lstatSync = fs.lstatSync;+ t.mock.method(fs, 'lstatSync', (target, options) => {+ const metadata = lstatSync(target, options);+ if (options?.bigint && path.resolve(target) === physicalOutput) {+ return new Proxy(metadata, {+ get(value, property) {+ if (property === 'ino') return 0n;+ const member = Reflect.get(value, property, value);+ return typeof member === 'function' ? member.bind(value) : member;+ },+ });+ }+ return metadata;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-indeterminate'+ && error.archifyDiagnostics[0].evidence.relation.code === 'target-identity-unavailable',+ );+ assert.match(fs.readFileSync(output, 'utf8'), /original/);+ assert.deepEqual(renderCandidates(root), []);+});++for (const linkCount of [0n, 2n]) {+ test(`an existing output with handle link count ${linkCount} fails closed before staging`, (t) => {+ const root = workspace(t, `archify-render-atomic-handle-links-${linkCount}-`);+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>original</title>\n');+ const loaded = loadWorkflow(input, output);+ const identity = fs.statSync(output, { bigint: true });++ const fstatSync = fs.fstatSync;+ t.mock.method(fs, 'fstatSync', (descriptor, options) => {+ const metadata = fstatSync(descriptor, options);+ if (options?.bigint && metadata.dev === identity.dev && metadata.ino === identity.ino) {+ return new Proxy(metadata, {+ get(value, property) {+ if (property === 'nlink') return linkCount;+ const member = Reflect.get(value, property, value);+ return typeof member === 'function' ? member.bind(value) : member;+ },+ });+ }+ return metadata;+ });+ const writeFileSync = fs.writeFileSync;+ let writes = 0;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === (linkCount === 0n+ ? 'output/target-indeterminate'+ : 'output/target-hardlinked')+ && error.archifyDiagnostics[0].evidence.relation.code === (linkCount === 0n+ ? 'target-link-count-unavailable'+ : 'target-hardlinked'),+ );+ assert.equal(writes, 0);+ assert.match(fs.readFileSync(output, 'utf8'), /original/);+ assert.deepEqual(renderCandidates(root), []);+ });+}++test('a path link count of one cannot hide a hardlinked handle identity', (t) => {+ const root = workspace(t, 'archify-render-atomic-windows-link-fallback-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>original</title>\n');+ const loaded = loadWorkflow(input, output);+ const identity = fs.statSync(output, { bigint: true });++ const lstatSync = fs.lstatSync;+ t.mock.method(fs, 'lstatSync', (target, options) => {+ const metadata = lstatSync(target, options);+ if (options?.bigint && metadata.dev === identity.dev && metadata.ino === identity.ino) {+ return new Proxy(metadata, {+ get(value, property) {+ if (property === 'nlink') return 1n;+ const member = Reflect.get(value, property, value);+ return typeof member === 'function' ? member.bind(value) : member;+ },+ });+ }+ return metadata;+ });+ const fstatSync = fs.fstatSync;+ t.mock.method(fs, 'fstatSync', (descriptor, options) => {+ const metadata = fstatSync(descriptor, options);+ if (options?.bigint && metadata.dev === identity.dev && metadata.ino === identity.ino) {+ return new Proxy(metadata, {+ get(value, property) {+ if (property === 'nlink') return 2n;+ const member = Reflect.get(value, property, value);+ return typeof member === 'function' ? member.bind(value) : member;+ },+ });+ }+ return metadata;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-hardlinked'+ && error.archifyDiagnostics[0].evidence.relation.code === 'target-hardlinked',+ );+ assert.match(fs.readFileSync(output, 'utf8'), /original/);+ assert.deepEqual(renderCandidates(root), []);+});++test('an existing output whose handle cannot be inspected fails closed before staging', (t) => {+ const root = workspace(t, 'archify-render-atomic-handle-open-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>original</title>\n');+ const loaded = loadWorkflow(input, output);+ const physicalOutput = fs.realpathSync.native(output);++ const openSync = fs.openSync;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ if (path.resolve(target) === physicalOutput) {+ throw Object.assign(new Error('injected sharing violation'), { code: 'EBUSY' });+ }+ return openSync(target, ...args);+ });+ const writeFileSync = fs.writeFileSync;+ let writes = 0;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-indeterminate'+ && error.archifyDiagnostics[0].evidence.relation.code === 'target-handle-inspection-failed'+ && error.archifyDiagnostics[0].evidence.relation.systemCode === 'EBUSY',+ );+ assert.equal(writes, 0);+ assert.match(fs.readFileSync(output, 'utf8'), /original/);+ assert.deepEqual(renderCandidates(root), []);+});++test('a staged candidate whose handle has multiple links is not published', (t) => {+ const root = workspace(t, 'archify-render-atomic-candidate-links-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const openSync = fs.openSync;+ const closeSync = fs.closeSync;+ const fstatSync = fs.fstatSync;+ const openPaths = new Map();+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ openPaths.set(descriptor, path.resolve(target));+ return descriptor;+ });+ t.mock.method(fs, 'fstatSync', (descriptor, options) => {+ const metadata = fstatSync(descriptor, options);+ if (options?.bigint+ && path.basename(openPaths.get(descriptor) || '').startsWith('.archify-render-')) {+ return new Proxy(metadata, {+ get(value, property) {+ if (property === 'nlink') return 2n;+ const member = Reflect.get(value, property, value);+ return typeof member === 'function' ? member.bind(value) : member;+ },+ });+ }+ return metadata;+ });+ t.mock.method(fs, 'closeSync', (descriptor) => {+ openPaths.delete(descriptor);+ return closeSync(descriptor);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-hardlinked'+ && error.archifyDiagnostics[0].evidence.relation.code === 'candidate-hardlinked',+ );+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(renderCandidates(root), []);+});++test('a staged candidate modified in place after capture is not published', (t) => {+ const root = workspace(t, 'archify-render-atomic-candidate-content-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ const writeFileSync = fs.writeFileSync;+ let candidatePath;+ let modified = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-render-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!modified && candidatePath && path.resolve(target) === output) {+ const before = fs.statSync(candidatePath, { bigint: true });+ writeFileSync(candidatePath, '<!doctype html><title>same inode claimant</title>');+ const after = fs.statSync(candidatePath, { bigint: true });+ assert.equal(after.dev, before.dev);+ assert.equal(after.ino, before.ino);+ modified = true;+ }+ return lstatSync(target, ...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'candidate-content-changed',+ );+ assert.equal(modified, true);+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(renderCandidates(root), []);+});++test('a staged candidate chmod after capture is not published', (t) => {+ if (process.platform === 'win32') {+ t.skip('POSIX candidate mode regression');+ return;+ }+ const root = workspace(t, 'archify-render-atomic-candidate-mode-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ let candidatePath;+ let modified = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-render-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!modified && candidatePath && path.resolve(target) === output) {+ const before = fs.statSync(candidatePath, { bigint: true });+ fs.chmodSync(candidatePath, Number(before.mode & 0o777n) ^ 0o111);+ const after = fs.statSync(candidatePath, { bigint: true });+ assert.equal(after.dev, before.dev);+ assert.equal(after.ino, before.ino);+ assert.notEqual(after.mode & 0o777n, before.mode & 0o777n);+ modified = true;+ }+ return lstatSync(target, ...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'candidate-mode-changed',+ );+ assert.equal(modified, true);+ assert.equal(fs.existsSync(output), false);+ assert.deepEqual(renderCandidates(root), []);+});++test('a staged candidate replaced after capture preserves the claimant', (t) => {+ const root = workspace(t, 'archify-render-atomic-candidate-replacement-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const detachedCandidate = path.join(root, 'detached-render-candidate.html');+ const sentinel = '<!doctype html><title>claimant must survive</title>';+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ const writeFileSync = fs.writeFileSync;+ let candidatePath;+ let replaced = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-render-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) === 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!replaced && candidatePath && path.resolve(target) === output) {+ fs.renameSync(candidatePath, detachedCandidate);+ writeFileSync(candidatePath, sentinel);+ replaced = true;+ }+ return lstatSync(target, ...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'candidate-identity-changed',+ );+ assert.equal(replaced, true);+ assert.equal(fs.existsSync(output), false);+ assert.equal(fs.readFileSync(candidatePath, 'utf8'), sentinel);+ assert.equal(fs.existsSync(detachedCandidate), true);+});++test('a byte-identical replacement before candidate capture is not published', (t) => {+ const root = workspace(t, 'archify-render-atomic-candidate-pre-capture-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const detachedCandidate = path.join(root, 'detached-owned-candidate.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const openSync = fs.openSync;+ const lstatSync = fs.lstatSync;+ let candidatePath;+ let claimantIdentity;+ let replaced = false;+ t.mock.method(fs, 'openSync', (target, ...args) => {+ const descriptor = openSync(target, ...args);+ if (path.basename(target).startsWith('.archify-render-')+ && (args[0] & (fs.constants.O_WRONLY | fs.constants.O_RDWR)) !== 0) {+ candidatePath = path.resolve(target);+ }+ return descriptor;+ });+ t.mock.method(fs, 'lstatSync', (target, ...args) => {+ if (!replaced && candidatePath && path.resolve(target) === candidatePath) {+ const owned = fs.statSync(candidatePath, { bigint: true });+ fs.renameSync(candidatePath, detachedCandidate);+ fs.copyFileSync(detachedCandidate, candidatePath);+ fs.chmodSync(candidatePath, Number(owned.mode & 0o777n));+ claimantIdentity = fs.statSync(candidatePath, { bigint: true });+ assert.notEqual(claimantIdentity.ino, owned.ino);+ replaced = true;+ }+ return lstatSync(target, ...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'candidate-identity-changed',+ );+ assert.equal(replaced, true);+ assert.equal(fs.existsSync(output), false);+ assert.equal(fs.statSync(candidatePath, { bigint: true }).ino, claimantIdentity.ino);+ assert.deepEqual(fs.readFileSync(candidatePath), fs.readFileSync(detachedCandidate));+});++test('a concurrent replacement of an existing output is not overwritten', (t) => {+ const root = workspace(t, 'archify-render-atomic-replaced-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const detached = path.join(root, 'detached-original.html');+ const replacement = '<!doctype html><title>concurrent replacement</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>original</title>\n');+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let replaced = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!replaced && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ replaced = true;+ fs.renameSync(output, detached);+ writeFileSync(output, replacement);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.equal(fs.readFileSync(output, 'utf8'), replacement);+ assert.deepEqual(renderCandidates(root), []);+});++test('a concurrent symlink claim cannot disguise an existing-output replacement', (t) => {+ const root = workspace(t, 'archify-render-atomic-replaced-by-symlink-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const detached = path.join(root, 'detached-original.html');+ const previous = '<!doctype html><title>original owner</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, previous);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let replaced = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!replaced && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ replaced = true;+ fs.renameSync(output, detached);+ fs.symlinkSync(detached, output, process.platform === 'win32' ? 'file' : undefined);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('a concurrently claimed new output is not overwritten', (t) => {+ const root = workspace(t, 'archify-render-atomic-claimed-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const replacement = '<!doctype html><title>concurrent owner</title>\n';+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let claimed = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!claimed && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ claimed = true;+ writeFileSync(output, replacement);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.equal(fs.readFileSync(output, 'utf8'), replacement);+ assert.deepEqual(renderCandidates(root), []);+});++test('a concurrently claimed new output symlink is not overwritten', (t) => {+ const root = workspace(t, 'archify-render-atomic-symlink-claim-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const claimTarget = path.join(root, 'concurrent-owner.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let claimed = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!claimed && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ claimed = true;+ fs.symlinkSync(claimTarget, output, process.platform === 'win32' ? 'file' : undefined);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.existsSync(claimTarget), false);+ assert.deepEqual(renderCandidates(root), []);+});++test('the output alias is revalidated after staging and before the atomic commit', (t) => {+ const root = workspace(t, 'archify-render-atomic-alias-');+ const inputDirectory = path.join(root, 'input');+ const safeDirectory = path.join(root, 'safe-output');+ const linkedDirectory = path.join(root, 'linked-output');+ fs.mkdirSync(inputDirectory);+ fs.mkdirSync(safeDirectory);+ try {+ fs.symlinkSync(safeDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`directory aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const input = path.join(inputDirectory, 'diagram.workflow.html');+ const output = path.join(linkedDirectory, 'diagram.workflow.html');+ const source = fs.readFileSync(workflowFixture);+ fs.writeFileSync(input, source);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let redirected = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!redirected) {+ redirected = true;+ fs.unlinkSync(linkedDirectory);+ fs.symlinkSync(inputDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');+ }+ return result;+ });++ assert.throws(() => writeWorkflow(loaded), /output must not replace an input/i);+ assert.deepEqual(fs.readFileSync(input), source);+ assert.deepEqual(renderCandidates(safeDirectory), []);+ assert.deepEqual(fs.readdirSync(safeDirectory), []);+});++test('a non-alias output redirect cannot commit to a stale physical target', (t) => {+ const root = workspace(t, 'archify-render-atomic-redirect-');+ const firstDirectory = path.join(root, 'first-output');+ const secondDirectory = path.join(root, 'second-output');+ const linkedDirectory = path.join(root, 'linked-output');+ fs.mkdirSync(firstDirectory);+ fs.mkdirSync(secondDirectory);+ try {+ fs.symlinkSync(firstDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`directory aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(linkedDirectory, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let redirected = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!redirected) {+ redirected = true;+ fs.unlinkSync(linkedDirectory);+ fs.symlinkSync(secondDirectory, linkedDirectory, process.platform === 'win32' ? 'junction' : 'dir');+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.deepEqual(fs.readdirSync(firstDirectory), []);+ assert.deepEqual(fs.readdirSync(secondDirectory), []);+});++test('a nested directory-alias redirect cannot commit to either physical target', (t) => {+ const root = workspace(t, 'archify-render-atomic-nested-redirect-');+ const firstDirectory = path.join(root, 'first-output');+ const secondDirectory = path.join(root, 'second-output');+ const innerAlias = path.join(root, 'inner-output');+ const outerAlias = path.join(root, 'outer-output');+ fs.mkdirSync(firstDirectory);+ fs.mkdirSync(secondDirectory);+ try {+ fs.symlinkSync(firstDirectory, innerAlias, process.platform === 'win32' ? 'junction' : 'dir');+ fs.symlinkSync(innerAlias, outerAlias, process.platform === 'win32' ? 'junction' : 'dir');+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`nested directory aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(outerAlias, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let redirected = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!redirected && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ redirected = true;+ fs.unlinkSync(innerAlias);+ fs.symlinkSync(secondDirectory, innerAlias, process.platform === 'win32' ? 'junction' : 'dir');+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'write-slot-changed',+ );+ assert.equal(redirected, true);+ assert.deepEqual(fs.readdirSync(firstDirectory), []);+ assert.deepEqual(fs.readdirSync(secondDirectory), []);+});++test('a hardlinked existing output is rejected before staging', (t) => {+ const root = workspace(t, 'archify-render-atomic-hardlink-');+ const output = path.join(root, 'diagram.html');+ const alias = path.join(root, 'diagram-alias.html');+ const previous = '<!doctype html><title>shared old inode</title>\n';+ fs.writeFileSync(output, previous);+ try {+ fs.linkSync(output, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const input = path.join(root, 'diagram.workflow.json');+ fs.copyFileSync(workflowFixture, input);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let writes = 0;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-hardlinked'+ && error.archifyDiagnostics[0].evidence.relation.code === 'target-hardlinked',+ );+ assert.equal(writes, 0);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.readFileSync(alias, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('the previous artifact remains visible until one atomic rename preserves its mode', (t) => {+ const root = workspace(t, 'archify-render-atomic-rename-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const previous = '<!doctype html><title>trusted previous artifact</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, previous);+ if (process.platform !== 'win32') fs.chmodSync(output, 0o640);+ const previousMode = fs.statSync(output).mode & 0o777;+ const loaded = loadWorkflow(input, output);++ const renameSync = fs.renameSync;+ let renames = 0;+ t.mock.method(fs, 'renameSync', (source, target) => {+ renames += 1;+ assert.equal(target, fs.realpathSync.native(output));+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.match(fs.readFileSync(source, 'utf8'), /<svg role="img"><\/svg>/);+ return renameSync(source, target);+ });++ writeWorkflow(loaded);++ assert.equal(renames, 1);+ assert.notEqual(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.statSync(output).mode & 0o777, previousMode);+ assert.deepEqual(renderCandidates(root), []);+});++test('atomic replacement preserves permissive existing modes despite a restrictive umask', (t) => {+ if (process.platform === 'win32') {+ t.skip('POSIX mode and umask regression');+ return;+ }+ const root = workspace(t, 'archify-render-atomic-umask-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, '<!doctype html><title>previous</title>\n');+ fs.chmodSync(output, 0o666);+ const loaded = loadWorkflow(input, output);++ const previousUmask = process.umask(0o077);+ try {+ writeWorkflow(loaded);+ } finally {+ process.umask(previousUmask);+ }++ assert.equal(fs.statSync(output).mode & 0o777, 0o666);+ assert.deepEqual(renderCandidates(root), []);+});++test('a concurrent mode change is preserved and fails the commit', (t) => {+ if (process.platform === 'win32') {+ t.skip('POSIX mode identity regression');+ return;+ }+ const root = workspace(t, 'archify-render-atomic-mode-race-');+ const input = path.join(root, 'diagram.workflow.json');+ const output = path.join(root, 'diagram.html');+ const previous = '<!doctype html><title>previous mode owner</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(output, previous);+ fs.chmodSync(output, 0o640);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let changed = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!changed && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ changed = true;+ fs.chmodSync(output, 0o600);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'target-mode-changed',+ );+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.statSync(output).mode & 0o777, 0o600);+ assert.deepEqual(renderCandidates(root), []);+});++test('replacing the requested output symlink with a hardlink fails instead of reporting stale success', (t) => {+ const root = workspace(t, 'archify-render-atomic-request-alias-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const target = path.join(root, 'target.html');+ const output = path.join(root, 'linked.html');+ const hardlinkProbe = path.join(root, 'hardlink-capability-probe');+ const previous = '<!doctype html><title>previous target</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(target, previous);+ try {+ fs.linkSync(target, hardlinkProbe);+ fs.unlinkSync(hardlinkProbe);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let replaced = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!replaced && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ replaced = true;+ fs.unlinkSync(output);+ fs.linkSync(target, output);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed',+ );+ assert.equal(fs.lstatSync(output).isSymbolicLink(), false);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.readFileSync(target, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('recreating the requested output symlink to the same target fails closed', (t) => {+ const root = workspace(t, 'archify-render-atomic-recreated-alias-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const target = path.join(root, 'target.html');+ const output = path.join(root, 'linked.html');+ const previous = '<!doctype html><title>previous target</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(target, previous);+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ const loaded = loadWorkflow(input, output);++ const writeFileSync = fs.writeFileSync;+ let replaced = false;+ t.mock.method(fs, 'writeFileSync', (file, ...args) => {+ const result = writeFileSync(file, ...args);+ if (!replaced && (typeof file === 'number'+ || path.basename(file).startsWith('.archify-render-'))) {+ replaced = true;+ fs.unlinkSync(output);+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ }+ return result;+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-changed'+ && error.archifyDiagnostics[0].evidence.relation.code === 'requested-entry-changed',+ );+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.readFileSync(target, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('recreating a requested symlink during handle inspection fails before staging', (t) => {+ const root = workspace(t, 'archify-render-atomic-capture-alias-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const target = path.join(root, 'target.html');+ const output = path.join(root, 'linked.html');+ const previous = '<!doctype html><title>previous target</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(target, previous);+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ const loaded = loadWorkflow(input, output);+ const physicalTarget = fs.realpathSync.native(target);++ const openSync = fs.openSync;+ let replaced = false;+ t.mock.method(fs, 'openSync', (candidate, ...args) => {+ if (!replaced && path.resolve(candidate) === physicalTarget) {+ replaced = true;+ fs.unlinkSync(output);+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ }+ return openSync(candidate, ...args);+ });+ const writeFileSync = fs.writeFileSync;+ let writes = 0;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-indeterminate'+ && error.archifyDiagnostics[0].evidence.relation.code === 'requested-entry-changed-during-inspection',+ );+ assert.equal(replaced, true);+ assert.equal(writes, 0);+ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.equal(fs.readFileSync(target, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('a requested symlink replaced during canonical resolution fails before staging', (t) => {+ const root = workspace(t, 'archify-render-atomic-resolution-race-');+ if (!fileSymlinksAvailable(t, root)) return;+ const input = path.join(root, 'diagram.workflow.json');+ const target = path.join(root, 'target.html');+ const output = path.join(root, 'linked.html');+ const hardlinkProbe = path.join(root, 'hardlink-capability-probe');+ const previous = '<!doctype html><title>previous target</title>\n';+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(target, previous);+ try {+ fs.linkSync(target, hardlinkProbe);+ fs.unlinkSync(hardlinkProbe);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP', 'EXDEV'].includes(error.code)) {+ t.skip(`hard links unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ fs.symlinkSync(target, output, process.platform === 'win32' ? 'file' : undefined);+ const loaded = loadWorkflow(input, output);++ const physicalTarget = fs.realpathSync.native(target);+ const nativeRealpath = fs.realpathSync.native;+ let replaced = false;+ t.mock.method(fs.realpathSync, 'native', (candidate) => {+ const resolved = nativeRealpath(candidate);+ if (!replaced && resolved === physicalTarget) {+ replaced = true;+ fs.unlinkSync(output);+ fs.linkSync(target, output);+ }+ return resolved;+ });+ const writeFileSync = fs.writeFileSync;+ let writes = 0;+ t.mock.method(fs, 'writeFileSync', (...args) => {+ writes += 1;+ return writeFileSync(...args);+ });++ assert.throws(+ () => writeWorkflow(loaded),+ (error) => error.archifyDiagnostics?.[0]?.code === 'output/target-hardlinked',+ );+ assert.equal(replaced, true);+ assert.equal(writes, 0);+ assert.equal(fs.lstatSync(output).isSymbolicLink(), false);+ assert.equal(fs.readFileSync(output, 'utf8'), previous);+ assert.equal(fs.readFileSync(target, 'utf8'), previous);+ assert.deepEqual(renderCandidates(root), []);+});++test('an existing output symlink remains intact while its target is atomically replaced', (t) => {+ const root = workspace(t, 'archify-render-atomic-symlink-');+ const input = path.join(root, 'diagram.workflow.json');+ const target = path.join(root, 'target.html');+ const output = path.join(root, 'linked.html');+ fs.copyFileSync(workflowFixture, input);+ fs.writeFileSync(target, '<!doctype html><title>previous target</title>\n');+ try {+ fs.symlinkSync(target, output, 'file');+ } catch (error) {+ if (error.code === 'EPERM' || error.code === 'EACCES') {+ t.skip(`file aliases unavailable: ${error.code}`);+ return;+ }+ throw error;+ }+ const loaded = loadWorkflow(input, output);++ writeWorkflow(loaded);++ assert.equal(fs.lstatSync(output).isSymbolicLink(), true);+ assert.match(fs.readFileSync(target, 'utf8'), /<svg role="img"><\/svg>/);+ assert.deepEqual(renderCandidates(root), []);+});++test('quarantine removal deletes only the public entry still owned by its binding', (t) => {+ const root = workspace(t, 'archify-quarantine-remove-owned-');+ const target = path.join(root, 'public.lock');+ fs.writeFileSync(target, 'owned\n');+ const captured = captureRegularFileBinding(target, { subject: 'test-owned-entry' });+ assert.equal(captured.status, 'captured');+ try {+ const removed = quarantineRemoveRegularFileBinding(captured.binding, target, {+ subject: 'test-owned-entry',+ });+ assert.equal(removed.status, 'removed');+ assert.equal(fs.existsSync(target), false);+ assert.deepEqual(+ fs.readdirSync(root).filter((entry) => entry.startsWith('.archify-remove-')),+ [],+ );+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+});++test('quarantine removal restores a successor swapped at the final move boundary', (t) => {+ const root = workspace(t, 'archify-quarantine-remove-successor-');+ const target = path.join(root, 'public.lock');+ const displacedOwner = path.join(root, 'displaced-owner');+ fs.writeFileSync(target, 'owned\n');+ const captured = captureRegularFileBinding(target, { subject: 'test-owned-entry' });+ assert.equal(captured.status, 'captured');+ const renameSync = fs.renameSync;+ let injected = false;+ t.mock.method(fs, 'renameSync', (source, destination) => {+ if (!injected && source === target+ && path.basename(path.dirname(destination)).startsWith('.archify-remove-')) {+ injected = true;+ renameSync(target, displacedOwner);+ fs.writeFileSync(target, 'successor\n', { flag: 'wx' });+ }+ return renameSync(source, destination);+ });+ try {+ const removed = quarantineRemoveRegularFileBinding(captured.binding, target, {+ subject: 'test-owned-entry',+ });+ assert.equal(injected, true);+ assert.equal(removed.status, 'preserved');+ assert.equal(fs.readFileSync(target, 'utf8'), 'successor\n');+ assert.equal(fs.readFileSync(displacedOwner, 'utf8'), 'owned\n');+ assert.deepEqual(+ fs.readdirSync(root).filter((entry) => entry.startsWith('.archify-remove-')),+ [],+ );+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+});++test('quarantine removal retains a moved successor when its public name is reclaimed', (t) => {+ const root = workspace(t, 'archify-quarantine-remove-recovery-');+ const target = path.join(root, 'public.lock');+ const displacedOwner = path.join(root, 'displaced-owner');+ fs.writeFileSync(target, 'owned\n');+ const captured = captureRegularFileBinding(target, { subject: 'test-owned-entry' });+ assert.equal(captured.status, 'captured');+ const renameSync = fs.renameSync;+ let injected = false;+ t.mock.method(fs, 'renameSync', (source, destination) => {+ if (!injected && source === target+ && path.basename(path.dirname(destination)).startsWith('.archify-remove-')) {+ injected = true;+ renameSync(target, displacedOwner);+ fs.writeFileSync(target, 'moved successor\n', { flag: 'wx' });+ const result = renameSync(source, destination);+ fs.writeFileSync(target, 'later claimant\n', { flag: 'wx' });+ return result;+ }+ return renameSync(source, destination);+ });+ try {+ const removed = quarantineRemoveRegularFileBinding(captured.binding, target, {+ subject: 'test-owned-entry',+ });+ assert.equal(injected, true);+ assert.equal(removed.status, 'recovery-required');+ assert.equal(fs.readFileSync(target, 'utf8'), 'later claimant\n');+ assert.equal(fs.readFileSync(displacedOwner, 'utf8'), 'owned\n');+ assert.equal(fs.readFileSync(removed.recoveryFile, 'utf8'), 'moved successor\n');+ assert.equal(path.dirname(removed.recoveryFile), removed.recoveryDirectory);+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+});++test('public backup keeps the bound file under a private no-clobber name', (t) => {+ const root = workspace(t, 'archify-public-backup-owned-');+ const target = path.join(root, 'artifact.html');+ const backup = path.join(root, '.previous-artifact');+ fs.writeFileSync(target, 'previous\n');+ const captured = captureRegularFileBinding(target, { subject: 'test-previous-entry' });+ assert.equal(captured.status, 'captured');+ try {+ const moved = backupPublicRegularFileBinding(captured.binding, target, backup, {+ subject: 'test-previous-entry',+ });+ assert.equal(moved.status, 'backed-up');+ assert.equal(fs.existsSync(target), false);+ assert.equal(fs.readFileSync(backup, 'utf8'), 'previous\n');+ assert.equal(fs.lstatSync(backup).nlink, 1);+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+});++test('public backup restores a successor swapped at its final public move boundary', (t) => {+ const root = workspace(t, 'archify-public-backup-successor-');+ const target = path.join(root, 'artifact.html');+ const backup = path.join(root, '.previous-artifact');+ const displacedOwner = path.join(root, 'displaced-owner');+ fs.writeFileSync(target, 'previous\n');+ const captured = captureRegularFileBinding(target, { subject: 'test-previous-entry' });+ assert.equal(captured.status, 'captured');+ const renameSync = fs.renameSync;+ let injected = false;+ t.mock.method(fs, 'renameSync', (source, destination) => {+ if (!injected && source === target+ && path.basename(path.dirname(destination)).startsWith('.archify-remove-')) {+ injected = true;+ renameSync(target, displacedOwner);+ fs.writeFileSync(target, 'successor\n', { flag: 'wx' });+ }+ return renameSync(source, destination);+ });+ try {+ const moved = backupPublicRegularFileBinding(captured.binding, target, backup, {+ subject: 'test-previous-entry',+ });+ assert.equal(injected, true);+ assert.equal(moved.status, 'preserved');+ assert.equal(moved.backupCreated, true);+ assert.equal(moved.backupVerified, true);+ assert.equal(fs.readFileSync(target, 'utf8'), 'successor\n');+ assert.equal(fs.readFileSync(backup, 'utf8'), 'previous\n');+ assert.equal(fs.readFileSync(displacedOwner, 'utf8'), 'previous\n');+ } finally {+ releaseRegularFileBinding(captured.binding);+ }+});diff --git a/archify/test/repository-evidence.test.mjs b/archify/test/repository-evidence.test.mjsindex eead6b60..5586dbb2 100644--- a/archify/test/repository-evidence.test.mjs+++ b/archify/test/repository-evidence.test.mjs@@ -7,6 +7,7 @@ import test from 'node:test';import { fileURLToPath } from 'node:url';import { startPreview } from '../bin/preview.mjs';import { ChromeVisualBrowser, findChrome } from '../bin/visual-check.mjs';+import { verifyRepositoryEvidence } from '../renderers/shared/repository-evidence.mjs';const here = path.dirname(fileURLToPath(import.meta.url));const skillRoot = path.resolve(here, '..');@@ -56,6 +57,58 @@ function evidencePayload(html) {return JSON.parse(match[1]);}+test('repository root accepts a different spelling of the same physical Git top-level', (t) => {+ const data = fixture();+ const alias = `${data.root}-alias`;+ fs.symlinkSync(data.root, alias, process.platform === 'win32' ? 'junction' : 'dir');+ t.after(() => fs.rmSync(alias, { recursive: true, force: true }));++ // Windows APIs and Git can report the same directory with different case or+ // long/short spellings. Preserve the authored alias for the first lookup so+ // this test exercises physical identity instead of string equality.+ const realpathSync = fs.realpathSync;+ let preservedAlias = false;+ t.mock.method(fs, 'realpathSync', (target, ...args) => {+ if (!preservedAlias && path.resolve(String(target)) === path.resolve(alias)) {+ preservedAlias = true;+ return alias;+ }+ return Reflect.apply(realpathSync, fs, [target, ...args]);+ });++ const evidence = verifyRepositoryEvidence('architecture', data.diagram, alias);+ assert.equal(preservedAlias, true);+ assert.equal(evidence.verified, true);+ assert.equal(evidence.repository.revision, data.revision);+});++test('repository root rejects a different physical directory inside the repository', () => {+ const data = fixture();+ assert.throws(+ () => verifyRepositoryEvidence('architecture', data.diagram, path.join(data.root, 'src')),+ (error) => error?.archifyDiagnostics?.some(({ code }) => code === 'repository-evidence/root-not-top-level'),+ );+});++test('repository root fails closed when physical identity is indeterminate', (t) => {+ const data = fixture();+ const inaccessible = Object.assign(new Error('synthetic identity failure'), { code: 'EACCES' });+ t.mock.method(fs, 'statSync', () => { throw inaccessible; });++ assert.throws(+ () => verifyRepositoryEvidence('architecture', data.diagram, data.root),+ (error) => {+ const diagnostic = error?.archifyDiagnostics?.find(+ ({ code }) => code === 'repository-evidence/root-identity-indeterminate',+ );+ assert.ok(diagnostic);+ assert.equal(diagnostic.evidence.relation.code, 'root-resolution-failed');+ assert.equal(diagnostic.evidence.relation.systemCode, 'EACCES');+ return true;+ },+ );+});+test('Gitee evidence generates provider-specific revision and line links', () => {const data = fixture();data.diagram.meta.repository.url = 'https://gitee.com/example/evidence-repo';diff --git a/archify/test/sidecar-path-length.test.mjs b/archify/test/sidecar-path-length.test.mjsnew file mode 100644index 00000000..a6c71553--- /dev/null+++ b/archify/test/sidecar-path-length.test.mjs@@ -0,0 +1,343 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { spawnSync } from 'node:child_process';+import test from 'node:test';+import assert from 'node:assert/strict';++import { sidecarPaths } from '../bin/visual-check.mjs';+import { sidecarNamespaceComponentKey } from '../renderers/shared/path-semantics.mjs';++function basenameFits(file) {+ const name = path.basename(file);+ return name.length <= 255 && Buffer.byteLength(name, 'utf8') <= 255;+}++function windowsShortPath(targetPath) {+ const result = spawnSync(+ process.env.ComSpec || 'cmd.exe',+ ['/d', '/s', '/c', '"for %I in ("%ARCHIFY_SHORT_PATH_TARGET%") do @echo %~sI"'],+ {+ encoding: 'utf8',+ env: { ...process.env, ARCHIFY_SHORT_PATH_TARGET: targetPath },+ windowsHide: true,+ windowsVerbatimArguments: true,+ },+ );+ if (result.error) throw new Error(`Could not query a Windows 8.3 path: ${result.error.message}`);+ if (result.status !== 0) {+ throw new Error(`Could not query a Windows 8.3 path: ${result.stderr.trim() || `exit ${result.status}`}`);+ }+ const shortPath = result.stdout.trim();+ if (!shortPath) throw new Error('Windows returned an empty 8.3 path');+ if (path.resolve(shortPath).toLowerCase() === path.resolve(targetPath).toLowerCase()) return null;+ if (fs.realpathSync.native(shortPath).toLowerCase()+ !== fs.realpathSync.native(targetPath).toLowerCase()) {+ throw new Error('Windows returned an 8.3 path for a different filesystem entry');+ }+ return shortPath;+}++function controlledWindowsShortRoot(required) {+ const root = process.env.ARCHIFY_WINDOWS_8DOT3_ROOT;+ const shortRoot = process.env.ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT;+ if (!root && !shortRoot) {+ if (required) {+ assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires the controlled long and short roots');+ }+ return null;+ }+ assert.ok(root && shortRoot, 'the controlled Windows 8.3 roots must be configured together');+ assert.match(path.win32.basename(shortRoot), /~/u, 'the controlled short root must use an explicit 8.3 alias');+ assert.equal(+ fs.realpathSync.native(root).toLowerCase(),+ fs.realpathSync.native(shortRoot).toLowerCase(),+ 'the controlled long and short roots must identify the same directory',+ );+ return { root, shortRoot };+}++test('visual-check deterministically bounds every derived sidecar component', () => {+ const stem = 'é'.repeat(120);+ const first = sidecarPaths(`/tmp/${stem}.html`);+ const second = sidecarPaths(`/tmp/${stem}.html`);+ const files = [first.receipt, first.contactSheet, ...first.screenshots.map(({ path: file }) => file)];++ assert.deepEqual(first, second);+ assert.equal(files.every(basenameFits), true);+ assert.match(path.basename(first.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/);+});++test('different overlong artifact stems do not collapse to one visual-check sidecar name', () => {+ const left = sidecarPaths(`/tmp/${'x'.repeat(260)}-left.html`);+ const right = sidecarPaths(`/tmp/${'x'.repeat(260)}-right.html`);+ assert.notEqual(path.basename(left.receipt), path.basename(right.receipt));+});++test('html and htm artifacts use distinct visual-check sidecar namespaces', () => {+ const html = sidecarPaths('/tmp/diagram.html');+ const htm = sidecarPaths('/tmp/diagram.htm');++ assert.notEqual(html.receipt, htm.receipt);+ assert.equal(path.basename(html.receipt), 'diagram.visual-check.json');+ assert.match(+ path.basename(htm.receipt),+ /^diagram\.htm\.~archify-[0-9a-f]{64}\.visual-check\.json$/u,+ );+});++test('HTML extension case follows the containing filesystem semantics', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-extension-case-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const lower = path.join(directory, 'diagram.html');+ const upper = path.join(directory, 'diagram.HTML');+ const lowerPaths = sidecarPaths(lower);+ const upperPaths = sidecarPaths(upper);+ fs.writeFileSync(lower, '<!doctype html>');++ if (fs.existsSync(upper)) {+ assert.deepEqual(upperPaths, lowerPaths);+ } else {+ assert.notEqual(upperPaths.receipt, lowerPaths.receipt);+ assert.match(+ path.basename(upperPaths.receipt),+ /^diagram\.HTML\.~archify-[0-9a-f]{64}\.visual-check\.json$/u,+ );+ }+});++test('bounded html and htm artifacts retain distinct hash namespaces', () => {+ const stem = 'x'.repeat(225);+ const html = sidecarPaths(`/tmp/${stem}.html`);+ const htm = sidecarPaths(`/tmp/${stem}.htm`);++ assert.notEqual(html.receipt, htm.receipt);+ assert.match(path.basename(html.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/u);+ assert.match(path.basename(htm.receipt), /\.~archify-[0-9a-f]{64}\.visual-check\.json$/u);+});++test('a crafted bounded stem cannot enter another artifact visual-check namespace', () => {+ const long = sidecarPaths(`/tmp/${'x'.repeat(245)}.html`);+ const encodedStem = path.basename(long.base).replace(/\.visual-check$/u, '');+ const crafted = sidecarPaths(`/tmp/${encodedStem}.html`);+ const allPaths = (value) => [+ value.receipt,+ value.contactSheet,+ ...value.screenshots.map(({ path: screenshot }) => screenshot),+ ];++ const longPaths = new Set(allPaths(long));+ assert.equal(allPaths(crafted).some((file) => longPaths.has(file)), false);+});++test('existing overlong artifact aliases derive identical visual-check sidecar paths', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-alias-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));++ const canonical = path.join(directory, `${'A'.repeat(225)}.html`);+ const alias = path.join(directory, `${'a'.repeat(225)}.html`);+ fs.writeFileSync(canonical, '<!doctype html>');++ if (!fs.existsSync(alias)) {+ t.skip('requires a case-insensitive filesystem');+ return;+ }++ assert.deepEqual(sidecarPaths(alias), sidecarPaths(canonical));+});++test('existing short-stem artifacts use the physical directory sidecar namespace', (t) => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-directory-alias-'));+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ const physicalDirectory = path.join(root, 'physical');+ const aliasDirectory = path.join(root, 'alias');+ fs.mkdirSync(physicalDirectory);+ try {+ fs.symlinkSync(+ physicalDirectory,+ aliasDirectory,+ process.platform === 'win32' ? 'junction' : 'dir',+ );+ } catch (error) {+ t.skip(`directory aliases are unavailable: ${error.message}`);+ return;+ }+ const physicalArtifact = path.join(physicalDirectory, 'diagram.html');+ const aliasArtifact = path.join(aliasDirectory, 'diagram.html');+ fs.writeFileSync(physicalArtifact, '<!doctype html>');++ assert.deepEqual(sidecarPaths(aliasArtifact), sidecarPaths(physicalArtifact));+});++test('future short-stem artifacts use the physical parent sidecar namespace', (t) => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-future-parent-alias-'));+ t.after(() => fs.rmSync(root, { recursive: true, force: true }));+ const physicalDirectory = path.join(root, 'physical');+ const aliasDirectory = path.join(root, 'alias');+ fs.mkdirSync(physicalDirectory);+ try {+ fs.symlinkSync(+ physicalDirectory,+ aliasDirectory,+ process.platform === 'win32' ? 'junction' : 'dir',+ );+ } catch (error) {+ t.skip(`directory aliases are unavailable: ${error.message}`);+ return;+ }++ assert.deepEqual(+ sidecarPaths(path.join(aliasDirectory, 'diagram.html')),+ sidecarPaths(path.join(physicalDirectory, 'diagram.html')),+ );+});++test('native existing file aliases use the physical basename sidecar namespace', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-native-file-alias-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const physicalArtifact = path.join(directory, 'diagram artifact with long name.html');+ const authoredAlias = path.join(directory, 'DIAGRA~1.HTM');+ fs.writeFileSync(physicalArtifact, '<!doctype html>');+ const nativeRealpath = fs.realpathSync.native;+ fs.realpathSync.native = (candidate, ...args) => (+ path.resolve(String(candidate)) === authoredAlias+ ? physicalArtifact+ : nativeRealpath(candidate, ...args)+ );+ t.after(() => {+ fs.realpathSync.native = nativeRealpath;+ });++ assert.deepEqual(sidecarPaths(authoredAlias), sidecarPaths(physicalArtifact));+});++test('Windows existing 8.3 artifact aliases derive one visual-check sidecar namespace', (t) => {+ const requiresWindows8dot3 = process.env.ARCHIFY_REQUIRE_WINDOWS_8DOT3 === '1';+ if (process.platform !== 'win32') {+ if (requiresWindows8dot3) assert.fail('ARCHIFY_REQUIRE_WINDOWS_8DOT3=1 requires Windows');+ t.skip('Windows-only 8.3 visual sidecar regression');+ return;+ }+ const controlledRoot = controlledWindowsShortRoot(requiresWindows8dot3);+ const directory = controlledRoot+ ? fs.mkdtempSync(path.join(controlledRoot.root, 'visual-sidecar-'))+ : fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-eight-dot-three-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const artifact = path.join(directory, 'diagram artifact with long name.html');+ fs.writeFileSync(artifact, '<!doctype html>');+ const shortArtifact = windowsShortPath(artifact);+ if (!shortArtifact) {+ if (requiresWindows8dot3) assert.fail('the controlled Windows volume did not expose a file 8.3 alias');+ t.skip('the Windows volume does not expose a distinct file 8.3 alias');+ return;+ }++ assert.deepEqual(sidecarPaths(shortArtifact), sidecarPaths(artifact));+});++test('existing overlong Unicode aliases derive identical visual-check sidecar paths', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-unicode-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));++ const composedStem = `${'x'.repeat(219)}éé`;+ const decomposedStem = composedStem.normalize('NFD');+ const canonical = path.join(directory, `${composedStem}.html`);+ const alias = path.join(directory, `${decomposedStem}.html`);+ fs.writeFileSync(canonical, '<!doctype html>');++ if (!fs.existsSync(alias)) {+ t.skip('requires a Unicode-normalization-insensitive filesystem');+ return;+ }++ assert.deepEqual(sidecarPaths(alias), sidecarPaths(canonical));+});++test('future and existing case aliases keep one bounded sidecar namespace', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-case-lifecycle-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const canonical = path.join(directory, `${'A'.repeat(225)}.html`);+ const alias = path.join(directory, `${'a'.repeat(225)}.html`);+ const future = sidecarPaths(alias);+ fs.writeFileSync(canonical, '<!doctype html>');+ if (!fs.existsSync(alias)) {+ t.skip('requires a case-insensitive filesystem');+ return;+ }++ assert.deepEqual(sidecarPaths(alias), future);+ assert.deepEqual(sidecarPaths(canonical), future);+});++test('future and existing normalization aliases keep one bounded sidecar namespace', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-unicode-lifecycle-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const composedStem = `${'x'.repeat(219)}éé`;+ const decomposedStem = composedStem.normalize('NFD');+ const canonical = path.join(directory, `${composedStem}.html`);+ const alias = path.join(directory, `${decomposedStem}.html`);+ const future = sidecarPaths(alias);+ fs.writeFileSync(canonical, '<!doctype html>');+ if (!fs.existsSync(alias)) {+ t.skip('requires a Unicode-normalization-insensitive filesystem');+ return;+ }++ assert.deepEqual(sidecarPaths(alias), future);+ assert.deepEqual(sidecarPaths(canonical), future);+});++test('case-expansion keys follow the directory filesystem instead of generic Unicode folding', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-case-expansion-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const prefix = 'x'.repeat(221);+ const sharpS = path.join(directory, `${prefix}ß.html`);+ const expanded = path.join(directory, `${prefix}ss.html`);+ const futureSharpS = sidecarPaths(sharpS);+ fs.writeFileSync(sharpS, '<!doctype html>');++ let distinct = true;+ try {+ fs.writeFileSync(expanded, '<!doctype html>', { flag: 'wx' });+ } catch (error) {+ if (error?.code !== 'EEXIST') throw error;+ distinct = false;+ }++ if (process.platform === 'win32') {+ assert.equal(distinct, true, 'NTFS-style one-to-one upcase keeps ß and ss distinct');+ }+ if (distinct) {+ assert.notEqual(sidecarPaths(sharpS).receipt, sidecarPaths(expanded).receipt);+ } else {+ assert.deepEqual(sidecarPaths(sharpS), futureSharpS);+ assert.deepEqual(sidecarPaths(expanded), futureSharpS);+ }+});++test('an indeterminate bounded namespace fails closed before returning sidecar paths', (t) => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-sidecar-unknown-'));+ t.after(() => fs.rmSync(directory, { recursive: true, force: true }));+ const stem = 'A'.repeat(225);+ const originalOpen = fs.openSync;+ fs.openSync = function rejectSidecarProbe(file, ...args) {+ if (path.basename(String(file)).startsWith('.archify-path-semantics-')) {+ const error = new Error('synthetic probe denial');+ error.code = 'EACCES';+ throw error;+ }+ return originalOpen.call(this, file, ...args);+ };+ t.after(() => {+ fs.openSync = originalOpen;+ });++ const key = sidecarNamespaceComponentKey(directory, stem);+ assert.equal(key.status, 'unknown');+ assert.equal(key.reason.code, 'sidecar-case-semantics-indeterminate');+ assert.throws(+ () => sidecarPaths(path.join(directory, `${stem}.html`)),+ (error) => error?.code === 'ARCHIFY_SIDECAR_NAMESPACE_INDETERMINATE',+ );+ assert.deepEqual(fs.readdirSync(directory), []);+});diff --git a/archify/test/update-notifier.test.mjs b/archify/test/update-notifier.test.mjsindex 8d9b6781..8528e165 100644--- a/archify/test/update-notifier.test.mjs+++ b/archify/test/update-notifier.test.mjs@@ -11,6 +11,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';import {acknowledgeUpdate,checkForUpdate,+ isMainModule,} from '../scripts/check-update.mjs';import { DEFAULT_MANIFEST_URL, compareSemver, parseSemver } from '../scripts/update-contract.mjs';@@ -161,6 +162,43 @@ function fixture(version = '2.15.0') {return { root, releasePath, cacheDirectory };}+function caseVariant(target) {+ const name = path.basename(target);+ const index = name.search(/[A-Za-z]/);+ if (index === -1) throw new Error(`path has no ASCII case variant: ${target}`);+ const character = name[index];+ const replacement = character === character.toLowerCase()+ ? character.toUpperCase()+ : character.toLowerCase();+ return path.join(path.dirname(target), `${name.slice(0, index)}${replacement}${name.slice(index + 1)}`);+}++function windowsShortPath(target) {+ const result = spawnSync(+ process.env.ComSpec || 'cmd.exe',+ ['/d', '/s', '/c', '"for %I in ("%ARCHIFY_SHORT_PATH_TARGET%") do @echo %~sI"'],+ {+ encoding: 'utf8',+ env: { ...process.env, ARCHIFY_SHORT_PATH_TARGET: target },+ windowsHide: true,+ windowsVerbatimArguments: true,+ },+ );+ if (result.error) throw new Error(`Could not query a Windows 8.3 path: ${result.error.message}`);+ if (result.status !== 0) {+ const detail = result.stderr.trim() || 'no stderr';+ throw new Error(`Could not query a Windows 8.3 path (exit ${result.status}): ${detail}`);+ }+ const shortPath = result.stdout.trim();+ if (!shortPath) throw new Error('Windows returned an empty 8.3 path');+ if (path.resolve(shortPath).toLowerCase() === path.resolve(target).toLowerCase()) return null;+ if (fs.realpathSync.native(shortPath).toLowerCase()+ !== fs.realpathSync.native(target).toLowerCase()) {+ throw new Error('Windows returned an 8.3 path for a different directory');+ }+ return shortPath;+}+function stateDirectory(testFixture, version = '2.15.0') {const partition = crypto.createHash('sha256').update(version).digest('hex').slice(0, 24);return path.join(testFixture.cacheDirectory, `version-${partition}`);@@ -1607,6 +1645,103 @@ test('prepared claim cleanup never recursively deletes through a replaced cacheassert.equal(discardedClaims[0].endsWith(`-${discardedOwner.token}`), true);});+test('a cache path case alias is accepted on case-aliasing filesystems', async (t) => {+ const testFixture = fixture();+ t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));+ const aliasedRoot = caseVariant(testFixture.root);+ if (!fs.existsSync(aliasedRoot)) {+ t.skip('the fixture filesystem does not alias path casing');+ return;+ }+ const cacheDirectory = path.join(aliasedRoot, 'cache');++ const result = await checkForUpdate(options(+ testFixture,+ async () => response(remoteRelease()),+ { cacheDirectory },+ ));++ assert.equal(result.status, 'update_available');+ assert.ok(fs.readdirSync(stateDirectory({ ...testFixture, cacheDirectory })).some(+ (entry) => entry.startsWith('committed-'),+ ));+});++test('updater accepts a Windows 8.3 short path for its cache', async (t) => {+ if (process.platform !== 'win32') {+ t.skip('Windows-only 8.3 cache path regression');+ return;+ }+ const testFixture = fixture();+ t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));+ const realDirectory = path.join(testFixture.root, 'cache directory requiring short alias');+ fs.mkdirSync(realDirectory);+ const shortDirectory = windowsShortPath(realDirectory);+ if (!shortDirectory) {+ t.skip('the Windows volume does not expose a distinct 8.3 short path');+ return;+ }+ const cacheDirectory = path.join(shortDirectory, 'cache');++ const result = await checkForUpdate(options(+ testFixture,+ async () => response(remoteRelease()),+ { cacheDirectory },+ ));++ assert.equal(result.status, 'update_available');+ const physicalCache = path.join(realDirectory, 'cache');+ assert.ok(fs.readdirSync(stateDirectory({ ...testFixture, cacheDirectory: physicalCache })).some(+ (entry) => entry.startsWith('committed-'),+ ));+});++test('updater rejects a case-only alias of its prepared cache root', async (t) => {+ if (process.platform !== 'win32') {+ t.skip('Windows-only cache root alias regression');+ return;+ }+ const testFixture = fixture();+ const originalJoin = path.join;+ const originalMkdir = fsPromises.mkdir;+ let injected = false;+ let rootAlias = null;+ let rootMutationAttempts = 0;+ t.after(() => {+ path.join = originalJoin;+ fsPromises.mkdir = originalMkdir;+ fs.rmSync(testFixture.root, { recursive: true, force: true });+ });+ path.join = (...parts) => {+ if (!injected+ && parts.length === 2+ && /^reserved-\d{20}$/.test(String(parts[1]))) {+ injected = true;+ rootAlias = caseVariant(parts[0]);+ assert.equal(fs.existsSync(rootAlias), true);+ return rootAlias;+ }+ return originalJoin(...parts);+ };+ fsPromises.mkdir = async (target, ...args) => {+ if (rootAlias !== null && path.resolve(target) === path.resolve(rootAlias)) {+ rootMutationAttempts += 1;+ }+ return originalMkdir(target, ...args);+ };+ let requests = 0;++ const result = await checkForUpdate(options(testFixture, async () => {+ requests += 1;+ return response(remoteRelease());+ }));++ assert.equal(injected, true);+ assert.deepEqual(result, { status: 'silent', reason: 'cache-unavailable' });+ assert.equal(rootMutationAttempts, 0);+ assert.equal(requests, 0);+});+test('a symlink cache root cannot write into its target', async (t) => {const testFixture = fixture();t.after(() => fs.rmSync(testFixture.root, { recursive: true, force: true }));@@ -3296,6 +3431,11 @@ test('CLI entry detection survives a realpath or symlink alias', (t) => {});assert.equal(result.status, 0, result.stderr);assert.deepEqual(JSON.parse(result.stdout), { status: 'silent', reason: 'disabled' });+ assert.equal(isMainModule({ argvPath: aliasPath, modulePath: checkerPath }), true);+ assert.equal(isMainModule({+ argvPath: path.join(aliasRoot, 'missing-entry.mjs'),+ modulePath: checkerPath,+ }), false);});test('notifier source has no process execution or remote-origin override surface', () => {diff --git a/archify/test/visual-check.test.mjs b/archify/test/visual-check.test.mjsindex 01f148fc..b33c0589 100644--- a/archify/test/visual-check.test.mjs+++ b/archify/test/visual-check.test.mjs@@ -1,17 +1,19 @@import { test } from 'node:test';import assert from 'node:assert/strict';+import { spawnSync } from 'node:child_process';import { createHash } from 'node:crypto';import { EventEmitter } from 'node:events';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import { PassThrough } from 'node:stream';-import { fileURLToPath } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';import {ChromeVisualBrowser,VISUAL_CHECK_VIEWPORTS,chromeVisualBrowserArgs,+ findChrome,persistVisualCheckFailure,runVisualCheck,sidecarPaths,@@ -32,6 +34,15 @@ function sha256(file) {return createHash('sha256').update(fs.readFileSync(file)).digest('hex');}+function entryIdentity(file) {+ const stat = fs.lstatSync(file, { bigint: true });+ return { device: stat.dev, inode: stat.ino, mode: stat.mode };+}++function stagingDirectories(directory) {+ return fs.readdirSync(directory).filter((name) => name.startsWith('.archify-visual-check-'));+}+function fakeBrowser({ overflowAt, unreadableAt, chromeCollisionAt, stageCollisionAt, stageGapAt, screenshotFailure } = {}) {const calls = [];return {@@ -41,7 +52,7 @@ function fakeBrowser({ overflowAt, unreadableAt, chromeCollisionAt, stageCollisiif (screenshotPath && screenshotFailure?.({ width, height, theme })) {throw new Error('synthetic screenshot failure');}- if (screenshotPath) fs.writeFileSync(screenshotPath, png);+ if (screenshotPath) fs.writeFileSync(screenshotPath, png, { flag: 'wx' });const overflow = overflowAt?.({ width, height, theme }) || false;const unreadable = unreadableAt?.({ width, height, theme }) || false;const chromeCollision = chromeCollisionAt?.({ width, height, theme }) || false;@@ -91,6 +102,79 @@ function fakeChromeChild() {return child;}+test('findChrome discovers chrome.exe from a Windows PATH after default locations', () => {+ const checked = [];+ const expected = String.raw`D:\Browser Bin\chrome.EXE`;+ const resolved = findChrome({+ platform: 'win32',+ env: {+ PROGRAMFILES: String.raw`C:\Program Files`,+ PATH: String.raw`C:\Tools;D:\Browser Bin`,+ PATHEXT: '.EXE;.CMD',+ },+ resolveExecutable(candidate) {+ checked.push(candidate);+ return candidate === expected ? candidate : null;+ },+ });++ assert.equal(resolved, expected);+ assert.deepEqual(checked.slice(0, 2), [+ String.raw`C:\Program Files\Google\Chrome\Application\chrome.exe`,+ String.raw`C:\Program Files\Chromium\Application\chrome.exe`,+ ]);+ assert.ok(+ checked.indexOf(String.raw`C:\Program Files\Chromium\Application\chrome.exe`)+ < checked.indexOf(String.raw`C:\Tools\chrome.EXE`),+ 'default install locations must be checked before PATH',+ );+});++test('findChrome keeps an installed Windows Chrome ahead of PATH candidates', () => {+ const checked = [];+ const installed = String.raw`C:\Program Files\Google\Chrome\Application\chrome.exe`;+ const portable = String.raw`D:\Browser Bin\chrome.EXE`;+ const resolved = findChrome({+ platform: 'win32',+ env: {+ PROGRAMFILES: String.raw`C:\Program Files`,+ PATH: String.raw`D:\Browser Bin`,+ PATHEXT: '.EXE',+ },+ resolveExecutable(candidate) {+ checked.push(candidate);+ return candidate === installed || candidate === portable ? candidate : null;+ },+ });++ assert.equal(resolved, installed);+ assert.deepEqual(checked, [installed]);+});++test('findChrome checks Chromium command names on a Windows PATH', () => {+ const checked = [];+ const expected = String.raw`D:\Browser Bin\chromium.EXE`;+ const resolved = findChrome({+ platform: 'win32',+ env: {+ PATH: String.raw`D:\Browser Bin`,+ PATHEXT: '.EXE',+ },+ resolveExecutable(candidate) {+ checked.push(candidate);+ return candidate === expected ? candidate : null;+ },+ });++ assert.equal(resolved, expected);+ assert.deepEqual(checked, [+ String.raw`D:\Browser Bin\chrome.EXE`,+ String.raw`D:\Browser Bin\google-chrome.EXE`,+ String.raw`D:\Browser Bin\google-chrome-stable.EXE`,+ expected,+ ]);+});+test('visual-check disables the Chrome sandbox only for root or an explicit environment opt-in', () => {const profileRoot = path.join(tmp, 'chrome-profile');const ordinary = chromeVisualBrowserArgs(profileRoot, { env: {}, getuid: () => 1001 });@@ -228,9 +312,9 @@ test('sidecarPaths places outputs in outDir instead of beside the artifact', ()assert.equal(outputs.screenshots.every((entry) => path.dirname(entry.path) === separateDir), true);assert.equal(path.basename(outputs.receipt), 'outdir-source.visual-check.json');- // Omitting outDir keeps the existing beside-the-artifact behavior unchanged.+ // Omitting outDir keeps evidence beside the physical artifact.const defaultOutputs = sidecarPaths(input);- assert.equal(path.dirname(defaultOutputs.receipt), path.dirname(input));+ assert.equal(path.dirname(defaultOutputs.receipt), path.dirname(fs.realpathSync.native(input)));});test('visual-check writes all sidecars into --out-dir end-to-end, none beside the artifact', async () => {@@ -260,6 +344,1582 @@ test('visual-check writes all sidecars into --out-dir end-to-end, none beside thassert.equal(fs.existsSync(besideArtifact.contactSheet), false);});+test('visual-check sidecar directory identity treats a physical alias as redundant', async (t) => {+ const physicalDirectory = path.join(tmp, 'physical-sidecar-directory');+ const aliasDirectory = path.join(tmp, 'aliased-sidecar-directory');+ fs.mkdirSync(physicalDirectory, { recursive: true });+ try {+ fs.symlinkSync(+ physicalDirectory,+ aliasDirectory,+ process.platform === 'win32' ? 'junction' : 'dir',+ );+ } catch (error) {+ t.skip(`directory aliases are unavailable: ${error.message}`);+ return;+ }++ const input = path.join(physicalDirectory, 'aliased-sidecars.html');+ fs.writeFileSync(input, '<!doctype html><html><body>aliased evidence</body></html>');+ const outputs = sidecarPaths(input, { outDir: aliasDirectory });+ assert.notEqual(path.dirname(outputs.receipt), path.dirname(input), 'precondition: spellings differ');++ const result = await runVisualCheck({+ artifactPath: input,+ outDir: aliasDirectory,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(result.exitCode, 0);+ assert.equal('directory' in result.receipt.sidecars, false);++ const failure = persistVisualCheckFailure(input, {+ schemaVersion: 1,+ command: 'visual-check',+ artifact: { path: input },+ error: 'synthetic delivery failure',+ diagnostics: [{ code: 'delivery/provenance-failed' }],+ }, { outDir: aliasDirectory });+ assert.equal('directory' in failure.sidecars, false);+});++test('visual-check preserves unowned receipt, contact-sheet, and screenshot path collisions', async () => {+ const cases = [+ { name: 'receipt', select: (outputs) => outputs.receipt, bytes: Buffer.from('{"foreign":true}\n') },+ { name: 'contact-sheet', select: (outputs) => outputs.contactSheet, bytes: Buffer.from('<!doctype html><title>real artifact</title>\n') },+ { name: 'screenshot', select: (outputs) => outputs.screenshots[0].path, bytes: Buffer.from('foreign png bytes\n') },+ ];++ for (const scenario of cases) {+ const input = artifact(`unowned-${scenario.name}.html`);+ const outputs = sidecarPaths(input);+ const collision = scenario.select(outputs);+ fs.writeFileSync(collision, scenario.bytes);+ let launched = false;++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => {+ launched = true;+ return fakeBrowser();+ },+ });++ assert.equal(result.exitCode, 1, scenario.name);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict', scenario.name);+ assert.equal(launched, false, scenario.name);+ assert.deepEqual(fs.readFileSync(collision), scenario.bytes, scenario.name);+ }++ const input = artifact('unowned-persist-failure.html');+ const outputs = sidecarPaths(input);+ const sentinel = Buffer.from('<!doctype html><title>real artifact</title>\n');+ fs.writeFileSync(outputs.contactSheet, sentinel);+ const receipt = persistVisualCheckFailure(input, {+ schemaVersion: 1,+ command: 'visual-check',+ artifact: { path: input, sha256: sha256(input), bytes: fs.statSync(input).size },+ error: 'synthetic delivery failure',+ diagnostics: [{ code: 'delivery/provenance-failed' }],+ });+ assert.equal(receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.equal(fs.existsSync(outputs.receipt), false);+});++test('visual-check preserves receipt, contact-sheet, and PNG claimants created after preflight', async () => {+ const cases = [+ { name: 'receipt', select: (outputs) => outputs.receipt, noChrome: true },+ { name: 'contact-sheet', select: (outputs) => outputs.contactSheet },+ { name: 'screenshot', select: (outputs) => outputs.screenshots[0].path },+ ];++ for (const scenario of cases) {+ const input = artifact(`late-${scenario.name}-claimant.html`);+ const outDir = path.join(tmp, `late-${scenario.name}-evidence`);+ const outputs = sidecarPaths(input, { outDir });+ const claimant = scenario.select(outputs);+ const sentinel = Buffer.from(`late ${scenario.name} claimant\n`);+ let claimed = false;+ const claim = () => {+ if (claimed) return;+ claimed = true;+ fs.writeFileSync(claimant, sentinel, { flag: 'wx' });+ };+ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ claim();+ return metrics;+ };++ const result = await runVisualCheck({+ artifactPath: input,+ outDir,+ ...(scenario.noChrome+ ? { resolveChrome: () => { claim(); return null; } }+ : { chromePath: '/fake/chrome', browserFactory: async () => browser }),+ });++ assert.equal(result.exitCode, 1, scenario.name);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict', scenario.name);+ assert.deepEqual(fs.readFileSync(claimant), sentinel, scenario.name);+ assert.deepEqual(stagingDirectories(outDir), [], scenario.name);+ for (const target of [outputs.receipt, outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)]) {+ if (target !== claimant) assert.equal(fs.existsSync(target), false, `${scenario.name}: ${target}`);+ }+ }+});++test('visual-check preserves receipt, contact-sheet, and PNG replacements made after preflight', async () => {+ const cases = [+ { name: 'receipt', select: (outputs) => outputs.receipt, noChrome: true },+ { name: 'contact-sheet', select: (outputs) => outputs.contactSheet },+ { name: 'screenshot', select: (outputs) => outputs.screenshots[0].path },+ ];++ for (const scenario of cases) {+ const input = artifact(`late-${scenario.name}-replacement.html`);+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0, `${scenario.name}: initial evidence`);+ const targets = [outputs.receipt, outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)];+ const before = new Map(targets.map((target) => [target, fs.readFileSync(target)]));+ const replaced = scenario.select(outputs);+ const sentinel = Buffer.from(`replacement ${scenario.name}\n`);+ let replacementIdentity;+ let injected = false;+ const replace = () => {+ if (injected) return;+ injected = true;+ fs.unlinkSync(replaced);+ fs.writeFileSync(replaced, sentinel, { flag: 'wx' });+ replacementIdentity = entryIdentity(replaced);+ };+ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ replace();+ return metrics;+ };++ const result = await runVisualCheck({+ artifactPath: input,+ ...(scenario.noChrome+ ? { resolveChrome: () => { replace(); return null; } }+ : { chromePath: '/fake/chrome', browserFactory: async () => browser }),+ });++ assert.equal(result.exitCode, 1, scenario.name);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict', scenario.name);+ assert.deepEqual(fs.readFileSync(replaced), sentinel, scenario.name);+ assert.deepEqual(entryIdentity(replaced), replacementIdentity, scenario.name);+ for (const target of targets) {+ if (target !== replaced) assert.deepEqual(fs.readFileSync(target), before.get(target), `${scenario.name}: ${target}`);+ }+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), [], scenario.name);+ }+});++test('visual-check preserves a regular successor swapped at the backup link boundary', async (t) => {+ const input = artifact('backup-link-regular-successor.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const displaced = path.join(tmp, 'backup-link-regular-displaced.json');+ const successor = Buffer.from('external regular successor at backup boundary\n');+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const linkSync = fs.linkSync.bind(fs);+ const renameSync = fs.renameSync.bind(fs);+ let injected = false;+ let successorIdentity;+ t.after(() => {+ fs.rmSync(displaced, { force: true });+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });+ t.mock.method(fs, 'linkSync', (source, target) => {+ const sourcePath = String(source);+ const targetPath = String(target);+ if (!injected+ && path.basename(sourcePath) === path.basename(outputs.receipt)+ && path.basename(targetPath) === 'previous-0'+ && path.basename(path.dirname(targetPath)).startsWith('.archify-visual-check-')) {+ renameSync(sourcePath, displaced);+ fs.writeFileSync(sourcePath, successor, { flag: 'wx' });+ successorIdentity = entryIdentity(sourcePath);+ injected = true;+ }+ return linkSync(sourcePath, targetPath);+ });++ const result = await runVisualCheck({+ artifactPath: input,+ resolveChrome: () => null,+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.deepEqual(fs.readFileSync(outputs.receipt), successor);+ assert.deepEqual(entryIdentity(outputs.receipt), successorIdentity);+});++for (const scenario of [+ {+ name: 'directory',+ create(file) {+ fs.mkdirSync(file);+ },+ assertPreserved(file) {+ assert.equal(fs.lstatSync(file).isDirectory(), true);+ },+ },+ {+ name: 'FIFO',+ create(file, t) {+ const created = spawnSync('mkfifo', [file], { encoding: 'utf8' });+ if (created.status !== 0) {+ t.skip(`mkfifo is unavailable: ${created.stderr || `exit ${created.status}`}`);+ const error = new Error('mkfifo unavailable');+ error.code = 'ARCHIFY_TEST_SKIPPED';+ throw error;+ }+ },+ assertPreserved(file) {+ assert.equal(fs.lstatSync(file).isFIFO(), true);+ },+ },+ {+ name: 'symlink',+ create(file, t) {+ const target = path.join(tmp, 'backup-link-symlink-target');+ fs.writeFileSync(target, 'symlink target', { flag: fs.existsSync(target) ? 'w' : 'wx' });+ try {+ fs.symlinkSync(target, file, 'file');+ } catch (error) {+ if (error?.code === 'EPERM') {+ t.skip(`file symlinks are unavailable: ${error.message}`);+ const skipped = new Error('file symlinks unavailable');+ skipped.code = 'ARCHIFY_TEST_SKIPPED';+ throw skipped;+ }+ throw error;+ }+ },+ assertPreserved(file) {+ assert.equal(fs.lstatSync(file).isSymbolicLink(), true);+ },+ },+]) {+ test(`visual-check preserves a ${scenario.name} swapped at the backup link boundary`, async (t) => {+ const input = artifact(`backup-link-${scenario.name.toLowerCase()}-successor.html`);+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const displaced = path.join(tmp, `backup-link-${scenario.name.toLowerCase()}-displaced.json`);+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const linkSync = fs.linkSync.bind(fs);+ const renameSync = fs.renameSync.bind(fs);+ let injected = false;+ t.after(() => {+ fs.rmSync(displaced, { force: true });+ fs.rmSync(outputs.receipt, { recursive: true, force: true });+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });+ t.mock.method(fs, 'linkSync', (source, target) => {+ const sourcePath = String(source);+ const targetPath = String(target);+ if (!injected+ && path.basename(sourcePath) === path.basename(outputs.receipt)+ && path.basename(targetPath) === 'previous-0'+ && path.basename(path.dirname(targetPath)).startsWith('.archify-visual-check-')) {+ renameSync(sourcePath, displaced);+ scenario.create(sourcePath, t);+ injected = true;+ }+ return linkSync(sourcePath, targetPath);+ });++ let result;+ try {+ result = await runVisualCheck({+ artifactPath: input,+ resolveChrome: () => null,+ });+ } catch (error) {+ if (error?.code === 'ARCHIFY_TEST_SKIPPED') return;+ throw error;+ }++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ scenario.assertPreserved(outputs.receipt);+ });+}++test('visual-check preserves an in-place evidence edit made after preflight', async () => {+ const input = artifact('late-in-place-evidence-edit.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const targets = [+ outputs.receipt,+ outputs.contactSheet,+ ...outputs.screenshots.map((entry) => entry.path),+ ];+ const before = new Map(targets.map((target) => [target, fs.readFileSync(target)]));+ const originalIdentity = entryIdentity(outputs.contactSheet);+ const sentinel = Buffer.from('external in-place contact-sheet edit\n');+ let editedIdentity;+ let injected = false;+ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ if (!injected) {+ fs.writeFileSync(outputs.contactSheet, sentinel);+ editedIdentity = entryIdentity(outputs.contactSheet);+ injected = true;+ }+ return metrics;+ };++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => browser,+ });++ assert.equal(injected, true);+ assert.deepEqual(editedIdentity, originalIdentity, 'the injected edit must retain the captured inode');+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(+ result.receipt.diagnostics.at(-1)?.evidence?.reason?.code,+ 'previous-evidence-content-changed',+ );+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.deepEqual(entryIdentity(outputs.contactSheet), editedIdentity);+ for (const target of targets) {+ if (target !== outputs.contactSheet) assert.deepEqual(fs.readFileSync(target), before.get(target), target);+ }+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++test('visual-check preserves an in-place backup edit made before cleanup', async (t) => {+ const input = artifact('late-in-place-backup-edit.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const targets = [+ outputs.receipt,+ outputs.contactSheet,+ ...outputs.screenshots.map((entry) => entry.path),+ ];+ const before = new Map(targets.map((target) => [target, fs.readFileSync(target)]));+ const originalIdentity = entryIdentity(outputs.contactSheet);+ const sentinel = Buffer.from('external in-place backup edit\n');+ const linkSync = fs.linkSync.bind(fs);+ let editedIdentity;+ let injected = false;+ t.mock.method(fs, 'linkSync', (source, target) => {+ const result = linkSync(source, target);+ if (!injected+ && path.basename(String(source)) === 'receipt.json'+ && path.basename(path.dirname(String(source))).startsWith('.archify-visual-check-')) {+ const backup = path.join(path.dirname(String(source)), 'previous-1');+ fs.writeFileSync(backup, sentinel);+ editedIdentity = entryIdentity(backup);+ injected = true;+ }+ return result;+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(injected, true);+ assert.deepEqual(editedIdentity, originalIdentity, 'the injected edit must retain the backup inode');+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(+ result.receipt.diagnostics.at(-1)?.evidence?.reason?.code,+ 'backup-content-changed-before-cleanup',+ );+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.deepEqual(entryIdentity(outputs.contactSheet), editedIdentity);+ for (const target of targets) {+ if (target !== outputs.contactSheet) assert.deepEqual(fs.readFileSync(target), before.get(target), target);+ }+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++test('visual-check refuses hard-linked receipt, contact-sheet, and PNG evidence without mutation', async (t) => {+ const selectors = [+ ['receipt', (outputs) => outputs.receipt],+ ['contact-sheet', (outputs) => outputs.contactSheet],+ ['screenshot', (outputs) => outputs.screenshots[0].path],+ ];++ for (const [name, select] of selectors) {+ const input = artifact(`hardlinked-${name}.html`);+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0, `${name}: initial evidence`);+ const target = select(outputs);+ const alias = `${target}.alias`;+ try {+ fs.linkSync(target, alias);+ } catch (error) {+ t.skip(`hard links are unavailable: ${error.message}`);+ return;+ }+ const before = fs.readFileSync(target);+ let launched = false;+ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => { launched = true; return fakeBrowser(); },+ });+ assert.equal(result.exitCode, 1, name);+ assert.equal(launched, false, name);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict', name);+ assert.match(+ result.receipt.diagnostics.at(-1)?.evidence?.reason?.code || '',+ /^(?:requested-entry|target)-hardlinked$/,+ name,+ );+ assert.deepEqual(fs.readFileSync(target), before, name);+ assert.deepEqual(fs.readFileSync(alias), before, `${name}: alias`);+ }+});++test('visual-check rejects an lstat-to-open symlink substitution without following it', async (t) => {+ const input = artifact('staged-evidence-symlink-race.html');+ const outputs = sidecarPaths(input);+ const sentinel = path.join(tmp, 'staged-evidence-symlink-sentinel.txt');+ const probe = path.join(tmp, 'staged-evidence-symlink-probe');+ const sentinelBytes = Buffer.from('must never be read through the staged evidence path\n');+ fs.writeFileSync(sentinel, sentinelBytes);+ try {+ fs.symlinkSync(sentinel, probe, 'file');+ fs.unlinkSync(probe);+ } catch (error) {+ t.skip(`file symlinks are unavailable: ${error.message}`);+ return;+ }++ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ let screenshotReady = false;+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ if (args.screenshotPath) screenshotReady = true;+ return metrics;+ };++ const openSync = fs.openSync.bind(fs);+ let injected = false;+ let claimant;+ t.mock.method(fs, 'openSync', (file, flags, mode) => {+ const candidate = String(file);+ if (!injected+ && screenshotReady+ && path.basename(candidate) === 'capture-0.png'+ && path.basename(path.dirname(candidate)).startsWith('.archify-visual-check-')) {+ fs.unlinkSync(candidate);+ fs.symlinkSync(sentinel, candidate, 'file');+ claimant = candidate;+ injected = true;+ }+ return openSync(file, flags, mode);+ });+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => browser,+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.deepEqual(fs.readFileSync(sentinel), sentinelBytes);+ assert.equal(fs.lstatSync(claimant).isSymbolicLink(), true);+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+});++test('visual-check rejects an lstat-to-open FIFO substitution without blocking', {+ skip: process.platform === 'win32' ? 'named pipes use different APIs on Windows' : false,+ timeout: 5_000,+}, async (t) => {+ const input = artifact('staged-evidence-fifo-race.html');+ const outputs = sidecarPaths(input);+ const probe = path.join(tmp, 'staged-evidence-fifo-probe');+ const probeResult = spawnSync('mkfifo', [probe]);+ if (probeResult.status !== 0) {+ t.skip(`mkfifo is unavailable: ${probeResult.stderr?.toString() || 'unknown error'}`);+ return;+ }+ fs.unlinkSync(probe);++ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ let screenshotReady = false;+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ if (args.screenshotPath) screenshotReady = true;+ return metrics;+ };++ const openSync = fs.openSync.bind(fs);+ let injected = false;+ let claimant;+ t.mock.method(fs, 'openSync', (file, flags, mode) => {+ const candidate = String(file);+ if (!injected+ && screenshotReady+ && path.basename(candidate) === 'capture-0.png'+ && path.basename(path.dirname(candidate)).startsWith('.archify-visual-check-')) {+ fs.unlinkSync(candidate);+ const created = spawnSync('mkfifo', [candidate]);+ assert.equal(created.status, 0, created.stderr?.toString());+ claimant = candidate;+ injected = true;+ }+ return openSync(file, flags, mode);+ });+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ });++ const started = Date.now();+ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => browser,+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.ok(Date.now() - started < 2_000, 'FIFO inspection must fail without waiting for a writer');+ assert.equal(fs.lstatSync(claimant).isFIFO(), true);+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+});++for (const operation of ['run', 'persist-failure']) {+ test(`visual-check ${operation} rejects an artifact changed to a FIFO before open`, {+ skip: process.platform === 'win32' ? 'named pipes use different APIs on Windows' : false,+ timeout: 10_000,+ }, (t) => {+ const input = artifact(`artifact-fifo-substitution-${operation}.html`);+ const outputs = sidecarPaths(input);+ const visualCheckUrl = new URL('../bin/visual-check.mjs', import.meta.url).href;+ t.after(() => {+ try {+ if (fs.lstatSync(input).isFIFO()) fs.unlinkSync(input);+ } catch {}+ });+ const script = `+ import { spawnSync } from 'node:child_process';+ import fs from 'node:fs';+ import path from 'node:path';+ import { persistVisualCheckFailure, runVisualCheck } from ${JSON.stringify(visualCheckUrl)};+ const artifact = ${JSON.stringify(input)};+ const openSync = fs.openSync.bind(fs);+ let injected = false;+ fs.openSync = (file, flags, mode) => {+ if (!injected && path.resolve(String(file)) === artifact) {+ fs.unlinkSync(artifact);+ const created = spawnSync('mkfifo', [artifact]);+ if (created.status !== 0) throw new Error(created.stderr?.toString() || 'mkfifo failed');+ injected = true;+ }+ return openSync(file, flags, mode);+ };+ ${operation === 'run'+ ? `try {+ await runVisualCheck({ artifactPath: artifact, resolveChrome: () => null });+ console.error('operation unexpectedly accepted the FIFO');+ process.exitCode = 2;+ } catch (error) {+ console.log(JSON.stringify({ injected, reason: error.evidenceReason?.code || error.message }));+ }`+ : `const receipt = persistVisualCheckFailure(artifact, {+ schemaVersion: 1,+ command: 'visual-check',+ status: 'fail',+ diagnostics: [],+ });+ console.log(JSON.stringify({+ injected,+ reason: receipt.diagnostics?.at(-1)?.evidence?.reason?.code || receipt.error,+ }));`}+ `;++ const child = spawnSync(process.execPath, ['--input-type=module', '--eval', script], {+ encoding: 'utf8',+ timeout: 3_000,+ });++ assert.equal(child.error, undefined, child.error?.message);+ assert.equal(child.status, 0, child.stderr || child.stdout);+ const observed = JSON.parse(child.stdout);+ assert.equal(observed.injected, true);+ assert.match(observed.reason, /not-regular-file|changed-during-inspection|artifact-unreadable/);+ assert.equal(fs.lstatSync(input).isFIFO(), true);+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+ });+}++test('visual-check rejects a previous receipt changed to a FIFO before its content open', {+ skip: process.platform === 'win32' ? 'named pipes use different APIs on Windows' : false,+ timeout: 10_000,+}, async (t) => {+ const input = artifact('previous-receipt-fifo-substitution.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({ artifactPath: input, resolveChrome: () => null });+ assert.equal(first.exitCode, 2);+ const receiptBefore = fs.readFileSync(outputs.receipt);+ const visualCheckUrl = new URL('../bin/visual-check.mjs', import.meta.url).href;+ t.after(() => {+ try {+ if (fs.lstatSync(outputs.receipt).isFIFO()) fs.unlinkSync(outputs.receipt);+ } catch {}+ });+ const script = `+ import { spawnSync } from 'node:child_process';+ import fs from 'node:fs';+ import path from 'node:path';+ import { runVisualCheck } from ${JSON.stringify(visualCheckUrl)};+ const artifact = ${JSON.stringify(input)};+ const receipt = ${JSON.stringify(outputs.receipt)};+ const openSync = fs.openSync.bind(fs);+ let receiptOpens = 0;+ let injected = false;+ fs.openSync = (file, flags, mode) => {+ if (path.resolve(String(file)) === receipt) {+ receiptOpens += 1;+ if (!injected && receiptOpens === 3) {+ fs.unlinkSync(receipt);+ const created = spawnSync('mkfifo', [receipt]);+ if (created.status !== 0) throw new Error(created.stderr?.toString() || 'mkfifo failed');+ injected = true;+ }+ }+ return openSync(file, flags, mode);+ };+ const result = await runVisualCheck({ artifactPath: artifact, resolveChrome: () => null });+ console.log(JSON.stringify({+ injected,+ receiptOpens,+ exitCode: result.exitCode,+ reason: result.receipt.diagnostics?.at(-1)?.evidence?.reason?.code,+ }));+ `;++ const child = spawnSync(process.execPath, ['--input-type=module', '--eval', script], {+ encoding: 'utf8',+ timeout: 3_000,+ });++ assert.equal(child.error, undefined, child.error?.message);+ assert.equal(child.status, 0, child.stderr || child.stdout);+ const observed = JSON.parse(child.stdout);+ assert.equal(observed.injected, true, JSON.stringify(observed));+ assert.equal(observed.receiptOpens, 3);+ assert.equal(observed.exitCode, 1);+ assert.equal(observed.reason, 'requested-entry-changed-during-inspection');+ assert.equal(fs.lstatSync(outputs.receipt).isFIFO(), true);+ assert.deepEqual(receiptBefore.length > 0, true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++test('visual-check preserves existing evidence modes under a restrictive umask', async (t) => {+ if (process.platform === 'win32') {+ t.skip('POSIX permission bits are not portable to Windows');+ return;+ }++ const input = artifact('preserved-evidence-modes.html');+ const outputs = sidecarPaths(input);+ const targets = [+ outputs.receipt,+ outputs.contactSheet,+ ...outputs.screenshots.map((entry) => entry.path),+ ];+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ for (const target of targets) fs.chmodSync(target, 0o666);++ const previousUmask = process.umask(0o077);+ let second;+ try {+ second = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ } finally {+ process.umask(previousUmask);+ }++ assert.equal(second.exitCode, 0);+ for (const target of targets) {+ assert.equal(fs.statSync(target).mode & 0o777, 0o666, target);+ }+});++test('visual-check never follows the former predictable temporary symlink', async (t) => {+ const input = artifact('predictable-temporary-symlink.html');+ const outputs = sidecarPaths(input);+ const sentinel = path.join(tmp, 'predictable-temporary-sentinel.txt');+ const temporary = `${outputs.receipt}.tmp-${process.pid}`;+ const bytes = Buffer.from('must not be truncated\n');+ fs.writeFileSync(sentinel, bytes);+ try {+ fs.symlinkSync(sentinel, temporary, 'file');+ } catch (error) {+ t.skip(`file symlinks are unavailable: ${error.message}`);+ return;+ }++ const result = await runVisualCheck({ artifactPath: input, resolveChrome: () => null });++ assert.equal(result.exitCode, 2);+ assert.deepEqual(fs.readFileSync(sentinel), bytes);+ assert.equal(fs.lstatSync(temporary).isSymbolicLink(), true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++test('visual-check preserves absent and replaced paths that become symlinks after preflight', async (t) => {+ const sentinel = path.join(tmp, 'late-symlink-sentinel.txt');+ const sentinelBytes = Buffer.from('symlink claimant target\n');+ fs.writeFileSync(sentinel, sentinelBytes);+ const cases = [+ { name: 'absent', prepare: async () => {} },+ {+ name: 'existing',+ prepare: async (input) => {+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ },+ },+ ];++ for (const scenario of cases) {+ const input = artifact(`late-${scenario.name}-symlink.html`);+ const outputs = sidecarPaths(input);+ await scenario.prepare(input);+ const before = new Map(+ [outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)]+ .filter((file) => fs.existsSync(file))+ .map((file) => [file, fs.readFileSync(file)]),+ );+ let injected = false;+ const inject = () => {+ if (injected) return;+ injected = true;+ if (fs.existsSync(outputs.receipt)) fs.unlinkSync(outputs.receipt);+ fs.symlinkSync(sentinel, outputs.receipt, 'file');+ };++ let result;+ try {+ result = await runVisualCheck({+ artifactPath: input,+ resolveChrome: () => { inject(); return null; },+ });+ } catch (error) {+ if (error?.code === 'EPERM') {+ t.skip(`file symlinks are unavailable: ${error.message}`);+ return;+ }+ throw error;+ }++ assert.equal(result.exitCode, 1, scenario.name);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict', scenario.name);+ assert.equal(fs.lstatSync(outputs.receipt).isSymbolicLink(), true, scenario.name);+ assert.deepEqual(fs.readFileSync(sentinel), sentinelBytes, scenario.name);+ for (const [file, bytes] of before) assert.deepEqual(fs.readFileSync(file), bytes, `${scenario.name}: ${file}`);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), [], scenario.name);+ }+});++test('visual-check rejects a screenshot candidate externally hard-linked before registration', async (t) => {+ const input = artifact('staged-screenshot-hardlink.html');+ const outputs = sidecarPaths(input);+ const alias = path.join(tmp, 'staged-screenshot-external-alias.png');+ const browser = fakeBrowser();+ const inspect = browser.inspect.bind(browser);+ let injected = false;+ let hardLinkUnavailable;+ browser.inspect = async (args) => {+ const metrics = await inspect(args);+ if (args.screenshotPath && !injected && !hardLinkUnavailable) {+ try {+ fs.linkSync(args.screenshotPath, alias);+ } catch (error) {+ if (['EPERM', 'EACCES', 'ENOTSUP'].includes(error?.code)) {+ hardLinkUnavailable = error;+ return metrics;+ }+ throw error;+ }+ injected = true;+ }+ return metrics;+ };++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => browser,+ });++ if (hardLinkUnavailable) {+ t.skip(`hard links are unavailable: ${hardLinkUnavailable.message}`);+ return;+ }+ assert.equal(injected, true, 'the staged screenshot hard-link injection must run');+ assert.equal(result.exitCode, 1);+ assert.equal(fs.existsSync(alias), true);+ assert.deepEqual(fs.readFileSync(alias), png);+ assert.equal(fs.lstatSync(alias, { bigint: true }).nlink, 1n);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++for (const candidate of [+ { name: 'contact-sheet', stagedName: 'contact-sheet.html', chrome: true },+ { name: 'receipt', stagedName: 'receipt.json', chrome: false },+]) {+ test(`visual-check rolls back when the staged ${candidate.name} gains an external hard link during publish`, async (t) => {+ const input = artifact(`staged-${candidate.name}-publish-hardlink.html`);+ const outputs = sidecarPaths(input);+ const alias = path.join(tmp, `staged-${candidate.name}-publish-external-alias`);+ const linkSync = fs.linkSync.bind(fs);+ let injected = false;+ t.mock.method(fs, 'linkSync', (source, target) => {+ if (!injected && path.basename(source) === candidate.stagedName) {+ linkSync(source, alias);+ injected = true;+ }+ return linkSync(source, target);+ });++ const result = await runVisualCheck({+ artifactPath: input,+ ...(candidate.chrome+ ? { chromePath: '/fake/chrome', browserFactory: async () => fakeBrowser() }+ : { resolveChrome: () => null }),+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(fs.existsSync(alias), true);+ assert.equal(fs.lstatSync(alias, { bigint: true }).nlink, 1n);+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+ });+}++for (const scenario of [+ {+ name: 'contact sheet',+ selectEarly: (outputs) => outputs.contactSheet,+ triggerStagedName: 'capture-0.png',+ },+ {+ name: 'first screenshot',+ selectEarly: (outputs) => outputs.screenshots[0].path,+ triggerStagedName: 'receipt.json',+ },+]) {+ test(`visual-check final set sweep preserves a replacement of the early ${scenario.name}`, async (t) => {+ const input = artifact(`final-sweep-${scenario.name.replaceAll(' ', '-')}.html`);+ const outputs = sidecarPaths(input);+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ const targets = [outputs.receipt, outputs.contactSheet, ...outputs.screenshots.map((entry) => entry.path)];+ const before = new Map(targets.map((target) => [target, fs.readFileSync(target)]));+ const replaced = scenario.selectEarly(outputs);+ const sentinel = Buffer.from(`late replacement of ${scenario.name}\n`);+ const linkSync = fs.linkSync.bind(fs);+ let replacementIdentity;+ let injected = false;+ t.mock.method(fs, 'linkSync', (source, target) => {+ const result = linkSync(source, target);+ if (!injected+ && path.basename(String(source)) === scenario.triggerStagedName+ && path.basename(path.dirname(String(source))).startsWith('.archify-visual-check-')) {+ injected = true;+ fs.unlinkSync(replaced);+ fs.writeFileSync(replaced, sentinel, { flag: 'wx' });+ replacementIdentity = entryIdentity(replaced);+ }+ return result;+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(result.receipt.diagnostics.at(-1)?.evidence?.reason?.code, 'published-set-identity-mismatch');+ assert.deepEqual(fs.readFileSync(replaced), sentinel);+ assert.deepEqual(entryIdentity(replaced), replacementIdentity);+ for (const target of targets) {+ if (target !== replaced) assert.deepEqual(fs.readFileSync(target), before.get(target), target);+ }+ });+}++test('visual-check rollback preserves an in-place edit to an already published member', async (t) => {+ const input = artifact('rollback-published-content-edit.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const targets = [+ outputs.receipt,+ outputs.contactSheet,+ ...outputs.screenshots.map((entry) => entry.path),+ ];+ const before = new Map(targets.map((target) => [target, fs.readFileSync(target)]));+ const originalContactIdentity = entryIdentity(outputs.contactSheet);+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });++ const sentinel = Buffer.from('external in-place edit after contact-sheet publication\n');+ const linkSync = fs.linkSync.bind(fs);+ let firstPublishedIdentity;+ let editedIdentity;+ let injected = false;+ t.mock.method(fs, 'linkSync', (source, target) => {+ const sourceName = path.basename(String(source));+ const fromStaging = path.basename(path.dirname(String(source))).startsWith('.archify-visual-check-');+ if (!injected && firstPublishedIdentity && fromStaging && sourceName === 'capture-0.png') {+ fs.writeFileSync(outputs.contactSheet, sentinel);+ editedIdentity = entryIdentity(outputs.contactSheet);+ injected = true;+ throw new Error('synthetic later evidence publication failure');+ }+ const result = linkSync(source, target);+ if (!firstPublishedIdentity && fromStaging && sourceName === 'contact-sheet.html') {+ firstPublishedIdentity = entryIdentity(target);+ }+ return result;+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(injected, true);+ assert.deepEqual(editedIdentity, firstPublishedIdentity, 'the edit must retain the published inode');+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-write');+ const rollbackReasons = result.receipt.diagnostics.at(-1)?.evidence?.errors+ ?.map((entry) => entry.reason).join('\n') || '';+ assert.match(rollbackReasons, /published entry content changed; it was preserved/);+ assert.match(rollbackReasons, /final path is occupied; the owned backup was preserved/);+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.deepEqual(entryIdentity(outputs.contactSheet), editedIdentity);+ for (const target of targets) {+ if (target !== outputs.contactSheet) assert.deepEqual(fs.readFileSync(target), before.get(target), target);+ }++ const retained = stagingDirectories(path.dirname(outputs.receipt))+ .filter((directory) => !stagingBefore.has(directory));+ assert.equal(retained.length, 1);+ const backup = path.join(path.dirname(outputs.receipt), retained[0], 'previous-1');+ assert.deepEqual(fs.readFileSync(backup), before.get(outputs.contactSheet));+ assert.deepEqual(entryIdentity(backup), originalContactIdentity);+});++test('visual-check rollback preserves a successor swapped at the public removal boundary', async (t) => {+ const input = artifact('rollback-public-removal-successor.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const displaced = path.join(tmp, 'rollback-public-removal-owned-displaced.html');+ const successor = Buffer.from('external successor at the public removal boundary\n');+ t.after(() => {+ fs.rmSync(displaced, { force: true });+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });++ const linkSync = fs.linkSync.bind(fs);+ const renameSync = fs.renameSync.bind(fs);+ let contactPublished = false;+ let failureInjected = false;+ let successorInjected = false;+ let successorIdentity;+ t.mock.method(fs, 'linkSync', (source, target) => {+ const sourceName = path.basename(String(source));+ const fromStaging = path.basename(path.dirname(String(source))).startsWith('.archify-visual-check-');+ if (!failureInjected && contactPublished && fromStaging && sourceName === 'capture-0.png') {+ failureInjected = true;+ throw new Error('synthetic later evidence publication failure');+ }+ const result = linkSync(source, target);+ if (!contactPublished && fromStaging && sourceName === 'contact-sheet.html') {+ contactPublished = true;+ }+ return result;+ });+ t.mock.method(fs, 'renameSync', (source, target) => {+ const sourcePath = String(source);+ const targetPath = String(target);+ if (failureInjected+ && !successorInjected+ && path.basename(sourcePath) === path.basename(outputs.contactSheet)+ && path.basename(path.dirname(targetPath)).startsWith('.archify-remove-')) {+ renameSync(sourcePath, displaced);+ fs.writeFileSync(sourcePath, successor, { flag: 'wx' });+ successorIdentity = entryIdentity(sourcePath);+ successorInjected = true;+ }+ return renameSync(sourcePath, targetPath);+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(failureInjected, true, JSON.stringify(result.receipt.diagnostics.at(-1)));+ assert.equal(successorInjected, true, JSON.stringify(result.receipt.diagnostics.at(-1)));+ assert.equal(result.exitCode, 1);+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), successor);+ assert.deepEqual(entryIdentity(outputs.contactSheet), successorIdentity);+ const rollbackErrors = result.receipt.diagnostics.at(-1)?.evidence?.errors || [];+ assert.ok(rollbackErrors.some(+ (entry) => entry.file+ && path.basename(entry.file) === path.basename(outputs.contactSheet)+ && /successor was restored and preserved/.test(entry.reason),+ ));+});++test('visual-check restore rollback preserves a successor swapped at its public cleanup boundary', async (t) => {+ const input = artifact('restore-public-cleanup-successor.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);++ const displaced = path.join(tmp, 'restore-public-cleanup-owned-displaced.html');+ const successor = Buffer.from('external successor at restore cleanup boundary\n');+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const linkSync = fs.linkSync.bind(fs);+ const lstatSync = fs.lstatSync.bind(fs);+ const unlinkSync = fs.unlinkSync.bind(fs);+ const renameSync = fs.renameSync.bind(fs);+ let publicationFailed = false;+ let corruptNextRestoredStat = false;+ let verificationInjected = false;+ let successorInjected = false;+ let successorIdentity;+ const injectSuccessor = (publicPath) => {+ renameSync(publicPath, displaced);+ fs.writeFileSync(publicPath, successor, { flag: 'wx' });+ successorIdentity = entryIdentity(publicPath);+ successorInjected = true;+ };+ t.after(() => {+ fs.rmSync(displaced, { force: true });+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });+ t.mock.method(fs, 'linkSync', (source, target) => {+ const sourcePath = String(source);+ const targetPath = String(target);+ const fromStaging = path.basename(path.dirname(sourcePath)).startsWith('.archify-visual-check-');+ if (!publicationFailed+ && fromStaging+ && path.basename(sourcePath) === 'contact-sheet.html'+ && path.basename(targetPath) === path.basename(outputs.contactSheet)) {+ publicationFailed = true;+ throw new Error('synthetic publication failure before backup restore');+ }+ const result = linkSync(sourcePath, targetPath);+ if (path.basename(sourcePath) === 'previous-1'+ && path.basename(targetPath) === path.basename(outputs.contactSheet)) {+ corruptNextRestoredStat = true;+ }+ return result;+ });+ t.mock.method(fs, 'lstatSync', (file, options) => {+ const filePath = String(file);+ const stat = lstatSync(filePath, options);+ if (corruptNextRestoredStat+ && path.basename(filePath) === path.basename(outputs.contactSheet)) {+ corruptNextRestoredStat = false;+ verificationInjected = true;+ return new Proxy(stat, {+ get(target, property, receiver) {+ if (property === 'ino') return target.ino + 1n;+ const value = Reflect.get(target, property, receiver);+ return typeof value === 'function' ? value.bind(target) : value;+ },+ });+ }+ return stat;+ });+ t.mock.method(fs, 'unlinkSync', (file) => {+ const filePath = String(file);+ if (verificationInjected+ && !successorInjected+ && path.basename(filePath) === path.basename(outputs.contactSheet)) {+ injectSuccessor(filePath);+ }+ return unlinkSync(filePath);+ });+ t.mock.method(fs, 'renameSync', (source, target) => {+ const sourcePath = String(source);+ const targetPath = String(target);+ if (verificationInjected+ && !successorInjected+ && path.basename(sourcePath) === path.basename(outputs.contactSheet)+ && path.basename(path.dirname(targetPath)).startsWith('.archify-remove-')) {+ injectSuccessor(sourcePath);+ }+ return renameSync(sourcePath, targetPath);+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(publicationFailed, true);+ assert.equal(verificationInjected, true);+ assert.equal(successorInjected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(fs.existsSync(outputs.contactSheet), true);+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), successor);+ assert.deepEqual(entryIdentity(outputs.contactSheet), successorIdentity);+});++for (const scenario of [+ { name: 'backup unlink', fault: 'unlink' },+ { name: 'staging rmdir', fault: 'rmdir' },+]) {+ test(`visual-check reports committed cleanup warning after ${scenario.name} failure`, async (t) => {+ const input = artifact(`committed-cleanup-${scenario.fault}.html`);+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ const oldContactSheet = fs.readFileSync(outputs.contactSheet);+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const claimantBytes = Buffer.from('external staging cleanup claimant\n');+ let injected = false;+ let retainedPath;++ if (scenario.fault === 'unlink') {+ const unlinkSync = fs.unlinkSync.bind(fs);+ t.mock.method(fs, 'unlinkSync', (file) => {+ const candidate = String(file);+ if (!injected+ && path.basename(candidate) === 'previous-1'+ && path.basename(path.dirname(candidate)).startsWith('.archify-visual-check-')) {+ injected = true;+ retainedPath = candidate;+ const error = new Error('synthetic backup unlink failure');+ error.code = 'EACCES';+ throw error;+ }+ return unlinkSync(file);+ });+ } else {+ const rmdirSync = fs.rmdirSync.bind(fs);+ t.mock.method(fs, 'rmdirSync', (directory) => {+ const candidate = String(directory);+ if (!injected && path.basename(candidate).startsWith('.archify-visual-check-')) {+ retainedPath = path.join(candidate, 'external-cleanup-claimant');+ fs.writeFileSync(retainedPath, claimantBytes, { flag: 'wx' });+ injected = true;+ }+ return rmdirSync(directory);+ });+ }+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.ok, false);+ assert.equal(result.receipt.status, 'fail');+ assert.equal(result.receipt.publication?.status, 'committed-with-warning');+ assert.equal(result.receipt.publication?.recoveryDirectory, path.dirname(retainedPath));+ assert.ok(result.receipt.publication?.cleanupErrors?.length > 0);+ assert.match(result.receipt.error, /cleanup is incomplete/i);+ assert.ok(result.receipt.error.includes(path.dirname(retainedPath)));+ const cleanupDiagnostic = result.receipt.diagnostics.at(-1);+ assert.equal(cleanupDiagnostic?.code, 'viewer/evidence-cleanup-incomplete');+ assert.equal(cleanupDiagnostic?.severity, 'warning');+ assert.equal(+ cleanupDiagnostic?.evidence?.recoveryDirectory,+ path.dirname(retainedPath),+ );+ assert.equal(fs.existsSync(retainedPath), true);+ assert.deepEqual(+ fs.readFileSync(retainedPath),+ scenario.fault === 'unlink' ? oldContactSheet : claimantBytes,+ );+ assert.equal(JSON.parse(fs.readFileSync(outputs.receipt, 'utf8')).status, 'pass');+ assert.equal(fs.existsSync(outputs.contactSheet), true);+ assert.equal(outputs.screenshots.every((entry) => fs.existsSync(entry.path)), true);+ });+}++test('public visual-check CLI reports a committed cleanup warning', (t) => {+ const input = artifact('public-cli-committed-cleanup-warning.html');+ const outputs = sidecarPaths(input);+ const cli = path.join(skillRoot, 'bin', 'archify.mjs');+ const missingChrome = path.join(tmp, 'missing-cleanup-warning-chrome');+ const baseEnv = {+ ...process.env,+ ARCHIFY_CHROME: missingChrome,+ ARCHIFY_UPDATE_CHECK_DISABLED: '1',+ };+ const first = spawnSync(process.execPath, [cli, 'visual-check', input, '--json'], {+ encoding: 'utf8',+ env: baseEnv,+ });+ assert.equal(first.status, 2, first.stderr || first.stdout);+ const oldReceipt = fs.readFileSync(outputs.receipt);+ const stagingBefore = new Set(stagingDirectories(path.dirname(outputs.receipt)));+ const hook = path.join(tmp, 'visual-cleanup-warning-hook.mjs');+ fs.writeFileSync(hook, `+ import fs from 'node:fs';+ import path from 'node:path';+ const unlinkSync = fs.unlinkSync.bind(fs);+ let injected = false;+ fs.unlinkSync = (file) => {+ const candidate = String(file);+ if (!injected+ && path.basename(candidate) === 'previous-0'+ && path.basename(path.dirname(candidate)).startsWith('.archify-visual-check-')) {+ injected = true;+ const error = new Error('synthetic public CLI backup unlink failure');+ error.code = 'EACCES';+ throw error;+ }+ return unlinkSync(file);+ };+ `);+ t.after(() => {+ for (const directory of stagingDirectories(path.dirname(outputs.receipt))) {+ if (!stagingBefore.has(directory)) {+ fs.rmSync(path.join(path.dirname(outputs.receipt), directory), { recursive: true, force: true });+ }+ }+ });++ const second = spawnSync(process.execPath, [cli, 'visual-check', input, '--json'], {+ encoding: 'utf8',+ env: {+ ...baseEnv,+ NODE_OPTIONS: `--import=${pathToFileURL(hook).href}`,+ },+ });++ assert.equal(second.status, 1, second.stderr || second.stdout);+ const receipt = JSON.parse(second.stdout);+ assert.equal(receipt.status, 'fail');+ assert.equal(receipt.ok, false);+ assert.equal(receipt.publication?.status, 'committed-with-warning');+ assert.match(receipt.error, /cleanup is incomplete/i);+ assert.equal(receipt.diagnostics.at(-1)?.code, 'viewer/evidence-cleanup-incomplete');+ assert.equal(receipt.diagnostics.at(-1)?.severity, 'warning');+ const recoveryDirectory = receipt.publication?.recoveryDirectory;+ assert.equal(typeof recoveryDirectory, 'string');+ const retained = path.join(recoveryDirectory, 'previous-0');+ assert.deepEqual(fs.readFileSync(retained), oldReceipt);+ assert.equal(JSON.parse(fs.readFileSync(outputs.receipt, 'utf8')).status, 'skipped');+});++test('visual-check rolls back when staged evidence changes after receipt binding', async (t) => {+ const input = artifact('staged-content-changed-after-receipt-binding.html');+ const outputs = sidecarPaths(input);+ const sentinel = Buffer.from('mutated staged screenshot bytes\n');+ const linkSync = fs.linkSync.bind(fs);+ let injected = false;+ t.mock.method(fs, 'linkSync', (source, target) => {+ const result = linkSync(source, target);+ if (!injected+ && path.basename(String(source)) === 'contact-sheet.html'+ && path.basename(path.dirname(String(source))).startsWith('.archify-visual-check-')) {+ fs.writeFileSync(path.join(path.dirname(String(source)), 'capture-0.png'), sentinel);+ injected = true;+ }+ return result;+ });++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });++ assert.equal(injected, true);+ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(+ result.receipt.diagnostics.at(-1)?.evidence?.reason?.code,+ 'staged-evidence-content-mismatch',+ );+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});++test('visual-check preserves digest-mismatched evidence instead of treating its receipt as ownership', async () => {+ const input = artifact('digest-mismatched-evidence.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ const sentinel = Buffer.from('tampered contact sheet\n');+ fs.writeFileSync(outputs.contactSheet, sentinel);+ const receiptBefore = fs.readFileSync(outputs.receipt);+ let launched = false;++ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => { launched = true; return fakeBrowser(); },+ });++ assert.equal(result.exitCode, 1);+ assert.equal(launched, false);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.equal(result.receipt.diagnostics.at(-1)?.evidence?.reason?.code, 'ownership-evidence-digest-mismatch');+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.deepEqual(fs.readFileSync(outputs.receipt), receiptBefore);+});++test('public visual-check CLI preserves an unowned contact-sheet path', () => {+ const input = artifact('public-cli-evidence-collision.html');+ const outputs = sidecarPaths(input);+ const sentinel = Buffer.from('<!doctype html><title>independent artifact</title>\n');+ fs.writeFileSync(outputs.contactSheet, sentinel);++ const result = spawnSync(process.execPath, [+ path.join(skillRoot, 'bin', 'archify.mjs'),+ 'visual-check',+ input,+ '--json',+ ], {+ cwd: skillRoot,+ encoding: 'utf8',+ env: { ...process.env, ARCHIFY_CHROME: '' },+ });++ assert.equal(result.status, 1, result.stderr);+ const receipt = JSON.parse(result.stdout);+ assert.equal(receipt.diagnostics.at(-1)?.code, 'viewer/evidence-path-conflict');+ assert.deepEqual(fs.readFileSync(outputs.contactSheet), sentinel);+ assert.equal(fs.existsSync(outputs.receipt), false);+});++test('visual-check fails closed without writes when sidecar directory identity is unknown', async () => {+ const input = artifact('unknown-sidecar-identity.html');+ const unknownIdentity = () => ({+ status: 'unknown',+ reason: { code: 'synthetic-identity-unavailable', systemCode: 'EACCES' },+ });+ const runOutDir = path.join(tmp, 'unknown-sidecar-run');+ let launched = false;++ const result = await runVisualCheck({+ artifactPath: input,+ outDir: runOutDir,+ chromePath: '/fake/chrome',+ compareSidecarParents: unknownIdentity,+ browserFactory: async () => {+ launched = true;+ return fakeBrowser();+ },+ });++ assert.equal(result.exitCode, 1);+ assert.equal(result.receipt.status, 'fail');+ assert.match(result.receipt.error, /physical identity/i);+ assert.equal(result.receipt.diagnostics.at(-1)?.code, 'viewer/sidecar-directory-identity');+ assert.equal(+ result.receipt.diagnostics.at(-1)?.evidence?.comparison?.code,+ 'synthetic-identity-unavailable',+ );+ assert.equal(launched, false);+ assert.equal(fs.existsSync(runOutDir), false, 'identity failure must precede evidence directory creation');++ const persistOutDir = path.join(tmp, 'unknown-sidecar-persist');+ const persistOutputs = sidecarPaths(input, { outDir: persistOutDir });+ fs.mkdirSync(persistOutDir, { recursive: true });+ const existingEvidence = [+ persistOutputs.receipt,+ persistOutputs.contactSheet,+ ...persistOutputs.screenshots.map((entry) => entry.path),+ ];+ for (const [index, file] of existingEvidence.entries()) {+ fs.writeFileSync(file, `existing evidence ${index}\n`);+ }+ const before = existingEvidence.map((file) => fs.readFileSync(file));+ const failure = persistVisualCheckFailure(input, {+ schemaVersion: 1,+ command: 'visual-check',+ artifact: { path: input },+ error: 'synthetic delivery failure',+ diagnostics: [{ code: 'delivery/provenance-failed' }],+ }, {+ outDir: persistOutDir,+ compareSidecarParents: unknownIdentity,+ });+ assert.match(failure.error, /physical identity/i);+ assert.equal(failure.diagnostics.at(-1)?.code, 'viewer/sidecar-directory-identity');+ assert.deepEqual(+ existingEvidence.map((file) => fs.readFileSync(file)),+ before,+ 'failure persistence must not invalidate or replace evidence on unknown identity',+ );+});+test('visual-check returns 1 and preserves evidence when any viewport overflows', async () => {const input = artifact('overflow.html');const result = await runVisualCheck({@@ -292,9 +1952,13 @@ test('visual-check refuses changed delivery evidence before launching a browser'const input = artifact('changed-before-browser.html');const outDir = path.join(tmp, 'changed-before-browser-evidence');const outputs = sidecarPaths(input, { outDir });- fs.mkdirSync(outDir, { recursive: true });- fs.writeFileSync(outputs.contactSheet, 'old evidence');- for (const entry of outputs.screenshots) fs.writeFileSync(entry.path, png);+ const previous = await runVisualCheck({+ artifactPath: input,+ outDir,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(previous.exitCode, 0);let launched = false;const result = await runVisualCheck({artifactPath: input,@@ -317,7 +1981,7 @@ test('visual-check refuses changed delivery evidence before launching a browser'assert.equal(fs.existsSync(sidecarPaths(input).receipt), false);});-test('visual-check persists cleanup errors in its failure receipt', () => {+test('visual-check failure persistence refuses an unowned non-file evidence path', () => {const input = artifact('uncleanable-evidence.html');const outputs = sidecarPaths(input);fs.mkdirSync(outputs.screenshots[0].path);@@ -325,11 +1989,10 @@ test('visual-check persists cleanup errors in its failure receipt', () => {schemaVersion: 1, command: 'visual-check', artifact: { path: input },error: 'delivery failed', diagnostics: [{ code: 'delivery/provenance-failed' }],});- const saved = JSON.parse(fs.readFileSync(outputs.receipt));- assert.deepEqual(saved.diagnostics, receipt.diagnostics);- assert.equal(saved.diagnostics[1].code, 'viewer/evidence-write');- assert.equal(saved.diagnostics[1].evidence.errors[0].file, outputs.screenshots[0].path);- assert.equal(saved.status, 'fail');+ assert.equal(receipt.diagnostics[1].code, 'viewer/evidence-path-conflict');+ assert.equal(receipt.diagnostics[1].subject.evidencePath, outputs.screenshots[0].path);+ assert.equal(fs.existsSync(outputs.receipt), false);+ assert.equal(fs.statSync(outputs.screenshots[0].path).isDirectory(), true);});test('visual-check rechecks delivery evidence after capture and discards screenshots on failure', async () => {@@ -360,7 +2023,7 @@ test('visual-check rechecks delivery evidence after capture and discards screensassert.ok(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)));});-test('visual-check records cleanup errors after post-capture provenance failure', async () => {+test('visual-check preserves a screenshot-path claimant after post-capture provenance failure', async () => {const input = artifact('changed-with-uncleanable-browser-evidence.html');const outputs = sidecarPaths(input);let verificationCount = 0;@@ -371,7 +2034,6 @@ test('visual-check records cleanup errors after post-capture provenance failure'verifyArtifact: () => {verificationCount += 1;if (verificationCount === 2) {- fs.rmSync(outputs.screenshots[0].path);fs.mkdirSync(outputs.screenshots[0].path);const error = new Error('Another delivery failed during capture.');error.deliveryProvenance = { status: 'failed' };@@ -386,12 +2048,11 @@ test('visual-check records cleanup errors after post-capture provenance failure'assert.equal(result.receipt.provenance, 'failed');assert.deepEqual(result.receipt.diagnostics.map((entry) => entry.code), ['delivery/provenance-failed',- 'viewer/evidence-write',+ 'viewer/evidence-path-conflict',]);- assert.equal(result.receipt.diagnostics[1].evidence.errors[0].file, outputs.screenshots[0].path);- const saved = JSON.parse(fs.readFileSync(outputs.receipt));- assert.deepEqual(saved.diagnostics, result.receipt.diagnostics);- assert.equal(saved.status, 'fail');+ assert.equal(result.receipt.diagnostics[1].subject.evidencePath, outputs.screenshots[0].path);+ assert.equal(fs.statSync(outputs.screenshots[0].path).isDirectory(), true);+ assert.equal(fs.existsSync(outputs.receipt), false);});test('visual-check returns 1 when the real reader projects node text below 6px', async () => {@@ -513,8 +2174,12 @@ test('visual-check describes insufficient stage clearance without claiming an ovtest('visual-check returns 1 and removes misleading capture sidecars on screenshot failure', async () => {const input = artifact('capture-failure.html');const outputs = sidecarPaths(input);- fs.writeFileSync(outputs.contactSheet, 'stale');- for (const screenshot of outputs.screenshots) fs.writeFileSync(screenshot.path, png);+ const previous = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(previous.exitCode, 0);const result = await runVisualCheck({artifactPath: input,@@ -553,6 +2218,27 @@ test('visual-check returns 2 with a truthful skipped receipt when Chrome is unavassert.equal(fs.existsSync(sidecarPaths(input).receipt), true);});+test('a no-Chrome rerun retires captures only when the successful receipt proves ownership', async () => {+ const input = artifact('no-chrome-owned-rerun.html');+ const outputs = sidecarPaths(input);+ const first = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser(),+ });+ assert.equal(first.exitCode, 0);+ assert.equal(fs.existsSync(outputs.contactSheet), true);+ assert.equal(outputs.screenshots.every((entry) => fs.existsSync(entry.path)), true);++ const skipped = await runVisualCheck({ artifactPath: input, resolveChrome: () => null });++ assert.equal(skipped.exitCode, 2);+ assert.equal(JSON.parse(fs.readFileSync(outputs.receipt, 'utf8')).status, 'skipped');+ assert.equal(fs.existsSync(outputs.contactSheet), false);+ assert.equal(outputs.screenshots.every((entry) => !fs.existsSync(entry.path)), true);+ assert.deepEqual(stagingDirectories(path.dirname(outputs.receipt)), []);+});+process.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));test('vertical workflow overflow reports measured frames and conditional reflow guidance without changing the artifact', async () => {diff --git a/archify/test/workflow-migration.test.mjs b/archify/test/workflow-migration.test.mjsindex 13bb4d27..c0ab2ebf 100644--- a/archify/test/workflow-migration.test.mjs+++ b/archify/test/workflow-migration.test.mjs@@ -597,6 +597,86 @@ test('workflow migration reports a cyclic-symlink destination as structured JSONassert.equal(failure.diagnostics[0].subject.output, path.resolve(destination));});+test('workflow migration rejects a dangling destination symlink without touching it', () => {+ const source = copyFixture('dangling-destination-source.workflow.json');+ const destination = path.join(tmp, 'dangling-destination.workflow.json');+ const missingTarget = path.join(tmp, 'missing-migration-target.workflow.json');+ fs.symlinkSync(missingTarget, destination, 'file');+ const linkBefore = fs.readlinkSync(destination);++ const result = runMigration(source, destination);++ assert.notEqual(result.status, 0, result.stderr || result.stdout);+ assert.equal(fs.lstatSync(destination).isSymbolicLink(), true);+ assert.equal(fs.readlinkSync(destination), linkBefore);+ assert.equal(fs.existsSync(missingTarget), false);+ assert.equal(parseJsonOutput(result).diagnostics[0].code, 'migration/destination-type');+});++test('workflow migration preserves a destination claimant created before final verification', () => {+ const source = copyFixture('destination-race-source.workflow.json');+ const destination = path.join(tmp, 'destination-race.workflow.json');+ const claimant = '{"claimant":"migration destination"}\n';+ const importModule = path.join(tmp, 'claim-migration-destination.mjs');+ fs.writeFileSync(importModule, `+import fs from 'node:fs';+const readFileSync = fs.readFileSync;+let sourceReads = 0;+fs.readFileSync = (file, ...args) => {+ const bytes = readFileSync(file, ...args);+ if (String(file) === ${JSON.stringify(source)}) {+ sourceReads += 1;+ if (sourceReads === 2) {+ fs.writeFileSync(${JSON.stringify(destination)}, ${JSON.stringify(claimant)}, { flag: 'wx' });+ }+ }+ return bytes;+};+`);++ const result = runMigration(source, destination, { importModule });++ assert.notEqual(result.status, 0, result.stderr || result.stdout);+ assert.equal(fs.readFileSync(destination, 'utf8'), claimant);+ assert.equal(parseJsonOutput(result).diagnostics[0].code, 'migration/destination-changed');+});++test('workflow migration preserves an existing destination replaced during candidate mode finalization', () => {+ const source = copyFixture('destination-chmod-race-source.workflow.json');+ const destination = path.join(tmp, 'destination-chmod-race.workflow.json');+ const detached = path.join(tmp, 'detached-destination-chmod-race.workflow.json');+ const previous = '{"previous":"migration destination"}\n';+ const claimant = '{"claimant":"migration destination during chmod"}\n';+ fs.writeFileSync(destination, previous);+ const importModule = path.join(tmp, 'claim-migration-destination-during-chmod.mjs');+ fs.writeFileSync(importModule, `+import fs from 'node:fs';+import path from 'node:path';+const chmodSync = fs.chmodSync.bind(fs);+const renameSync = fs.renameSync.bind(fs);+const writeFileSync = fs.writeFileSync.bind(fs);+let claimed = false;+fs.chmodSync = (file, ...args) => {+ const result = chmodSync(file, ...args);+ if (!claimed+ && path.basename(String(file)) === 'candidate.workflow.json'+ && path.basename(path.dirname(String(file))).startsWith('.archify-migration-')) {+ claimed = true;+ renameSync(${JSON.stringify(destination)}, ${JSON.stringify(detached)});+ writeFileSync(${JSON.stringify(destination)}, ${JSON.stringify(claimant)}, { flag: 'wx' });+ }+ return result;+};+`);++ const result = runMigration(source, destination, { importModule });++ assert.notEqual(result.status, 0, result.stderr || result.stdout);+ assert.equal(fs.readFileSync(destination, 'utf8'), claimant);+ assert.equal(fs.readFileSync(detached, 'utf8'), previous);+ assert.equal(parseJsonOutput(result).diagnostics[0].code, 'migration/destination-changed');+});+test('failed workflow migration emits diagnostics and never writes its destination', () => {const source = path.join(tmp, 'pin-conflict-source.workflow.json');const destination = path.join(tmp, 'pin-conflict-destination.workflow.json');diff --git a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs b/integrations/deepseek-harness/scripts/distribution-acceptance.mjsindex 7dd9ed8c..f933b5b0 100644--- a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs+++ b/integrations/deepseek-harness/scripts/distribution-acceptance.mjs@@ -4,6 +4,7 @@ import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import { fileURLToPath, pathToFileURL } from 'node:url';+import { containedBy, sameEntry } from '../../../archify/renderers/shared/path-semantics.mjs';import { spawnCli, spawnCliSync } from './resolve-cli.mjs';import { runWithTransientNetworkRetry } from './transient-retry.mjs';import { adapterCommit, manifest, release, releaseSnapshot } from './release-source.mjs';@@ -178,14 +179,18 @@ requireStatus('tarball-inspect', run('tar', ['-xzf', path.basename(tarball), '-Cconst packedPkg = JSON.parse(fs.readFileSync(path.join(inspectRoot, 'package', 'package.json'), 'utf8'));const packedFiles = listRelativeFiles(path.join(inspectRoot, 'package'));const forbidden = packedFiles.filter((file) => (+ // path-contract-allow: portable-logical-path -- npm tar entries use normalized slash-separated names.file.startsWith('test/')- || file.includes('node_modules/')- || file.includes('package-lock.json')- || file.includes('.hive')- || file.includes('.workbuddy')- || file.includes('probe-skills')- || file.includes('generate-brand-marks.mjs')- || file.includes('generate-validators.mjs')+ || [+ 'node_modules/',+ 'package-lock.json',+ '.hive',+ '.workbuddy',+ 'probe-skills',+ 'generate-brand-marks.mjs',+ 'generate-validators.mjs',+ // path-contract-allow: portable-logical-path -- Each fragment is matched inside an npm tar entry name.+ ].some((fragment) => file.includes(fragment))));if (packedPkg.name !== PACKAGE_NAME || packedPkg.version !== PACKAGE_VERSION || forbidden.length > 0) {fail('tarball-inspect', 'packed identity or exclusions failed', { forbidden, packedPkg });@@ -354,15 +359,19 @@ try {} catch (error) {fail('resource-base', `cannot realpath installed Skill root: ${error.message}`, { resourcePath, installedPackage });}-const resourceRelative = path.relative(packageReal, resourceReal);-const resourceInsidePackage = resourceRelative- && !resourceRelative.startsWith(`..${path.sep}`)- && resourceRelative !== '..'- && !path.isAbsolute(resourceRelative);-if (!resourceInsidePackage || !resourceReal.includes(`${path.sep}skills${path.sep}archify`)) {+const resourceContainment = containedBy(packageReal, resourceReal);+const expectedResourceRoots = [+ path.join(packageReal, 'skills'),+ path.join(packageReal, 'skills', 'archify'),+];+const expectedResource = expectedResourceRoots.some((candidate) => (+ fs.existsSync(candidate) && sameEntry(candidate, resourceReal).status === 'match'+));+if (resourceContainment.status !== 'match' || !expectedResource) {fail('resource-base', 'Skill resource base is not inside the installed tarball package', {resourcePath: resourceReal,installedPackage: packageReal,+ relation: resourceContainment,});}pass('resource-base', { resourcePath: resourceReal });diff --git a/integrations/deepseek-harness/scripts/release-source.mjs b/integrations/deepseek-harness/scripts/release-source.mjsindex 9d80880c..add431e7 100644--- a/integrations/deepseek-harness/scripts/release-source.mjs+++ b/integrations/deepseek-harness/scripts/release-source.mjs@@ -1,6 +1,7 @@import fs from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';+import { validatePortablePathSet } from '../../../archify/renderers/shared/portable-path.mjs';import { spawnCliSync } from './resolve-cli.mjs';export const integrationRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');@@ -23,9 +24,11 @@ const adapterEntries = new TextDecoder('utf-8', { fatal: true })const separator = record.indexOf('\t');const [mode, type, objectId] = record.slice(0, separator).split(' ');return { mode, type, objectId, relative: record.slice(separator + 1).slice(adapterPrefix.length) };+ // path-contract-allow: git-path -- ls-tree entries are repository-relative POSIX names.}).filter(({ relative }) => requiredAdapterFiles.includes(relative) || relative.startsWith('lib/'));for (const relative of requiredAdapterFiles) {+ // path-contract-allow: git-path -- Both operands are exact ls-tree entry names.if (!adapterEntries.some((entry) => entry.relative === relative)) {throw new Error(`required committed DSH adapter input is missing: ${relative}`);}@@ -33,21 +36,8 @@ for (const relative of requiredAdapterFiles) {// Capture Git blobs, not working-tree paths: local edits and symlink swaps cannot// change the package identified by adapterCommit.-const portablePaths = new Map();+validatePortablePathSet(adapterEntries.map((entry) => entry.relative), { profile: 'archive' });const adapterFiles = new Map(adapterEntries.map((entry) => {- const segments = entry.relative.split('/');- for (const [index, segment] of segments.entries()) {- if (!segment || /[\\:\x00-\x1f<>"|?*]/.test(segment) || /[. ]$/.test(segment)- || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(segment)) {- throw new Error(`DSH adapter input has an unsupported path: ${entry.relative}`);- }- const prefix = segments.slice(0, index + 1).join('/');- const key = prefix.normalize('NFC').toLowerCase();- if (portablePaths.has(key) && portablePaths.get(key) !== prefix) {- throw new Error(`DSH adapter paths collide across supported filesystems: ${portablePaths.get(key)} and ${prefix}`);- }- portablePaths.set(key, prefix);- }if (entry.mode === '120000') {throw new Error(`refusing to package committed DSH adapter symlink: ${entry.relative}`);}diff --git a/integrations/deepseek-harness/test/adapter-staging.test.mjs b/integrations/deepseek-harness/test/adapter-staging.test.mjsindex e9d58be8..e1aea38b 100644--- a/integrations/deepseek-harness/test/adapter-staging.test.mjs+++ b/integrations/deepseek-harness/test/adapter-staging.test.mjs@@ -25,13 +25,38 @@ function git(cwd, args, options = {}) {function fixture() {const root = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-dsh-pack-fixture-'));const checkout = path.join(root, 'repo');- const head = git(repoRoot, ['rev-parse', 'HEAD']);+ const sourceHead = git(repoRoot, ['rev-parse', 'HEAD']);const clone = spawnSync('git', ['clone', '--shared', '--no-checkout', '--', repoRoot, checkout], {cwd: repoRoot,encoding: 'utf8',});assert.equal(clone.status, 0, clone.stderr || clone.stdout);- git(checkout, ['checkout', '--detach', head]);+ git(checkout, ['checkout', '--detach', sourceHead]);++ // Exercise the working contract even before it is committed. In CI these+ // copies are byte-identical to HEAD and no fixture commit is needed.+ const contractFiles = [+ 'scripts/stage-clean-skill.mjs',+ 'archify/renderers/shared/atomic-output.mjs',+ 'archify/renderers/shared/path-semantics.mjs',+ 'archify/renderers/shared/portable-path.mjs',+ 'integrations/deepseek-harness/scripts/release-source.mjs',+ ];+ for (const relative of contractFiles) {+ const target = path.join(checkout, ...relative.split('/'));+ fs.mkdirSync(path.dirname(target), { recursive: true });+ fs.copyFileSync(path.join(repoRoot, ...relative.split('/')), target);+ }+ git(checkout, ['add', '--', ...contractFiles]);+ const diff = spawnSync('git', ['diff', '--cached', '--quiet'], { cwd: checkout, encoding: 'utf8' });+ assert.equal(diff.error, undefined, diff.error?.message);+ assert.ok([0, 1].includes(diff.status), diff.stderr || diff.stdout);+ if (diff.status === 1) {+ git(checkout, ['config', 'user.email', '[email protected]']);+ git(checkout, ['config', 'user.name', 'Archify tests']);+ git(checkout, ['commit', '--no-gpg-sign', '-m', 'test: apply working portable path contract']);+ }+ const head = git(checkout, ['rev-parse', 'HEAD']);return { root, checkout, head };}@@ -54,6 +79,7 @@ function pack(checkout, root) {const result = spawnSync(process.execPath, [script, '--out', out, '--json'], {cwd: checkout,encoding: 'utf8',+ env: { ...process.env, npm_config_cache: path.join(root, 'npm-cache') },});return { out, result };}@@ -76,6 +102,32 @@ function commitFixture(checkout, message, { stage = true } = {}) {git(checkout, ['commit', '--no-gpg-sign', '-m', message]);}+function addIndexedAdapterBlob(checkout, relative, content) {+ const repositoryRelative = `integrations/deepseek-harness/${relative}`;+ const blob = git(checkout, ['hash-object', '-w', '--stdin'], { input: content });+ git(checkout, ['update-index', '--add', '--cacheinfo', `100644,${blob},${repositoryRelative}`]);+ return repositoryRelative;+}++test('DSH workflow runs when the shared portable-path contract changes', () => {+ const workflow = fs.readFileSync(path.join(repoRoot, '.github', 'workflows', 'dsh.yml'), 'utf8');+ assert.equal(+ workflow.match(/archify\/renderers\/shared\/atomic-output\.mjs/g)?.length,+ 2,+ 'pull requests and branch pushes must both watch the atomic output runtime',+ );+ assert.equal(+ workflow.match(/archify\/renderers\/shared\/portable-path\.mjs/g)?.length,+ 2,+ 'pull requests and branch pushes must both watch the shared validator',+ );+ assert.equal(+ workflow.match(/archify\/renderers\/shared\/path-semantics\.mjs/g)?.length,+ 2,+ 'pull requests and branch pushes must both watch the staging identity runtime',+ );+});+test('pack stages adapter inputs from the fixture HEAD despite dirty and untracked files', () => {const { root, checkout, head } = fixture();try {@@ -199,7 +251,7 @@ test('pack rejects a committed reserved device-name path and leaves no target taconst { out, result } = pack(checkout, root);assert.notEqual(result.status, 0);- assert.match(`${result.stderr}\n${result.stdout}`, /unsupported path|NUL\.js/i);+ assert.match(`${result.stderr}\n${result.stdout}`, /reserved Windows device name/i);assert.equal(fs.existsSync(out), false);} finally {fs.rmSync(root, { recursive: true, force: true });@@ -218,7 +270,55 @@ test('pack rejects committed adapter paths that collide by case and leaves no taconst { out, result } = pack(checkout, root);assert.notEqual(result.status, 0);- assert.match(`${result.stderr}\n${result.stdout}`, /collide across supported filesystems|INDEX\.js|index\.js/i);+ assert.match(`${result.stderr}\n${result.stdout}`, /collide under portable filesystem semantics/i);+ assert.equal(fs.existsSync(out), false);+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});++test('pack rejects committed adapter directory prefixes that collide by case', () => {+ const { root, checkout } = fixture();+ try {+ git(checkout, ['config', 'core.ignorecase', 'false']);+ const collisionPaths = [+ addIndexedAdapterBlob(checkout, 'lib/Docs/one.js', 'upper directory fixture\n'),+ addIndexedAdapterBlob(checkout, 'lib/docs/two.js', 'lower directory fixture\n'),+ ];+ commitFixture(checkout, 'test: commit directory-prefix case collision', { stage: false });+ for (const relative of collisionPaths) {+ assert.match(git(checkout, ['ls-tree', 'HEAD', '--', relative]), /^100644 blob /);+ }++ const { out, result } = pack(checkout, root);+ assert.notEqual(result.status, 0);+ assert.match(`${result.stderr}\n${result.stdout}`, /collide under portable filesystem semantics/i);+ assert.equal(fs.existsSync(out), false);+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});++test('pack rejects committed adapter paths that collide by normalization and case', () => {+ const { root, checkout } = fixture();+ try {+ for (const [key, value] of [+ ['core.ignorecase', 'false'],+ ['core.precomposeunicode', 'false'],+ ['core.protectHFS', 'false'],+ ]) git(checkout, ['config', key, value]);+ const paths = [+ addIndexedAdapterBlob(checkout, 'lib/Résumé.js', 'composed collision fixture\n'),+ addIndexedAdapterBlob(checkout, 'lib/re\u0301sume\u0301.js', 'decomposed collision fixture\n'),+ ];+ commitFixture(checkout, 'test: commit normalization-and-case collision', { stage: false });+ for (const relative of paths) {+ assert.match(git(checkout, ['ls-tree', 'HEAD', '--', relative]), /^100644 blob /);+ }++ const { out, result } = pack(checkout, root);+ assert.notEqual(result.status, 0);+ assert.match(`${result.stderr}\n${result.stdout}`, /collide under portable filesystem semantics/i);assert.equal(fs.existsSync(out), false);} finally {fs.rmSync(root, { recursive: true, force: true });diff --git a/integrations/deepseek-harness/test/zero-regression.test.mjs b/integrations/deepseek-harness/test/zero-regression.test.mjsindex 103282c9..10d66770 100644--- a/integrations/deepseek-harness/test/zero-regression.test.mjs+++ b/integrations/deepseek-harness/test/zero-regression.test.mjs@@ -29,15 +29,24 @@ test('the repository still has exactly one checked-in Archify SKILL.md and no ge});test('Archify core does not import, detect, or branch on DeepSeek Harness', () => {+ // Tests may verify the adapter without making any shipped Archify file+ // depend on it. Keep the full product tree in scope, including SKILL.md,+ // schemas, references, examples, and assets.+ const protectedPaths = [+ 'archify',+ ':(exclude)archify/test/**',+ 'scripts/build-zip.sh',+ 'scripts/package-smoke.mjs',+ ];+ const protectedFiles = git(['ls-files', '--', ...protectedPaths]).split('\n').filter(Boolean);+ assert.ok(protectedFiles.includes('archify/SKILL.md'), 'zero-coupling scan must include the shipped Skill');const grep = spawnSync('git', ['grep','-n','-E','deepseek-harness|@deepseek-ai/dsh|DSH_HOME|DSH_AGENTS_HOME|archify-dsh','--',- 'archify',- 'scripts/build-zip.sh',- 'scripts/package-smoke.mjs',+ ...protectedPaths,], { cwd: repoRoot, encoding: 'utf8' });assert.equal(grep.status, 1, grep.stderr || grep.stdout);assert.equal(grep.stdout.trim(), '');diff --git a/scripts/build-readme-showcase.mjs b/scripts/build-readme-showcase.mjsindex 6c78f6a3..49bec6af 100644--- a/scripts/build-readme-showcase.mjs+++ b/scripts/build-readme-showcase.mjs@@ -17,6 +17,10 @@ const height = 540;const fps = 10;const framesPerScene = 18;+function portableRelative(from, to) {+ return path.relative(from, to).split(path.sep).join('/');+}+const scenes = [{id: 'signal-flow',@@ -329,7 +333,7 @@ async function main() {const receipt = {schemaVersion: 1,generator: 'scripts/build-readme-showcase.mjs',- output: path.relative(repoRoot, outputPath),+ output: portableRelative(repoRoot, outputPath),width,height,fps,diff --git a/scripts/build-zip.sh b/scripts/build-zip.shindex cc686bdf..3f75133d 100755--- a/scripts/build-zip.sh+++ b/scripts/build-zip.sh@@ -5,14 +5,11 @@ set -euo pipefailrepo_root="$(cd "$(dirname "$0")/.." && pwd)"out="${1:-$repo_root/archify.zip}"-# Git Bash callers may pass Windows-style absolute paths: drive paths (C:\...-# or C:/...) and \\-prefixed forms such as UNC shares or the \\?\ extended-length-# prefix. Node resolves those natively, so only genuinely relative paths get the-# cwd prefix; prefixing a Windows path would send MSYS a malformed mixed path.-windows_absolute='^([A-Za-z]:[/\\]|\\\\)'-if [[ "$out" != /* && ! "$out" =~ $windows_absolute ]]; then- out="$(pwd)/$out"-fi++# Reject unsafe raw output spellings before the canonical-toolchain gate so+# every maintained Node lane exercises the same shared native path grammar.+# This validation-only mode is read-only and does not create parent paths.+node "$repo_root/scripts/write-deterministic-zip.mjs" --validate-output "$out"# Runtime consumers support every Node version declared by archify/package.json,# but canonical ZIP bytes depend on the Node/zlib toolchain. CI and releases usediff --git a/scripts/copy-site-assets.mjs b/scripts/copy-site-assets.mjsindex 91d5749a..53a97db6 100644--- a/scripts/copy-site-assets.mjs+++ b/scripts/copy-site-assets.mjs@@ -1,7 +1,18 @@+import { randomBytes } from 'node:crypto';import fs from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';+import {+ captureAtomicOutput,+ captureRegularFileBinding,+ releaseRegularFileBinding,+ removeOwnedRegularFile,+ verifyAtomicOutput,+ verifyRegularFileBinding,+} from '../archify/renderers/shared/atomic-output.mjs';+import { containedBy, sameLocation } from '../archify/renderers/shared/path-semantics.mjs';+const __dirname = path.dirname(fileURLToPath(import.meta.url));const sourceRoot = path.resolve(__dirname, '../docs/assets');const SITE_ASSETS = Object.freeze([@@ -9,13 +20,139 @@ const SITE_ASSETS = Object.freeze(['site-navigation.css',]);+function publicationError(asset, state) {+ const reason = state?.reason || state;+ return new Error(`Cannot safely publish site asset "${asset}" (${reason?.code || 'indeterminate'}).`, {+ cause: reason,+ });+}++function stageSiteAsset(source, commitPath, mode) {+ const content = fs.readFileSync(source);+ for (let attempt = 0; attempt < 100; attempt += 1) {+ const candidatePath = path.join(+ path.dirname(commitPath),+ `.${path.basename(commitPath)}.archify-${randomBytes(16).toString('hex')}.tmp`,+ );+ let descriptor;+ let identity;+ try {+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ descriptor = fs.openSync(+ candidatePath,+ fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | noFollow,+ mode ?? 0o666,+ );+ const metadata = fs.fstatSync(descriptor, { bigint: true });+ if (!metadata.isFile() || metadata.ino === 0n) {+ throw new Error('Temporary site asset identity could not be verified safely.');+ }+ identity = { device: metadata.dev, inode: metadata.ino };+ fs.writeFileSync(descriptor, content);+ if (mode !== null) fs.fchmodSync(descriptor, mode);+ fs.closeSync(descriptor);+ descriptor = undefined;+ return { candidatePath, identity };+ } catch (error) {+ if (descriptor !== undefined) {+ try { fs.closeSync(descriptor); } catch {}+ }+ if (error?.code === 'EEXIST') continue;+ if (identity) removeOwnedRegularFile(candidatePath, identity, { subject: 'site-asset-candidate' });+ throw error;+ }+ }+ throw Object.assign(new Error(`Could not reserve a temporary site asset beside "${commitPath}".`), {+ code: 'EEXIST',+ });+}+export function copySiteAssets(outputHtmlPath) {- const targetRoot = path.join(path.dirname(path.resolve(outputHtmlPath)), 'assets');- fs.mkdirSync(targetRoot, { recursive: true });+ const requestedOutputParent = path.dirname(path.resolve(outputHtmlPath));+ fs.mkdirSync(requestedOutputParent, { recursive: true });+ const outputParent = fs.realpathSync.native(requestedOutputParent);+ const targetRoot = path.join(outputParent, 'assets');+ try {+ fs.mkdirSync(targetRoot);+ } catch (error) {+ if (error?.code !== 'EEXIST') throw error;+ }+ const assetsEntry = fs.lstatSync(targetRoot, { bigint: true });+ if (assetsEntry.isSymbolicLink() || !assetsEntry.isDirectory()) {+ throw new Error('Site assets directory must be a physical directory, not a symbolic link or special entry.');+ }+ const containment = containedBy(outputParent, targetRoot);+ if (containment.status !== 'match') {+ throw new Error('Site assets directory is not physically contained by the output directory.', {+ cause: containment.reason,+ });+ }+ const publications = [];for (const asset of SITE_ASSETS) {const source = path.join(sourceRoot, asset);const target = path.join(targetRoot, asset);- if (path.resolve(source) !== path.resolve(target)) fs.copyFileSync(source, target);+ const capture = captureAtomicOutput(target, {+ requestedEntryPolicy: 'regular-or-absent',+ });+ if (capture.status !== 'captured') {+ throw publicationError(asset, capture);+ }+ if (capture.snapshot.slot.parentDevice !== assetsEntry.dev+ || capture.snapshot.slot.parentInode !== assetsEntry.ino) {+ throw new Error(`Cannot safely publish site asset "${asset}" (assets-directory-changed).`);+ }+ const relation = sameLocation(source, capture.commitPath);+ if (relation.status === 'match') continue;+ if (relation.status === 'unknown') {+ throw new Error(`Cannot determine whether site asset source and target alias: ${asset}`, {+ cause: relation.reason,+ });+ }+ publications.push({ asset, source, capture });+ }++ for (const { asset, source, capture } of publications) {+ let candidatePath;+ let candidateIdentity;+ let candidateBinding;+ try {+ ({ candidatePath, identity: candidateIdentity } = stageSiteAsset(+ source,+ capture.commitPath,+ capture.mode,+ ));+ const candidate = captureRegularFileBinding(candidatePath, {+ subject: 'site-asset-candidate',+ expectedIdentity: candidateIdentity,+ ...(capture.mode === null ? {} : { expectedMode: capture.mode }),+ });+ if (candidate.status !== 'captured') throw publicationError(asset, candidate);+ candidateBinding = candidate.binding;+ const targetVerification = verifyAtomicOutput(capture.snapshot);+ if (targetVerification.status !== 'match') {+ throw publicationError(asset, targetVerification);+ }+ const candidateVerification = verifyRegularFileBinding(candidateBinding);+ if (candidateVerification.status !== 'match') {+ throw publicationError(asset, candidateVerification);+ }+ const released = releaseRegularFileBinding(candidateBinding);+ candidateBinding = undefined;+ if (released.status !== 'released') throw publicationError(asset, released);+ fs.renameSync(candidatePath, capture.commitPath);+ candidatePath = undefined;+ candidateIdentity = undefined;+ } finally {+ if (candidateBinding) releaseRegularFileBinding(candidateBinding);+ if (candidatePath && candidateIdentity) {+ const cleanup = removeOwnedRegularFile(candidatePath, candidateIdentity, {+ subject: 'site-asset-candidate',+ });+ if (!['removed', 'absent', 'preserved'].includes(cleanup.status)) {+ throw publicationError(asset, cleanup);+ }+ }+ }}}diff --git a/scripts/publish-star-history.sh b/scripts/publish-star-history.shindex e0378248..9e2a4b84 100755--- a/scripts/publish-star-history.sh+++ b/scripts/publish-star-history.sh@@ -1,4 +1,6 @@#!/usr/bin/env bash+# Maintainer-only POSIX/GitHub Actions helper; it is not part of Archify's+# supported Windows CLI or package-consumer surface.set -euo pipefaildiff --git a/scripts/run-windows-path-tests.mjs b/scripts/run-windows-path-tests.mjsnew file mode 100644index 00000000..c983e259--- /dev/null+++ b/scripts/run-windows-path-tests.mjs@@ -0,0 +1,349 @@+#!/usr/bin/env node++import assert from 'node:assert/strict';+import { spawnSync } from 'node:child_process';+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++import { sameLocation } from '../archify/renderers/shared/path-semantics.mjs';++const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const skillRoot = path.join(repoRoot, 'archify');+const cli = path.join(skillRoot, 'bin', 'archify.mjs');++function commandFailure(label, result) {+ return [+ `${label} exited ${result.status ?? 'without a status'}`,+ result.error?.message,+ result.stdout,+ result.stderr,+ ].filter(Boolean).join('\n');+}++function runCli(args, { timeout = 120_000 } = {}) {+ return spawnSync(process.execPath, [cli, ...args], {+ cwd: skillRoot,+ encoding: 'utf8',+ timeout,+ });+}++function requireSuccess(label, result) {+ assert.equal(result.status, 0, commandFailure(label, result));+}++function requireControlledDirectory(name) {+ const value = process.env[name];+ assert.ok(value, `${name} is required on the controlled Windows path lane`);+ assert.ok(fs.statSync(value).isDirectory(), `${name} must name an existing directory: ${value}`);+ return value;+}++function driveLetterCaseAlias(targetPath) {+ assert.match(targetPath, /^[A-Za-z]:\\/u, 'controlled NTFS fixture must use a drive path');+ const drive = targetPath[0];+ const alternate = drive === drive.toUpperCase() ? drive.toLowerCase() : drive.toUpperCase();+ assert.notEqual(alternate, drive, 'drive-letter alias must use the alternate case');+ return `${alternate}${targetPath.slice(1)}`;+}++function removeChildren(directory) {+ try {+ for (const entry of fs.readdirSync(directory)) {+ fs.rmSync(path.join(directory, entry), { recursive: true, force: true });+ }+ } catch {+ // The workflow's always-run cleanup owns final fixture removal. Avoid+ // masking the path-contract failure that reached this best-effort cleanup.+ }+}++async function waitForVerifiedPreview(url, timeoutMs = 30_000) {+ const started = Date.now();+ let latest;+ while (Date.now() - started < timeoutMs) {+ const response = await fetch(new URL('/state', url));+ assert.equal(response.status, 200, 'preview state endpoint must remain readable');+ latest = await response.json();+ if (latest.status === 'verified' && latest.revision === 1) return latest;+ if (latest.status === 'needs-fix') {+ assert.fail(`preview failed on the controlled Windows path: ${JSON.stringify(latest.failure)}`);+ }+ await new Promise((resolve) => setTimeout(resolve, 50));+ }+ assert.fail(`preview did not verify on the controlled Windows path: ${JSON.stringify(latest)}`);+}++async function runControlledWindowsPathE2E() {+ const required = process.env.ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS === '1';+ if (process.platform !== 'win32') {+ assert.equal(required, false, 'ARCHIFY_REQUIRE_WINDOWS_REAL_PATHS=1 requires Windows');+ return;+ }+ if (!required) return;++ const caseRoot = requireControlledDirectory('ARCHIFY_WINDOWS_CASE_SENSITIVE_ROOT');+ const uncRoot = requireControlledDirectory('ARCHIFY_WINDOWS_UNC_ROOT');+ const extendedUncRoot = requireControlledDirectory('ARCHIFY_WINDOWS_EXTENDED_UNC_ROOT');+ const eightDotThreeRoot = requireControlledDirectory('ARCHIFY_WINDOWS_8DOT3_ROOT');+ const eightDotThreeShortRoot = requireControlledDirectory('ARCHIFY_WINDOWS_8DOT3_SHORT_ROOT');+ assert.match(uncRoot, /^\\\\[^\\]+\\[^\\]+$/u, 'ordinary UNC fixture must name a share root');+ assert.match(+ extendedUncRoot,+ /^\\\\[?]\\UNC\\[^\\]+\\[^\\]+$/u,+ 'extended UNC fixture must name an extended share root',+ );+ assert.equal(sameLocation(uncRoot, extendedUncRoot).status, 'match');+ assert.match(+ path.win32.basename(eightDotThreeShortRoot),+ /~/u,+ 'controlled 8.3 fixture must expose an explicit short-name component',+ );+ assert.equal(+ sameLocation(eightDotThreeRoot, eightDotThreeShortRoot).status,+ 'match',+ 'the explicit 8.3 root must resolve to the controlled long-name directory',+ );+ const driveCaseRoot = driveLetterCaseAlias(caseRoot);+ assert.equal(+ sameLocation(caseRoot, driveCaseRoot).status,+ 'match',+ 'drive-letter case aliases must resolve to the same controlled directory',+ );++ const token = `archify-windows-${process.pid}-${Date.now().toString(36)}`;+ const architectureInput = path.join(skillRoot, 'examples', 'web-app.architecture.json');+ const workflowInput = path.join(skillRoot, 'examples', 'agent-tool-call.workflow.json');+ let preview;+ try {+ const aliasRoot = path.join(caseRoot, `${token}-native-aliases`);+ const junctionTarget = path.join(aliasRoot, 'junction-target');+ const differentDirectory = path.join(aliasRoot, 'different-directory');+ const junctionAlias = path.join(aliasRoot, 'junction-alias');+ const fileTarget = path.join(aliasRoot, 'file-target.txt');+ const fileSymlink = path.join(aliasRoot, 'file-symlink.txt');+ const hardlink = path.join(aliasRoot, 'file-hardlink.txt');+ fs.mkdirSync(junctionTarget, { recursive: true });+ fs.mkdirSync(differentDirectory);+ fs.writeFileSync(fileTarget, 'controlled Windows alias evidence\n');+ fs.symlinkSync(junctionTarget, junctionAlias, 'junction');+ fs.symlinkSync(fileTarget, fileSymlink, 'file');+ fs.linkSync(fileTarget, hardlink);+ assert.equal(sameLocation(junctionTarget, junctionAlias).status, 'match');+ assert.equal(sameLocation(junctionTarget, differentDirectory).status, 'different');+ assert.equal(sameLocation(fileTarget, fileSymlink).status, 'match');+ assert.equal(sameLocation(fileTarget, hardlink).status, 'match');+ assert.equal(fs.readFileSync(fileSymlink, 'utf8'), 'controlled Windows alias evidence\n');+ assert.equal(fs.readFileSync(hardlink, 'utf8'), 'controlled Windows alias evidence\n');++ const upperOutput = path.join(caseRoot, `${token}-Case.html`);+ const lowerOutput = path.join(caseRoot, `${token}-case.html`);+ requireSuccess('case-sensitive render (upper)', runCli([+ 'render', 'architecture', architectureInput, upperOutput,+ ]));+ assert.equal(+ sameLocation(upperOutput, lowerOutput).status,+ 'different',+ 'a future case-variant name must remain distinct in the controlled directory',+ );+ requireSuccess('case-sensitive render (lower)', runCli([+ 'render', 'architecture', architectureInput, lowerOutput,+ ]));+ assert.equal(sameLocation(upperOutput, lowerOutput).status, 'different');+ assert.ok(fs.existsSync(upperOutput) && fs.existsSync(lowerOutput));++ const caseDelivery = path.join(caseRoot, `${token}-drive-case-delivery.html`);+ const driveCaseDelivery = path.join(driveCaseRoot, path.basename(caseDelivery));+ const deliveredCase = runCli([+ 'deliver', 'workflow', workflowInput, caseDelivery,+ '--quality', 'showcase', '--json',+ ]);+ requireSuccess('case-sensitive NTFS delivery', deliveredCase);+ assert.equal(JSON.parse(deliveredCase.stdout).ok, true);+ assert.equal(sameLocation(caseDelivery, driveCaseDelivery).status, 'match');+ const strictDriveCaseCheck = runCli([+ 'check', driveCaseDelivery, '--require-provenance',+ ]);+ requireSuccess('strict check through drive-letter case alias', strictDriveCaseCheck);+ assert.equal(JSON.parse(strictDriveCaseCheck.stdout).provenance, 'current');++ const ordinaryRender = path.win32.join(uncRoot, `${token}-ordinary-render.html`);+ const extendedRender = path.win32.join(extendedUncRoot, `${token}-extended-render.html`);+ requireSuccess('ordinary UNC render', runCli([+ 'render', 'architecture', architectureInput, ordinaryRender,+ ]));+ requireSuccess('extended UNC render', runCli([+ 'render', 'architecture', architectureInput, extendedRender,+ ]));+ assert.ok(fs.existsSync(ordinaryRender) && fs.existsSync(extendedRender));++ const ordinaryDelivery = path.win32.join(uncRoot, `${token}-ordinary-delivery.html`);+ const extendedOrdinaryDelivery = path.win32.join(+ extendedUncRoot,+ path.win32.basename(ordinaryDelivery),+ );+ const delivered = runCli([+ 'deliver', 'workflow', workflowInput, ordinaryDelivery,+ '--quality', 'showcase', '--json',+ ]);+ requireSuccess('ordinary UNC delivery', delivered);+ assert.equal(JSON.parse(delivered.stdout).ok, true);+ assert.equal(sameLocation(ordinaryDelivery, extendedOrdinaryDelivery).status, 'match');+ const strictAliasCheck = runCli([+ 'check', extendedOrdinaryDelivery, '--require-provenance',+ ]);+ requireSuccess('strict check through extended UNC alias', strictAliasCheck);+ assert.equal(JSON.parse(strictAliasCheck.stdout).provenance, 'current');++ const extendedDelivery = path.win32.join(extendedUncRoot, `${token}-extended-delivery.html`);+ const ordinaryExtendedDelivery = path.win32.join(uncRoot, path.win32.basename(extendedDelivery));+ const deliveredExtended = runCli([+ 'deliver', 'workflow', workflowInput, extendedDelivery,+ '--quality', 'showcase', '--json',+ ]);+ requireSuccess('extended UNC delivery', deliveredExtended);+ assert.equal(JSON.parse(deliveredExtended.stdout).ok, true);+ const strictOrdinaryCheck = runCli([+ 'check', ordinaryExtendedDelivery, '--require-provenance',+ ]);+ requireSuccess('strict check through ordinary UNC alias', strictOrdinaryCheck);+ assert.equal(JSON.parse(strictOrdinaryCheck.stdout).provenance, 'current');++ const evidenceDirectory = path.win32.join(uncRoot, `${token}-visual-evidence`);+ const visual = runCli([+ 'visual-check', ordinaryDelivery, '--json', '--require-provenance',+ '--out-dir', evidenceDirectory,+ ], { timeout: 180_000 });+ requireSuccess('ordinary UNC visual-check', visual);+ assert.equal(JSON.parse(visual.stdout).status, 'pass');++ const previewOutput = path.win32.join(extendedUncRoot, `${token}-preview.html`);+ const { startPreview } = await import('../archify/bin/preview.mjs');+ preview = await startPreview({+ type: 'architecture',+ input: architectureInput,+ output: previewOutput,+ quality: 'showcase',+ open: false,+ debounceMs: 20,+ pollMs: 60_000,+ });+ await waitForVerifiedPreview(preview.url);+ assert.ok(fs.existsSync(path.win32.join(uncRoot, path.win32.basename(previewOutput))));+ await preview.stop();+ preview = null;++ if (Number(process.versions.node.split('.')[0]) === 22) {+ const uncArchive = path.win32.join(uncRoot, `${token}-archify.zip`);+ const bashCandidates = [+ process.env.BASH,+ 'C:\\Program Files\\Git\\bin\\bash.exe',+ 'bash',+ ].filter(Boolean);+ const bash = bashCandidates.find((candidate) => (+ candidate === 'bash' || fs.existsSync(candidate)+ )) || 'bash';+ const archiveBuild = spawnSync(+ bash,+ [path.join(repoRoot, 'scripts', 'build-zip.sh'), uncArchive],+ { cwd: repoRoot, encoding: 'utf8', timeout: 180_000 },+ );+ requireSuccess('canonical ZIP publication to ordinary UNC', archiveBuild);+ assert.equal(fs.readFileSync(uncArchive).subarray(0, 4).toString('hex'), '504b0304');+ }+ } finally {+ if (preview) await preview.stop().catch(() => {});+ removeChildren(caseRoot);+ removeChildren(uncRoot);+ }+}++const fullSuites = [+ 'test/release-package-gates.test.mjs',+ 'test/copy-site-assets.test.mjs',+ 'test/path-boundary-contract.test.mjs',+ 'test/path-semantics.test.mjs',+ 'test/portable-path.test.mjs',+ 'test/native-output-path.test.mjs',+ 'test/meta-output-contract.test.mjs',+ 'test/output-path.test.mjs',+ 'test/cli-output-types.test.mjs',+ 'test/delivery-sidecar-path.test.mjs',+ 'test/sidecar-path-length.test.mjs',+ 'test/open-artifact.test.mjs',+ 'test/repository-evidence.test.mjs',+ 'test/renderer-atomic-write.test.mjs',+];++const portabilitySuites = [+ 'test/checkout-line-endings.test.mjs',+ 'test/clean-skill-staging.test.mjs',+ 'test/workflow-migration.test.mjs',+ 'test/cli.test.mjs',+ 'test/preview.test.mjs',+ 'test/visual-check.test.mjs',+ 'test/update-notifier.test.mjs',+];++const portabilityPattern = [+ 'Git checkout preserves',+ 'clean staging preserves index modes',+ 'entry detection',+ 'workflow migration cleanup failure',+ 'workflow migration rejects a dangling destination symlink',+ 'workflow migration preserves a destination claimant created before final verification',+ 'workflow migration preserves an existing destination replaced during candidate mode finalization',+ 'preview runs from an installed skill',+ 'publishing through an existing output symlink',+ 'publishing through a dangling output symlink',+ 'recreating an output symlink',+ 'concurrently claimed absent output',+ 'concurrent replacement of an existing output',+ 'hardlinked existing output',+ 'watcher accepts',+ 'canonical watch target',+ 'Windows 8.3 short path',+ 'preview: publishing through an existing output symlink',+ 'preview: publishing through a dangling output symlink',+ 'preview: recreating an output symlink',+ 'preview: a concurrently claimed absent output',+ 'preview: a concurrent replacement of an existing output',+ 'preview: a hardlinked existing output',+ 'updater rejects a case-only alias',+ 'symlink cache root',+ 'symlink cache ancestor',+ 'trusted cache prefix switched',+ 'findChrome',+ 'visual-check',+ 'doctor identifies an incomplete installation',+].join('|');++const groups = [+ ['--test', '--test-concurrency=1', ...fullSuites],+ [+ '--test',+ '--test-concurrency=1',+ `--test-name-pattern=${portabilityPattern}`,+ ...portabilitySuites,+ ],+];++await runControlledWindowsPathE2E();++for (const args of groups) {+ const result = spawnSync(process.execPath, args, {+ cwd: skillRoot,+ stdio: 'inherit',+ });+ if (result.error) throw result.error;+ if (result.signal) {+ process.stderr.write(`Windows path test runner terminated by ${result.signal}\n`);+ process.exitCode = 1;+ break;+ }+ if (result.status !== 0) {+ process.exitCode = result.status ?? 1;+ break;+ }+}diff --git a/scripts/stage-clean-skill.mjs b/scripts/stage-clean-skill.mjsindex fc1fd16c..1dca77b0 100644--- a/scripts/stage-clean-skill.mjs+++ b/scripts/stage-clean-skill.mjs@@ -5,6 +5,8 @@ import fs from 'node:fs';import path from 'node:path';import { fileURLToPath } from 'node:url';+import { containedBy, sameEntry } from '../archify/renderers/shared/path-semantics.mjs';+import { validatePortablePathSet } from '../archify/renderers/shared/portable-path.mjs';import { assertThirdPartyNotices } from './third-party-notices-contract.mjs';const scriptRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');@@ -16,6 +18,12 @@ const REQUIRED_INPUTS = new Set(['archify/scripts/update-contract.mjs','archify/skill-release.json',]);+const RUNTIME_DEPENDENCIES = Object.freeze([+ 'archify/renderers/shared/atomic-output.mjs',+ 'archify/renderers/shared/output-path.mjs',+ 'archify/renderers/shared/path-semantics.mjs',+ 'archify/renderers/shared/portable-path.mjs',+]);const EXCLUDED_FILES = new Set(['archify/package-lock.json','archify/scripts/generate-brand-marks.mjs',@@ -59,6 +67,7 @@ function trackedEntries(repoRoot) {const separator = record.indexOf('\t');const metadata = separator === -1 ? [] : record.slice(0, separator).split(' ');const relative = separator === -1 ? '' : record.slice(separator + 1);+ // path-contract-allow: git-path -- git ls-files emits repository-relative POSIX paths.if (metadata.length !== 3 || !relative.startsWith('archify/')) {throw new Error(`invalid tracked package record: ${JSON.stringify(record)}`);}@@ -181,23 +190,6 @@ function snapshotSourceEntry(entry) {}}-function canonicalizeExistingPrefix(target) {- // realpathSync rejects paths that do not exist yet, so resolve the deepest- // existing ancestor through symlinks and re-append the missing tail.- const pending = [];- let current = path.resolve(target);- for (;;) {- try {- return path.join(fs.realpathSync(current), ...pending);- } catch {- const parent = path.dirname(current);- if (parent === current) return path.join(current, ...pending);- pending.unshift(path.basename(current));- current = parent;- }- }-}-function cleanPackageManifest(destination) {const packagePath = path.join(destination, 'package.json');const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));@@ -236,6 +228,22 @@ function validateThirdPartyNoticeInputs(repoRoot, packageEntries) {}}+function validateRuntimeDependencies(packageEntries) {+ const packaged = new Set(packageEntries.map((entry) => entry.relative));+ for (const relative of RUNTIME_DEPENDENCIES) {+ const basename = path.basename(relative);+ const imported = packageEntries.some((entry) => (+ // path-contract-allow: portable-logical-path -- Both values are tracked package entry names.+ entry.relative !== relative+ && /[.]m?js$/u.test(entry.relative)+ && entry.content.includes(basename)+ ));+ if (imported && !packaged.has(relative)) {+ throw new Error(`required package input is not tracked by Git: ${relative}`);+ }+ }+}+export function stageCleanSkill({ repoRoot = scriptRoot, destination, modeManifest = null }) {const resolvedRoot = fs.realpathSync(path.resolve(repoRoot));if (!destination) throw new Error('clean Skill staging requires a destination');@@ -248,18 +256,6 @@ export function stageCleanSkill({ repoRoot = scriptRoot, destination, modeManife// an executable bit), so the archive must not re-derive modes from stat.const resolvedModeManifest = modeManifest === null ? null : path.resolve(modeManifest);if (resolvedModeManifest !== null) {- // Compare physical locations: a symlinked ancestor on either side must not- // let the manifest land inside the staged tree, where the writer would see- // an unrecorded file and refuse the archive.- const canonicalDestination = canonicalizeExistingPrefix(resolvedDestination);- const canonicalManifest = canonicalizeExistingPrefix(resolvedModeManifest);- const relativeToDestination = path.relative(canonicalDestination, canonicalManifest);- const outsideDestination = relativeToDestination === '..'- || relativeToDestination.startsWith(`..${path.sep}`)- || path.isAbsolute(relativeToDestination);- if (!outsideDestination) {- throw new Error(`mode manifest must be written outside the staged Skill tree: ${resolvedModeManifest}`);- }// The manifest belongs to this invocation only: never overwrite, and never// later remove, a file that already existed at that path.let manifestExists = true;@@ -272,6 +268,16 @@ export function stageCleanSkill({ repoRoot = scriptRoot, destination, modeManifeif (manifestExists) {throw new Error(`mode manifest path already exists: ${resolvedModeManifest}`);}+ // Compare physical locations: a symlinked ancestor on either side must not+ // let the manifest land inside the staged tree, where the writer would see+ // an unrecorded file and refuse the archive.+ const manifestContainment = containedBy(resolvedDestination, resolvedModeManifest);+ if (manifestContainment.status === 'match') {+ throw new Error(`mode manifest must be written outside the staged Skill tree: ${resolvedModeManifest}`);+ }+ if (manifestContainment.status === 'unknown') {+ throw new Error(`mode manifest location could not be verified safely (${manifestContainment.reason.code}): ${resolvedModeManifest}`);+ }}const entries = trackedEntries(resolvedRoot);@@ -288,10 +294,18 @@ export function stageCleanSkill({ repoRoot = scriptRoot, destination, modeManife}requireTrackedFile(resolvedRoot, 'THIRD_PARTY_NOTICES.md');- const packageEntries = entries- .filter((entry) => !excluded(entry.relative))+ const includedEntries = entries.filter((entry) => !excluded(entry.relative));+ validatePortablePathSet(+ includedEntries.map((entry) => entry.relative.slice('archify/'.length)),+ { profile: 'archive' },+ );++ const packageEntries = includedEntries.map((entry) => preflightSourceEntry(resolvedRoot, entry)).map((entry) => snapshotSourceEntry(entry));+ // Current packages must contain every imported runtime, while historical+ // snapshots that predate a runtime remain reproducible by the DSH adapter.+ validateRuntimeDependencies(packageEntries);validateThirdPartyNoticeInputs(resolvedRoot, packageEntries);const modes = Object.fromEntries(@@ -327,13 +341,15 @@ export function stageCleanSkill({ repoRoot = scriptRoot, destination, modeManifereturn { destination: resolvedDestination, fileCount, modes };}-function isMainModule() {- if (!process.argv[1]) return false;+export function isMainModule({+ argvPath = process.argv[1],+ modulePath = fileURLToPath(import.meta.url),+} = {}) {+ if (!argvPath) return false;try {- return fs.realpathSync(path.resolve(process.argv[1]))- === fs.realpathSync(fileURLToPath(import.meta.url));+ return sameEntry(argvPath, modulePath).status === 'match';} catch {- return path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));+ return false;}}diff --git a/scripts/write-deterministic-zip.mjs b/scripts/write-deterministic-zip.mjsindex a4297144..074d5813 100644--- a/scripts/write-deterministic-zip.mjs+++ b/scripts/write-deterministic-zip.mjs@@ -2,17 +2,36 @@import fs from 'node:fs';import path from 'node:path';-import { randomBytes } from 'node:crypto';+import { createHash, randomBytes } from 'node:crypto';import { constants as zlibConstants, deflateRawSync } from 'node:zlib';+import {+ captureAtomicOutput,+ captureRegularFileBinding,+ releaseRegularFileBinding,+ removeOwnedRegularFile,+ verifyAtomicOutput,+ verifyRegularFileBinding,+} from '../archify/renderers/shared/atomic-output.mjs';+import { validateNativeOutputPath } from '../archify/renderers/shared/output-path.mjs';+import { validatePortablePathSet } from '../archify/renderers/shared/portable-path.mjs';+function usage() {- console.error('Usage: node scripts/write-deterministic-zip.mjs <directory> <output.zip> --mode-manifest <modes.json>');+ console.error([+ 'Usage: node scripts/write-deterministic-zip.mjs <directory> <output.zip> --mode-manifest <modes.json>',+ ' node scripts/write-deterministic-zip.mjs --validate-output <output.zip>',+ ].join('\n'));process.exit(2);}const positionals = [];let modeManifestArg = null;const argv = process.argv.slice(2);+if (argv[0] === '--validate-output') {+ if (argv.length !== 2) usage();+ validateArchiveOutputPath(argv[1]);+ process.exit(0);+}for (let index = 0; index < argv.length; index += 1) {if (argv[index] === '--mode-manifest') {modeManifestArg = argv[index + 1] ?? null;@@ -26,8 +45,38 @@ for (let index = 0; index < argv.length; index += 1) {const [rootArg, outputArg] = positionals;if (!rootArg || !outputArg || positionals.length !== 2 || !modeManifestArg) usage();+function validateArchiveOutputPath(rawOutput) {+ try {+ validateNativeOutputPath(rawOutput, { kind: 'file' });+ if (process.platform !== 'win32') {+ // ZIPs are published and consumed cross-platform. Apply the shared+ // Windows component grammar on POSIX too, while removing only the POSIX+ // root marker so an ordinary /tmp/archive.zip is not mistaken for a+ // current-drive-rooted Windows spelling.+ const posixRoot = path.posix.parse(rawOutput).root;+ const windowsComparable = posixRoot ? rawOutput.slice(posixRoot.length) : rawOutput;+ validateNativeOutputPath(windowsComparable, { platform: 'win32', kind: 'file' });+ }+ } catch (error) {+ const reason = error?.archifyDiagnostics?.[0]?.evidence?.reason;+ console.error(+ `archive output is not a valid native filesystem path${reason ? ` (${reason})` : ''}: ${JSON.stringify(rawOutput)}`,+ );+ process.exit(2);+ }+}++validateArchiveOutputPath(outputArg);const root = path.resolve(rootArg);const output = path.resolve(outputArg);+const outputCapture = captureAtomicOutput(output, {+ requestedEntryPolicy: 'regular-or-absent',+});+if (outputCapture.status !== 'captured') {+ throw new Error(+ `archive output cannot be published safely (${outputCapture.reason?.code || 'capture-failed'}): ${output}`,+ );+}// Entry modes come from the Git index, recorded by scripts/stage-clean-skill.mjs.// Filesystem permission bits are not portable across platforms (Windows cannot@@ -50,6 +99,7 @@ function loadModeManifest(manifestPath) {}modes.set(relative, gitMode === '100755' ? 0o755 : 0o644);}+ validatePortablePathSet([...modes.keys()], { profile: 'archive' });return modes;}@@ -143,6 +193,10 @@ const localParts = [];const centralParts = [];let offset = 0;const files = sortedEntries(root);+validatePortablePathSet(+ files.map((file) => `${path.basename(root)}/${file.relative}`),+ { profile: 'archive' },+);requireZip32(files.length < ZIP32_MAX_ENTRIES, `entry count ${files.length} reaches ZIP64 sentinel ${ZIP32_MAX_ENTRIES}`);for (const file of files) {@@ -200,20 +254,80 @@ end.writeUInt32LE(centralOffset, 16);end.writeUInt16LE(0, 20);const archive = Buffer.concat([...localParts, ...centralParts, end]);+const archiveSha256 = createHash('sha256').update(archive).digest('hex');const temporary = path.join(- path.dirname(output),- `.${path.basename(output)}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`,+ path.dirname(outputCapture.commitPath),+ `.${path.basename(outputCapture.commitPath)}.${randomBytes(16).toString('hex')}.tmp`,);let descriptor;+let candidateIdentity;+let candidateBinding;try {- descriptor = fs.openSync(temporary, 'wx', 0o666);+ const noFollow = process.platform === 'win32' ? 0 : (fs.constants.O_NOFOLLOW || 0);+ descriptor = fs.openSync(+ temporary,+ fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL | noFollow,+ 0o666,+ );+ const candidateMetadata = fs.fstatSync(descriptor, { bigint: true });+ if (!candidateMetadata.isFile() || candidateMetadata.ino === 0n) {+ throw new Error(`archive candidate identity is unavailable: ${temporary}`);+ }+ candidateIdentity = {+ device: candidateMetadata.dev,+ inode: candidateMetadata.ino,+ };fs.writeFileSync(descriptor, archive);+ if (outputCapture.mode !== null) fs.fchmodSync(descriptor, outputCapture.mode);fs.fsyncSync(descriptor);fs.closeSync(descriptor);descriptor = undefined;- fs.renameSync(temporary, output);+ const candidate = captureRegularFileBinding(temporary, {+ subject: 'archive-candidate',+ expectedIdentity: candidateIdentity,+ expectedSha256: archiveSha256,+ expectedBytes: archive.length,+ ...(outputCapture.mode === null ? {} : { expectedMode: outputCapture.mode }),+ });+ if (candidate.status !== 'captured') {+ throw new Error(+ `archive candidate cannot be published safely (${candidate.reason?.code || 'capture-failed'}): ${temporary}`,+ );+ }+ candidateBinding = candidate.binding;+ const verifiedOutput = verifyAtomicOutput(outputCapture.snapshot);+ if (verifiedOutput.status !== 'match') {+ throw new Error(+ `archive output changed before publication (${verifiedOutput.reason?.code || 'verification-failed'}): ${output}`,+ );+ }+ const verifiedCandidate = verifyRegularFileBinding(candidateBinding);+ if (verifiedCandidate.status !== 'match') {+ throw new Error(+ `archive candidate changed before publication (${verifiedCandidate.reason?.code || 'verification-failed'}): ${temporary}`,+ );+ }+ const releasedCandidate = releaseRegularFileBinding(candidateBinding);+ candidateBinding = undefined;+ if (releasedCandidate.status !== 'released') {+ throw new Error(+ `archive candidate handle could not be released (${releasedCandidate.reason?.code || 'release-failed'}): ${temporary}`,+ );+ }+ fs.renameSync(temporary, outputCapture.commitPath);+ candidateIdentity = undefined;} finally {if (descriptor !== undefined) fs.closeSync(descriptor);- fs.rmSync(temporary, { force: true });+ if (candidateBinding) releaseRegularFileBinding(candidateBinding);+ if (candidateIdentity) {+ const cleanup = removeOwnedRegularFile(temporary, candidateIdentity, {+ subject: 'archive-candidate',+ });+ if (!['removed', 'absent', 'preserved'].includes(cleanup.status)) {+ throw new Error(+ `archive candidate could not be cleaned safely (${cleanup.reason?.code || 'cleanup-failed'}): ${temporary}`,+ );+ }+ }}console.log(`built ${output} (${entryCount} files)`);