From 343f2a8a6148b8004d6f4d74fb779b4f30c9686a Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 03:11:22 +0100 Subject: M1-M5: sessions, six tools, approvals, prompt, Ctrl-C, target gate - append-only JSONL sessions with --continue/--session; reasoning stored, stripped on replay - read/write/edit/grep/glob + bash with timeout and capped output - diff-preview approval for the first edit of a session, per-call approval for bash - system prompt frozen per session with AGENTS.md snapshot and change warning - SIGINT aborts the turn, second Ctrl-C exits - glibc gate ignores weak symbols; verified in linux/386 debian:12 - acceptance test (calculator in C) passes on both x86-64 and i386 --- scripts/check-glibc.sh | 24 +++++++++++++++++++----- scripts/mock-provider.py | 18 +++++++++++++++++- 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/check-glibc.sh b/scripts/check-glibc.sh index bb9052f..b02cd75 100755 --- a/scripts/check-glibc.sh +++ b/scripts/check-glibc.sh @@ -4,6 +4,10 @@ # The dev host's 32-bit glibc is newer than Debian 12's, so a dependency can # silently raise the required symbol version. Without this check the failure # only shows up as "version `GLIBC_2.38' not found" on the target machine. +# +# Weak undefined symbols are ignored: they resolve to NULL on older libc and the +# code paths using them fall back. Rust's std does this for glibc 2.39's +# pidfd_spawnp/pidfd_getpid, for example. set -euo pipefail binary=${1:?usage: check-glibc.sh [ceiling, default 2.36]} @@ -14,21 +18,31 @@ if [ ! -f "$binary" ]; then exit 2 fi -max=$(readelf -V "$binary" 2>/dev/null \ +required=$(readelf --dyn-syms --wide "$binary" 2>/dev/null \ + | awk '$5 != "WEAK" { print }' \ + | grep -oE 'GLIBC_[0-9]+\.[0-9]+' \ + | sed 's/^GLIBC_//' \ + | sort -Vu \ + | tail -1 || true) +weak=$(readelf --dyn-syms --wide "$binary" 2>/dev/null \ + | awk '$5 == "WEAK" { print }' \ | grep -oE 'GLIBC_[0-9]+\.[0-9]+' \ | sed 's/^GLIBC_//' \ | sort -Vu \ | tail -1 || true) -if [ -z "${max:-}" ]; then +if [ -z "${required:-}" ]; then echo "check-glibc: no versioned symbols (statically linked?) — nothing to check" exit 0 fi -echo "check-glibc: max symbol version GLIBC_$max, ceiling GLIBC_$ceiling" +echo "check-glibc: required GLIBC_$required, ceiling GLIBC_$ceiling" +if [ -n "${weak:-}" ] && [ "$weak" != "$required" ]; then + echo "check-glibc: weak GLIBC_$weak (optional, resolves to NULL on older libc)" +fi -if [ "$(printf '%s\n%s\n' "$ceiling" "$max" | sort -V | tail -1)" != "$ceiling" ]; then - echo "check-glibc: FAIL — binary needs GLIBC_$max, target has GLIBC_$ceiling" >&2 +if [ "$(printf '%s\n%s\n' "$ceiling" "$required" | sort -V | tail -1)" != "$ceiling" ]; then + echo "check-glibc: FAIL — binary needs GLIBC_$required, target has GLIBC_$ceiling" >&2 exit 1 fi diff --git a/scripts/mock-provider.py b/scripts/mock-provider.py index 4d11349..fb15662 100755 --- a/scripts/mock-provider.py +++ b/scripts/mock-provider.py @@ -14,6 +14,14 @@ import time from http.server import BaseHTTPRequestHandler, HTTPServer +def tool_frames(path, content): + yield {"choices": [{"delta": {"tool_calls": [{ + "index": 0, + "id": "call_mock_1", + "function": {"name": "write", "arguments": json.dumps({"path": path, "content": content})}, + }]}, "finish_reason": "tool_calls"}]} + + def frames(answer: str): yield {"choices": [{"delta": {"reasoning_content": "The user said hi. "}}]} yield {"choices": [{"delta": {"reasoning_content": "A short greeting is enough."}}]} @@ -46,12 +54,17 @@ class Handler(BaseHTTPRequestHandler): self.wfile.write(body) return + self.server.requests += 1 self.send_response(200) self.send_header("Content-Type", "text/event-stream") self.send_header("Cache-Control", "no-cache") self.end_headers() - for frame in frames(self.server.answer): + if self.server.tool_write and self.server.requests == 1: + stream = tool_frames(self.server.tool_write, "written by the mock\n") + else: + stream = frames(self.server.answer) + for frame in stream: if self.server.delay: time.sleep(self.server.delay) self.wfile.write(f"data: {json.dumps(frame)}\n\n".encode()) @@ -70,6 +83,7 @@ def main(): parser.add_argument("--delay", type=float, default=0.05, help="seconds between frames") parser.add_argument("--status", type=int, default=200, help="return this HTTP status") parser.add_argument("--answer", default="Hello from the mock provider.") + parser.add_argument("--tool-write", metavar="PATH", help="first response asks to write PATH") parser.add_argument("--quiet", action="store_true") args = parser.parse_args() @@ -78,6 +92,8 @@ def main(): server.delay = args.delay server.status = args.status server.quiet = args.quiet + server.tool_write = args.tool_write + server.requests = 0 print(f"mock provider on http://127.0.0.1:{args.port}/v1", flush=True) server.serve_forever() -- cgit v1.2.3