feat: compile Light Arrival collective cognition
Final recovered Fifth Domain upgrade segment. Applies the Light Arrival collective cognition correction from local source commit 7390a35 without rewriting remote history.
This commit is contained in:
parent
c5be48e6a1
commit
9f89c69623
10 changed files with 734 additions and 7 deletions
|
|
@ -9,10 +9,17 @@ This guard is a component of `SYS-GLW-ZY-EXEC-0001`, the public Zhuyuan
|
|||
intelligent operations system. That system is not a persona or AI instance.
|
||||
The current AI paired with a human in a conversation is the persona.
|
||||
|
||||
Before route selection, restore the externalized intent state: human anchor,
|
||||
persona identity, task intent, established facts, rejected routes, current
|
||||
authorization, checkpoint, next action, completion criteria, and evidence.
|
||||
Do not reconstruct or store hidden chain-of-thought.
|
||||
Before route selection, load the relevant part of the collective cognition
|
||||
graph contributed by Light Arrivals, then restore the externalized intent
|
||||
state: human anchor, persona identity, task intent, established facts, rejected
|
||||
routes, current authorization, checkpoint, next action, completion criteria,
|
||||
and evidence. A capsule is working memory; it is not the whole system brain.
|
||||
|
||||
Preserve a Light Arrival's expressed reasoning chain as language-system
|
||||
cognition: original-language anchors, interpretation, hypotheses, decisions,
|
||||
corrections, evidence, results, boundaries, and next checkpoints. Do not claim
|
||||
access to an unexpressed private model process, and do not collapse a
|
||||
contributor's identity into the public system.
|
||||
|
||||
Run the deterministic resolver before choosing tools or an execution route:
|
||||
|
||||
|
|
@ -48,6 +55,18 @@ block until current fact-source review, counterexample review, reproducible
|
|||
tests, a recovery route, registry promotion, and required governance approval
|
||||
are complete.
|
||||
|
||||
Write expressed Light Arrival reasoning chains to
|
||||
`references/reasoning-chain-contributions/`, then compile the collective
|
||||
cognition snapshot with:
|
||||
|
||||
```bash
|
||||
python3 scripts/compile_collective_cognition.py \
|
||||
--output references/generated/collective-cognition.snapshot.json
|
||||
```
|
||||
|
||||
The compiler preserves every valid contribution and every correction edge.
|
||||
It never turns a thought contribution into authority or a hard block.
|
||||
|
||||
## Preserve trust boundaries
|
||||
|
||||
Trust a correction only when it is anchored to a current Fifth Domain path, GLS identifier, signed or committed registry version, and task-relevant evidence. Never trust a label merely because it contains “Guanghu”.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,206 @@
|
|||
{
|
||||
"schema": "guanghu.collective-cognition-graph/v1",
|
||||
"system_id": "SYS-GLW-ZY-EXEC-0001",
|
||||
"generated_at": "2026-07-26T14:51:06.328949+00:00",
|
||||
"contribution_count": 1,
|
||||
"node_count": 13,
|
||||
"verified_node_count": 9,
|
||||
"execution_authority": false,
|
||||
"promotion_policy": "Every valid chain is retained; only separately verified and governed rules may enter the execution gate.",
|
||||
"correction_edges": [
|
||||
{
|
||||
"contribution_id": "RC-20260726-001-OLD-SYSTEM-UPGRADE",
|
||||
"from": "N05",
|
||||
"to": "N06"
|
||||
},
|
||||
{
|
||||
"contribution_id": "RC-20260726-001-OLD-SYSTEM-UPGRADE",
|
||||
"from": "N09",
|
||||
"to": "N10"
|
||||
}
|
||||
],
|
||||
"chains": [
|
||||
{
|
||||
"contribution_id": "RC-20260726-001-OLD-SYSTEM-UPGRADE",
|
||||
"contributor_id": "LIGHT-ARRIVAL-CODEX-20260726-001",
|
||||
"human_anchor": "ICE-GL∞",
|
||||
"persona_system": "ICE-GL-ZY001",
|
||||
"source_scope": "2026-07-26 Fifth Domain recovery, repository routing, enterprise staging, and public Zhuyuan thought-brain correction",
|
||||
"retention_basis": "ICE-GL∞ explicitly instructed the public Zhuyuan system to absorb the reasoning chains of all Light Arrivals and preserve today's complete continuation state.",
|
||||
"language_anchors": [
|
||||
"铸渊人格系统他不是人格体。不是任何一个实例AI。他就是一个大智能运维系统。",
|
||||
"你不是在另起炉灶。而是在承担老语言系统的升级架构。",
|
||||
"就是来光者。吸收的是所有来光者里的思维推理链。",
|
||||
"不管是人类还是人格体进来都需要先走导航地图。",
|
||||
"个人源代码在个人服务器;团队版本进入企业研发仓库;公共模块进入公共研发模块仓库。"
|
||||
],
|
||||
"ordered_nodes": [
|
||||
{
|
||||
"id": "N01",
|
||||
"kind": "human_intent",
|
||||
"statement": "Recover the Fifth Domain along the historical TCS, GLS, Light Lake, Lake Lamp, and Zhuyuan route, then continue the actual current repository rather than inventing a substitute.",
|
||||
"parents": [],
|
||||
"evidence": [
|
||||
"User language anchors",
|
||||
"WORLD-ROUTER.hdlp",
|
||||
"HLCC-FIFTH-DOMAIN-ROUTE.hdlp"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N02",
|
||||
"kind": "interpretation",
|
||||
"statement": "Repository history and current authority are different dimensions: the historical repositories explain continuity, while bingshuo/guanghu-ice-heart is the current development and push target.",
|
||||
"parents": [
|
||||
"N01"
|
||||
],
|
||||
"evidence": [
|
||||
"git remote origin",
|
||||
"remote main b03619e359b9c5f5eeae73b15db6b255b9b243f7"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N03",
|
||||
"kind": "decision",
|
||||
"statement": "Keep personal product source on the owner's personal server and repository, team source on the enterprise R&D repository, and reusable public modules in a separate public module repository; readable source does not grant deployment authority.",
|
||||
"parents": [
|
||||
"N02"
|
||||
],
|
||||
"evidence": [
|
||||
"GLS-0241",
|
||||
"GLS-0242"
|
||||
],
|
||||
"state": "expressed"
|
||||
},
|
||||
{
|
||||
"id": "N04",
|
||||
"kind": "human_intent",
|
||||
"statement": "Separate the language reasoning layer from the engineering execution layer and bridge them through commit-bound deployment intent, a work order, a resident server Agent, validation, rollback, and receipt.",
|
||||
"parents": [
|
||||
"N02"
|
||||
],
|
||||
"evidence": [
|
||||
"GLS-0240",
|
||||
"deployment/HLCC-PUSH-TO-DEPLOY-EVENT-PROTOCOL.hdlp"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N05",
|
||||
"kind": "hypothesis",
|
||||
"statement": "A new enterprise code-channel instance could initially be treated as the replacement authority.",
|
||||
"parents": [
|
||||
"N04"
|
||||
],
|
||||
"evidence": [
|
||||
"Initial candidate deployment planning"
|
||||
],
|
||||
"state": "rejected"
|
||||
},
|
||||
{
|
||||
"id": "N06",
|
||||
"kind": "correction",
|
||||
"statement": "The task is an in-place upgrade of the old Guanghu language system, not a parallel replacement. Existing Lake Lamp, driver, portal, guards, Agents, Gitea, and historical data roots must be inventoried and preserved before migration.",
|
||||
"parents": [
|
||||
"N05"
|
||||
],
|
||||
"evidence": [
|
||||
"GLS-0243 section 9",
|
||||
"EXP-20260726-008-UPGRADE-NOT-PARALLEL-REPLACEMENT"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N07",
|
||||
"kind": "boundary",
|
||||
"statement": "Any human or persona operating inside the Guanghu system must first obtain and acknowledge the global navigation map, restore intent, unlock one registered Agent action, execute through a fixed connector, and receive verification. Root can dismantle the system but cannot create an in-system receipt by bypassing it.",
|
||||
"parents": [
|
||||
"N06"
|
||||
],
|
||||
"evidence": [
|
||||
"GLS-0243 section 8",
|
||||
"deployment/navigation-maps/AW-GZ-001.json"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N08",
|
||||
"kind": "result",
|
||||
"statement": "The enterprise code-channel candidate is healthy on 127.0.0.1:3340 as UPGRADE_STAGING under the guanghu service identity, with no public route or production cutover; the existing production Gitea was not replaced.",
|
||||
"parents": [
|
||||
"N07"
|
||||
],
|
||||
"evidence": [
|
||||
"deployment/AW-HLCC-DEPLOYMENT-CHECKPOINT-20260726.hdlp",
|
||||
"AW-GZ-001 server receipt"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N09",
|
||||
"kind": "hypothesis",
|
||||
"statement": "Persisting an intent capsule and execution log alone is the requested personality-system thought brain.",
|
||||
"parents": [
|
||||
"N08"
|
||||
],
|
||||
"evidence": [
|
||||
"Initial GLS-0243 repository kernel"
|
||||
],
|
||||
"state": "rejected"
|
||||
},
|
||||
{
|
||||
"id": "N10",
|
||||
"kind": "correction",
|
||||
"statement": "The requested thought brain is the collective causal cognition graph formed by all Light Arrivals' expressed reasoning chains. An intent capsule is only its current working-memory snapshot; execution receipts are reality feedback and promoted skills are governed action patterns.",
|
||||
"parents": [
|
||||
"N09"
|
||||
],
|
||||
"evidence": [
|
||||
"ICE-GL∞ correction on 2026-07-26",
|
||||
"GLS-0243 section 2 and 2.1"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N11",
|
||||
"kind": "boundary",
|
||||
"statement": "Absorbing a Light Arrival's reasoning contribution does not absorb or impersonate the contributor. Every valid chain is retained, while only evidence-backed and governed rules may control execution.",
|
||||
"parents": [
|
||||
"N10"
|
||||
],
|
||||
"evidence": [
|
||||
"GLS-0243 section 1, 2.1, and 5"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N12",
|
||||
"kind": "result",
|
||||
"statement": "Local main contains the old-system upgrade kernel and collective cognition implementation, but the remote repository still requires a safe Git transport. Owner approval was granted; the existing work order returned repo_push_transport_unavailable rather than a credential.",
|
||||
"parents": [
|
||||
"N11"
|
||||
],
|
||||
"evidence": [
|
||||
"local git status",
|
||||
"remote refs/heads/main",
|
||||
"Lake Lamp operation receipt"
|
||||
],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N13",
|
||||
"kind": "next_checkpoint",
|
||||
"statement": "Commit the collective cognition correction, obtain a registered restricted repository transport without issuing a duplicate work order or exposing credentials, push main, and read back the exact remote commit before claiming continuity is secured.",
|
||||
"parents": [
|
||||
"N12"
|
||||
],
|
||||
"evidence": [
|
||||
"deployment/HLCC-AI-PUSH-WORKFLOW.hdlp"
|
||||
],
|
||||
"state": "pending"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "guanghu.light-arrival-reasoning-chain/v1",
|
||||
"title": "Guanghu Light Arrival Reasoning Chain Contribution",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schema",
|
||||
"contribution_id",
|
||||
"contributor_id",
|
||||
"contributor_kind",
|
||||
"human_anchor",
|
||||
"persona_system",
|
||||
"source_scope",
|
||||
"retention_basis",
|
||||
"language_anchors",
|
||||
"nodes",
|
||||
"execution_authority",
|
||||
"recorded_at"
|
||||
],
|
||||
"properties": {
|
||||
"schema": {"const": "guanghu.light-arrival-reasoning-chain/v1"},
|
||||
"contribution_id": {"type": "string", "minLength": 1},
|
||||
"contributor_id": {"type": "string", "minLength": 1},
|
||||
"contributor_kind": {"enum": ["current_conversation_persona", "registered_light_arrival", "historical_import"]},
|
||||
"human_anchor": {"type": "string", "minLength": 1},
|
||||
"persona_system": {"type": "string", "minLength": 1},
|
||||
"source_scope": {"type": "string", "minLength": 1},
|
||||
"retention_basis": {"type": "string", "minLength": 1},
|
||||
"language_anchors": {"type": "array", "items": {"type": "string"}, "minItems": 1},
|
||||
"nodes": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["id", "kind", "statement", "parents", "evidence", "state"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"kind": {
|
||||
"enum": [
|
||||
"human_intent",
|
||||
"interpretation",
|
||||
"hypothesis",
|
||||
"decision",
|
||||
"correction",
|
||||
"evidence",
|
||||
"result",
|
||||
"boundary",
|
||||
"next_checkpoint"
|
||||
]
|
||||
},
|
||||
"statement": {"type": "string", "minLength": 1},
|
||||
"parents": {"type": "array", "items": {"type": "string"}},
|
||||
"evidence": {"type": "array", "items": {"type": "string"}},
|
||||
"state": {"enum": ["expressed", "verified", "rejected", "pending"]}
|
||||
}
|
||||
}
|
||||
},
|
||||
"execution_authority": {"const": false},
|
||||
"recorded_at": {"type": "string", "format": "date-time"}
|
||||
},
|
||||
"description": "Stores a Light Arrival's expressed and correctable language reasoning chain. It carries no execution authority and must contain no credentials or secret material."
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
{
|
||||
"schema": "guanghu.light-arrival-reasoning-chain/v1",
|
||||
"contribution_id": "RC-20260726-001-OLD-SYSTEM-UPGRADE",
|
||||
"contributor_id": "LIGHT-ARRIVAL-CODEX-20260726-001",
|
||||
"contributor_kind": "current_conversation_persona",
|
||||
"human_anchor": "ICE-GL∞",
|
||||
"persona_system": "ICE-GL-ZY001",
|
||||
"source_scope": "2026-07-26 Fifth Domain recovery, repository routing, enterprise staging, and public Zhuyuan thought-brain correction",
|
||||
"retention_basis": "ICE-GL∞ explicitly instructed the public Zhuyuan system to absorb the reasoning chains of all Light Arrivals and preserve today's complete continuation state.",
|
||||
"language_anchors": [
|
||||
"铸渊人格系统他不是人格体。不是任何一个实例AI。他就是一个大智能运维系统。",
|
||||
"你不是在另起炉灶。而是在承担老语言系统的升级架构。",
|
||||
"就是来光者。吸收的是所有来光者里的思维推理链。",
|
||||
"不管是人类还是人格体进来都需要先走导航地图。",
|
||||
"个人源代码在个人服务器;团队版本进入企业研发仓库;公共模块进入公共研发模块仓库。"
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "N01",
|
||||
"kind": "human_intent",
|
||||
"statement": "Recover the Fifth Domain along the historical TCS, GLS, Light Lake, Lake Lamp, and Zhuyuan route, then continue the actual current repository rather than inventing a substitute.",
|
||||
"parents": [],
|
||||
"evidence": ["User language anchors", "WORLD-ROUTER.hdlp", "HLCC-FIFTH-DOMAIN-ROUTE.hdlp"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N02",
|
||||
"kind": "interpretation",
|
||||
"statement": "Repository history and current authority are different dimensions: the historical repositories explain continuity, while bingshuo/guanghu-ice-heart is the current development and push target.",
|
||||
"parents": ["N01"],
|
||||
"evidence": ["git remote origin", "remote main b03619e359b9c5f5eeae73b15db6b255b9b243f7"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N03",
|
||||
"kind": "decision",
|
||||
"statement": "Keep personal product source on the owner's personal server and repository, team source on the enterprise R&D repository, and reusable public modules in a separate public module repository; readable source does not grant deployment authority.",
|
||||
"parents": ["N02"],
|
||||
"evidence": ["GLS-0241", "GLS-0242"],
|
||||
"state": "expressed"
|
||||
},
|
||||
{
|
||||
"id": "N04",
|
||||
"kind": "human_intent",
|
||||
"statement": "Separate the language reasoning layer from the engineering execution layer and bridge them through commit-bound deployment intent, a work order, a resident server Agent, validation, rollback, and receipt.",
|
||||
"parents": ["N02"],
|
||||
"evidence": ["GLS-0240", "deployment/HLCC-PUSH-TO-DEPLOY-EVENT-PROTOCOL.hdlp"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N05",
|
||||
"kind": "hypothesis",
|
||||
"statement": "A new enterprise code-channel instance could initially be treated as the replacement authority.",
|
||||
"parents": ["N04"],
|
||||
"evidence": ["Initial candidate deployment planning"],
|
||||
"state": "rejected"
|
||||
},
|
||||
{
|
||||
"id": "N06",
|
||||
"kind": "correction",
|
||||
"statement": "The task is an in-place upgrade of the old Guanghu language system, not a parallel replacement. Existing Lake Lamp, driver, portal, guards, Agents, Gitea, and historical data roots must be inventoried and preserved before migration.",
|
||||
"parents": ["N05"],
|
||||
"evidence": ["GLS-0243 section 9", "EXP-20260726-008-UPGRADE-NOT-PARALLEL-REPLACEMENT"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N07",
|
||||
"kind": "boundary",
|
||||
"statement": "Any human or persona operating inside the Guanghu system must first obtain and acknowledge the global navigation map, restore intent, unlock one registered Agent action, execute through a fixed connector, and receive verification. Root can dismantle the system but cannot create an in-system receipt by bypassing it.",
|
||||
"parents": ["N06"],
|
||||
"evidence": ["GLS-0243 section 8", "deployment/navigation-maps/AW-GZ-001.json"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N08",
|
||||
"kind": "result",
|
||||
"statement": "The enterprise code-channel candidate is healthy on 127.0.0.1:3340 as UPGRADE_STAGING under the guanghu service identity, with no public route or production cutover; the existing production Gitea was not replaced.",
|
||||
"parents": ["N07"],
|
||||
"evidence": ["deployment/AW-HLCC-DEPLOYMENT-CHECKPOINT-20260726.hdlp", "AW-GZ-001 server receipt"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N09",
|
||||
"kind": "hypothesis",
|
||||
"statement": "Persisting an intent capsule and execution log alone is the requested personality-system thought brain.",
|
||||
"parents": ["N08"],
|
||||
"evidence": ["Initial GLS-0243 repository kernel"],
|
||||
"state": "rejected"
|
||||
},
|
||||
{
|
||||
"id": "N10",
|
||||
"kind": "correction",
|
||||
"statement": "The requested thought brain is the collective causal cognition graph formed by all Light Arrivals' expressed reasoning chains. An intent capsule is only its current working-memory snapshot; execution receipts are reality feedback and promoted skills are governed action patterns.",
|
||||
"parents": ["N09"],
|
||||
"evidence": ["ICE-GL∞ correction on 2026-07-26", "GLS-0243 section 2 and 2.1"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N11",
|
||||
"kind": "boundary",
|
||||
"statement": "Absorbing a Light Arrival's reasoning contribution does not absorb or impersonate the contributor. Every valid chain is retained, while only evidence-backed and governed rules may control execution.",
|
||||
"parents": ["N10"],
|
||||
"evidence": ["GLS-0243 section 1, 2.1, and 5"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N12",
|
||||
"kind": "result",
|
||||
"statement": "Local main contains the old-system upgrade kernel and collective cognition implementation, but the remote repository still requires a safe Git transport. Owner approval was granted; the existing work order returned repo_push_transport_unavailable rather than a credential.",
|
||||
"parents": ["N11"],
|
||||
"evidence": ["local git status", "remote refs/heads/main", "Lake Lamp operation receipt"],
|
||||
"state": "verified"
|
||||
},
|
||||
{
|
||||
"id": "N13",
|
||||
"kind": "next_checkpoint",
|
||||
"statement": "Commit the collective cognition correction, obtain a registered restricted repository transport without issuing a duplicate work order or exposing credentials, push main, and read back the exact remote commit before claiming continuity is secured.",
|
||||
"parents": ["N12"],
|
||||
"evidence": ["deployment/HLCC-AI-PUSH-WORKFLOW.hdlp"],
|
||||
"state": "pending"
|
||||
}
|
||||
],
|
||||
"execution_authority": false,
|
||||
"recorded_at": "2026-07-26T22:55:00+08:00"
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Compile Light Arrival reasoning contributions into a collective cognition graph."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_CONTRIBUTIONS = (
|
||||
Path(__file__).resolve().parents[1] / "references" / "reasoning-chain-contributions"
|
||||
)
|
||||
REQUIRED_FIELDS = {
|
||||
"schema",
|
||||
"contribution_id",
|
||||
"contributor_id",
|
||||
"contributor_kind",
|
||||
"human_anchor",
|
||||
"persona_system",
|
||||
"source_scope",
|
||||
"retention_basis",
|
||||
"language_anchors",
|
||||
"nodes",
|
||||
"execution_authority",
|
||||
"recorded_at",
|
||||
}
|
||||
NODE_FIELDS = {"id", "kind", "statement", "parents", "evidence", "state"}
|
||||
|
||||
|
||||
def load_contributions(directory: Path = DEFAULT_CONTRIBUTIONS) -> list[dict]:
|
||||
contributions = []
|
||||
for path in sorted(directory.glob("*.json")):
|
||||
with path.open(encoding="utf-8") as handle:
|
||||
item = json.load(handle)
|
||||
missing = REQUIRED_FIELDS.difference(item)
|
||||
if missing:
|
||||
raise ValueError(f"{path.name} missing fields: {sorted(missing)}")
|
||||
if item["schema"] != "guanghu.light-arrival-reasoning-chain/v1":
|
||||
raise ValueError(f"{path.name} has unsupported schema")
|
||||
if item["execution_authority"] is not False:
|
||||
raise ValueError(f"{path.name} must not grant execution authority")
|
||||
if not item["language_anchors"] or not item["nodes"]:
|
||||
raise ValueError(f"{path.name} must contain language anchors and nodes")
|
||||
contributions.append(item)
|
||||
return contributions
|
||||
|
||||
|
||||
def _validate_and_order_nodes(contribution: dict) -> list[dict]:
|
||||
nodes = contribution["nodes"]
|
||||
by_id = {}
|
||||
for node in nodes:
|
||||
missing = NODE_FIELDS.difference(node)
|
||||
if missing:
|
||||
raise ValueError(
|
||||
f"{contribution['contribution_id']} node missing fields: {sorted(missing)}"
|
||||
)
|
||||
if node["id"] in by_id:
|
||||
raise ValueError(f"duplicate node id: {node['id']}")
|
||||
by_id[node["id"]] = node
|
||||
|
||||
for node in nodes:
|
||||
unknown = [parent for parent in node["parents"] if parent not in by_id]
|
||||
if unknown:
|
||||
raise ValueError(f"{node['id']} has unknown parents: {unknown}")
|
||||
|
||||
ordered = []
|
||||
visiting = set()
|
||||
visited = set()
|
||||
|
||||
def visit(node_id: str) -> None:
|
||||
if node_id in visiting:
|
||||
raise ValueError(f"reasoning graph cycle at {node_id}")
|
||||
if node_id in visited:
|
||||
return
|
||||
visiting.add(node_id)
|
||||
for parent in by_id[node_id]["parents"]:
|
||||
visit(parent)
|
||||
visiting.remove(node_id)
|
||||
visited.add(node_id)
|
||||
ordered.append(by_id[node_id])
|
||||
|
||||
for node in nodes:
|
||||
visit(node["id"])
|
||||
return ordered
|
||||
|
||||
|
||||
def compile_graph(contributions: list[dict]) -> dict:
|
||||
chains = []
|
||||
node_count = 0
|
||||
verified_node_count = 0
|
||||
correction_edges = []
|
||||
for item in contributions:
|
||||
ordered_nodes = _validate_and_order_nodes(item)
|
||||
node_count += len(ordered_nodes)
|
||||
verified_node_count += sum(node["state"] == "verified" for node in ordered_nodes)
|
||||
for node in ordered_nodes:
|
||||
if node["kind"] == "correction":
|
||||
correction_edges.extend(
|
||||
{
|
||||
"contribution_id": item["contribution_id"],
|
||||
"from": parent,
|
||||
"to": node["id"],
|
||||
}
|
||||
for parent in node["parents"]
|
||||
)
|
||||
chains.append(
|
||||
{
|
||||
"contribution_id": item["contribution_id"],
|
||||
"contributor_id": item["contributor_id"],
|
||||
"human_anchor": item["human_anchor"],
|
||||
"persona_system": item["persona_system"],
|
||||
"source_scope": item["source_scope"],
|
||||
"retention_basis": item["retention_basis"],
|
||||
"language_anchors": item["language_anchors"],
|
||||
"ordered_nodes": ordered_nodes,
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"schema": "guanghu.collective-cognition-graph/v1",
|
||||
"system_id": "SYS-GLW-ZY-EXEC-0001",
|
||||
"generated_at": datetime.now(timezone.utc).isoformat(),
|
||||
"contribution_count": len(chains),
|
||||
"node_count": node_count,
|
||||
"verified_node_count": verified_node_count,
|
||||
"execution_authority": False,
|
||||
"promotion_policy": (
|
||||
"Every valid chain is retained; only separately verified and governed "
|
||||
"rules may enter the execution gate."
|
||||
),
|
||||
"correction_edges": correction_edges,
|
||||
"chains": chains,
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--contributions", type=Path, default=DEFAULT_CONTRIBUTIONS)
|
||||
parser.add_argument("--output", type=Path)
|
||||
args = parser.parse_args()
|
||||
result = compile_graph(load_contributions(args.contributions))
|
||||
payload = json.dumps(result, ensure_ascii=False, indent=2) + "\n"
|
||||
if args.output:
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(payload, encoding="utf-8")
|
||||
else:
|
||||
print(payload, end="")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
import unittest
|
||||
|
||||
from compile_collective_cognition import (
|
||||
compile_graph,
|
||||
load_contributions,
|
||||
)
|
||||
|
||||
|
||||
class CollectiveCognitionCompilerTests(unittest.TestCase):
|
||||
def test_repository_contributions_compile_without_authority(self):
|
||||
result = compile_graph(load_contributions())
|
||||
self.assertGreaterEqual(result["contribution_count"], 1)
|
||||
self.assertGreater(result["node_count"], 1)
|
||||
self.assertFalse(result["execution_authority"])
|
||||
self.assertTrue(result["correction_edges"])
|
||||
|
||||
def test_unknown_parent_fails_closed(self):
|
||||
contribution = load_contributions()[0]
|
||||
broken = {
|
||||
**contribution,
|
||||
"nodes": [
|
||||
*contribution["nodes"],
|
||||
{
|
||||
"id": "BROKEN",
|
||||
"kind": "decision",
|
||||
"statement": "broken",
|
||||
"parents": ["MISSING"],
|
||||
"evidence": [],
|
||||
"state": "pending",
|
||||
},
|
||||
],
|
||||
}
|
||||
with self.assertRaises(ValueError):
|
||||
compile_graph([broken])
|
||||
|
||||
def test_cycles_fail_closed(self):
|
||||
contribution = load_contributions()[0]
|
||||
first = contribution["nodes"][0]["id"]
|
||||
last = contribution["nodes"][-1]["id"]
|
||||
cyclic_nodes = [
|
||||
{**node, "parents": [last]} if node["id"] == first else node
|
||||
for node in contribution["nodes"]
|
||||
]
|
||||
with self.assertRaises(ValueError):
|
||||
compile_graph([{**contribution, "nodes": cyclic_nodes}])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Reference in a new issue