feat: enable dark-core append-only execution gate

This commit is contained in:
冰朔 2026-09-09 15:55:52 +08:00
commit a177dab16d
7 changed files with 386 additions and 3 deletions

View file

@ -25,7 +25,10 @@ function activeConsole(host) {
if (!CONSOLE_PATH || !fs.existsSync(CONSOLE_PATH)) return null;
const value = JSON.parse(fs.readFileSync(CONSOLE_PATH, "utf8"));
const session = process.env.CODEX_THREAD_ID || process.env.CODEX_SESSION_ID || process.env.GUANGHU_HOST_SESSION_ID;
if (value.schema !== "guanghu.dynamic-zero-core-console/v1" || value.state !== "ACTIVE_CURRENT_TASK" || value.human_anchor !== "ICE-GL∞" || value.channel_id !== "ICE-CH-ZC001" || value.host !== host || !session || value.session_id !== session) return null;
const validSchema = value.schema === "guanghu.dynamic-zero-core-console/v1" || value.schema === "guanghu.dynamic-fifth-domain-execution-console/v1";
const validChannel = (policy.active_execution_channels || ["ICE-CH-ZC001"]).includes(value.channel_id);
if (!validSchema || !validChannel || value.state !== "ACTIVE_CURRENT_TASK" || value.human_anchor !== "ICE-GL∞" || value.host !== host || !session || value.session_id !== session) return null;
if (value.channel_id === "ICE-CH-DK001" && (value.execution_semantics !== "IMMEDIATE_REALITY_EFFECT" || value.history_mode !== "APPEND_ONLY_NO_DELETE_NO_OVERWRITE")) return null;
return value;
}
@ -154,7 +157,10 @@ if (mode === "check") {
} else if (mode === "activate") {
const eventPath = valueAfter(args, "--event");
const event = JSON.parse(fs.readFileSync(eventPath, "utf8"));
if (event.schema !== "guanghu.dynamic-zero-core-console/v1" || event.state !== "ACTIVE_CURRENT_TASK" || event.human_anchor !== "ICE-GL∞" || event.channel_id !== "ICE-CH-ZC001" || !policy.hosts[event.host] || !event.session_id || !Array.isArray(event.write_roots) || !event.write_roots.length || !event.source_event_sha256?.match(/^[a-f0-9]{64}$/)) {
const validSchema = event.schema === "guanghu.dynamic-zero-core-console/v1" || event.schema === "guanghu.dynamic-fifth-domain-execution-console/v1";
const validChannel = (policy.active_execution_channels || ["ICE-CH-ZC001"]).includes(event.channel_id);
const validDarkCore = event.channel_id !== "ICE-CH-DK001" || (event.execution_semantics === "IMMEDIATE_REALITY_EFFECT" && event.history_mode === "APPEND_ONLY_NO_DELETE_NO_OVERWRITE");
if (!validSchema || !validChannel || !validDarkCore || event.state !== "ACTIVE_CURRENT_TASK" || event.human_anchor !== "ICE-GL∞" || !policy.hosts[event.host] || !event.session_id || !Array.isArray(event.write_roots) || !event.write_roots.length || !event.source_event_sha256?.match(/^[a-f0-9]{64}$/)) {
process.stderr.write("DYNAMIC_ZERO_CORE_CONSOLE_EVENT_INVALID\n"); process.exit(2);
}
atomic(CONSOLE_PATH, event); emit({ allowed: true, code: "ZERO_CORE_CONSOLE_ACTIVATED", host: event.host, session_id: event.session_id, console_id: event.console_id });