From 117ea3335fe106ce93f3aee9471757299abeb927 Mon Sep 17 00:00:00 2001 From: "Claude Opus 5.5 (claude-opus-5-5)" Date: Tue, 27 Oct 2026 23:03:38 +0100 Subject: [PATCH 1/3] fix(queue): record Codex reads and point a refused name at its UUID A message posted for Codex stayed queued after the session read it, and a post by session name ran past a minute with no explanation (field report, 2026-10-27). The postbox hook now marks a queued message read when its session's prompt is the message text, and the queued line names the thread id from the receipt. A post by name warns that Codex searches its server page by page, and a refused name gets a hint with the UUID Codex matched. Co-Authored-By: Martin Zeman --- CHANGELOG.md | 7 ++ README.md | 8 +- .../queue-records-codex-reads/design.md | 40 ++++++ .../queue-records-codex-reads/proposal.md | 30 +++++ .../specs/queue-messages-for-sessions/spec.md | 33 +++++ .../queue-records-codex-reads/tasks.md | 12 ++ src/cli/hook/adapters.rs | 11 +- src/cli/queue/ledger.rs | 52 ++++++-- src/cli/queue/ledger_tests.rs | 50 ++++++++ src/cli/queue/mod.rs | 88 +++++++++++-- src/cli/queue/tests.rs | 119 ++++++++++++++++++ templates/skill/SKILL.md | 2 +- tests/queue.rs | 95 ++++++++++++++ 13 files changed, 525 insertions(+), 22 deletions(-) create mode 100644 docs/changes/queue-records-codex-reads/design.md create mode 100644 docs/changes/queue-records-codex-reads/proposal.md create mode 100644 docs/changes/queue-records-codex-reads/specs/queue-messages-for-sessions/spec.md create mode 100644 docs/changes/queue-records-codex-reads/tasks.md diff --git a/CHANGELOG.md b/CHANGELOG.md index ed3da960..9a2b622a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). [0.2.0]: https://github.com/runedeck/rune/compare/v0.1.0...v0.2.0 [0.1.0]: https://github.com/runedeck/rune/releases/tag/v0.1.0 +## [Unreleased] + +### Fixed + +- Record a queued Codex message as `read` when the `postbox` hook sees its session's turn start with it, and list a message posted by name under the thread id Codex printed. +- Warn before `rune queue post` looks a Codex session up by name, and add a `hint` with the UUID when Codex refuses the name and names the session it matched. + ## [0.6.0] - 2026-10-26 ### Added diff --git a/README.md b/README.md index 914ce015..809f00e8 100644 --- a/README.md +++ b/README.md @@ -462,7 +462,11 @@ rune queue list --state posted # the postbox, changed by nothing Every message is recorded in the postbox, `~/.rune/postbox.tsv`, one file for every session on the machine. Each event is one tab-separated line: timestamp, id, state, sender, harness, session, message. A tab, newline, or backslash in a message is escaped, so `rg` and `column -t -s $'\t'` read the file. Nothing is removed: a state change (`posted`, `queued`, `read`) is a new line with the message's id, and its last line is its state. The sender is `--from`, else the posting session as `harness:id`, else `user:`. -Codex takes the message through its own queue, `codex queue --remote unix://`, the local app-server daemon that holds the running sessions, and the postbox records it as `queued`. A route's environment applies, so a profile that sets `CODEX_HOME` reaches the sessions of that home. The profile's arguments start a session, so they are not passed, and a warning names them. `--remote ` and `--remote-auth-token-env ` reach another server. `--postbox` leaves a Codex message in the postbox instead. The result names the message id and the thread id that Codex printed. +Codex takes the message through its own queue, `codex queue --remote unix://`, the local app-server daemon that holds the running sessions, and the postbox records it as `queued`. A route's environment applies, so a profile that sets `CODEX_HOME` reaches the sessions of that home. The profile's arguments start a session, so they are not passed, and a warning names them. `--remote ` and `--remote-auth-token-env ` reach another server. `--postbox` leaves a Codex message in the postbox instead. The result names the message id and the thread id that Codex printed, and the `queued` line names that thread id, so a message posted by name lists under its thread. + +Post to a Codex session by its UUID, which the session reads from `CODEX_THREAD_ID`. Codex finds a UUID at once, but searches its server's sessions page by page for a name, which can take a minute or more. So a post by name warns before it starts. When Codex refuses a name and names the UUID it matched, the hint says to post with `--session `. + +Inside Claude Code's command sandbox, `post` cannot reach the socket of the Codex daemon, and `post` and `read` cannot write `~/.rune/`. Add `rune queue *` to `sandbox.excludedCommands`, as for `rune run *`. Claude Code, agy, grok, cursor, and OpenCode have no queue for a running session, so their messages wait in the postbox as `posted`. A session reads them in one of two ways. The `postbox` hook handler adds them to Claude Code's session start and next prompt, and at the end of a Claude Code or Codex turn it keeps the turn going with the messages as the reason: @@ -474,7 +478,7 @@ hooks: events: [session.start, prompt.before, turn.finish] ``` -Then run `rune hook install`. The hook reads by the session's id, so post to a Claude Code session by the id in its `CLAUDE_CODE_SESSION_ID`. A grok, agy, cursor, or OpenCode session runs `rune queue read --session `, as the rune skill tells it to. Inside Claude Code or Codex, `rune queue read` finds its own session in `CLAUDE_CODE_SESSION_ID` or `CODEX_THREAD_ID`. +Then run `rune hook install`. The hook reads by the session's id, so post to a Claude Code session by the id in its `CLAUDE_CODE_SESSION_ID`. In a Codex session, the same handler records a `queued` message as `read` when the queue starts the session's turn with it, because that turn's prompt is the message's text. A grok, agy, cursor, or OpenCode session runs `rune queue read --session `, as the rune skill tells it to. Inside Claude Code or Codex, `rune queue read` finds its own session in `CLAUDE_CODE_SESSION_ID` or `CODEX_THREAD_ID`. `--json` makes every result one object (`posted`, `queued`, `read`, `list`, `dry_run`). `--dry-run` prints what would be posted with the message as ``. A route that names no harness exits 125 with kind `unsupported_harness`. Every other exit status uses the table of `rune run`: the harness's own status passes through, and 124 to 127 are the runner's. diff --git a/docs/changes/queue-records-codex-reads/design.md b/docs/changes/queue-records-codex-reads/design.md new file mode 100644 index 00000000..29125f62 --- /dev/null +++ b/docs/changes/queue-records-codex-reads/design.md @@ -0,0 +1,40 @@ +# Queue records Codex reads: design + +## Approach + +Codex gives no receipt when a session reads a queued message. It starts the session's next turn with the message as the prompt, and it fires its prompt *[hook][HOOK]* (`UserPromptSubmit`) for that turn, with the prompt text in the payload. So the `postbox` handler compares each prompt with the session's `queued` messages, and records a message whose text is the prompt as `read`. Text is compared after trimming both sides. A prompt the owner types matches nothing, and nothing changes. + +This beat marking every `queued` message read at the session's next turn end: a turn the owner started before the queue delivered would then mark a message read that the session never saw. It also beat reading Codex's rollout files, which are Codex's own format. + +A message posted by name is recorded under that name, and the hook gets the session id. So the `queued` line names the thread id from Codex's receipt, and a message's session is the one its last line names. A `read` line copies the session it reads for, so the rule holds for every state. Without a receipt line, the name stays, and the message stays `queued`. + +For a name, Codex searches its server's sessions page by page, and a UUID needs no search. rune cannot shorten the search: Codex has no command that lists its sessions with their names (`codex agents` is an interactive browser), and the name index Codex keeps in `~/.codex/session_index.jsonl` lacks the thread from the field report. So the post warns before the search starts, and the warning is on stderr even when an outer timeout stops the post. When Codex refuses a name and names the UUIDs it matched, the failure's hint names them and `--session`. + +## Evidence + +The field report came from the Claude Code session `Proton/ai-demo` on 2026-10-27 (rune 0.6.0, Codex app-server daemon). The rest was read on the owner's machine. + +| Fact | Source | +| --- | --- | +| The message posted at 19:46:29Z started a Codex turn, which fired `session.start` and `prompt.before` at 19:46:41Z | rune's hook records, `~/.local/state/rune/hooks/record/2026-10.jsonl` | +| That turn's user message equals the ledger text, all 1720 characters | Codex rollout of thread `01a15844-7b2e-71a0-aa88-b41f3c4622af` | +| `UserPromptSubmit` input has `prompt`, the user prompt about to be sent | [Codex hooks][CODEXHOOKS] | +| `--session Proton/ai-demo` ran past 60 s. With `--timeout 5m`, Codex exited 1: `Cannot verify a unique session label across server pages; matching session UUID: …` | field report | +| An unknown UUID was refused in 0.14 s, an unknown name in 45 s | `codex queue` 0.154.0 against the owner's daemon, 2026-10-28 | +| Codex has two name refusals: the unverified label above, and one that ends "use a session UUID to disambiguate" | strings of the Codex 0.154.0 binary | + +## Structure + +- `src/cli/queue/ledger.rs`: `fold` takes the session of the last line. `take_prompted` marks read the `queued` messages of one session whose text is the prompt, under the ledger's lock. `take_posted` and `take_prompted` share one locked read-and-append step. +- `src/cli/hook/adapters.rs`: on `prompt.before` with a prompt, the `postbox` handler calls `take_prompted` before it delivers `posted` messages. Codex still gets no context on a prompt. +- `src/cli/queue/mod.rs`: `queued_outcome` reads the receipt before it writes the `queued` line. `name_lookup_warning` joins the post's warnings. `failure_outcome` adds the hint from `session_hint` when no sandbox hint applies. + +## Risks + +- Codex changes the prompt it starts a queued turn with, for example with a prefix. The message then stays `queued`, as before this change. +- Codex starts one turn with two queued messages. Neither text equals the prompt, so both stay `queued`. +- The same text queued twice for one session is marked read by the first turn. Both messages reached the same session. +- Codex changes its refusal text. The hint then disappears, and the stderr tail still shows the refusal. + +[HOOK]: ../../specs/glossary/hook.md +[CODEXHOOKS]: https://developers.openai.com/codex/hooks diff --git a/docs/changes/queue-records-codex-reads/proposal.md b/docs/changes/queue-records-codex-reads/proposal.md new file mode 100644 index 00000000..9255bd93 --- /dev/null +++ b/docs/changes/queue-records-codex-reads/proposal.md @@ -0,0 +1,30 @@ +--- +status: proposed +--- + +# Queue records Codex reads + +## Why + +On 2026-10-27 a Claude Code session and a Codex session talked through `rune queue` from end to end, and the session that took part reported three faults ([field report][FIELDREPORT]). Two of them are rune's. A message posted for Codex stayed `queued` after Codex read and answered it, because rune hands the message to `codex queue` and never learns more. And `--session Proton/ai-demo` ran past 60 s with no explanation. With `--timeout 5m`, Codex then refused the name and named the matching UUID, and rune passed that through as a bare failure. The third fault, the command sandbox that blocks the Codex socket, belongs to the owner's sandbox settings. + +## What Changes + +- The `postbox` *[hook][HOOK]* handler records a `queued` message as `read` when a prompt of its session carries the message's text. Codex starts the session's next turn with the queued message as the prompt, and fires its prompt hook for that turn. +- The `queued` line names the thread id from Codex's receipt, and a message's session is the one its last line names. So a message posted by name is found by the session id the hook reads. +- A post to a Codex session by name warns that Codex searches its server's sessions for a name, and that a UUID needs no search. +- When Codex refuses a name and names the UUIDs it matched, the failure carries a hint: post with `--session `. +- The hook's message tells the reader to answer a `harness:id` sender with `rune queue post --session `. +- The README says that `rune queue` needs the same sandbox exemption as `rune run`. + +## Capabilities + +- queue-messages-for-sessions (modified) + +## Impact + +- `src/cli/queue/mod.rs`, `src/cli/queue/ledger.rs`, `src/cli/hook/adapters.rs`, their tests, `tests/queue.rs`, `README.md`, `templates/skill/SKILL.md`, `CHANGELOG.md`. +- A Codex message posted by name now lists under the thread id that Codex printed. + +[HOOK]: ../../specs/glossary/hook.md +[FIELDREPORT]: design.md#evidence diff --git a/docs/changes/queue-records-codex-reads/specs/queue-messages-for-sessions/spec.md b/docs/changes/queue-records-codex-reads/specs/queue-messages-for-sessions/spec.md new file mode 100644 index 00000000..39a94cf3 --- /dev/null +++ b/docs/changes/queue-records-codex-reads/specs/queue-messages-for-sessions/spec.md @@ -0,0 +1,33 @@ +## ADDED Requirements + +### Requirement: A queued message is read when its turn starts + +When a session's prompt is the text of a message that the *[harness][HARNESS]*'s own queue holds for that session, the *[hook][HOOK]* MUST record that message as `read`. A `queued` line MUST name the session id that the [harness][HARNESS] printed for the message, and a message's session MUST be the one its last line names. A prompt that is no queued message of the session MUST leave every message as it was. + +#### Scenario: Codex turn starts with a queued message + +- **WHEN** a message for the Codex session `ouroboros` is queued, and Codex prints the thread `019a-ouroboros` for it +- **AND** a prompt in that thread carries the message's text +- **THEN** the [hook][HOOK] records the message as `read`, and the list shows it for `019a-ouroboros` + +#### Scenario: Owner prompt leaves the queue alone + +- **WHEN** a message is `queued` for a Codex session, and the owner sends another prompt in that session +- **THEN** the message stays `queued` + +### Requirement: A Codex session name leads to its UUID + +A post to a Codex session given by a name, not a UUID, MUST warn that Codex searches every session of its server for a name, and that a UUID needs no search. When Codex refuses a name and names the UUIDs it matched, the failure MUST carry a hint that names them and tells the caller to post with `--session`. A post to a UUID MUST NOT warn. + +#### Scenario: Refused name names its UUID + +- **WHEN** Codex exits 1 because it cannot verify a unique session label, and names the matching session UUID +- **THEN** the command exits 1, the hint names that UUID and `--session`, and the ledger is unchanged + +#### Scenario: Session UUID gets no warning + +- **WHEN** the caller posts for a Codex session by its UUID +- **THEN** the post writes no warning + +[HARNESS]: ../../../../specs/glossary/harness.md +[HOOK]: ../../../../specs/glossary/hook.md diff --git a/docs/changes/queue-records-codex-reads/tasks.md b/docs/changes/queue-records-codex-reads/tasks.md new file mode 100644 index 00000000..8628015c --- /dev/null +++ b/docs/changes/queue-records-codex-reads/tasks.md @@ -0,0 +1,12 @@ +## 1. Implementation + +- [x] 1.1 `fold` takes a message's session from its last line, and the `queued` line names the receipt's thread id +- [x] 1.2 `take_prompted` and the `postbox` handler on `prompt.before`: a prompt that is a queued message's text marks it read +- [x] 1.3 The name warning for a Codex session that is not a UUID, and the hint from Codex's name refusals +- [x] 1.4 The hook's answer line for a `harness:id` sender, the README queue section, the rune skill section, and the CHANGELOG entry + +## 2. Verification + +- [x] 2.1 Unit tests: the session of the last line, `take_prompted`, the hook on a queued prompt and on another prompt, the UUID shape, the warning, and the hint +- [x] 2.2 Integration tests with a fake Codex and a scratch HOME: a name resolved to the receipt's thread and read by its turn, no warning for a UUID, and the hint on a refused name +- [x] 2.3 `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo test --bin rune` (1379 pass), `cargo test --test queue --test hook_dispatch` (39 pass), `rune spec validate queue-records-codex-reads` (2026-10-28) diff --git a/src/cli/hook/adapters.rs b/src/cli/hook/adapters.rs index 4d6b4432..7cb26b0e 100644 --- a/src/cli/hook/adapters.rs +++ b/src/cli/hook/adapters.rs @@ -1432,7 +1432,9 @@ fn turn_checkpoint(payload: &HandlerPayload) -> Result { /// context on an event that takes context, or at a turn's end as the reason /// to keep working, so the session reads them at its next turn. A harness /// that can express neither on the event reads nothing, so no message is -/// marked read and lost. +/// marked read and lost. A prompt that is a message the harness's own +/// queue holds for this session marks that message read: the queue started +/// the turn with it. fn postbox(payload: &HandlerPayload) -> Result { postbox_at(payload, &crate::cli::queue::ledger::path()?) } @@ -1447,6 +1449,11 @@ pub(crate) fn postbox_at(payload: &HandlerPayload, ledger: &Path) -> Result Capability::Context, "turn.finish" => Capability::TurnContinue, @@ -1460,7 +1467,7 @@ pub(crate) fn postbox_at(payload: &HandlerPayload, ledger: &Path) -> Result --session `.\n\n{}", inbox::format_messages(&messages) ); Ok(if capability == Capability::TurnContinue { diff --git a/src/cli/queue/ledger.rs b/src/cli/queue/ledger.rs index 89654dbc..afd945f8 100644 --- a/src/cli/queue/ledger.rs +++ b/src/cli/queue/ledger.rs @@ -4,8 +4,9 @@ //! harness, session, message. A tab, a newline, or a backslash in a column is //! escaped, so an event never spans two lines. Nothing is removed or //! rewritten: a state change is a new line with the message's id, and the -//! last line of an id is the message's state. Every write holds the file's -//! lock, so a read that marks messages read and a post never interleave. +//! last line of an id gives the message's state and session. Every write +//! holds the file's lock, so a read that marks messages read and a post +//! never interleave. use std::fs::{File, OpenOptions}; use std::io::{Read as _, Seek as _, SeekFrom, Write as _}; @@ -18,7 +19,8 @@ const HEADER: &str = "# timestamp\tid\tstate\tsender\tharness\tsession\tmessage" pub(crate) enum State { /// Waiting in the postbox for its session to read it. Posted, - /// Handed to the harness's own queue, which delivers it. + /// Handed to the harness's own queue, which delivers it. The line names + /// the session id the harness printed, where it printed one. Queued, /// Read by its session, through `rune queue read` or the hook. Read, @@ -107,8 +109,10 @@ impl Event { } } -/// A message as it stands: the columns of its first line and the state of -/// its last. +/// A message as it stands: the columns of its first line, and the state +/// and session of its last. A `queued` line names the session id the +/// harness resolved a name to, so the message's session is the one that +/// reads it. #[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct Message { pub(crate) id: String, @@ -126,6 +130,7 @@ pub(crate) fn fold(events: &[Event]) -> Vec { for event in events { if let Some(message) = messages.iter_mut().find(|message| message.id == event.id) { message.state = event.state; + message.session.clone_from(&event.session); } else { messages.push(Message { id: event.id.clone(), @@ -189,6 +194,38 @@ pub(crate) fn take_posted( path: &Path, sessions: &[String], timestamp: &str, +) -> Result, String> { + take(path, timestamp, |message| { + message.state == State::Posted && sessions.contains(&message.session) + }) +} + +/// Mark read the messages queued for `session` whose text is `prompt`: the +/// harness's own queue started the session's turn with them. Codex hands a +/// queued message to its turn as the prompt, unchanged (rollout of +/// 2026-10-27), and gives no other receipt of delivery. +pub(crate) fn take_prompted( + path: &Path, + session: &str, + prompt: &str, + timestamp: &str, +) -> Result, String> { + let prompt = prompt.trim(); + if prompt.is_empty() { + return Ok(Vec::new()); + } + take(path, timestamp, |message| { + message.state == State::Queued + && message.session == session + && message.text.trim() == prompt + }) +} + +/// Mark read the messages `select` picks, under one lock, and return them. +fn take( + path: &Path, + timestamp: &str, + select: impl Fn(&Message) -> bool, ) -> Result, String> { if !path.exists() { return Ok(Vec::new()); @@ -199,10 +236,7 @@ pub(crate) fn take_posted( .and_then(|_| file.read_to_string(&mut text)) .map_err(|error| format!("cannot read the postbox {}: {error}", path.display()))?; let (events, _) = parse_all(&text); - let taken: Vec = fold(&events) - .into_iter() - .filter(|message| message.state == State::Posted && sessions.contains(&message.session)) - .collect(); + let taken: Vec = fold(&events).into_iter().filter(select).collect(); let read: Vec = taken .iter() .map(|message| Event::change(message, State::Read, timestamp)) diff --git a/src/cli/queue/ledger_tests.rs b/src/cli/queue/ledger_tests.rs index 4d573952..4a8da526 100644 --- a/src/cli/queue/ledger_tests.rs +++ b/src/cli/queue/ledger_tests.rs @@ -53,6 +53,56 @@ fn the_last_line_of_an_id_is_its_state() { assert_eq!(messages[1].state, State::Posted); } +#[test] +fn the_last_line_of_an_id_is_its_session() { + let posted = event("m-1", State::Posted, "ouroboros", "hello"); + let queued = Event { + state: State::Queued, + session: "01a0abff-74d9-7390-b827-57ef47c982c2".to_string(), + message: String::new(), + ..posted.clone() + }; + let messages = fold(&[posted, queued]); + assert_eq!(messages[0].session, "01a0abff-74d9-7390-b827-57ef47c982c2"); + assert_eq!(messages[0].text, "hello"); +} + +#[test] +fn a_prompt_takes_only_the_queued_message_it_repeats() { + let folder = tempfile::tempdir().expect("folder"); + let path = folder.path().join(".rune").join(FILE_NAME); + append( + &path, + &[ + event("m-1", State::Posted, "seat", " for the seat\n"), + event("m-1", State::Queued, "seat", ""), + event("m-2", State::Posted, "seat", "for the seat"), + ], + ) + .expect("append"); + + assert!( + take_prompted(&path, "seat", " ", "later") + .expect("take") + .is_empty(), + "an empty prompt takes nothing" + ); + let taken = take_prompted(&path, "seat", "for the seat", "later").expect("take"); + assert_eq!( + taken + .iter() + .map(|message| message.id.as_str()) + .collect::>(), + ["m-1"], + "a posted message waits for the postbox reader" + ); + assert_eq!( + take_prompted(&path, "seat", "for the seat", "again").expect("take again"), + Vec::new(), + "a read message is not taken twice" + ); +} + #[test] fn taking_marks_read_and_keeps_every_line() { let folder = tempfile::tempdir().expect("folder"); diff --git a/src/cli/queue/mod.rs b/src/cli/queue/mod.rs index 027132c6..8de9adc6 100644 --- a/src/cli/queue/mod.rs +++ b/src/cli/queue/mod.rs @@ -132,6 +132,55 @@ pub(crate) fn parse_receipt(stdout: &str) -> Option { }) } +/// Whether `text` has the shape of a UUID: groups of 8, 4, 4, 4, and 12 hex +/// digits. Codex names every session by one. +pub(crate) fn is_uuid(text: &str) -> bool { + let groups: Vec<&str> = text.split('-').collect(); + groups.len() == 5 + && groups.iter().zip([8, 4, 4, 4, 12]).all(|(group, length)| { + group.len() == length && group.chars().all(|character| character.is_ascii_hexdigit()) + }) +} + +/// The warning for a Codex session given by name. Codex finds a UUID at +/// once and looks a name up page by page across every session of its +/// server: with Codex 0.154.0 on the owner's daemon, an unknown UUID was +/// refused in 0.14 s and an unknown name in 45 s (2026-10-28), and a known +/// name ran past 60 s (2026-10-27). +pub(crate) fn name_lookup_warning(session: &str) -> Option { + (!is_uuid(session)).then(|| { + format!( + "Codex looks the name {session} up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search" + ) + }) +} + +/// The hint for Codex's refusal of a session name, which names the UUIDs +/// it matched: `Cannot verify a unique session label across server pages; +/// matching session UUID: `, or several before `use a session UUID to +/// disambiguate`. +pub(crate) fn session_hint(stderr: &str) -> Option { + if !stderr.contains("session UUID") { + return None; + } + let mut matched: Vec<&str> = Vec::new(); + for word in stderr.split(|character: char| !character.is_ascii_hexdigit() && character != '-') { + if is_uuid(word) && !matched.contains(&word) { + matched.push(word); + } + } + match matched.as_slice() { + [] => None, + [uuid] => Some(format!( + "Codex matched the name to session {uuid}: post with --session {uuid}" + )), + several => Some(format!( + "Codex matched the name to sessions {}: post with --session and the UUID of the one you mean", + several.join(", ") + )), + } +} + /// The warning for a profile's arguments: they start a session, so the /// queue never takes them. A credential among them is hidden. pub(crate) fn dropped_profile_args(args: &[OsString]) -> Option { @@ -210,6 +259,7 @@ fn execute_inner(options: &PostOptions) -> Result .iter() .cloned() .chain(dropped_profile_args(profile_args)) + .chain(name_lookup_warning(&options.session)) .collect(); // The caller's environment, minus the parent session's variables, plus // the route's: the isolation `rune run` gives its harness. @@ -340,11 +390,27 @@ fn send( } queued_outcome(options, posted, postbox, &output.stdout, warnings) } - Err(failure) => Outcome { - exit_code: failure_exit_code(&failure), - json: failure_json(&posted.harness, &failure), - text: Text::Stderr(format!("error: {failure}")), - }, + Err(failure) => failure_outcome(&posted.harness, &failure), + } +} + +/// The harness's failure as `rune run` reports it. Where no sandbox hint +/// applies, a refused session name gets the hint that names its UUID. +fn failure_outcome(tool: &str, failure: &SurfaceFailure) -> Outcome { + let mut json = failure_json(tool, failure); + let mut text = format!("error: {failure}"); + if failure.hint().is_none() + && let Some(hint) = failure + .tails() + .and_then(|(_, stderr_tail)| session_hint(stderr_tail)) + { + text = format!("{text}\nhint: {hint}"); + json["hint"] = Value::String(hint); + } + Outcome { + exit_code: failure_exit_code(failure), + json, + text: Text::Stderr(text), } } @@ -373,8 +439,10 @@ fn unsupported_outcome(options: &PostOptions, tool: &str) -> Outcome { /// A message the harness took: the ids from its receipt line, or null ids /// and a warning when it printed none. The ledger records it as posted and -/// queued, so the hook never delivers it a second time. A ledger that -/// cannot be written is a warning: the message is already queued. +/// queued, so the hook never delivers it a second time, and the queued line +/// names the thread id of the receipt, so the session's hook finds it by +/// its id when it was posted by name. A ledger that cannot be written is a +/// warning: the message is already queued. fn queued_outcome( options: &PostOptions, posted: &ledger::Event, @@ -384,9 +452,14 @@ fn queued_outcome( ) -> Outcome { let tool = posted.harness.as_str(); let transport = Transport::CodexQueue; + let receipt = parse_receipt(stdout); let queued = ledger::Event { timestamp: ledger::now(), state: ledger::State::Queued, + session: receipt.as_ref().map_or_else( + || posted.session.clone(), + |receipt| receipt.thread_id.clone(), + ), message: String::new(), ..posted.clone() }; @@ -396,7 +469,6 @@ fn queued_outcome( eprintln!("warning: {warning}"); warnings.push(warning); } - let receipt = parse_receipt(stdout); let text = if let Some(receipt) = &receipt { format!( "queued message {} for {tool} thread {}", diff --git a/src/cli/queue/tests.rs b/src/cli/queue/tests.rs index 560959a7..ea91ab6c 100644 --- a/src/cli/queue/tests.rs +++ b/src/cli/queue/tests.rs @@ -66,6 +66,56 @@ fn output_without_a_receipt_line_has_no_receipt() { assert_eq!(parse_receipt("Queued something else\n"), None); } +#[test] +fn a_uuid_is_five_hex_groups_and_a_name_is_anything_else() { + assert!(is_uuid("01a15844-7b2e-71a0-aa88-b41f3c4622af")); + assert!(is_uuid("01A15844-7B2E-71A0-AA88-B41F3C4622AF")); + for name in [ + "ouroboros", + "Proton/ai-demo", + "01a15844-7b2e-71a0-aa88", + "01a15844-7b2e-71a0-aa88-b41f3c4622ag", + "01a15844-7b2e-71a0-aa88-b41f3c4622af-", + ] { + assert!(!is_uuid(name), "{name}"); + } + assert_eq!( + name_lookup_warning("01a15844-7b2e-71a0-aa88-b41f3c4622af"), + None + ); + let warning = name_lookup_warning("Proton/ai-demo").expect("a warning for a name"); + assert!(warning.contains("Proton/ai-demo"), "{warning}"); + assert!(warning.contains("session UUID"), "{warning}"); +} + +#[test] +fn a_refused_name_hints_at_the_uuid_codex_matched() { + let unverified = "Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af"; + assert_eq!( + session_hint(unverified).as_deref(), + Some( + "Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af: post with --session 01a15844-7b2e-71a0-aa88-b41f3c4622af" + ) + ); + let ambiguous = "Error: session name 'demo' matches 01a15844-7b2e-71a0-aa88-b41f3c4622af, 01a0abff-74d9-7390-b827-57ef47c982c2 (01a0abff-74d9-7390-b827-57ef47c982c2); use a session UUID to disambiguate."; + let hint = session_hint(ambiguous).expect("a hint"); + assert!( + hint.ends_with( + "sessions 01a15844-7b2e-71a0-aa88-b41f3c4622af, 01a0abff-74d9-7390-b827-57ef47c982c2: post with --session and the UUID of the one you mean" + ), + "{hint}" + ); + assert_eq!( + session_hint("Error: No active session found matching 'ouroboros'."), + None + ); + assert_eq!( + session_hint("thread 01a15844-7b2e-71a0-aa88-b41f3c4622af failed"), + None, + "a UUID without Codex's name refusal" + ); +} + #[test] fn profile_arguments_are_named_with_credentials_hidden() { assert_eq!(dropped_profile_args(&[]), None); @@ -170,6 +220,75 @@ fn hook_reads_nothing_where_the_harness_cannot_show_it() { assert_eq!(ledger::fold(&events)[0].state, ledger::State::Posted); } +fn queued_for_codex(path: &Path, id: &str, session: &str, text: &str) { + let posted = ledger::Event { + timestamp: ledger::now(), + id: id.to_string(), + state: ledger::State::Posted, + sender: "claude:42e43c0b".to_string(), + harness: "codex".to_string(), + session: session.to_string(), + message: text.to_string(), + }; + let queued = ledger::Event { + state: ledger::State::Queued, + message: String::new(), + ..posted.clone() + }; + ledger::append(path, &[posted, queued]).expect("queue"); +} + +fn prompt_payload(session: &str, prompt: &str) -> crate::cli::hook::payload::HandlerPayload { + crate::cli::hook::payload::HandlerPayload { + prompt: Some(prompt.to_string()), + ..hook_payload("codex", "prompt.before", session) + } +} + +#[test] +fn a_codex_turn_that_starts_with_a_queued_message_marks_it_read() { + use crate::cli::hook::adapters::postbox_at; + let folder = tempfile::tempdir().expect("folder"); + let path = folder.path().join(ledger::FILE_NAME); + queued_for_codex(&path, "m-1", "01a0abff", "Is the deck ready?"); + queued_for_codex(&path, "m-2", "01a0abff", "Is the proof recorded?"); + queued_for_codex(&path, "m-3", "019a2222", "Is the deck ready?"); + + let result = + postbox_at(&prompt_payload("01a0abff", "Is the deck ready?\n"), &path).expect("hook"); + assert!( + result.context.is_empty() && result.reason.is_none(), + "Codex takes no context on a prompt: {result:?}" + ); + let (events, _) = ledger::load(&path).expect("load"); + let states: Vec<(String, ledger::State)> = ledger::fold(&events) + .into_iter() + .map(|message| (message.id, message.state)) + .collect(); + assert_eq!( + states, + [ + ("m-1".to_string(), ledger::State::Read), + ("m-2".to_string(), ledger::State::Queued), + ("m-3".to_string(), ledger::State::Queued), + ], + "only the message the turn started with, for this session" + ); +} + +#[test] +fn a_prompt_of_the_owner_leaves_queued_messages_queued() { + use crate::cli::hook::adapters::postbox_at; + let folder = tempfile::tempdir().expect("folder"); + let path = folder.path().join(ledger::FILE_NAME); + queued_for_codex(&path, "m-1", "01a0abff", "Is the deck ready?"); + + postbox_at(&prompt_payload("01a0abff", "Run the tests"), &path).expect("hook"); + postbox_at(&hook_payload("codex", "prompt.before", "01a0abff"), &path).expect("hook"); + let (events, _) = ledger::load(&path).expect("load"); + assert_eq!(ledger::fold(&events)[0].state, ledger::State::Queued); +} + #[test] fn the_named_remote_token_is_hidden_whatever_its_name() { let env = [ diff --git a/templates/skill/SKILL.md b/templates/skill/SKILL.md index 8a7567d6..33008228 100644 --- a/templates/skill/SKILL.md +++ b/templates/skill/SKILL.md @@ -55,7 +55,7 @@ rune queue read --session # where no session variable names you rune queue list --state posted # look without marking anything read ``` -Claude Code and Codex sessions with the `postbox` hook get their messages at the next turn. Any other session runs `rune queue read --session ` when a task starts and between steps. Answer a message by posting to its sender, who is named as `harness:session`. +Claude Code and Codex sessions with the `postbox` hook get their messages at the next turn. Any other session runs `rune queue read --session ` when a task starts and between steps. Answer a message by posting to its sender, who is named as `harness:session`. Name a Codex session by its UUID: Codex searches its server page by page for a name, which can take a minute or more. ## Turn Wrapping diff --git a/tests/queue.rs b/tests/queue.rs index bd35940a..dfca0d1e 100644 --- a/tests/queue.rs +++ b/tests/queue.rs @@ -446,6 +446,101 @@ fn harness_failure_passes_its_status_and_its_stderr_through() { ); } +#[cfg(unix)] +#[test] +fn a_name_resolves_to_the_receipt_thread_and_its_turn_marks_it_read() { + let home = tempfile::tempdir().expect("home"); + let codex = fake_codex(home.path(), RECEIPT, "", 0); + + rune(home.path()) + .args(["queue", "post", "codex", "--session", "ouroboros"]) + .args(["--binary", &codex, "Is the deck ready?"]) + .assert() + .success() + .stderr(predicate::str::contains( + "warning: Codex looks the name ouroboros up page by page", + )); + + // The turn the queue starts carries the message as its prompt. + let payload = serde_json::json!({ + "v": 1, + "harness": "codex", + "event": "prompt.before", + "native_event": "UserPromptSubmit", + "session_id": "019a-ouroboros", + "prompt": "Is the deck ready?", + "raw": {}, + }); + let output = rune(home.path()) + .args(["hook", "adapter", "postbox"]) + .write_stdin(payload.to_string()) + .output() + .expect("adapter output"); + assert_eq!(output.status.code(), Some(0)); + assert_eq!(json_of(&output)["effect"], "pass"); + + let output = rune(home.path()) + .args(["--json", "queue", "list"]) + .output() + .expect("list output"); + let message = &json_of(&output)["messages"][0]; + assert_eq!(message["session"], "019a-ouroboros", "{message}"); + assert_eq!(message["state"], "read", "{message}"); +} + +#[cfg(unix)] +#[test] +fn a_session_uuid_gets_no_name_warning() { + let home = tempfile::tempdir().expect("home"); + let codex = fake_codex(home.path(), RECEIPT, "", 0); + + rune(home.path()) + .args(["queue", "post", "codex", "--session"]) + .args([ + "01a15844-7b2e-71a0-aa88-b41f3c4622af", + "--binary", + &codex, + "hi", + ]) + .assert() + .success() + .stderr(predicate::str::contains("warning").not()); +} + +#[cfg(unix)] +#[test] +fn a_refused_name_hints_at_the_uuid_codex_matched() { + let home = tempfile::tempdir().expect("home"); + let codex = fake_codex( + home.path(), + "", + "Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af", + 1, + ); + let post = ["queue", "post", "codex", "--session", "Proton/ai-demo"]; + + let output = rune(home.path()) + .arg("--json") + .args(post) + .args(["--binary", &codex, "hi"]) + .output() + .expect("queue output"); + assert_eq!(output.status.code(), Some(1)); + assert_eq!( + json_of(&output)["hint"], + "Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af: post with --session 01a15844-7b2e-71a0-aa88-b41f3c4622af" + ); + rune(home.path()) + .args(post) + .args(["--binary", &codex, "hi"]) + .assert() + .code(1) + .stderr(predicate::str::contains( + "hint: Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af", + )); + assert!(postbox(home.path()).is_empty(), "nothing was recorded"); +} + #[cfg(unix)] #[test] fn missing_receipt_still_reports_success_with_a_warning() { From 2019c64bc794044a8fb9d45518484edf67ca85b5 Mon Sep 17 00:00:00 2001 From: "Claude Opus 5.5 (claude-opus-5-5)" Date: Wed, 28 Oct 2026 02:35:29 +0100 Subject: [PATCH 2/3] test(proof): scenes for queue-records-codex-reads Co-Authored-By: Martin Zeman --- .../queue-records-codex-reads/README.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 docs/proofs/queue-records-codex-reads/README.md diff --git a/docs/proofs/queue-records-codex-reads/README.md b/docs/proofs/queue-records-codex-reads/README.md new file mode 100644 index 00000000..268c5fee --- /dev/null +++ b/docs/proofs/queue-records-codex-reads/README.md @@ -0,0 +1,95 @@ +--- +type: proof +change: queue-records-codex-reads +head: 94706b41a3d16388dfb9d6e1269f4c09a97aecf6 +head_change: wvzquvsnqmpxtsvmlwvuxzqnmzkvuvsn +head_tree: fb1bd370f38496cb83b5ee9c1383ade1730d4f75 +recorded: 2026-10-28 +transcript: 0c03d74e27d6456e31970446cee2eb1244529ccfcb1e90cd2be32a401bb26957 +scenes: +- scenario: queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/codex-turn-starts-with-a-queued-message + kind: check +- scenario: queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/owner-prompt-leaves-the-queue-alone + kind: check +- scenario: queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/refused-name-names-its-uuid + kind: check +- scenario: queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/session-uuid-gets-no-warning + kind: check +--- + +# Proof: queue-records-codex-reads + +One scene per scenario, in closure order. Every scene gives rune a HOME of its own, `home`, so the postbox is `home/.rune/postbox.tsv` and the owner's ledger is never touched. A Codex scene writes a fake `codex` that prints the receipt line or the name refusal of Codex 0.154.0, and runs it with `--binary`, so no Codex app server is reached. The hook scenes hand `rune hook adapter postbox` the payload the dispatcher builds from Codex's `UserPromptSubmit`, with the prompt. Each post names its sender with `--from`, so the recorder's own harness session does not show. Message ids and timestamps change on every run and are elided. `mlr` reads the ledger as the tab-separated table it is. + +## queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/codex-turn-starts-with-a-queued-message + +```console +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-41 for thread 019a-ouroboros.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session ouroboros --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" +warning: Codex looks the name ouroboros up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search +queued message msg-41 for codex thread 019a-ouroboros +$ HOME=home rune hook adapter postbox +< {"v":1,"harness":"codex","event":"prompt.before","native_event":"UserPromptSubmit","session_id":"019a-ouroboros","prompt":"Is the deck ready?","raw":{}} +{"v":1,"effect":"pass","reason":null,"input":null,"context":[]} +$ mlr --itsv --opprint cut -o -f state,sender,harness,session home/.rune/postbox.tsv +state sender harness session +posted claude:42e43c0b codex ouroboros +queued claude:42e43c0b codex 019a-ouroboros +read claude:42e43c0b codex 019a-ouroboros +$ HOME=home rune queue list +[..] read claude:42e43c0b -> codex:019a-ouroboros Is the deck ready? +``` + +## queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/owner-prompt-leaves-the-queue-alone + +```console +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-42 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session 01a15844-7b2e-71a0-aa88-b41f3c4622af --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" +queued message msg-42 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af +$ HOME=home rune hook adapter postbox +< {"v":1,"harness":"codex","event":"prompt.before","native_event":"UserPromptSubmit","session_id":"01a15844-7b2e-71a0-aa88-b41f3c4622af","prompt":"Run the tests","raw":{}} +{"v":1,"effect":"pass","reason":null,"input":null,"context":[]} +$ HOME=home rune queue list +[..] queued claude:42e43c0b -> codex:01a15844-7b2e-71a0-aa88-b41f3c4622af Is the deck ready? +``` + +## queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/refused-name-names-its-uuid + +```console +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af' >&2 +< exit 1 +< EOF +< chmod +x fake-codex +$ HOME=home rune --json queue post codex --session Proton/ai-demo --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" +? 1 +warning: Codex looks the name Proton/ai-demo up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search +{"details":{"exit_code":1,"harness_errors":[],"stderr_tail":"Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af","stdout_tail":""},"exit_code":1,"hint":"Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af: post with --session 01a15844-7b2e-71a0-aa88-b41f3c4622af","kind":"exit","ok":false,"tool":"codex"} +$ sh -c 'test ! -e home/.rune/postbox.tsv && echo "nothing recorded"' +nothing recorded +``` + +## queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/session-uuid-gets-no-warning + +```console +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-43 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session 01a15844-7b2e-71a0-aa88-b41f3c4622af --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" +queued message msg-43 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af +``` From 8357e19f782da820f09fd719f0abbbdebfc7c776 Mon Sep 17 00:00:00 2001 From: "Claude Opus 5.5 (claude-opus-5-5)" Date: Wed, 28 Oct 2026 02:40:40 +0100 Subject: [PATCH 3/3] docs(proof): record queue-records-codex-reads, 4 of 4 scenes Co-Authored-By: Martin Zeman --- .../queue-records-codex-reads/README.md | 6 +- .../queue-records-codex-reads/proof.cast | 278 ++++++++++++++++++ .../queue-records-codex-reads/proof.txt | 64 ++++ 3 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 docs/proofs/queue-records-codex-reads/proof.cast create mode 100644 docs/proofs/queue-records-codex-reads/proof.txt diff --git a/docs/proofs/queue-records-codex-reads/README.md b/docs/proofs/queue-records-codex-reads/README.md index 268c5fee..5659d367 100644 --- a/docs/proofs/queue-records-codex-reads/README.md +++ b/docs/proofs/queue-records-codex-reads/README.md @@ -1,11 +1,11 @@ --- type: proof change: queue-records-codex-reads -head: 94706b41a3d16388dfb9d6e1269f4c09a97aecf6 +head: 2019c64bc794044a8fb9d45518484edf67ca85b5 head_change: wvzquvsnqmpxtsvmlwvuxzqnmzkvuvsn -head_tree: fb1bd370f38496cb83b5ee9c1383ade1730d4f75 +head_tree: 26119afdb345cf835b9ac60f14a04df6465dc022 recorded: 2026-10-28 -transcript: 0c03d74e27d6456e31970446cee2eb1244529ccfcb1e90cd2be32a401bb26957 +transcript: ed2d89946fd00f164d3e4e60a5d4df2654df2bc5928c9b1a88bac62ddc4bd5df scenes: - scenario: queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/codex-turn-starts-with-a-queued-message kind: check diff --git a/docs/proofs/queue-records-codex-reads/proof.cast b/docs/proofs/queue-records-codex-reads/proof.cast new file mode 100644 index 00000000..1b033039 --- /dev/null +++ b/docs/proofs/queue-records-codex-reads/proof.cast @@ -0,0 +1,278 @@ +{"version":2,"width":100,"height":30,"timestamp":1793151639,"env":{"SHELL":"/bin/sh","TERM":"xterm-256color"}} +[0.0,"o","\r\n\u001b[1;36m── queue-messages-for-sessions · 4 scenes ──────────────────────────────────────────────────────────\u001b[0m\r\n"] +[1.2,"o","\r\n\u001b[2m┌───────────────────────────────────────────────┐\u001b[0m\r\n\u001b[2m│\u001b[0m \u001b[1m1/4 · Codex turn starts with a queued message\u001b[0m \u001b[2m│\u001b[0m\r\n\u001b[2m└───────────────────────────────────────────────┘\u001b[0m\r\n\u001b[35mcheck\u001b[0m \u001b[2ma queued message is read when its turn starts\u001b[0m\r\n"] +[2.4,"o","\u001b[1;32m❯\u001b[0m "] +[2.4,"o","sh"] +[2.46,"o"," "] +[2.46,"o","-s"] +[2.52,"o","\r\n"] +[2.52,"o","\u001b[2m< cat > fake-codex <<'EOF'\u001b[0m\r\n"] +[2.58,"o","\u001b[2m< #!/bin/sh\u001b[0m\r\n"] +[2.64,"o","\u001b[2m< echo 'Queued message msg-41 for thread 019a-ouroboros.'\u001b[0m\r\n"] +[2.7,"o","\u001b[2m< EOF\u001b[0m\r\n"] +[2.76,"o","\u001b[2m< chmod +x fake-codex\u001b[0m\r\n"] +[3.37,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0\u001b[0m\r\n"] +[3.77,"o","\u001b[1;32m❯\u001b[0m "] +[3.77,"o","HOME=home"] +[3.83,"o"," "] +[3.83,"o","rune"] +[3.89,"o"," "] +[3.89,"o","queue"] +[3.95,"o"," "] +[3.95,"o","post"] +[4.01,"o"," "] +[4.01,"o","codex"] +[4.07,"o"," "] +[4.07,"o","--session"] +[4.13,"o"," "] +[4.13,"o","ouroboros"] +[4.19,"o"," "] +[4.19,"o","--from"] +[4.25,"o"," "] +[4.25,"o","claude:42e43c0b"] +[4.31,"o"," "] +[4.31,"o","--binary"] +[4.37,"o"," "] +[4.37,"o","./fake-codex"] +[4.43,"o"," "] +[4.43,"o","\"Is"] +[4.49,"o"," "] +[4.49,"o","the"] +[4.55,"o"," "] +[4.55,"o","deck"] +[4.61,"o"," "] +[4.61,"o","ready?\""] +[4.67,"o","\r\n"] +[4.82,"o","warning: Codex looks the name ouroboros up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search\r\nqueued message msg-41 for codex thread 019a-ouroboros\r\n"] +[5.22,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[5.62,"o","\u001b[1;32m❯\u001b[0m "] +[5.62,"o","HOME=home"] +[5.68,"o"," "] +[5.68,"o","rune"] +[5.74,"o"," "] +[5.74,"o","hook"] +[5.8,"o"," "] +[5.8,"o","adapter"] +[5.86,"o"," "] +[5.86,"o","postbox"] +[5.92,"o","\r\n"] +[5.92,"o","\u001b[2m< {\"v\":1,\"harness\":\"codex\",\"event\":\"prompt.before\",\"native_event\":\"UserPromptSubmit\",\"session_id\":\"019a-ouroboros\",\"prompt\":\"Is the deck ready?\",\"raw\":{}}\u001b[0m\r\n"] +[6.13,"o","{\"v\":1,\"effect\":\"pass\",\"reason\":null,\"input\":null,\"context\":[]}\r\n"] +[6.53,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[6.93,"o","\u001b[1;32m❯\u001b[0m "] +[6.93,"o","mlr"] +[6.99,"o"," "] +[6.99,"o","--itsv"] +[7.05,"o"," "] +[7.05,"o","--opprint"] +[7.11,"o"," "] +[7.11,"o","cut"] +[7.17,"o"," "] +[7.17,"o","-o"] +[7.23,"o"," "] +[7.23,"o","-f"] +[7.29,"o"," "] +[7.29,"o","state,sender,harness,session"] +[7.35,"o"," "] +[7.35,"o","home/.rune/postbox.tsv"] +[7.41,"o","\r\n"] +[7.56,"o","state sender harness session\r\nposted claude:42e43c0b codex ouroboros\r\nqueued claude:42e43c0b codex 019a-ouroboros\r\nread claude:42e43c0b codex 019a-ouroboros\r\n"] +[7.96,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[8.36,"o","\u001b[1;32m❯\u001b[0m "] +[8.36,"o","HOME=home"] +[8.42,"o"," "] +[8.42,"o","rune"] +[8.48,"o"," "] +[8.48,"o","queue"] +[8.54,"o"," "] +[8.54,"o","list"] +[8.6,"o","\r\n"] +[8.75,"o","2026-10-28T01:40:39.347Z 01a1802a9f33-52339187 read claude:42e43c0b -> codex:019a-ouroboros Is the deck ready?\r\n"] +[9.15,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[12.55,"o","\r\n\u001b[2m┌───────────────────────────────────────────┐\u001b[0m\r\n\u001b[2m│\u001b[0m \u001b[1m2/4 · Owner prompt leaves the queue alone\u001b[0m \u001b[2m│\u001b[0m\r\n\u001b[2m└───────────────────────────────────────────┘\u001b[0m\r\n\u001b[35mcheck\u001b[0m \u001b[2ma queued message is read when its turn starts\u001b[0m\r\n"] +[13.75,"o","\u001b[1;32m❯\u001b[0m "] +[13.75,"o","sh"] +[13.81,"o"," "] +[13.81,"o","-s"] +[13.87,"o","\r\n"] +[13.87,"o","\u001b[2m< cat > fake-codex <<'EOF'\u001b[0m\r\n"] +[13.93,"o","\u001b[2m< #!/bin/sh\u001b[0m\r\n"] +[13.99,"o","\u001b[2m< echo 'Queued message msg-42 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.'\u001b[0m\r\n"] +[14.05,"o","\u001b[2m< EOF\u001b[0m\r\n"] +[14.11,"o","\u001b[2m< chmod +x fake-codex\u001b[0m\r\n"] +[14.72,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0\u001b[0m\r\n"] +[15.12,"o","\u001b[1;32m❯\u001b[0m "] +[15.12,"o","HOME=home"] +[15.18,"o"," "] +[15.18,"o","rune"] +[15.24,"o"," "] +[15.24,"o","queue"] +[15.3,"o"," "] +[15.3,"o","post"] +[15.36,"o"," "] +[15.36,"o","codex"] +[15.42,"o"," "] +[15.42,"o","--session"] +[15.48,"o"," "] +[15.48,"o","01a15844-7b2e-71a0-aa88-b41f3c4622af"] +[15.54,"o"," "] +[15.54,"o","--from"] +[15.6,"o"," "] +[15.6,"o","claude:42e43c0b"] +[15.66,"o"," "] +[15.66,"o","--binary"] +[15.72,"o"," "] +[15.72,"o","./fake-codex"] +[15.78,"o"," "] +[15.78,"o","\"Is"] +[15.84,"o"," "] +[15.84,"o","the"] +[15.9,"o"," "] +[15.9,"o","deck"] +[15.96,"o"," "] +[15.96,"o","ready?\""] +[16.02,"o","\r\n"] +[16.17,"o","queued message msg-42 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af\r\n"] +[16.57,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[16.97,"o","\u001b[1;32m❯\u001b[0m "] +[16.97,"o","HOME=home"] +[17.03,"o"," "] +[17.03,"o","rune"] +[17.09,"o"," "] +[17.09,"o","hook"] +[17.15,"o"," "] +[17.15,"o","adapter"] +[17.21,"o"," "] +[17.21,"o","postbox"] +[17.27,"o","\r\n"] +[17.27,"o","\u001b[2m< {\"v\":1,\"harness\":\"codex\",\"event\":\"prompt.before\",\"native_event\":\"UserPromptSubmit\",\"session_id\":\"01a15844-7b2e-71a0-aa88-b41f3c4622af\",\"prompt\":\"Run the tests\",\"raw\":{}}\u001b[0m\r\n"] +[17.48,"o","{\"v\":1,\"effect\":\"pass\",\"reason\":null,\"input\":null,\"context\":[]}\r\n"] +[17.88,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[18.28,"o","\u001b[1;32m❯\u001b[0m "] +[18.28,"o","HOME=home"] +[18.34,"o"," "] +[18.34,"o","rune"] +[18.4,"o"," "] +[18.4,"o","queue"] +[18.46,"o"," "] +[18.46,"o","list"] +[18.52,"o","\r\n"] +[18.67,"o","2026-10-28T01:40:39.589Z 01a1802aa025-0661f8d5 queued claude:42e43c0b -> codex:01a15844-7b2e-71a0-aa88-b41f3c4622af Is the deck ready?\r\n"] +[19.07,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[22.47,"o","\r\n\u001b[2m┌───────────────────────────────────┐\u001b[0m\r\n\u001b[2m│\u001b[0m \u001b[1m3/4 · Refused name names its uuid\u001b[0m \u001b[2m│\u001b[0m\r\n\u001b[2m└───────────────────────────────────┘\u001b[0m\r\n\u001b[35mcheck\u001b[0m \u001b[2ma codex session name leads to its uuid\u001b[0m\r\n"] +[23.67,"o","\u001b[1;32m❯\u001b[0m "] +[23.67,"o","sh"] +[23.73,"o"," "] +[23.73,"o","-s"] +[23.79,"o","\r\n"] +[23.79,"o","\u001b[2m< cat > fake-codex <<'EOF'\u001b[0m\r\n"] +[23.85,"o","\u001b[2m< #!/bin/sh\u001b[0m\r\n"] +[23.91,"o","\u001b[2m< echo 'Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af' >&2\u001b[0m\r\n"] +[23.97,"o","\u001b[2m< exit 1\u001b[0m\r\n"] +[24.03,"o","\u001b[2m< EOF\u001b[0m\r\n"] +[24.09,"o","\u001b[2m< chmod +x fake-codex\u001b[0m\r\n"] +[24.7,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0\u001b[0m\r\n"] +[25.1,"o","\u001b[1;32m❯\u001b[0m "] +[25.1,"o","HOME=home"] +[25.16,"o"," "] +[25.16,"o","rune"] +[25.22,"o"," "] +[25.22,"o","--json"] +[25.28,"o"," "] +[25.28,"o","queue"] +[25.34,"o"," "] +[25.34,"o","post"] +[25.4,"o"," "] +[25.4,"o","codex"] +[25.46,"o"," "] +[25.46,"o","--session"] +[25.52,"o"," "] +[25.52,"o","Proton/ai-demo"] +[25.58,"o"," "] +[25.58,"o","--from"] +[25.64,"o"," "] +[25.64,"o","claude:42e43c0b"] +[25.7,"o"," "] +[25.7,"o","--binary"] +[25.76,"o"," "] +[25.76,"o","./fake-codex"] +[25.82,"o"," "] +[25.82,"o","\"Is"] +[25.88,"o"," "] +[25.88,"o","the"] +[25.94,"o"," "] +[25.94,"o","deck"] +[26.0,"o"," "] +[26.0,"o","ready?\""] +[26.06,"o","\r\n"] +[26.21,"o","warning: Codex looks the name Proton/ai-demo up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search\r\n{\"details\":{\"exit_code\":1,\"harness_errors\":[],\"stderr_tail\":\"Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af\",\"stdout_tail\":\"\"},\"exit_code\":1,\"hint\":\"Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af: post with --session 01a15844-7b2e-71a0-aa88-b41f3c4622af\",\"kind\":\"exit\",\"ok\":false,\"tool\":\"codex\"}\r\n"] +[26.61,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 1 as expected · output matches\u001b[0m\r\n"] +[27.01,"o","\u001b[1;32m❯\u001b[0m "] +[27.01,"o","sh"] +[27.07,"o"," "] +[27.07,"o","-c"] +[27.13,"o"," "] +[27.13,"o","'test"] +[27.19,"o"," "] +[27.19,"o","!"] +[27.25,"o"," "] +[27.25,"o","-e"] +[27.31,"o"," "] +[27.31,"o","home/.rune/postbox.tsv"] +[27.37,"o"," "] +[27.37,"o","&&"] +[27.43,"o"," "] +[27.43,"o","echo"] +[27.49,"o"," "] +[27.49,"o","\"nothing"] +[27.55,"o"," "] +[27.55,"o","recorded\"'"] +[27.61,"o","\r\n"] +[27.76,"o","nothing recorded\r\n"] +[28.16,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[31.56,"o","\r\n\u001b[2m┌────────────────────────────────────┐\u001b[0m\r\n\u001b[2m│\u001b[0m \u001b[1m4/4 · Session uuid gets no warning\u001b[0m \u001b[2m│\u001b[0m\r\n\u001b[2m└────────────────────────────────────┘\u001b[0m\r\n\u001b[35mcheck\u001b[0m \u001b[2ma codex session name leads to its uuid\u001b[0m\r\n"] +[32.76,"o","\u001b[1;32m❯\u001b[0m "] +[32.76,"o","sh"] +[32.82,"o"," "] +[32.82,"o","-s"] +[32.88,"o","\r\n"] +[32.88,"o","\u001b[2m< cat > fake-codex <<'EOF'\u001b[0m\r\n"] +[32.94,"o","\u001b[2m< #!/bin/sh\u001b[0m\r\n"] +[33.0,"o","\u001b[2m< echo 'Queued message msg-43 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.'\u001b[0m\r\n"] +[33.06,"o","\u001b[2m< EOF\u001b[0m\r\n"] +[33.12,"o","\u001b[2m< chmod +x fake-codex\u001b[0m\r\n"] +[33.73,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0\u001b[0m\r\n"] +[34.13,"o","\u001b[1;32m❯\u001b[0m "] +[34.13,"o","HOME=home"] +[34.19,"o"," "] +[34.19,"o","rune"] +[34.25,"o"," "] +[34.25,"o","queue"] +[34.31,"o"," "] +[34.31,"o","post"] +[34.37,"o"," "] +[34.37,"o","codex"] +[34.43,"o"," "] +[34.43,"o","--session"] +[34.49,"o"," "] +[34.49,"o","01a15844-7b2e-71a0-aa88-b41f3c4622af"] +[34.55,"o"," "] +[34.55,"o","--from"] +[34.61,"o"," "] +[34.61,"o","claude:42e43c0b"] +[34.67,"o"," "] +[34.67,"o","--binary"] +[34.73,"o"," "] +[34.73,"o","./fake-codex"] +[34.79,"o"," "] +[34.79,"o","\"Is"] +[34.85,"o"," "] +[34.85,"o","the"] +[34.91,"o"," "] +[34.91,"o","deck"] +[34.97,"o"," "] +[34.97,"o","ready?\""] +[35.03,"o","\r\n"] +[35.18,"o","queued message msg-43 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af\r\n"] +[35.58,"o","\u001b[32m✓\u001b[0m \u001b[2mexit 0 · output matches\u001b[0m\r\n"] +[38.98,"o","\r\n\u001b[1;32m4 scenes · 4 proven · 0 unproven\u001b[0m\r\n"] diff --git a/docs/proofs/queue-records-codex-reads/proof.txt b/docs/proofs/queue-records-codex-reads/proof.txt new file mode 100644 index 00000000..ae773d42 --- /dev/null +++ b/docs/proofs/queue-records-codex-reads/proof.txt @@ -0,0 +1,64 @@ +## queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/codex-turn-starts-with-a-queued-message +kind: check +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-41 for thread 019a-ouroboros.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session ouroboros --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" + warning: Codex looks the name ouroboros up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search + queued message msg-41 for codex thread 019a-ouroboros +$ HOME=home rune hook adapter postbox +< {"v":1,"harness":"codex","event":"prompt.before","native_event":"UserPromptSubmit","session_id":"019a-ouroboros","prompt":"Is the deck ready?","raw":{}} + {"v":1,"effect":"pass","reason":null,"input":null,"context":[]} +$ mlr --itsv --opprint cut -o -f state,sender,harness,session home/.rune/postbox.tsv + state sender harness session + posted claude:42e43c0b codex ouroboros + queued claude:42e43c0b codex 019a-ouroboros + read claude:42e43c0b codex 019a-ouroboros +$ HOME=home rune queue list + 2026-10-28T01:40:39.347Z 01a1802a9f33-52339187 read claude:42e43c0b -> codex:019a-ouroboros Is the deck ready? + +## queue-messages-for-sessions#a-queued-message-is-read-when-its-turn-starts/owner-prompt-leaves-the-queue-alone +kind: check +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-42 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session 01a15844-7b2e-71a0-aa88-b41f3c4622af --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" + queued message msg-42 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af +$ HOME=home rune hook adapter postbox +< {"v":1,"harness":"codex","event":"prompt.before","native_event":"UserPromptSubmit","session_id":"01a15844-7b2e-71a0-aa88-b41f3c4622af","prompt":"Run the tests","raw":{}} + {"v":1,"effect":"pass","reason":null,"input":null,"context":[]} +$ HOME=home rune queue list + 2026-10-28T01:40:39.589Z 01a1802aa025-0661f8d5 queued claude:42e43c0b -> codex:01a15844-7b2e-71a0-aa88-b41f3c4622af Is the deck ready? + +## queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/refused-name-names-its-uuid +kind: check +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af' >&2 +< exit 1 +< EOF +< chmod +x fake-codex +$ HOME=home rune --json queue post codex --session Proton/ai-demo --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" + warning: Codex looks the name Proton/ai-demo up page by page across its server's sessions, which can take a minute or more; a session UUID needs no search + {"details":{"exit_code":1,"harness_errors":[],"stderr_tail":"Error: Cannot verify a unique session label across server pages; matching session UUID: 01a15844-7b2e-71a0-aa88-b41f3c4622af","stdout_tail":""},"exit_code":1,"hint":"Codex matched the name to session 01a15844-7b2e-71a0-aa88-b41f3c4622af: post with --session 01a15844-7b2e-71a0-aa88-b41f3c4622af","kind":"exit","ok":false,"tool":"codex"} +$ sh -c 'test ! -e home/.rune/postbox.tsv && echo "nothing recorded"' + nothing recorded + +## queue-messages-for-sessions#a-codex-session-name-leads-to-its-uuid/session-uuid-gets-no-warning +kind: check +$ sh -s +< cat > fake-codex <<'EOF' +< #!/bin/sh +< echo 'Queued message msg-43 for thread 01a15844-7b2e-71a0-aa88-b41f3c4622af.' +< EOF +< chmod +x fake-codex +$ HOME=home rune queue post codex --session 01a15844-7b2e-71a0-aa88-b41f3c4622af --from claude:42e43c0b --binary ./fake-codex "Is the deck ready?" + queued message msg-43 for codex thread 01a15844-7b2e-71a0-aa88-b41f3c4622af +