Artifact 27182f284f1dc4a7e880561d7ce46a93d05f131435e7204cadb4d6027cd18cc3:
- File
tools/remote/payload.sh
— part of check-in
[af92ae84b2]
at
2026-11-19 22:04:56
on branch steering
— Durable steering and follow-ups, as Pi's
With --json --commands, a running pic reads Pi's RPC command lines on stdin (steer, follow_up, clear_queue, abort, set_steering_mode, set_follow_up_mode) wherever it already waits, and answers as Pi does. Each accepted message is journaled (pic_queued, journal version 8) before it is acknowledged. Steering becomes a user entry after the turn's tool results, before the next model call (and after a compaction); follow-ups become the next request when the answer is recorded, in the same transaction. Messages belong to the request that accepted them; on a failure or an abort they are marked returned and listed in a queue_returned event, never run later. pic check verifies each delivered entry against its queued row. Bash commands get /dev/null on stdin, as in Pi. (user: dmestas, size: 7280) [annotate] [blame] [check-ins using]
#!/bin/sh # Trusted S0 fixtures only. The system manager bounds this entire process tree. set -eu umask 077 [ "$#" -eq 2 ] || exit 1 mode=$1 compiler=$2 # pic keeps user state under $HOME/.pic: keep it inside this run, never the # account's real home (teardown removes the workspace, not $HOME). mkdir -p home export HOME="$PWD/home" PIC_MODEL_CATALOG=offline failed() { status=$? [ "$status" -eq 0 ] || printf 'FAIL\n' > result.txt # pic mode's objects and binaries are large and reproducible; the logs are # the evidence, pass or fail. [ "$mode" != pic ] || rm -rf run/obj run/pic run/test_sse run/test_tui run/decode_stream run/test_http run/test_models run/fake_server } trap failed EXIT case "$mode" in noop) : ;; disconnect) /bin/sleep 10 ;; timeout) /bin/sleep 30 ;; filc) [ -x "$compiler" ] || exit 1 mkdir run "$compiler" --version > run/compiler-version.txt compile() { output=$1 source=$2 set -- -O2 -g -std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow \ -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual \ test/qualification/fixture.c test/qualification/oracle.c \ "test/qualification/$source" -o "run/$output" printf '%s\n' "$compiler" "$@" > "run/$output.argv" "$compiler" "$@" } compile test_qualification test_qualification.c compile test_oracle_mutant test_oracle_mutant.c compile replay replay.c run/test_qualification run/test_oracle_mutant run/replay test/fuzz/corpus/empty.bin test/fuzz/corpus/dedup.bin \ test/fuzz/corpus/admit_commit.bin test/fuzz/corpus/effect_before_receipt.bin \ test/fuzz/corpus/truncated.bin test/fuzz/corpus/unsafe_interrupt.bin \ test/fuzz/corpus/retry-after-uncommitted-crash.bin ;; pic) # pic and its suites under Fil-C: every memory error is a crash here. [ -x "$compiler" ] || exit 1 mkdir run run/obj "$compiler" --version > run/compiler-version.txt vflags="-O1 -g -w -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_THREADSAFE=1 -DSQLITE_OMIT_LOAD_EXTENSION -DHAVE_LIBFOSSIL_CONFIG_H -DWITHOUT_ICONV -DZ_HAVE_UNISTD_H -Ivendor/libfossil -Ivendor/zlib" brflags="-O1 -g -w -Ivendor/bearssl/inc -Ivendor/bearssl/src -DBR_RDRAND=0 -DBR_USE_URANDOM=0 -DBR_USE_WIN32_RAND=0 -DBR_USE_UNIX_TIME=0 -DBR_USE_WIN32_TIME=0 -DBR_AES_X86NI=0 -DBR_SSE2=0 -DBR_POWER8=0" warn="-std=c11 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wvla -Wcast-qual -D_DEFAULT_SOURCE -O1 -g" # Two compiles at a time (the unit has two CPUs); any failure fails the run. pids= running=0 join() { for p in $pids; do wait "$p" || exit 1; done; pids=; running=0; } bg() { "$@" & pids="$pids $!"; running=$((running + 1)); [ "$running" -lt 2 ] || join; } for src in vendor/libfossil/sqlite3.c vendor/libfossil/libfossil.c vendor/zlib/*.c; do # shellcheck disable=SC2086 bg "$compiler" $vflags -c -o "run/obj/$(printf '%s' "$src" | tr / _).o" "$src" done for src in vendor/bearssl/src/*.c vendor/bearssl/src/*/*.c; do # shellcheck disable=SC2086 bg "$compiler" $brflags -c -o "run/obj/$(printf '%s' "$src" | tr / _).o" "$src" done join printf 'compiled %s vendored objects\n' "$(ls run/obj | wc -l)" inc="-Isrc -isystem vendor/libfossil -isystem vendor/zlib -DHAVE_LIBFOSSIL_CONFIG_H -isystem vendor/bearssl/inc" # shellcheck disable=SC2086 "$compiler" $warn -DPIC_FAULTS $inc -o run/pic src/store.c src/loop.c src/compact.c src/events.c src/export_pi.c src/export_html.c src/import_pi.c src/tree.c src/commands.c src/tui/app.c src/tui/width.c src/tui/term.c src/tui/render.c src/tui/editor.c src/tui/fuzzy.c src/provider_fake.c \ src/provider_anthropic.c src/tools.c src/context.c src/prompts.c src/sse.c src/anthropic.c src/http.c src/net.c src/input.c src/platform.c src/cred.c src/models.c src/userdb.c src/sqlar.c src/catalog.c src/catalog_fetch.c src/transform.c src/openai_chat.c src/provider_http.c src/provider_chat.c src/openai_responses.c src/provider_responses.c \ src/main.c run/obj/*.o -lm -lpthread # shellcheck disable=SC2086 "$compiler" $warn -Isrc -o run/test_sse test/pic/test_sse.c src/sse.c "$compiler" $warn -Isrc -o run/test_tui test/tui/test_tui.c src/tui/width.c src/tui/term.c src/tui/render.c src/tui/editor.c src/tui/fuzzy.c # shellcheck disable=SC2086 "$compiler" $warn $inc -o run/decode_stream test/pic/decode_stream.c src/anthropic.c src/openai_chat.c \ src/openai_responses.c src/sse.c \ run/obj/vendor_libfossil_sqlite3.c.o -lm -lpthread # shellcheck disable=SC2086 "$compiler" $warn $inc -o run/test_http test/pic/test_http.c src/http.c src/net.c src/input.c src/platform.c \ run/obj/vendor_bearssl_src_*.o -lm -lpthread # shellcheck disable=SC2086 "$compiler" $warn $inc -o run/test_files test/pic/test_files.c src/tools.c src/net.c src/input.c src/platform.c \ run/obj/vendor_bearssl_src_*.o -lm -lpthread # shellcheck disable=SC2086 "$compiler" $warn $inc -o run/test_models test/pic/test_models.c src/models.c src/input.c src/platform.c src/catalog.c src/userdb.c src/sqlar.c \ run/obj/vendor_libfossil_sqlite3.c.o run/obj/vendor_zlib_*.o -lm -lpthread # shellcheck disable=SC2086 "$compiler" $warn -Isrc -o run/test_prompts test/pic/test_prompts.c src/prompts.c src/input.c src/platform.c "$compiler" -std=c11 -Wall -Wextra -Werror -D_DEFAULT_SOURCE -O1 -o run/fake_server test/pic/fake_server.c printf 'built pic and its tests\n' run/test_sse run/test_tui sh test/pic/decode.sh run/decode_stream run/test_http run/test_files run/test_models run/test_prompts PIC="$PWD/run/pic" sh test/pic/crash.sh PIC="$PWD/run/pic" sh test/pic/tools.sh PIC="$PWD/run/pic" sh test/pic/migrate.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/sessions.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/compact.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/events.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/interrupt.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/steer.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/chat.sh PIC="$PWD/run/pic" sh test/pic/export_pi.sh PIC="$PWD/run/pic" sh test/pic/slash.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/prompts.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/catalog.sh PIC="$PWD/run/pic" SERVER="$PWD/run/fake_server" sh test/pic/provider.sh ;; *) exit 1 ;; esac printf 'PASS\n' > result.txt printf 'payload: %s complete\n' "$mode"