Compare commits

...
3 changed files with 54 additions and 125 deletions

No files matched your search

+21 -122
View File
@@ -1,142 +1,41 @@
name: Tests
# Builds, type-checks and runs every test suite on a clean GitHub runner, and records the file
# list each published package would contain. Each suite is its own job so one failure does not
# hide the others. No provider credentials or operator configuration are supplied.
# Package suites deny external networking; scenario runtime has no external route.
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
on: workflow_dispatch
permissions:
contents: read
concurrency:
group: tests-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-package:
notice-recovery:
runs-on: ubuntu-latest
timeout-minutes: 30
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
ref: 689a9a81a87bf4387f1c08e701e9c3665e41935d
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: command -v tmux || (sudo apt-get update && sudo apt-get install -y tmux)
- run: npm ci
- run: npm run build
- name: Record the published file list of each package
- name: Hook child interpreter regression
shell: bash
run: |
set -euo pipefail
mkdir -p pack-lists
for p in cli daemon tui; do
(cd packages/$p && npm pack --dry-run --json --ignore-scripts) \
| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{for(const f of JSON.parse(s)[0].files)console.log(f.path)})' \
| sort > pack-lists/$p.txt
echo "$p: $(wc -l < pack-lists/$p.txt) files"
done
- uses: actions/upload-artifact@v4
with:
name: pack-lists
path: pack-lists/
typecheck:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint
repo-checks:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run test:repo
package-tests:
if: ${{ github.event_name != 'push' }}
# macOS, the platform OpenRig runs on: several daemon and cli tests read macOS ps columns,
# file-inode behaviour and release tags.
runs-on: macos-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
package: [daemon, cli, tui, ui]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: brew install tmux
- run: npm ci
- name: Build the packages the tests import
run: npm run build
- name: Run the suite without ambient credentials or external network
run: |
suite_root=$(mktemp -d "$RUNNER_TEMP/opr-test.XXXXXX")
suite_root=$(cd "$suite_root" && pwd -P)
mkdir -p "$suite_root/home" "$suite_root/bin"
# Same system bytes, nonprivileged mode; no system file is changed.
/usr/bin/install -m 0755 /bin/ps "$suite_root/bin/ps"
# Only this job's temporary sockets (including tmux) are reachable.
env -i HOME="$suite_root/home" PATH="$PATH" TMPDIR="$suite_root" TMUX_TMPDIR="$suite_root" \
CI=true TERM=xterm-256color \
sandbox-exec -D IPC_ROOT="$suite_root" -p '(version 1)(allow default)(deny network-outbound)(allow network-outbound (remote ip "localhost:*"))(allow network-outbound (subpath (param "IPC_ROOT")))' \
/bin/bash -s "${{ matrix.package }}" <<'SUITE'
set -euo pipefail
node scripts/ci-macos-process-probe.mjs
# The production readers use bare ps. Select real system bytes only after
# self/owned-child observation and network/IPC confinement are proved.
export PATH="$TMPDIR/bin:$PATH"
test "$(command -v ps)" = "$TMPDIR/bin/ps"
exec npm run test -w "packages/$1"
SUITE
installed-scenario:
runs-on: ubuntu-latest
timeout-minutes: 35
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Installed package, daemon restart, and seeded durability failure
run: bash scripts/run-pr-scenarios.sh
set +e
set -uo pipefail
mkdir -p proof
git rev-parse HEAD HEAD^{tree} > proof/source.txt
node --version > proof/node-version.txt
npm --workspace @openrig/daemon test -- test/precompact-hook.test.ts test/refocus-context-ref.test.ts test/refocus-managed-result.test.ts test/refocus-work-packet.test.ts --reporter=verbose 2>&1 | tee proof/daemon.log
result=${PIPESTATUS[0]}
npm run lint 2>&1 | tee proof/typecheck.log
lint_result=${PIPESTATUS[0]}
git diff --exit-code > proof/source-unchanged.txt
printf 'daemon=%s\ntypecheck=%s\n' "$result" "$lint_result" > proof/exits.txt
test "$result" -eq 0 && test "$lint_result" -eq 0
- uses: actions/upload-artifact@v4
if: always()
with:
name: installed-scenario-evidence
path: dist/pr-scenarios/
name: hook-child-node-red
path: proof/
if-no-files-found: error
+10 -1
View File
@@ -44,7 +44,7 @@ const BRIDGE_SCRIPT = resolve(
);
const APPEND_MARKER = "Operator-configured post-compaction restore instruction";
function runHook(openrigHome: string, withTranscript = true): { stdout: string; stderr: string; status: number | null } {
function runHook(openrigHome: string, withTranscript = true, extraEnv: NodeJS.ProcessEnv = {}): { stdout: string; stderr: string; status: number | null } {
const fixtureRoot = dirname(openrigHome);
const transcript = join(fixtureRoot, "transcript.jsonl");
if (withTranscript) writeFileSync(transcript, `${JSON.stringify({
@@ -64,6 +64,7 @@ function runHook(openrigHome: string, withTranscript = true): { stdout: string;
OPENRIG_COMPACTION_OUT_ROOT: join(fixtureRoot, "packets"),
// Ensure RIGGED_HOME doesn't pre-empt OPENRIG_HOME selection.
RIGGED_HOME: undefined,
...extraEnv,
} as NodeJS.ProcessEnv,
});
return {
@@ -145,6 +146,14 @@ describe("precompact-hook.mjs (slice 27 custom message append)", () => {
rmSync(tmpDir, { recursive: true, force: true });
});
it("prepares the restore packet and pending marker with no Node on PATH", () => {
const { stdout, status } = runHook(openrigHome, true, { PATH: "" });
expect(status).toBe(0);
expect(JSON.parse(stdout).systemMessage).toContain("Pre-compaction restore seed packet prepared");
const marker = JSON.parse(readFileSync(join(openrigHome, "compaction/restore-pending/[email protected]"), "utf8"));
expect(existsSync(join(marker.outputDir, "restore-instructions.md"))).toBe(true);
});
it("HG-6: inline message is appended to systemMessage", () => {
writePolicyConfig(openrigHome, {
messageInline: "Operator says hi — remember the migration step.",
@@ -41,6 +41,7 @@ function runHook(options: {
whoamiStdout?: string;
whoamiStatus?: number;
capturePython?: boolean;
nodeRig?: boolean;
}) {
if (root) rmSync(root, { recursive: true, force: true });
root = mkdtempSync(join(tmpdir(), "refocus-context-ref-"));
@@ -65,7 +66,15 @@ function runHook(options: {
// The fake answers two verbs. `queue whoami` is dispatched first and returns its own
// stdout/status, so a whoami failure can be exercised without disturbing the context-get
// contract below, which stays byte-identical to keep the existing suites unaffected.
writeFileSync(rig, `#!/bin/sh
writeFileSync(rig, options.nodeRig ? `#!/usr/bin/env node
const fs = require("node:fs");
const args = process.argv.slice(2);
fs.appendFileSync(process.env.RIG_VERB_LOG, args.join(" ") + "\\n");
if (args.includes("--work-candidates")) { process.stderr.write("unknown option --work-candidates"); process.exit(1); }
if (args[0] === "queue") process.stdout.write(process.env.RIG_WHOAMI_STDOUT);
else if (args[0] === "config") process.stdout.write(JSON.stringify({ workspace: { root: process.env.OPENRIG_HOME } }));
else process.stdout.write(process.env.RIG_STDOUT);
` : `#!/bin/sh
printf '%s %s %s\\n' "$1" "$2" "$3" >> "$RIG_VERB_LOG"
if [ "$1" = "queue" ] && [ "$2" = "whoami" ]; then
printf '%s' "$RIG_WHOAMI_STDOUT"
@@ -96,7 +105,7 @@ exit 0
const env = {
...process.env,
PATH: `${bin}:${process.env.PATH || ""}`,
PATH: options.nodeRig ? bin : `${bin}:${process.env.PATH || ""}`,
OPENRIG_HOME: home,
OPENRIG_SESSION_NAME: "seat@test",
OPENRIG_REFOCUS_CONTENT_REF: options.ref,
@@ -141,6 +150,18 @@ exit 0
}
describe("openrig-core refocus hook — context library refs", () => {
it("reads work, legacy CLI fallback, roots and content through an env-node rig with no Node on PATH", () => {
const bundle = "# Minimal-PATH context\n";
const result = runHook({ nodeRig: true, ref: REF, capturePython: true, rigStdout: bundle,
whoamiStdout: JSON.stringify({ currentWorkBasis: "fixture has no current work" }),
extraEnv: { OPENRIG_REFOCUS_WORK_NODE: undefined, OPENRIG_WORKSPACE_ROOT: undefined, OPENRIG_REFOCUS_WORK_PACKET: "1" } });
expect(result.status).toBe(0);
expect(result.payload?.hookSpecificOutput.additionalContext.endsWith(bundle)).toBe(true);
expect(result.rigVerbs().trim().split("\n")).toEqual([
"queue whoami --json --work-candidates", "queue whoami --json", "config --json", `context get ${REF}`,
]);
});
it("REF wins over FILE and delivers the exact rig context get bytes", () => {
const bundle = "# OpenRig Context Pack: proof v1\n\nassembled bytes\n";
const result = runHook({ ref: REF, fileContent: "FILE MUST NOT WIN", rigStdout: bundle });