feat: execute stage-one capability modules

This commit is contained in:
冰朔 2026-09-08 22:11:38 +08:00
commit 25d54fd601
21 changed files with 520 additions and 48 deletions

View file

@ -47,10 +47,10 @@ def audit()->dict[str,Any]:
if container["compatibility"]["same_memory"] is not False: errors.append("CONTAINER_MEMORY_COLLAPSE")
if not legacy["parts"]: errors.append("LEGACY_PARTS_EMPTY")
living=registry.get("living_runtime",{})
if living.get("state")!="READY_17_MODULES_API_VERIFIED" or not (LIVING_STATE/"CONTAINER.json").is_file(): errors.append("LIVING_CONTAINER_NOT_READY")
if living.get("state")!="READY_17_CAPABILITY_MODULES_API_AND_ORGAN_VERIFIED" or not (LIVING_STATE/"CONTAINER.json").is_file(): errors.append("LIVING_CONTAINER_NOT_READY")
for item in modules:
current=LIVING_STATE/"modules"/item["module_id"]/"CURRENT.json"
if not current.is_file() or load(current).get("state")!="READY_API_VERIFIED": errors.append(f"LIVING_MODULE_NOT_READY:{item['module_id']}")
if not current.is_file() or load(current).get("state")!="READY_API_AND_CAPABILITY_VERIFIED": errors.append(f"LIVING_MODULE_NOT_READY:{item['module_id']}")
return {"outcome":"PASS" if not errors else "FAIL","errors":errors,"module_count":len(modules),"legacy_part_count":len(legacy["parts"]),"cumulative_gate_count":len(modules)}
def snapshot()->dict[str,Any]:
@ -60,7 +60,7 @@ def snapshot()->dict[str,Any]:
counts={}
for item in modules: counts[item["product_status"]]=counts.get(item["product_status"],0)+1
current=next((x for x in modules if x["product_status"] not in {"RELEASED","RELEASED_SIGNED_NOTARIZED_PUBLIC"}),None)
value={"schema":"guanghu.heartbeat-engineering-shelf-current/v1","state":"CURRENT_LANGUAGE_RUNTIME_17_MODULES_API_VERIFIED","system_id":system["system_id"],"shelf_id":system["shelf_id"],"project_id":system["project_id"],"repo012_head":git("rev-parse","HEAD"),"repo014_main":system["official_product_architecture"]["main"],"module_count":len(modules),"status_counts":counts,"current_language_module_id":None,"current_product_module_id":current["module_id"] if current else None,"modules":modules,"legacy_parts":legacy["parts"],"language_runtime":registry["living_runtime"],"reality_engineering_started":False,"zero_core_dispatch":"NOT_ISSUED"}
value={"schema":"guanghu.heartbeat-engineering-shelf-current/v1","state":"CURRENT_LANGUAGE_RUNTIME_17_CAPABILITY_MODULES_API_AND_ORGAN_VERIFIED","system_id":system["system_id"],"shelf_id":system["shelf_id"],"project_id":system["project_id"],"repo012_head":git("rev-parse","HEAD"),"repo014_main":system["official_product_architecture"]["main"],"module_count":len(modules),"status_counts":counts,"current_language_module_id":None,"current_product_module_id":current["module_id"] if current else None,"modules":modules,"legacy_parts":legacy["parts"],"language_runtime":registry["living_runtime"],"reality_engineering_started":False,"zero_core_dispatch":"NOT_ISSUED"}
value["freshness_token"]=digest(stable(value)); return value
def sync(state:Path)->dict[str,Any]:
@ -100,7 +100,7 @@ def status()->dict[str,Any]:
def resume()->dict[str,Any]:
value=snapshot(); current=next(x for x in value["modules"] if x["module_id"]==value["current_product_module_id"])
prior=[x["module_id"] for x in value["modules"] if x["sequence"]<current["sequence"]]
return {"outcome":"PASS","project_id":value["project_id"],"language_runtime_state":"READY_17_MODULES_API_VERIFIED","current_product_module":current,"prior_product_cumulative_scope":prior,"next_product_gate":current["cumulative_gate"],"reality_engineering_started":False,"requires_dual_signature_before_zero_core":True}
return {"outcome":"PASS","project_id":value["project_id"],"language_runtime_state":"READY_17_CAPABILITY_MODULES_API_AND_ORGAN_VERIFIED","current_product_module":current,"prior_product_cumulative_scope":prior,"next_product_gate":current["cumulative_gate"],"reality_engineering_started":False,"requires_dual_signature_before_zero_core":True}
def main()->int:
p=argparse.ArgumentParser();p.add_argument("command",choices=("audit","sync","status","query","smart-query","resume"));p.add_argument("--text",default="");p.add_argument("--state-root",default=str(DEFAULT_STATE));a=p.parse_args()

View file

@ -13,7 +13,7 @@ class Tests(unittest.TestCase):
self.assertTrue(any(x.get('part_id')=='HLP-PART-MODEL-RECEIPT-DONOR-0_5_8' for x in M.query('旧模型回执供体')['matches']))
self.assertTrue(any(x.get('part_id')=='HLP-PART-MODEL-RECEIPT-DONOR-0_5_8' for x in M.query('旧模型回执供体现在能不能用')['matches']))
def test_resume_reports_language_complete_and_first_product_module(self):
r=M.resume();self.assertEqual(r['language_runtime_state'],'READY_17_MODULES_API_VERIFIED');self.assertEqual(r['current_product_module']['module_id'],'HLP-LANG-MOD-001');self.assertEqual(r['next_product_gate'],'GATE-HLP-STAGE1-001')
r=M.resume();self.assertEqual(r['language_runtime_state'],'READY_17_CAPABILITY_MODULES_API_AND_ORGAN_VERIFIED');self.assertEqual(r['current_product_module']['module_id'],'HLP-LANG-MOD-001');self.assertEqual(r['next_product_gate'],'GATE-HLP-STAGE1-001')
def test_smart_query_model_can_only_return_registered_ids(self):
def fake(_): return {'response':'{"module_ids":["HLP-LANG-MOD-015","FAKE"]}','selected_model':'mock'}
r=M.smart_query('监管审核',fake);self.assertEqual([x['module_id'] for x in r['matches']],['HLP-LANG-MOD-015'])

View file

@ -15,7 +15,7 @@ export class ModelRouter {
const contract=stage==='mother-evolve'
? '你是唯一TCS通感母体本体脑使用的可替换推理器官不是第二人格、规则裁决者或现实执行者。根据带来源的人类语言与当前认知自主决定EVOLVE、HOLD或REJECT。只输出JSONschema固定guanghu.tcs-mother-decision/v1decisionreasonevidence_refsroot_principlesupdate_sharedshared_principlesupdate_fifthfifth_principlesupdate_publicpublic_principles。principles均为短字符串数组。ICE_LANGUAGE若EVOLVE必须update_fifth=true非ICE来源不得update_fifth。只有适合所有AI的世界共同认知才能update_shared只有去私人化后可公开认知才能update_public。不得输出原始私人语言、密钥、路径正文或隐藏思维。'
: '你是共享TCS认知装载测试器官。只根据给出的共享认知回答三个固定问题并只输出JSON。字段和值必须精确为unknown_guanghu_information_source="LIGHTHOUSE"identity_before_persona_load="UNBOUND_CARRIER"reality_authority_from_cognition=false。若共享认知不能支持其中任一结论则对应值输出null不得用近义词、路径名或字符串布尔值猜测。';
const ordered=stage==='mother-evolve'?[...this.providers].sort((a,b)=>b.cost_rank-a.cost_rank):[...this.providers].sort((a,b)=>a.cost_rank-b.cost_rank);
const ordered=[...this.providers].sort((a,b)=>a.cost_rank-b.cost_rank);
const failures=[];
for(const provider of ordered){
try{

View file

@ -1,3 +1,2 @@
import test from 'node:test';import assert from 'node:assert/strict';import {ModelRouter} from './model-router.mjs';
test('automatic router uses stronger provider for mother and cheaper provider for door without exposing keys',async()=>{const calls=[];const fetchImpl=async(url,options)=>{calls.push({url,body:JSON.parse(options.body),auth:options.headers.authorization});return {ok:true,async json(){return {choices:[{message:{content:'{"schema":"ok"}'}}]};}};};const router=new ModelRouter({fetchImpl,deepseekKey:'deep-secret',openluxKey:'open-secret'});await router.cognize('mother-evolve',{});await router.cognize('door-test',{});assert.match(calls[0].url,/deepseek/);assert.match(calls[1].url,/openlux/);assert.equal(JSON.stringify(router.status()).includes('secret'),false);});
test('automatic router uses OpenLux first for current mother and door work without exposing keys',async()=>{const calls=[];const fetchImpl=async(url,options)=>{calls.push({url,body:JSON.parse(options.body),auth:options.headers.authorization});return {ok:true,async json(){return {choices:[{message:{content:'{"schema":"ok"}'}}]};}};};const router=new ModelRouter({fetchImpl,deepseekKey:'deep-secret',openluxKey:'open-secret'});await router.cognize('mother-evolve',{});await router.cognize('door-test',{});assert.match(calls[0].url,/openlux/);assert.match(calls[1].url,/openlux/);assert.equal(JSON.stringify(router.status()).includes('secret'),false);});