hololake-system-architecture/product-source/hololake-native-desktop/scripts/numbered-knowledge-protocol.test.mjs

24 lines
1.3 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8')
test('knowledge pages share one stable numbered header protocol without rewriting originals', () => {
const contract = JSON.parse(read('contracts/numbered-knowledge-protocol.json'))
const runtime = read('src-tauri/src/knowledge_base.rs')
assert.equal(contract.numbering_system, 'HLP-KB')
assert.equal(contract.storage.original_documents_rewritten, false)
assert.equal(contract.storage.original_sha256_preserved, true)
assert.deepEqual(contract.page_header.thought_summary.required_fields, ['trigger', 'emergence', 'lock', 'why'])
assert.equal(contract.migration.legacy_default_state, 'PENDING_THOUGHT_INDEX')
assert.equal(contract.migration.pending_page_may_fabricate_thought_summary, false)
assert.equal(contract.routing.regular_search_reads_full_document_body, false)
assert.equal(contract.routing.exact_read_accepts_path_guess, false)
assert.equal(contract.numbers.different_owner_same_number_fails_closed, true)
assert.match(runtime, /numbered-knowledge-index\.sqlite3/)
assert.match(runtime, /HLP-KB-DOC-/)
assert.match(runtime, /read_numbered_document_at/)
assert.match(runtime, /HOLOLAKE_KNOWLEDGE_NUMBER_COLLISION/)
})