mirror of
https://github.com/mvschwarz/openrig.git
synced 2026-11-07 05:56:21 -10:00
Adds a first-launch auto posture through permission_policy: the built-in policy builtin:auto, or launch_posture: auto in a custom policy, at rig or member level. Claude seats launch with --permission-mode auto; Codex and Pi have no auto mode and launch at the floor, and rig seat status says why. Restore and handover keep using the seat's current policy (pod-aware restore included); NativePermissionStore.apply() re-applies only an explicit per-seat selection, plus auto for Claude when the binding's own posture is auto. rig policy list and show include auto, the before-install view reports it per runtime, and the rig-spec policy table has a builtin:auto row. Thanks to @shravansumanthanan. Requested in #611.
50 lines
2.9 KiB
JavaScript
50 lines
2.9 KiB
JavaScript
// OPR.0.4.8.3 — built-in policy PACKING pins (guard-sealed plan v2 eea3c778,
|
|
// D4 T6/T7). NEW file beside the existing check-packing floor (the floor is
|
|
// added-beside, never edited).
|
|
//
|
|
// The chain this file pins (mirrors the sdlc-conventions daemon-package
|
|
// precedent documented in check-packing.test.mjs):
|
|
// repo source packages/daemon/policies/builtin/<name>.policy.md
|
|
// packed daemon/policies/builtin/<name>.policy.md (build-package.sh staging)
|
|
// installed stable $OPENRIG_HOME/reference/policies/builtin/<name>.policy.md
|
|
// (daemon startup materializer, mode 0444 inspection copies)
|
|
// The runtime edge is proven at the compiled assembled boundary by
|
|
// scripts/verify-packaged-builtins.mjs (plan D5b); these tests pin the source
|
|
// and staging legs so a dropped staging block or edited source fails loudly.
|
|
import { readFileSync, readdirSync } from "node:fs";
|
|
import { createHash } from "node:crypto";
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
const AUTHORITY_SHA256 = {
|
|
"auto.policy.md": "ffd0347af4bc5d5fdb4e5f8208577ca72dcc085883ea4fa0b10e9c6ac3022bde",
|
|
"locked.policy.md": "dcb38c372def7fe58ddfc9f1f3e97b9ba391ae79a99ef486e44f017cb39e57fe",
|
|
"open.policy.md": "bb5fbb18e1f3706bd0676a9e709e29b5754bb6b41b6f304453dd6d73e7a4d62b",
|
|
"standard.policy.md": "737d3f56e6d8275fe548a3a06e9b02ede8f328207ec2e6223cea6a83f40f5148",
|
|
// 0.6.0 (#109): accepted Codex full_bypass now includes approval policy never.
|
|
"yolo.policy.md": "1c34fff0b385426689fd26e20b8b431de6b688028d584924e7d5384fe5ff6d42",
|
|
};
|
|
|
|
test("T6: build-package.sh stages daemon policies into the assembled package", () => {
|
|
const sh = readFileSync("scripts/build-package.sh", "utf-8");
|
|
assert.ok(
|
|
/if \[ -d "\$DAEMON_DIR\/policies" \]/.test(sh),
|
|
"build-package.sh no longer stages $DAEMON_DIR/policies — the assembled daemon would ship no built-in policies and the startup materializer would find nothing to copy to $OPENRIG_HOME/reference/policies/builtin/."
|
|
);
|
|
assert.ok(
|
|
sh.includes('cp -r "$DAEMON_DIR/policies" "$CLI_DIR/daemon/policies"'),
|
|
"the policies staging copy line is missing/changed — packed daemon/policies would not match the repo source."
|
|
);
|
|
});
|
|
|
|
test("T7: the canonical repo-source built-ins are exactly the known five, byte-equal to authority", () => {
|
|
const dir = "packages/daemon/policies/builtin";
|
|
const files = readdirSync(dir).sort();
|
|
assert.deepEqual(files, ["auto.policy.md", "locked.policy.md", "open.policy.md", "standard.policy.md", "yolo.policy.md"],
|
|
"the built-in policy inventory must be EXACTLY locked|standard|open|yolo|auto");
|
|
for (const [file, expected] of Object.entries(AUTHORITY_SHA256)) {
|
|
const actual = createHash("sha256").update(readFileSync(`${dir}/${file}`)).digest("hex");
|
|
assert.equal(actual, expected, `${file} diverged from the authoritative verbatim content`);
|
|
}
|
|
});
|