70 lines
4.6 KiB
JavaScript
70 lines
4.6 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
import test from 'node:test'
|
|
|
|
const registryUrl = new URL('../contracts/gls-runtime-registry.json', import.meta.url)
|
|
|
|
test('compiled GLS v2 manifest reconciles current registration sources without executing raw text', async () => {
|
|
const registry = JSON.parse(await readFile(registryUrl, 'utf8'))
|
|
|
|
assert.equal(registry.schema, 'hololake.gls-runtime-manifest/v2')
|
|
assert.equal(registry.source.repository, 'REPO-012')
|
|
assert.equal(registry.source.commit, '2598fbfba8caf64c7ab9740a3036c5aab977502e')
|
|
assert.equal(registry.source.authority_files.length, 4)
|
|
assert.equal(registry.compiler.raw_protocol_text_executed, false)
|
|
assert.equal(registry.compiler.arbitrary_protocol_code_allowed, false)
|
|
assert.equal(registry.compiler.unprojected_protocol_behavior, 'INVENTORIED_NOT_EXECUTABLE')
|
|
assert.equal(registry.compiler.source_dependency_behavior, 'TYPED_AUDIT_ONLY_NEVER_ACTIVATES')
|
|
assert.equal(registry.protocol_count, 75)
|
|
assert.equal(new Set(registry.protocols.map((protocol) => protocol.id)).size, 75)
|
|
assert.ok(registry.protocols.every((protocol) => /^[a-f0-9]{64}$/.test(protocol.source_sha256)))
|
|
assert.equal(registry.reconciliation.protocol_registry_id_count, 52)
|
|
assert.equal(registry.reconciliation.existing_registered_count, 19)
|
|
assert.equal(registry.reconciliation.registered_draft_count, 33)
|
|
assert.equal(registry.reconciliation.registered_draft_not_started_count, 21)
|
|
assert.equal(registry.reconciliation.legacy_dependency_target_count, 57)
|
|
assert.equal(registry.reconciliation.dependencies_not_in_protocol_registry.length, 19)
|
|
assert.equal(registry.reconciliation.dependencies_without_numbered_source.length, 24)
|
|
assert.equal(registry.reconciliation.numbered_sources_not_in_protocol_registry.length, 31)
|
|
assert.equal(registry.reconciliation.legacy_dependency_cycles.length, 3)
|
|
assert.equal(registry.reconciliation.discovered_unreconciled_count, 0)
|
|
assert.equal(registry.reconciliation.authority_conflict_count, 0)
|
|
assert.equal(registry.reconciliation.unclassified_source_dependency_count, 0)
|
|
assert.equal(Object.values(registry.reconciliation.typed_source_dependency_counts).reduce((sum, count) => sum + count, 0), 183)
|
|
})
|
|
|
|
test('only explicit deterministic projections enter the runtime enforcement set', async () => {
|
|
const registry = JSON.parse(await readFile(registryUrl, 'utf8'))
|
|
const protocols = Object.fromEntries(registry.protocols.map((protocol) => [protocol.id, protocol]))
|
|
|
|
assert.equal(protocols['GLS-0253'].projection_state, 'EXECUTABLE_PROJECTION')
|
|
assert.equal(protocols['GLS-0253'].adapter, 'zero-core-numbering')
|
|
assert.ok(protocols['GLS-0253'].event_kinds.includes('IDENTITY_ROUTE'))
|
|
assert.ok(protocols['GLS-0253'].dependency_edges.every((edge) => edge.edge_kind === 'RUNTIME_REQUIRES'))
|
|
assert.equal(protocols['GLS-0130'].registration.state, 'REGISTERED_PROTOCOL_REGISTRY')
|
|
assert.equal(protocols['GLS-0130'].contract_kind, 'BOOTSTRAP_HLDP_TO_GIR_COMPILER')
|
|
assert.ok(protocols['GLS-0130'].dependency_edges.some((edge) => edge.target === 'GLS-0131' && edge.edge_kind === 'BUILD_REQUIRES' && !edge.enters_runtime_graph))
|
|
assert.ok(protocols['GLS-0130'].dependency_edges.some((edge) => edge.target === 'GLS-0411' && edge.edge_kind === 'BUILD_REQUIRES' && !edge.enters_runtime_graph))
|
|
assert.equal(protocols['GLS-0130'].implementation_stage, 'P6')
|
|
assert.equal(protocols['GLS-0003'], undefined)
|
|
assert.equal(registry.executable_projection_count, 25)
|
|
assert.equal(registry.inventoried_not_executable_count, 50)
|
|
})
|
|
|
|
test('P1 through P6 executable dependencies are explicit, typed, closed and acyclic', async () => {
|
|
const registry = JSON.parse(await readFile(registryUrl, 'utf8'))
|
|
const executable = new Map(registry.protocols.filter((protocol) => protocol.projection_state === 'EXECUTABLE_PROJECTION').map((protocol) => [protocol.id, protocol]))
|
|
assert.deepEqual(new Set([...executable.values()].map((protocol) => protocol.implementation_stage)), new Set(['P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6']))
|
|
assert.ok([...executable.values()].every((protocol) => protocol.dependency_edges.filter((edge) => edge.enters_runtime_graph).every((edge) => edge.edge_kind === 'RUNTIME_REQUIRES' && executable.has(edge.target))))
|
|
const visiting = new Set()
|
|
const visited = new Set()
|
|
const visit = (id) => {
|
|
assert.equal(visiting.has(id), false, `runtime cycle at ${id}`)
|
|
if (visited.has(id)) return
|
|
visiting.add(id)
|
|
for (const dependency of executable.get(id).dependencies) visit(dependency)
|
|
visiting.delete(id)
|
|
visited.add(id)
|
|
}
|
|
for (const id of executable.keys()) visit(id)
|
|
})
|