mirror of
https://github.com/mvschwarz/openrig.git
synced 2026-11-11 17:32:22 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a76fd02ae | ||
|
|
031a3942cf | ||
|
|
3b8d0c5796 |
No files matched your search
+20
-122
@@ -1,31 +1,15 @@
|
||||
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:
|
||||
refocus-envelope:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: 031a3942cf671176ab5c839cadd46e0656458be6
|
||||
persist-credentials: false
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
@@ -33,110 +17,24 @@ jobs:
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: Record the published file list of each package
|
||||
- name: Bounded pasted-envelope 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/refocus-continuation.test.ts test/refocus-managed-result.test.ts test/refocus-context-ref.test.ts test/refocus-notes-local.test.ts test/refocus-occupant-baseline.test.ts test/refocus-role.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: refocus-envelope-green
|
||||
path: proof/
|
||||
if-no-files-found: error
|
||||
@@ -336,8 +336,14 @@ function runsForThisSeatsProject(env = process.env) {
|
||||
const rawPrompt = typeof input.prompt === "string" ? input.prompt.trim() : "";
|
||||
// Claude can wrap a complete submitted message as pasted content. Unwrap only
|
||||
// that envelope; a peer quoting a restore request is still an ordinary prompt.
|
||||
const prompt = harness === "claude"
|
||||
? (rawPrompt.match(/^<pasted_content id="([^"]+)">\s*([\s\S]*)\s*<\/pasted_content id="\1">$/)?.[2]?.trim() ?? rawPrompt)
|
||||
// Check the delimiters separately: overlapping whitespace/wildcard matches can
|
||||
// backtrack excessively on an incomplete paste or text after the closing tag.
|
||||
const opening = harness === "claude" ? rawPrompt.match(/^<pasted_content id="([^"]+)">/) : null;
|
||||
const closing = opening ? `</pasted_content id="${opening[1]}">` : "";
|
||||
const prompt = opening
|
||||
&& rawPrompt.length >= opening[0].length + closing.length
|
||||
&& rawPrompt.endsWith(closing)
|
||||
? rawPrompt.slice(opening[0].length, -closing.length).trim()
|
||||
: rawPrompt;
|
||||
if (event === "UserPromptSubmit" && prompt.startsWith("OpenRig post-compaction turn boundary.")) process.exit(0);
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ function fixture() {
|
||||
writeFileSync(rig, '#!/bin/sh\nif [ "$1 $2" = "stream emit" ]; then\n printf "%s\\n" "$*" >> "$CALLS"\n exit "${STREAM_EXIT:-0}"\nfi\nprintf "{}"\n');
|
||||
chmodSync(trace, 0o755);
|
||||
chmodSync(rig, 0o755);
|
||||
const run = (event: string, prompt = "continue", good = true, extra: NodeJS.ProcessEnv = {}, identity = "occupant") => {
|
||||
const run = (event: string, prompt = "continue", good = true, extra: NodeJS.ProcessEnv = {}, identity = "occupant", timeout = 10_000) => {
|
||||
const result = spawnSync(process.execPath, [hook, "--runtime", "claude"], {
|
||||
input: JSON.stringify({ hook_event_name: event, session_id: identity, prompt, transcript_path: transcript }),
|
||||
encoding: "utf8", timeout: 10_000,
|
||||
encoding: "utf8", timeout, killSignal: "SIGKILL",
|
||||
env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, OPENRIG_HOME: root,
|
||||
OPENRIG_SESSION_NAME: "seat@test", OPENRIG_REFOCUS_ENABLED: "1", OPENRIG_REFOCUS_NOW: "",
|
||||
OPENRIG_REFOCUS_CONTENT_REF: "", OPENRIG_REFOCUS_CONTENT_FILE: "", OPENRIG_REFOCUS_TREES: "work",
|
||||
@@ -34,7 +34,7 @@ function fixture() {
|
||||
PYTHON: trace, TRACE_RESULT: good ? "WORK TRACE: current intent" : "TRACE GAP — fixture resolver unavailable",
|
||||
TRACE_STATUS: good ? "0" : "1", CALLS: calls, ...extra },
|
||||
});
|
||||
expect(result.status, result.stderr).toBe(0);
|
||||
expect(result.status, result.error?.message || result.stderr).toBe(0);
|
||||
return result.stdout;
|
||||
};
|
||||
return { root, run, transcript, calls: () => existsSync(calls) ? readFileSync(calls, "utf8").trim().split("\n") : [],
|
||||
@@ -42,6 +42,16 @@ function fixture() {
|
||||
}
|
||||
|
||||
describe("refocus continuation", () => {
|
||||
it.each(["missing close", "trailing text"])("finishes a long pasted prompt with %s within the parsing bound", (ending) => {
|
||||
const f = fixture();
|
||||
const prompt = `<pasted_content id="fixture">${" ".repeat(64_000)}tail`
|
||||
+ (ending === "trailing text" ? '</pasted_content id="fixture"> extra' : "");
|
||||
const started = Date.now();
|
||||
// A separate process deadline stops even a synchronous parser regression.
|
||||
expect(f.run("UserPromptSubmit", prompt, true, {}, "occupant", 2_000)).toBe("");
|
||||
expect(Date.now() - started).toBeLessThan(1_000);
|
||||
expect(f.state().lastBytes).toBe(100);
|
||||
}, 5_000);
|
||||
it("leaves PostCompact due through repeated acknowledgement turns, then delivers once on restore", () => {
|
||||
const f = fixture();
|
||||
expect(f.run("PostCompact")).toBe("");
|
||||
|
||||
@@ -79,6 +79,8 @@ describe("managed refocus and trace results", () => {
|
||||
"From: peer@test\nThe build is done.", submit(buildPostCompactTurnBoundaryPrompt()), "Another peer update.",
|
||||
`A peer quotes an earlier restore:\n${submit(restore)}`,
|
||||
`<pasted_content id="fixture">\n${restore}\n</pasted_content id="other">`,
|
||||
`<pasted_content id="fixture">\n${restore}`,
|
||||
`<pasted_content id="fixture">\n${restore}\n</pasted_content id="fixture"> trailing text`,
|
||||
]) {
|
||||
expect(f.run("UserPromptSubmit", prompt)).toBe("");
|
||||
expect(f.state()).toEqual(before);
|
||||
|
||||
Reference in new issue
Block a user