Files
chimera-Public/test/server/ch-1401-p15-r2-product-lane.test.js
T

79 lines
4.6 KiB
JavaScript

'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const ROOT = path.resolve(__dirname, '..', '..');
test('server exposes a dedicated persistent R2 lane and blocks generic PPSA launch bypass', () => {
const source = fs.readFileSync(path.join(ROOT, 'src', 'server', 'create-registry.js'), 'utf8');
assert.match(source, /createP15R2QualificationService/);
assert.match(source, /name: 'ps5-p15-r2:status', classification: 'read-only'/);
assert.match(source, /name: 'ps5-p15-r2:preflight', classification: 'read-only'/);
assert.match(source, /name: 'ps5-p15-r2:qualify', classification: 'mutating'/);
assert.match(source, /name: 'ps5-p15-r2:launch', classification: 'destructive', confirmation: P15_R2_CONFIRMATION/);
assert.match(source, /operation\.titleId === P15_R2_TITLE_ID/);
assert.match(source, /code: 'P15_R2_GATE_REQUIRED'/);
});
test('renderer exposes only status, preflight and qualification for R4, never launch', () => {
const preload = fs.readFileSync(path.join(ROOT, 'preload.js'), 'utf8');
const web = fs.readFileSync(path.join(ROOT, 'renderer', 'pork-web-shim.js'), 'utf8');
const modal = fs.readFileSync(path.join(ROOT, 'renderer', 'modules', 'modal.js'), 'utf8');
const html = fs.readFileSync(path.join(ROOT, 'renderer', 'index.html'), 'utf8');
for (const source of [preload, web]) {
assert.match(source, /ps5P15R2Status/);
assert.match(source, /ps5P15R2Preflight/);
assert.match(source, /ps5P15R2Qualify/);
assert.doesNotMatch(source, /ps5P15R2Launch/);
}
assert.match(html, /id="ps5-p15-r2-preflight"/);
assert.match(html, /id="ps5-p15-r2-qualify"/);
assert.doesNotMatch(html, /id="ps5-p15-r2-launch"/);
assert.match(modal, /renderPs5P15R2Qualification/);
assert.match(modal, /preflight\?\.evidence\?\.kstuff/);
assert.match(modal, /ps5-p15-r2-kstuff-evidence/);
assert.match(modal, /window\.pork\.ps5P15R2Preflight\(\)/);
assert.match(modal, /window\.pork\.ps5P15R2Qualify\(\)/);
});
test('PPSA observer selection is server-owned and bound to the A10 transition runtime', () => {
const source = fs.readFileSync(path.join(ROOT, 'src', 'server', 'create-registry.js'), 'utf8');
assert.match(source, /titleId === A10_TRANSITION_CONTROL\.titleId \|\| titleId === P15_R2_TITLE_ID/);
assert.match(source, /const currentProductionExact = productionIdentity\.status === 'exact' && productionIdentity\.lane === 'production'/);
assert.match(source, /transitionEvidence\?\.valid === true/);
assert.match(source, /transitionEvidence\.profileIdentity === P15_A10_RUNTIME_PROFILE\.identity/);
assert.match(source, /observerIdentity\.status === 'exact' && observerIdentity\.lane === 'diagnostic'/);
assert.match(source, /classifyPs5FpkgKstuffRuntimeObservation\(runtimeObservation\)/);
assert.doesNotMatch(source, /observedHash|loaderExecuted\\s/);
const adapter = fs.readFileSync(path.join(ROOT, 'src', 'services', 'ps5-fpkg-kstuff-runtime-identity.js'), 'utf8');
assert.match(adapter, /expected: P15_R4_KSTUFF_RUNTIME/);
assert.match(adapter, /processInventoryComplete: inventoryComplete/);
assert.match(adapter, /kstuff_current_boot_execution_receipt_unavailable/);
assert.match(source, /kstuff_process_inventory_unavailable/);
assert.match(source, /kstuffIdentityExact: kstuffIdentity\.status === 'exact'/);
assert.match(source, /expected: kstuffIdentity\.expected/);
assert.match(source, /observed: kstuffIdentity\.observed/);
assert.match(source, /evidenceContract: kstuffIdentity\.evidenceContract/);
assert.match(source, /shellUiPid: runtimeObservation\.shellUiPid/);
assert.match(source, /runningBigAppId: runtimeObservation\.runningBigAppId/);
assert.match(source, /ps5Klog\.captureIdentity/);
assert.match(source, /port: 9081/);
assert.doesNotMatch(source, /kstuffIdentityExact: false/);
});
test('R4 host qualification reuses the canonical control service target instead of a projected database path', () => {
const source = fs.readFileSync(path.join(ROOT, 'src', 'server', 'create-registry.js'), 'utf8');
assert.match(source, /const hostArtifact = await ps5UpstreamControlPackage\.status\(\)/);
assert.doesNotMatch(source, /qualifyP15R3HostArtifact/);
});
test('R4 installed-content qualification resolves the package set by external title identity', () => {
const source = fs.readFileSync(path.join(ROOT, 'src', 'server', 'create-registry.js'), 'utf8');
assert.match(source, /packageSets\.listCatalog\(\)/);
assert.match(source, /item\.title\?\.externalTitleId/);
assert.doesNotMatch(source, /packageSets\.listByTitle\(P15_R2_TITLE_ID\)/);
});