feat: publish HoloLake model-native living system source
This commit is contained in:
parent
6ad10edde1
commit
c395dd3a99
2467 changed files with 615073 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
import { describe, it, beforeEach, afterEach } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { mkdtemp, readFile, rm } from 'node:fs/promises'
|
||||
import os from 'node:os'
|
||||
import path from 'node:path'
|
||||
import {
|
||||
finalizeHldpCheckpoint,
|
||||
readHldpHeartbeat,
|
||||
recordHldpHeartbeat,
|
||||
} from './hldp-journal.js'
|
||||
|
||||
let basePath
|
||||
|
||||
beforeEach(async () => {
|
||||
basePath = await mkdtemp(path.join(os.tmpdir(), 'hololake-hldp-mcp-'))
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await rm(basePath, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
describe('HLDP MCP journal', () => {
|
||||
it('appends structured events and reads them in order', async () => {
|
||||
await recordHldpHeartbeat({
|
||||
session_id: 'chat-42',
|
||||
event_kind: 'decision',
|
||||
summary: 'Keep working memory local.',
|
||||
details: ['Publish only finalized checkpoints.'],
|
||||
}, { basePath })
|
||||
await recordHldpHeartbeat({
|
||||
session_id: 'chat-42',
|
||||
event_kind: 'correction',
|
||||
summary: 'Do not treat Codex logs as persona memory.',
|
||||
}, { basePath })
|
||||
|
||||
const events = await readHldpHeartbeat({ session_id: 'chat-42' }, { basePath })
|
||||
|
||||
assert.equal(events.length, 2)
|
||||
assert.equal(events[0].event_kind, 'decision')
|
||||
assert.equal(events[1].event_kind, 'correction')
|
||||
assert.equal(events[0].source, 'persona')
|
||||
})
|
||||
|
||||
it('writes one immutable finalized checkpoint', async () => {
|
||||
const receipt = await finalizeHldpCheckpoint({
|
||||
session_id: 'chat-42',
|
||||
checkpoint: '# Continuity checkpoint',
|
||||
}, { basePath })
|
||||
|
||||
assert.equal(receipt.relativePath, path.join('checkpoints', 'chat-42.hdlp'))
|
||||
assert.equal(
|
||||
await readFile(path.join(basePath, receipt.relativePath), 'utf8'),
|
||||
'# Continuity checkpoint\n',
|
||||
)
|
||||
await assert.rejects(
|
||||
() => finalizeHldpCheckpoint({
|
||||
session_id: 'chat-42',
|
||||
checkpoint: '# Replacement',
|
||||
}, { basePath }),
|
||||
error => error?.code === 'EEXIST',
|
||||
)
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue