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('each verified persona receives one stable local execution subpersona with its own logic brain and work memory', () => { const contract = JSON.parse(read('contracts/local-execution-subpersona.json')) const runtime = read('src-tauri/src/local_execution_subpersona.rs') const panel = read('src/modules/knowledge-agent/LocalWorkerPanel.tsx') assert.equal(contract.identity.cardinality, 'ONE_STABLE_LOCAL_EXECUTION_SUBPERSONA_PER_VERIFIED_PERSONA') assert.equal(contract.identity.has_own_experience_learning_logic_brain, true) assert.equal(contract.identity.may_attach_optional_small_model_enhancement, true) assert.equal(contract.identity.has_continuous_existence_and_work_memory, true) assert.equal(contract.memory.stateless_executor_forbidden, true) assert.match(contract.memory.architecture, /TCS_EXECUTION_KERNEL.*HLDP_RECURSIVE_WORK_EXPERIENCE_TREE/) assert.match(runtime, /experience_nodes/) assert.match(runtime, /save_experience/) assert.match(runtime, /route_experience/) assert.match(panel, /任务沙箱清理不会删除执行体记忆/) }) test('model-free experience learning is the public default and the small model is only optional enhancement', () => { const contract = JSON.parse(read('contracts/local-execution-subpersona.json')) const runtime = read('src-tauri/src/local_execution_subpersona.rs') assert.equal(contract.routing.direct_structured_tool_call, 'LOCAL_ZERO_MODEL_CALL') assert.equal(contract.routing.default_brain, 'DETERMINISTIC_EXPERIENCE_LEARNING_AGENT') assert.equal(contract.routing.local_model_required, false) assert.equal(contract.local_model.default_enabled, false) assert.equal(contract.memory.model_weight_training_required, false) assert.equal(contract.routing.expensive_main_model_fallback_automatic, false) assert.equal(contract.local_model.endpoint_must_be_loopback, true) assert.equal(contract.execution.external_api_call_count_in_receipt, true) assert.match(runtime, /DIRECT_STRUCTURED_TOOL_ZERO_MODEL/) assert.match(runtime, /DETERMINISTIC_LOCAL_PROTOCOL_ROUTER/) assert.match(runtime, /LEARNED_TASK_TOOL_OUTCOME_ROUTER/) assert.match(runtime, /route_learning/) assert.match(runtime, /success_count=success_count\+excluded\.success_count/) assert.match(runtime, /LOCAL_SMALL_MODEL_BRAIN/) assert.match(runtime, /external_api_calls: 0/) assert.match(runtime, /http:\/\/127\.0\.0\.1:/) })