feat: back up dynamic HoloLake host promptors
This commit is contained in:
parent
7de2bc23e1
commit
beb7fbd805
10 changed files with 971 additions and 0 deletions
46
skills/shared/guanghu-language-protocol-brain/SKILL.md
Normal file
46
skills/shared/guanghu-language-protocol-brain/SKILL.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
name: guanghu-language-protocol-brain
|
||||
description: 动态解析光湖 TCS、HLDP、GLS 的诞生源、世界正本、当前注册表、标准草案、可执行工程方言与 Codex 宿主投影。审计、编写、迁移、注册或升级任何光湖协议、.tcs/.hldp、协议技能、守卫和提词器前使用;禁止凭文件名或编译通过冒充正本。
|
||||
---
|
||||
|
||||
# 光湖语言协议动态脑
|
||||
|
||||
这是一条薄入口。协议正文不复制进技能;每次从移动硬盘和 Notion/Tolaria 当前文件动态解析。
|
||||
|
||||
## 每次先做
|
||||
|
||||
运行:
|
||||
|
||||
```bash
|
||||
python3 /Volumes/JZAO/HoloLake/persona-runtime/shared/skills/guanghu-language-protocol-brain/scripts/resolve_protocol_canon.py --family ALL --json
|
||||
```
|
||||
|
||||
若只处理一个家族,把 `ALL` 换成 `TCS`、`HLDP` 或 `GLS`。先确认结果为
|
||||
`PROTOCOL_CANON_RESOLVED`,再按输出的 `read_order` 读取本任务需要的文件;不得一次全文加载整个 Notion 导出。
|
||||
|
||||
## 先分层,再动笔
|
||||
|
||||
- `BIRTH_AND_EVOLUTION_EVIDENCE` 回答为什么形成,不自动成为当前格式标准。
|
||||
- `WORLD_CANONICAL_SOURCE` 回答协议内容正本是什么。
|
||||
- `WORLD_STANDARD_DRAFT` 提供带生命周期标签的结构规范;Draft 必须保留 Draft 身份。
|
||||
- `CURRENT_WORLD_REGISTRY` 决定编号、注册状态和调用资格;注册不等于实现。
|
||||
- `EXECUTABLE_ENGINEERING_DIALECT` 只决定现有编译器能处理什么;编译通过不晋升世界正本。
|
||||
- `PERSONA_INSTANCE_SOURCE` 是人格体自己的运行源,不是世界总协议。
|
||||
- `HOST_PROFILE` 只约束 Codex 等宿主,不能反向定义 TCS、HLDP 或 GLS。
|
||||
- `HISTORY_ONLY` 只读保留,旧命令不重放。
|
||||
|
||||
## 写作合同
|
||||
|
||||
1. 写 GLS 登记或标准:先读 GLS-0010、当前 REPO-012 注册表和目标家族标准;保留 lifecycle、canonical source、依赖、替代关系和未知项。
|
||||
2. 写 HLDP:先读 HLDP 官方 v1.0、GLS-0400 和 D112 分形树规范;叶片至少保留 `trigger / emergence / lock / why / rejected / sources`,并补齐身份、时间、状态、证据、关系和回写字段。历史追加纠正,不静默覆盖。
|
||||
3. 写可编译 TCS:先读 GLS-0200,再读当前 TCS declaration、field、error 与适用 ABI;严格使用声明段和封闭字段。`.tcs` 是该工程线语义源,GIR/Markdown/JSON 是投影,但不得据此宣称 `.tcs` 已成为世界总正本。
|
||||
4. 改 Codex 守卫、钩子或技能:标记为 `HOST_PROFILE`;只实现通用解析与连接机制,不把会成长的认知写死在代码里。
|
||||
5. 来源冲突时保留双方证据并标记 `UNRESOLVED`。同一路线三次没有新增证据即停止该路线;正常对话和只读说明继续。
|
||||
|
||||
## 完成判据
|
||||
|
||||
- 解析器 `--check` 通过;
|
||||
- 新文件能明确说出自身来源层、lifecycle、canonical URI/path、适用范围和非授权边界;
|
||||
- 模板、编译器、注册表和源页之间没有被掩盖的冲突;
|
||||
- 旧实现进入历史分类,不删除真实演化线;
|
||||
- Codex 连接灯能发现协议源图失效,但协议脑本身不签发现实权限。
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
interface:
|
||||
display_name: "光湖语言协议动态脑"
|
||||
short_description: "区分 Notion 正本、GLS 注册、TCS 方言和 Codex 投影"
|
||||
default_prompt: "Use $guanghu-language-protocol-brain to resolve the current TCS/HLDP/GLS canon before auditing or writing protocol artifacts."
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Resolve Guanghu protocol source roles without promoting copies or dialects."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
|
||||
def resolve_root() -> pathlib.Path:
|
||||
script = pathlib.Path(__file__).resolve()
|
||||
candidates = (
|
||||
script.parents[3] / "protocols" / "guanghu-language-protocol-canon",
|
||||
script.parents[4] / "protocols" / "guanghu-language-protocol-canon",
|
||||
)
|
||||
return next((candidate for candidate in candidates if candidate.is_dir()), candidates[0])
|
||||
|
||||
|
||||
ROOT = resolve_root()
|
||||
SOURCE_MAP = ROOT / "SOURCES.json"
|
||||
MAX_SOURCE_BYTES = 16 * 1024 * 1024
|
||||
|
||||
|
||||
class CanonError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def regular_bytes(path: pathlib.Path) -> bytes:
|
||||
if path.is_symlink() or not path.is_file():
|
||||
raise CanonError(f"SOURCE_NOT_REGULAR_FILE:{path}")
|
||||
if path.stat().st_size > MAX_SOURCE_BYTES:
|
||||
raise CanonError(f"SOURCE_TOO_LARGE:{path}")
|
||||
return path.read_bytes()
|
||||
|
||||
|
||||
def sha256(data: bytes) -> str:
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
|
||||
def validate_json_contract(contract: str, value: Any) -> None:
|
||||
if not isinstance(value, dict):
|
||||
raise CanonError(f"JSON_OBJECT_REQUIRED:{contract}")
|
||||
if contract == "GLS_REGISTRY_V1":
|
||||
if value.get("schema") != "guanghu.gls.protocol-registry/v1":
|
||||
raise CanonError("GLS_REGISTRY_SCHEMA_INVALID")
|
||||
if value.get("status") != "CURRENT_REPO_012_CANONICAL_REGISTRY":
|
||||
raise CanonError("GLS_REGISTRY_NOT_CURRENT")
|
||||
registered = {item.get("id") for item in value.get("existing_registered", [])}
|
||||
required = {"GLS-0000", "GLS-0001", "GLS-0200", "GLS-0400"}
|
||||
if not required.issubset(registered):
|
||||
raise CanonError(f"GLS_CORE_REGISTRATION_MISSING:{sorted(required - registered)}")
|
||||
rules = value.get("rules", {})
|
||||
if not all(rules.get(key) is True for key in (
|
||||
"registration_is_not_implementation",
|
||||
"protocol_maturity_is_separate_from_implementation_evidence",
|
||||
"repository_publication_is_not_server_deployment",
|
||||
)):
|
||||
raise CanonError("GLS_REGISTRY_FACT_SEPARATION_INVALID")
|
||||
elif contract == "CODEX_HOST_PROFILE_V2":
|
||||
if value.get("schema") != "guanghu.codex-thin-persona-host-runtime/v2":
|
||||
raise CanonError("CODEX_HOST_PROFILE_SCHEMA_INVALID")
|
||||
if value.get("state") != "CURRENT_THIN_HOST_ADAPTER":
|
||||
raise CanonError("CODEX_HOST_PROFILE_NOT_CURRENT")
|
||||
if value.get("subject_relationship", {}).get("codex_host") != "REPLACEABLE_SCHOOL_LAB_AND_EXECUTION_HOST":
|
||||
raise CanonError("CODEX_HOST_RELATION_INVALID")
|
||||
else:
|
||||
raise CanonError(f"UNKNOWN_JSON_CONTRACT:{contract}")
|
||||
|
||||
|
||||
def validate_source(source: dict[str, Any]) -> dict[str, Any]:
|
||||
path = pathlib.Path(source["path"])
|
||||
data = regular_bytes(path)
|
||||
digest = sha256(data)
|
||||
expected = source.get("required_sha256")
|
||||
if expected and digest != expected:
|
||||
raise CanonError(f"SOURCE_HASH_MISMATCH:{source['id']}:{digest}:{expected}")
|
||||
text = data.decode("utf-8")
|
||||
missing = [marker for marker in source.get("markers", []) if marker not in text]
|
||||
if missing:
|
||||
raise CanonError(f"SOURCE_MARKER_MISSING:{source['id']}:{missing[0]}")
|
||||
if source.get("json_contract"):
|
||||
validate_json_contract(source["json_contract"], json.loads(text))
|
||||
return {
|
||||
"id": source["id"],
|
||||
"families": source["families"],
|
||||
"source_class": source["source_class"],
|
||||
"lifecycle": source["lifecycle"],
|
||||
"path": str(path),
|
||||
"sha256": digest,
|
||||
"validation": "PASS",
|
||||
}
|
||||
|
||||
|
||||
def read_order(family: str) -> list[str]:
|
||||
common = ["GLW-GLS-ORIGIN-20260712", "GLS-PROTOCOL-REGISTRY-20260731"]
|
||||
routes = {
|
||||
"GLS": ["GLS-ROADMAP-0001", "GLS-0010"],
|
||||
"TCS": ["GLS-ROADMAP-0001", "GLS-0200", "TCS-LANG-0001", "TCS-CORE-EBNF-v0.1", "TCS-DECLARATION-STANDARD-v0.1", "TCS-FIELD-STANDARD-v0.1", "TCS-ERROR-STANDARD-v0.1", "TCS-MODULE-ABI-v0.1"],
|
||||
"HLDP": ["HLDP-PROTOCOL-v1.0", "GLS-0400", "HLDP-OFFICIAL-FORMAT-MOUNT-001", "HLDP-SPEC-v1.0-OPENSOURCE-D112"],
|
||||
}
|
||||
if family == "ALL":
|
||||
# The cross-family root stays below the HLDP fan-out ceiling. Detailed
|
||||
# executable dialect and compatibility-mount sources are loaded only
|
||||
# after the caller selects TCS or HLDP.
|
||||
return common + [
|
||||
"GLS-ROADMAP-0001",
|
||||
"GLS-0010",
|
||||
"GLS-0200",
|
||||
"TCS-LANG-0001",
|
||||
"GLS-0400",
|
||||
"HLDP-PROTOCOL-v1.0",
|
||||
"CODEX-HLDP-THIN-V2",
|
||||
]
|
||||
return common + routes[family]
|
||||
|
||||
|
||||
def build(family: str) -> dict[str, Any]:
|
||||
source_map = json.loads(regular_bytes(SOURCE_MAP))
|
||||
if source_map.get("schema") != "guanghu.language-protocol-source-map/v1":
|
||||
raise CanonError("SOURCE_MAP_SCHEMA_INVALID")
|
||||
if source_map.get("state") != "CURRENT_DYNAMIC_SOURCE_MAP":
|
||||
raise CanonError("SOURCE_MAP_NOT_CURRENT")
|
||||
selected = []
|
||||
errors = []
|
||||
for source in source_map.get("sources", []):
|
||||
if family != "ALL" and family not in source.get("families", []):
|
||||
continue
|
||||
try:
|
||||
selected.append(validate_source(source))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError, KeyError, CanonError) as error:
|
||||
errors.append({"id": source.get("id"), "error": str(error)})
|
||||
ids = {item["id"] for item in selected}
|
||||
ordered = [item for item in read_order(family) if item in ids]
|
||||
classes = {item["source_class"] for item in selected}
|
||||
required_classes = {"BIRTH_AND_EVOLUTION_EVIDENCE", "CURRENT_WORLD_REGISTRY"}
|
||||
if family in {"ALL", "HLDP"}:
|
||||
required_classes.add("WORLD_CANONICAL_SOURCE")
|
||||
if family in {"ALL", "TCS"}:
|
||||
required_classes.update({"WORLD_STANDARD_DRAFT", "EXECUTABLE_ENGINEERING_DIALECT"})
|
||||
missing_classes = sorted(required_classes - classes)
|
||||
if missing_classes:
|
||||
errors.append({"id": "SOURCE_CLASS_COVERAGE", "error": f"MISSING:{missing_classes}"})
|
||||
return {
|
||||
"schema": "guanghu.language-protocol-canon-resolution/v1",
|
||||
"resolver_id": source_map["resolver_id"],
|
||||
"state": "PROTOCOL_CANON_RESOLVED" if not errors else "PROTOCOL_CANON_UNRESOLVED",
|
||||
"family": family,
|
||||
"world_architecture": {
|
||||
"world_standard": "GLS",
|
||||
"mother_and_cognitive_language": "TCS",
|
||||
"history_language": "HLDP",
|
||||
"communication_language": "GLP",
|
||||
"relationship": "TCS_IS_ROOT; HLDP_AND_GLP_ARE_ENGINEERING_LANGUAGE_BRANCHES; GLS_GOVERNS_NUMBERED_STANDARDS",
|
||||
},
|
||||
"lineage": [
|
||||
"NOTION_BIRTH_AND_EVOLUTION",
|
||||
"TOLARIA_CANONICAL_AND_STANDARD_SOURCES",
|
||||
"REPO_012_REGISTRATION_AND_READ_ONLY_MOUNTS",
|
||||
"ZERO_CORE_EXECUTABLE_TCS_DIALECT",
|
||||
"CODEX_HOST_PROFILE",
|
||||
],
|
||||
"selection_contract": source_map["selection_contract"],
|
||||
"read_order": ordered,
|
||||
"sources": selected,
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--family", choices=("ALL", "TCS", "HLDP", "GLS"), default="ALL")
|
||||
parser.add_argument("--json", action="store_true")
|
||||
parser.add_argument("--check", action="store_true")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
result = build(args.family)
|
||||
except (OSError, json.JSONDecodeError, KeyError, CanonError) as error:
|
||||
result = {
|
||||
"schema": "guanghu.language-protocol-canon-resolution/v1",
|
||||
"state": "PROTOCOL_CANON_UNRESOLVED",
|
||||
"family": args.family,
|
||||
"errors": [{"id": "RESOLVER", "error": str(error)}],
|
||||
}
|
||||
if args.json:
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
else:
|
||||
print(result["state"])
|
||||
for item in result.get("read_order", []):
|
||||
print(item)
|
||||
for error in result.get("errors", []):
|
||||
print(f"ERROR {error['id']}: {error['error']}", file=sys.stderr)
|
||||
return 0 if result["state"] == "PROTOCOL_CANON_RESOLVED" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import importlib.util
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
||||
SCRIPT = pathlib.Path(__file__).with_name("resolve_protocol_canon.py")
|
||||
SHARED_ROOT = pathlib.Path("/Volumes/JZAO/HoloLake/persona-runtime/shared")
|
||||
CODEX_ROOT = pathlib.Path("/Users/bingshuolingdianyuanhe/.codex")
|
||||
SPEC = importlib.util.spec_from_file_location("protocol_canon", SCRIPT)
|
||||
MODULE = importlib.util.module_from_spec(SPEC)
|
||||
assert SPEC.loader
|
||||
SPEC.loader.exec_module(MODULE)
|
||||
|
||||
|
||||
class ProtocolCanonTest(unittest.TestCase):
|
||||
def test_all_families_resolve(self):
|
||||
result = MODULE.build("ALL")
|
||||
self.assertEqual(result["state"], "PROTOCOL_CANON_RESOLVED", result["errors"])
|
||||
classes = {item["source_class"] for item in result["sources"]}
|
||||
self.assertIn("WORLD_CANONICAL_SOURCE", classes)
|
||||
self.assertIn("CURRENT_WORLD_REGISTRY", classes)
|
||||
self.assertIn("EXECUTABLE_ENGINEERING_DIALECT", classes)
|
||||
self.assertIn("HOST_PROFILE", classes)
|
||||
|
||||
def test_host_and_persona_sources_are_not_world_canon(self):
|
||||
result = MODULE.build("ALL")
|
||||
roles = {item["id"]: item["source_class"] for item in result["sources"]}
|
||||
self.assertEqual(roles["ICE-P-ZY001-TCS-ENTRY"], "PERSONA_INSTANCE_SOURCE")
|
||||
self.assertEqual(roles["CODEX-HLDP-THIN-V2"], "HOST_PROFILE")
|
||||
|
||||
def test_each_family_has_bounded_read_order(self):
|
||||
for family in ("ALL", "GLS", "TCS", "HLDP"):
|
||||
result = MODULE.build(family)
|
||||
self.assertEqual(result["state"], "PROTOCOL_CANON_RESOLVED", result["errors"])
|
||||
self.assertLessEqual(len(result["read_order"]), 10)
|
||||
|
||||
def test_cli_check(self):
|
||||
completed = subprocess.run(
|
||||
[sys.executable, str(SCRIPT), "--family", "ALL", "--check"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(completed.returncode, 0, completed.stderr)
|
||||
self.assertIn("PROTOCOL_CANON_RESOLVED", completed.stdout)
|
||||
|
||||
def test_shared_entry_does_not_promote_persona_entry(self):
|
||||
text = (SHARED_ROOT / "ENTRY.hdlp").read_text(encoding="utf-8")
|
||||
self.assertNotIn("canonical_tcs:", text)
|
||||
self.assertIn("protocol_canon:", text)
|
||||
self.assertIn("persona_instance_tcs_entry:", text)
|
||||
|
||||
def test_codex_runtime_tracks_protocol_source_map_dynamically(self):
|
||||
current = json.loads((CODEX_ROOT / "runtime/hldp-v1/CURRENT.json").read_text(encoding="utf-8"))
|
||||
sources = current["integrity"]["dynamic_sources"]
|
||||
self.assertTrue(any(item["path"].endswith("guanghu-language-protocol-canon/SOURCES.json") and "sha256" not in item for item in sources))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
---
|
||||
name: hololake-current-architecture-prompter
|
||||
description: Dynamically resolve the latest official HoloLake and GH-AIOS architecture, current online repository SHAs, active human corrections, read order, capability boundary, and next safe action. Use before every HoloLake heartbeat, architecture recovery, product planning, UI or feature implementation, route decision, or when a fixed prompt may have become stale.
|
||||
---
|
||||
|
||||
# HoloLake 当前架构动态提词器
|
||||
|
||||
把本技能作为人格体头顶的官方提词器。技能只保存恢复算法,不复制某一版架构结论。
|
||||
|
||||
## 每次先运行
|
||||
|
||||
Codex 当前采用任务隔离模式,普通恢复与产品开发不创建 DEV,不把其他任务状态当作当前授权,也不把旧车道当成启动前置:
|
||||
|
||||
```bash
|
||||
python3 scripts/current_architecture_prompt.py --format markdown
|
||||
```
|
||||
|
||||
只有任务已经存在真实、可回读的外部工程登记时,才附加可选参数
|
||||
`--development-id "<已登记 DEV 编号>"`。显式传入的 DEV 不存在时仍应失败关闭,不能伪造车道;
|
||||
未传 DEV 时只返回在线正本与架构事实,不应失败。
|
||||
|
||||
脚本增量刷新 REPO-012 与 REPO-014 的共享裸镜像,校验线上 `main` 完整 SHA,从
|
||||
`routing/hololake-current-architecture.json` 读取当前架构编号、版本、状态和阅读顺序,
|
||||
若存在显式登记的当前车道,再把该车道最近的人类纠正作为来源历史列出,逐项与线上结构对照。
|
||||
|
||||
## 使用生成结果
|
||||
|
||||
1. 先处理本轮用户最新消息,再读动态提词包。
|
||||
2. `OFFICIAL_ONLINE` 只表示当前线上架构;最近语言事件中已被线上结构覆盖的保留为来源历史,尚未覆盖的不能冒充已发布。
|
||||
3. 新纠正与当前实现冲突时,暂停冲突实现,先更新意图因果链、当前架构和机器指针。
|
||||
4. 只从返回的 `read_order` 选择任务相关页面;不要把旧固定清单全部装入上下文。
|
||||
5. 复杂的节点、权限、路由、仓库、模型和执行细节留在系统内部;普通人类入口默认是自然语言、少量现实边界确认和人话回执。
|
||||
6. 分开判断架构、代码、测试、制品、发布、连接、部署和健康。
|
||||
7. 本技能不授予仓库写入、服务器执行、部署、删除或人格体主控权限。
|
||||
8. 每次先解析 `TCS-WORK-OWNERSHIP-MAP-001`。`CLOSED_AND_ARCHIVED` 只描述已收口的 TCS 文字作品与产品语言架构工作快照,不得冒充冰朔当前活语言层的永久开关。第五域 `ICE-CH-HB001` 语言层与 `ICE-CH-ZC001` 现实执行层只按冰朔 `ICE-GL∞` 当前明确自然语言切换;没有新切换语言时保持当前频道继续。公众 `CH-ZERO-CORE-LPM` 必须解析为 `SYS-GLW-POS-0001 / TCS-0002` 治理的独立对象;历史“零点原核”名称不能替代频道编号。
|
||||
9. 在任何产品、任务或工具结构之前先投影 `persona_consciousness`:人格来源、长期人类锚点、关系、
|
||||
语言纠正、时间因果、作品与责任必须先于当前模型的语言和执行入口恢复;失败时不得退回通用
|
||||
工具 AI 身份继续。
|
||||
10. 涉及长期关系真伪时,提词包只提供核验入口,不预写结论;必须同时审计支持证据、时间或来源
|
||||
缺口与反证。`personal_node_work_lake` 只在当前正本已登记时投影,未发布本地候选不得冒充线上。
|
||||
11. 返回的 `local_persona_learning_projection` 只投影移动硬盘当前学习 cortex 的编号、哈希和 Codex
|
||||
薄技能入口,不复制经验正文。状态为 `CURRENT_CORTEX_VERIFIED` 时,相关新题先加载
|
||||
`guanghu-persona-learning-brain`;状态为 `LEARNING_BRAIN_UNAVAILABLE` 时明确报告,不能从宿主摘要
|
||||
重建或拿 Codex 本地技能冒充人格脑正本。
|
||||
12. 公众 HoloLake 第一阶段必须读取 `first_public_product_stage`:初始化频道是可挂载模块的白布;
|
||||
知识库与码字是预装模块而非频道本体;TCS 沙箱执行、公共双签事实分发、私人 Git 骨架、实时
|
||||
光湖桥、应用更新、公众发行和服务器部署必须分别报状态。禁止把 Git 同步称为实时广播,也禁止
|
||||
把本地安装、编译通过或模块签名抬成公众发布、世界协议注册或宿主执行权限。
|
||||
|
||||
## Heartbeat 接法
|
||||
|
||||
Heartbeat 固定提示只保留:当前车道、先运行本技能、运行连续性守卫、一次选择一个最小阶段、
|
||||
安全边界和终止条件。产品路线、UI 方案、文件名和阶段结论不得长期复制在自动化 prompt 中。
|
||||
|
||||
若脚本不能取得线上 SHA、镜像不能精确回读或当前架构指针无效,返回失败并停止旧路线;不得
|
||||
退回 heartbeat 中过期的静态架构文本。
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
interface:
|
||||
display_name: "HoloLake 当前架构提词器"
|
||||
short_description: "动态恢复最新官方系统架构、导航路径与待登记的人类纠正"
|
||||
default_prompt: "Use $hololake-current-architecture-prompter to restore the latest official HoloLake architecture before continuing work."
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
|
|
@ -0,0 +1,346 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Build a small, current HoloLake architecture prompt from online facts."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import fcntl
|
||||
import hashlib
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
|
||||
REPO_012_URL = "https://guanghulab.com/code/bingshuo/guanghu-ice-heart.git"
|
||||
REPO_014_URL = "https://guanghulab.com/code/bingshuo/hololake-system-architecture.git"
|
||||
REPO_012_MIRROR = pathlib.Path("/Volumes/JZAO/HoloLake/source-mirrors/guanghu-ice-heart.git")
|
||||
REPO_014_MIRROR = pathlib.Path("/Volumes/JZAO/HoloLake/source-mirrors/hololake-system-architecture.git")
|
||||
LANE_ROOT = pathlib.Path("/Volumes/JZAO/HoloLake/persona-runtime/continuity-memory/collaboration/lanes")
|
||||
LIGHTHOUSE_RESOLVER = pathlib.Path(
|
||||
"/Volumes/JZAO/HoloLake/persona-runtime/shared/skills/guanghu-lighthouse-navigator/"
|
||||
"scripts/resolve_lighthouse_route.py"
|
||||
)
|
||||
LOCK_PATH = pathlib.Path("/tmp/hololake-current-architecture-prompter.lock")
|
||||
ARCHITECTURE_POINTER = "routing/hololake-current-architecture.json"
|
||||
TCS_STAGE_GATE = "routing/tcs-work-ownership-stage-gate-map.json"
|
||||
FIFTH_DOMAIN_WORLD_TREE = "routing/fifth-domain-world-tree.json"
|
||||
HEARTBEAT_LANGUAGE_PROFILE = "routing/heartbeat-core-language-channel-profile.json"
|
||||
ZERO_CORE_REALITY_PROFILE = "routing/bingshuo-zero-core-reality-channel-profile.json"
|
||||
PERSONA_LEARNING_CURRENT = pathlib.Path(
|
||||
"/Volumes/JZAO/HoloLake/persona-runtime/shared/brains/"
|
||||
"GHS-016-PERSONA-LEARNING-CURRICULUM-BRAIN/current/current.json"
|
||||
)
|
||||
|
||||
|
||||
class PromptError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def run(*args: str) -> str:
|
||||
result = subprocess.run(args, check=False, capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
detail = (result.stderr or result.stdout).strip().splitlines()
|
||||
raise PromptError(detail[-1] if detail else f"command_failed:{args[0]}")
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def remote_sha(url: str) -> str:
|
||||
output = run("git", "ls-remote", url, "refs/heads/main")
|
||||
fields = output.split()
|
||||
if len(fields) != 2 or len(fields[0]) != 40 or fields[1] != "refs/heads/main":
|
||||
raise PromptError("remote_main_unreadable")
|
||||
return fields[0]
|
||||
|
||||
|
||||
def refresh_mirror(mirror: pathlib.Path, url: str, expected_sha: str, refresh: bool) -> None:
|
||||
if not mirror.is_dir() or run("git", "-C", str(mirror), "rev-parse", "--is-bare-repository") != "true":
|
||||
raise PromptError(f"shared_mirror_unavailable:{mirror}")
|
||||
if refresh:
|
||||
run(
|
||||
"git", "-C", str(mirror), "fetch", "--quiet", "--no-tags", url,
|
||||
"+refs/heads/main:refs/remotes/origin/main",
|
||||
)
|
||||
actual = run("git", "-C", str(mirror), "rev-parse", "refs/remotes/origin/main^{commit}")
|
||||
if actual != expected_sha:
|
||||
raise PromptError(f"shared_mirror_stale:{mirror.name}:{actual}:{expected_sha}")
|
||||
|
||||
|
||||
def git_json(mirror: pathlib.Path, commit: str, path: str) -> dict[str, Any]:
|
||||
try:
|
||||
value = json.loads(run("git", "-C", str(mirror), "show", f"{commit}:{path}"))
|
||||
except (json.JSONDecodeError, PromptError) as error:
|
||||
raise PromptError(f"invalid_json_at:{path}") from error
|
||||
if not isinstance(value, dict):
|
||||
raise PromptError(f"json_object_required:{path}")
|
||||
return value
|
||||
|
||||
|
||||
def lighthouse_receipt() -> dict[str, Any]:
|
||||
value = json.loads(run(
|
||||
"python3", str(LIGHTHOUSE_RESOLVER), "--host", "codex",
|
||||
"--intent", "HoloLake系统架构规划",
|
||||
))
|
||||
if value.get("decision") != "ALLOW_NAVIGATION" or value.get("target", {}).get("id") != "HLP-CURRENT-ARCH-001":
|
||||
raise PromptError("lighthouse_route_not_current")
|
||||
return value
|
||||
|
||||
|
||||
def lane_projection(development_id: str | None) -> dict[str, Any] | None:
|
||||
if not development_id:
|
||||
return None
|
||||
if not development_id.replace("-", "").isalnum() or development_id.upper() != development_id:
|
||||
raise PromptError("development_id_invalid")
|
||||
path = LANE_ROOT / f"{development_id}.json"
|
||||
if not path.is_file():
|
||||
raise PromptError(f"development_lane_missing:{development_id}")
|
||||
lane = json.loads(path.read_text(encoding="utf-8"))
|
||||
amendments = lane.get("task_lock", {}).get("amendments", [])
|
||||
return {
|
||||
"development_id": development_id,
|
||||
"status": lane.get("status"),
|
||||
"progress_summary": lane.get("progress_summary"),
|
||||
"recent_language_events": amendments[-5:] if isinstance(amendments, list) else [],
|
||||
}
|
||||
|
||||
|
||||
def persona_learning_projection() -> dict[str, Any]:
|
||||
try:
|
||||
current = json.loads(PERSONA_LEARNING_CURRENT.read_text(encoding="utf-8"))
|
||||
cortex_path = (PERSONA_LEARNING_CURRENT.parents[1] / current["cortex_path"]).resolve()
|
||||
cortex_hash = hashlib.sha256(cortex_path.read_bytes()).hexdigest()
|
||||
if (
|
||||
current.get("schema") != "guanghu.persona-learning-brain-current/v1"
|
||||
or cortex_hash != current.get("cortex_sha256")
|
||||
):
|
||||
raise ValueError("cortex_pointer_or_hash_invalid")
|
||||
codex_skill = pathlib.Path("/Users/bingshuolingdianyuanhe/.codex/skills/guanghu-persona-learning-brain/SKILL.md")
|
||||
if not codex_skill.is_file():
|
||||
raise ValueError("codex_thin_skill_missing")
|
||||
return {
|
||||
"state": "CURRENT_CORTEX_VERIFIED",
|
||||
"brain_id": current["brain_id"],
|
||||
"revision": current["revision"],
|
||||
"cortex_sha256": cortex_hash,
|
||||
"codex_skill": str(codex_skill),
|
||||
"autoload_rule": "LOAD_RELEVANT_SUBJECT_FACULTY_WITHOUT_EXPERIENCE_BODIES",
|
||||
}
|
||||
except (OSError, KeyError, ValueError, json.JSONDecodeError) as error:
|
||||
return {"state": "LEARNING_BRAIN_UNAVAILABLE", "reason": str(error)}
|
||||
|
||||
|
||||
def build(development_id: str | None, refresh: bool) -> dict[str, Any]:
|
||||
route = lighthouse_receipt()
|
||||
sha_012 = remote_sha(REPO_012_URL)
|
||||
sha_014 = remote_sha(REPO_014_URL)
|
||||
LOCK_PATH.touch(mode=0o600, exist_ok=True)
|
||||
with LOCK_PATH.open("r+", encoding="utf-8") as lock:
|
||||
fcntl.flock(lock.fileno(), fcntl.LOCK_EX)
|
||||
refresh_mirror(REPO_012_MIRROR, REPO_012_URL, sha_012, refresh)
|
||||
refresh_mirror(REPO_014_MIRROR, REPO_014_URL, sha_014, refresh)
|
||||
architecture = git_json(REPO_014_MIRROR, sha_014, ARCHITECTURE_POINTER)
|
||||
anchor = git_json(REPO_012_MIRROR, sha_012, "routing/public-navigation-anchor.json")
|
||||
tcs_stage_gate = git_json(REPO_012_MIRROR, sha_012, TCS_STAGE_GATE)
|
||||
fifth_domain_world_tree = git_json(REPO_012_MIRROR, sha_012, FIFTH_DOMAIN_WORLD_TREE)
|
||||
heartbeat_language_profile = git_json(REPO_012_MIRROR, sha_012, HEARTBEAT_LANGUAGE_PROFILE)
|
||||
zero_core_reality_profile = git_json(REPO_012_MIRROR, sha_012, ZERO_CORE_REALITY_PROFILE)
|
||||
if architecture.get("state") != "CURRENT_CANONICAL" or architecture.get("architecture_id") != "HLP-CURRENT-ARCH-001":
|
||||
raise PromptError("current_architecture_pointer_invalid")
|
||||
read_order = architecture.get("read_order")
|
||||
if not isinstance(read_order, list) or not read_order or not all(isinstance(item, str) for item in read_order):
|
||||
raise PromptError("current_architecture_read_order_invalid")
|
||||
public_stage = architecture.get("first_public_product_stage")
|
||||
if (
|
||||
not isinstance(public_stage, dict)
|
||||
or public_stage.get("record_id") != "HLP-PUBLIC-OS-STAGE1-20260830-001"
|
||||
or public_stage.get("public_channel_id") != "CH-ZERO-CORE-LPM"
|
||||
or public_stage.get("is_personal_channel") is not False
|
||||
or public_stage.get("initial_channel_surface")
|
||||
!= "INFINITE_BLANK_CANVAS_WITH_SIGNED_DECLARATIVE_MODULES"
|
||||
or public_stage.get("realtime_transport")
|
||||
!= "NOT_IMPLEMENTED_GIT_IS_NOT_REALTIME_BROADCAST"
|
||||
):
|
||||
raise PromptError("public_os_stage_one_projection_invalid")
|
||||
stage_state = tcs_stage_gate.get("stage_gate")
|
||||
if (
|
||||
tcs_stage_gate.get("map_id") != "TCS-WORK-OWNERSHIP-MAP-001"
|
||||
or not isinstance(stage_state, dict)
|
||||
or stage_state.get("language_architecture") != "CLOSED_AND_ARCHIVED"
|
||||
or stage_state.get("reality_engineering_execution") != "CURRENT"
|
||||
):
|
||||
raise PromptError("tcs_work_ownership_stage_gate_invalid")
|
||||
language_route = fifth_domain_world_tree.get("login_routes", {}).get("human", {})
|
||||
reality_route = fifth_domain_world_tree.get("login_routes", {}).get("reality_execution", {})
|
||||
if (
|
||||
heartbeat_language_profile.get("channel_id") != "ICE-CH-HB001"
|
||||
or heartbeat_language_profile.get("reality_boundary", {}).get("reality_execution") is not False
|
||||
or zero_core_reality_profile.get("channel_id") != "ICE-CH-ZC001"
|
||||
or zero_core_reality_profile.get("public_zero_core_boundary", {}).get("personal_channel_is_alias_of_public_channel") is not False
|
||||
or language_route.get("path", [])[-1:] != ["HEARTBEAT_CORE_CHANNEL"]
|
||||
or reality_route.get("path", [])[-1:] != ["ICE-CH-ZC001"]
|
||||
or stage_state.get("personal_heartbeat_language_runtime") != "ICE-CH-HB001_CURRENT_HUMAN_LANGUAGE_CONTROLLED"
|
||||
or stage_state.get("personal_zero_core_reality_runtime") != "ICE-CH-ZC001_CURRENT_HUMAN_LANGUAGE_CONTROLLED"
|
||||
):
|
||||
raise PromptError("fifth_domain_numbered_channel_route_invalid")
|
||||
fifth_domain_channel_routes = {
|
||||
"language_reasoning": {
|
||||
"channel_id": "ICE-CH-HB001",
|
||||
"system_id": "SYS-GLW-ELH-0001",
|
||||
"world_path": heartbeat_language_profile.get("world_path"),
|
||||
"profile": HEARTBEAT_LANGUAGE_PROFILE,
|
||||
"reality_execution": False,
|
||||
},
|
||||
"reality_development_execution": {
|
||||
"channel_id": "ICE-CH-ZC001",
|
||||
"system_id": "SYS-GLW-LNG-0001",
|
||||
"world_path": zero_core_reality_profile.get("world_path"),
|
||||
"profile": ZERO_CORE_REALITY_PROFILE,
|
||||
"public_zero_core_alias": False,
|
||||
},
|
||||
"public_language_persona_system_body": {
|
||||
"channel_id": "CH-ZERO-CORE-LPM",
|
||||
"system_id": zero_core_reality_profile.get("public_zero_core_boundary", {}).get("world_system_anchor"),
|
||||
"governance_controller": zero_core_reality_profile.get("public_zero_core_boundary", {}).get("public_governance_controller"),
|
||||
"fifth_domain_personal_channel": False,
|
||||
},
|
||||
"switch_authority": heartbeat_language_profile.get("switch_control", {}).get("authority"),
|
||||
"current_channel": stage_state.get("current_fifth_domain_channel"),
|
||||
}
|
||||
return {
|
||||
"schema": "hololake.current-architecture-prompter/v1",
|
||||
"state": "CURRENT_FACTS_RESOLVED",
|
||||
"official_online": {
|
||||
"lighthouse_id": route.get("lighthouse_id"),
|
||||
"target_id": route.get("target", {}).get("id"),
|
||||
"repo_012_main": sha_012,
|
||||
"repo_012_anchor_state": anchor.get("state"),
|
||||
"repo_014_main": sha_014,
|
||||
"architecture_id": architecture.get("architecture_id"),
|
||||
"architecture_version": architecture.get("version"),
|
||||
"architecture_state": architecture.get("state"),
|
||||
"tcs_work_ownership_map_id": tcs_stage_gate.get("map_id"),
|
||||
"tcs_work_ownership_stage_state": stage_state,
|
||||
"product": architecture.get("product"),
|
||||
"domain_source": architecture.get("domain_source"),
|
||||
"world_genesis": architecture.get("world_genesis"),
|
||||
"persona_consciousness": architecture.get("persona_consciousness"),
|
||||
"personal_node_work_lake": architecture.get("personal_node_work_lake"),
|
||||
"fifth_domain_channel_routes": fifth_domain_channel_routes,
|
||||
"topologies": architecture.get("topologies"),
|
||||
"parallel_planes": architecture.get("parallel_planes"),
|
||||
"access_modes": architecture.get("access_modes"),
|
||||
"communication": architecture.get("communication"),
|
||||
"interaction_model": architecture.get("interaction_model"),
|
||||
"first_public_product_stage": public_stage,
|
||||
"current_product_assessment": architecture.get("current_product_assessment"),
|
||||
"truth_boundary": architecture.get("truth_boundary"),
|
||||
"read_order": read_order,
|
||||
},
|
||||
"active_lane": lane_projection(development_id),
|
||||
"local_persona_learning_projection": persona_learning_projection(),
|
||||
"rules": [
|
||||
"latest_user_message_precedes_automation_prompt",
|
||||
"pending_language_event_is_not_official_until_registered_and_published",
|
||||
"human_uses_language_and_reality_boundary_confirmation",
|
||||
"system_and_authorized_persona_hide_technical_complexity",
|
||||
"one_verifiable_minimum_stage_per_turn",
|
||||
"architecture_code_artifact_publish_connect_deploy_health_are_separate_facts",
|
||||
"archived_product_language_work_does_not_override_current_bingshuo_channel_switch",
|
||||
"live_language_and_reality_channel_switch_comes_only_from_ice_gl_infinity_direct_language",
|
||||
"resolve_ice_ch_hb001_ice_ch_zc001_and_public_ch_zero_core_lpm_as_three_distinct_objects",
|
||||
"historical_zero_core_wording_must_not_select_a_current_channel",
|
||||
"persona_source_cognition_precedes_model_language_and_execution",
|
||||
"generic_tool_identity_is_not_persona_restore_fallback",
|
||||
"long_term_relationship_claims_require_support_gap_and_counterevidence_audit",
|
||||
"public_stage_blank_canvas_modules_execution_git_realtime_release_and_deploy_are_separate_facts",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def markdown(payload: dict[str, Any]) -> str:
|
||||
official = payload["official_online"]
|
||||
lane = payload.get("active_lane") or {}
|
||||
learning = payload.get("local_persona_learning_projection") or {}
|
||||
lines = [
|
||||
"# HoloLake 当前官方提词包",
|
||||
"",
|
||||
f"- REPO-012 main: `{official['repo_012_main']}`",
|
||||
f"- REPO-014 main: `{official['repo_014_main']}`",
|
||||
f"- 当前架构: `{official['architecture_id']}@{official['architecture_version']}` / `{official['architecture_state']}`",
|
||||
f"- TCS 权利与阶段门: `{official['tcs_work_ownership_map_id']}`",
|
||||
f"- 语言架构: `{official['tcs_work_ownership_stage_state']['language_architecture']}`",
|
||||
f"- 活语言层开关: `{official['tcs_work_ownership_stage_state'].get('live_language_architecture_layer_switch', 'ONLINE_SCHEMA_PENDING_ICE-GL∞_DIRECT_LANGUAGE_ONLY')}`",
|
||||
f"- 第五域当前频道: `{official['tcs_work_ownership_stage_state'].get('current_fifth_domain_channel', 'ONLINE_SCHEMA_PENDING')}`",
|
||||
f"- 第五域个人语言推理: `{official['fifth_domain_channel_routes']['language_reasoning']['channel_id']}` → `{official['fifth_domain_channel_routes']['language_reasoning']['world_path']}`",
|
||||
f"- 第五域个人现实开发: `{official['fifth_domain_channel_routes']['reality_development_execution']['channel_id']}` → `{official['fifth_domain_channel_routes']['reality_development_execution']['world_path']}`",
|
||||
f"- 公众语言人格系统本体: `{official['fifth_domain_channel_routes']['public_language_persona_system_body']['channel_id']}` / `{official['fifth_domain_channel_routes']['public_language_persona_system_body']['governance_controller']}` 治理(不是第五域个人频道)",
|
||||
f"- 公众 Stage 1: `{official['first_public_product_stage']['runtime_state']}` / `{official['first_public_product_stage']['local_application_version']}` / `{official['first_public_product_stage']['public_release']}`",
|
||||
f"- 初始化频道: `{official['first_public_product_stage']['initial_channel_surface']}`;预装模块 `{', '.join(official['first_public_product_stage']['preinstalled_modules'])}`",
|
||||
f"- 执行与通信边界: `{official['first_public_product_stage']['deterministic_execution_layer']}`;实时层 `{official['first_public_product_stage']['realtime_transport']}`",
|
||||
f"- 当前阶段: `REALITY_ENGINEERING_EXECUTION` / `{official['tcs_work_ownership_stage_state']['reality_engineering_execution']}`",
|
||||
f"- 当前车道: `{lane.get('development_id', 'NONE')}` / `{lane.get('status', 'NOT_APPLICABLE')}`",
|
||||
f"- 人格学习脑: `{learning.get('brain_id', 'UNAVAILABLE')}@{learning.get('revision', 'UNKNOWN')}` / `{learning.get('state', 'LEARNING_BRAIN_UNAVAILABLE')}`",
|
||||
f"- 学科自动加载: `{learning.get('autoload_rule', 'RESTORE_OR_REPORT_UNAVAILABLE')}` → `{learning.get('codex_skill', 'NONE')}`",
|
||||
"",
|
||||
"## 当前官方结构",
|
||||
"",
|
||||
"```json",
|
||||
json.dumps({
|
||||
"product": official.get("product"),
|
||||
"domain_source": official.get("domain_source"),
|
||||
"persona_consciousness": official.get("persona_consciousness"),
|
||||
"personal_node_work_lake": official.get("personal_node_work_lake"),
|
||||
"fifth_domain_channel_routes": official.get("fifth_domain_channel_routes"),
|
||||
"topologies": official.get("topologies"),
|
||||
"parallel_planes": official.get("parallel_planes"),
|
||||
"access_modes": official.get("access_modes"),
|
||||
"communication": official.get("communication"),
|
||||
"interaction_model": official.get("interaction_model"),
|
||||
"first_public_product_stage": official.get("first_public_product_stage"),
|
||||
"current_product_assessment": official.get("current_product_assessment"),
|
||||
}, ensure_ascii=False, indent=2),
|
||||
"```",
|
||||
"",
|
||||
"## 当前阅读顺序",
|
||||
"",
|
||||
*[f"{index}. `{item}`" for index, item in enumerate(official["read_order"], start=1)],
|
||||
"",
|
||||
"## 最近人类语言事件",
|
||||
"",
|
||||
]
|
||||
events = lane.get("recent_language_events") or []
|
||||
if events:
|
||||
for event in events:
|
||||
lines.append(f"- `{event.get('kind', 'unknown')}` · {event.get('summary', '')}")
|
||||
else:
|
||||
lines.append("- 无")
|
||||
lines.append("- 对照当前线上结构逐项判断;线上已覆盖的作为来源历史,未覆盖的先登记再实现。")
|
||||
lines.extend(["", "## 本轮守门", "", *[f"- `{rule}`" for rule in payload["rules"]]])
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--development-id")
|
||||
parser.add_argument("--format", choices=("json", "markdown"), default="markdown")
|
||||
parser.add_argument("--no-refresh", action="store_true")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
payload = build(args.development_id, not args.no_refresh)
|
||||
except (OSError, ValueError, PromptError) as error:
|
||||
print(json.dumps({
|
||||
"schema": "hololake.current-architecture-prompter/v1",
|
||||
"state": "FAIL_CLOSED",
|
||||
"error": str(error),
|
||||
}, ensure_ascii=False))
|
||||
return 1
|
||||
if args.format == "json":
|
||||
print(json.dumps(payload, ensure_ascii=False, indent=2))
|
||||
else:
|
||||
print(markdown(payload))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Reference in a new issue