Skip to content

fix(shared): the session-ledger recipe writes /tmp quote files that trip the approvals reviewer; derive run-ids in a helper #779

Description

@thewrz

This was written agentically; verify its assertions:

North star

Six times on 2026-09-16 a Codex approvals-reviewer session was spun up to judge a session-ledger.sh append, costing 290k tokens and 5-9 s each, all verdict allow. Every one was triggered by the recipe at parallel-issues/SKILL.md:117-119: quote_file=$(mktemp) lands in /tmp, outside the workspace roots, so the harness asks. The helper already accepts --quote TEXT inline (.shared/scripts/session-ledger.sh:28-31). Separately the root hand-hashed three different strings to derive run-ids and produced two ids for the same PR (review-pr-7dcf51e0… and review-pr-f7aae90d… for #511), so the ledger holds three receipts for one grant.

North star rules this change must obey

  • Runbook first, hooks second. The skill preamble (env contract, helper output, composed prompt) hands the agent a complete runbook before the first mutating call. Hooks only nudge when the agent drifts; a hook or guard that manufactures tool calls is itself a defect.
  • No new refusal that a retry can trip. The remedy for every failure path is a helper that does the right thing or an exact line to paste, never "run it again". A stricter kit makes the agent try harder and burn turns getting blocked.
  • Diff shape: negative in prose (agentkit/skills/**/*.md), positive in scripts, hooks, or tests. If the prose line count goes up, the PR needs a stated reason.
  • Show the number it buys. Every acceptance criterion below is measurable on the next parallel-issues run from the rollout files.

Problem

A recipe that writes outside the workspace is a recipe that costs an approval; a run-id computed by the model is a run-id computed differently every time. Both are helper jobs.

Change

Prose (cut):

  • parallel-issues/SKILL.md:117-119, review-remote-pr/SKILL.md and pr-to-green/SKILL.md equivalents: replace the mktemp recipe with the one-line session-ledger.sh append … --quote "$QUOTE"; delete the run-id derivation formulas (printf 'scope=…;flags=…' | sha256sum | cut -c1-32).

Scripts (add):

  • .shared/scripts/session-ledger.sh: new run-id --procedure-set NAME --scope CSV [--flags CSV] --repo SLUG --base BRANCH printing the canonical id; append accepts --quote-stdin for multi-line quotes so no temp file is ever needed; if a temp file is still required, create it under $repo_root/.agent/cache.
  • review-remote-pr/scripts/run-dir.sh: derive from session-ledger.sh run-id.
  • tests/test-session-ledger-run-id.sh: same inputs → same id; scope order-insensitive; a second append with identical decision/scope/quote/run-id is a no-op that prints the existing record.

Acceptance criteria

  • Next run: approvals-reviewer evaluations attributable to ledger appends = 0 (was 6).
  • grep -rn 'mktemp' agentkit/skills/**/*.md returns 0 lines.
  • One run-id per (procedure, scope); duplicate receipts = 0.

🤖 Co-authored by Claude Fable 5.1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/skillsThe three skills and their proceduresbugSomething isn't workingp1Blocks public release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions