feat(hololake): define native stage one modules
This commit is contained in:
parent
458ead4e43
commit
1da52a61a1
43 changed files with 1332 additions and 111 deletions
|
|
@ -46,7 +46,7 @@ function expandPattern(value) {
|
|||
|
||||
function validateQueuedEvent(host, eventPath) {
|
||||
const rule = POLICY.hosts[host];
|
||||
if (!rule || rule.write_mode !== "BRANCH_LOCAL_ONLY") throw new Error("HOST_NOT_ACTIVE_BRANCH");
|
||||
if (!rule || rule.role !== "REPLACEABLE_HOST" || !["BRANCH_LOCAL_ONLY", "HOST_LOCAL_UNLESS_ACTIVE_ZERO_CORE_CONSOLE"].includes(rule.write_mode)) throw new Error("HOST_NOT_ACTIVE_BRANCH");
|
||||
const real = fs.realpathSync(eventPath);
|
||||
if (!real.includes("/ingress/persona-events/pending/")) throw new Error("EVENT_NOT_IN_PENDING_INGRESS");
|
||||
const allowed = rule.allowed_write_roots.some((item) => new RegExp(`^${expandPattern(item)}(?:/.*)?$`).test(real));
|
||||
|
|
@ -74,20 +74,15 @@ if (command === "caller") {
|
|||
process.exit(caller === "codex" ? 0 : 2);
|
||||
}
|
||||
|
||||
if (command !== "accept") {
|
||||
process.stderr.write("usage: branch-event-door.mjs caller | accept --host HOST --event PENDING_JSON\n");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
if (caller !== "codex") {
|
||||
process.stderr.write(`BRANCH_EVENT_ACCEPT_REJECTED caller=${caller}; only current Codex primary task may accept\n`);
|
||||
if (!['validate', 'accept'].includes(command)) {
|
||||
process.stderr.write("usage: branch-event-door.mjs caller | validate --host HOST --event PENDING_JSON | accept --host HOST --event PENDING_JSON\n");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const host = argsValue(args, "--host");
|
||||
const eventPath = argsValue(args, "--event");
|
||||
if (!host || !eventPath) {
|
||||
process.stderr.write("accept requires --host and --event\n");
|
||||
process.stderr.write(`${command} requires --host and --event\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +93,16 @@ catch (error) {
|
|||
process.exit(2);
|
||||
}
|
||||
|
||||
if (command === "validate") {
|
||||
process.stdout.write(`${JSON.stringify({ outcome: "PASS", state: "BRANCH_EVENT_PREFLIGHT_VALID", host, event_id: checked.event.event_id, event_path: checked.real, shared_write_performed: false }, null, 2)}\n`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (caller !== "codex") {
|
||||
process.stderr.write(`BRANCH_EVENT_ACCEPT_REJECTED caller=${caller}; only current Codex primary task may accept\n`);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const run = spawnSync(process.execPath, [RUNNER, "append", "--allowed-root", MEMORY_ROOT, "--store", STORE, "--event", checked.real], { encoding: "utf8" });
|
||||
if (run.status !== 0 || !run.stdout.includes('"outcome": "PASS"')) {
|
||||
process.stderr.write(run.stderr || run.stdout || "BRANCH_EVENT_APPEND_FAILED\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue