Skip to content

Fix Grok read-only cancellation and preserve runner failure evidence #78

Closed

Description

@cliffordfajardo

A Grok read-only review on Open Pstack 1.4.1 ended with a tool permission cancellation, but the runner reported malformed-output and erased the provider model/session/usage evidence.

The CLI completed two model calls using grok-4.6-build, then a headless plan-mode permission request for a compound git diff command was cancelled. The CLI exited 0 with a failure result. parseGrok throws a generic error for that valid terminal result; executeLane treats it as malformed output. Its evidence keeps the first 4,000 characters of stderr followed by stdout, so startup warnings hide the actual failure.

A deterministic CLI replay with a valid cancelled terminal event and more than 4,000 stderr characters reproduces wrapper exit 65, status malformed-output, reportedModel null, and loss of the cancellation reason.

The live review retry completed with grok-4.6-build using only read_file,grep,list_dir while retaining plan mode and the read-only sandbox.

Proposed fix:

  • Use file-only tools for Grok read-only lanes; retain shell in isolated-write lanes.
  • Distinguish provider failure/cancellation from malformed output and preserve reason/model/session/usage.
  • Save separate complete stdout/stderr artifacts safely and identify them in the receipt.
  • Add regression coverage for warning-heavy cancellation, malformed output, and artifact collisions.

Related to #34, but this does not change isolated-write permission policy or use bypassPermissions.

Activity

  1. smashru commented on Sep 24, 2026

    @smashru

    Reader tool-policy candidate: https://github.com/smashru/open-pstack/tree/fix/grok-lanes-headless at 88dd41d, stacked on the #84 branch. The final diff removes run_terminal_cmd from Grok read-only tools. It leaves terminal and file edit tools available to isolated writers.

    Live worktree launcher proof in a throwaway Git repo: Grok 4.7 high reader used read_file, returned cobalt, and recorded exit 0 / complete with grok-4.7-build. Grok 4.7 high writer used write, search_replace, git add, and git commit, with allow decisions in events.jsonl; commit 52350acc1c2da111bb1360c42256109a28d713fc contains both requested files. Codex GPT-6 Sol high isolated writer created and read back a new file, exit 0 / complete. Bun tests: 162 passed, 0 failed. Strict typecheck, static invariants, and plugin validation passed.

    The installed plugin was not changed. This branch addresses the read-only tool policy and live lane proof; the broader output-artifact work in this issue remains open. No PR was opened.

  2. ericlitman commented on Oct 1, 2026

    @ericlitman
    Owner

    Prior art: #79, #81, and smashru's branch noted above. Planned as one PR with #34.

  3. ericlitman commented on Oct 2, 2026

    @ericlitman
    Owner

    Operator live test for MASTRA-751 (mobilyze-llc/factory#92, deployed 269bdfe): this comment on a Delivery card in Plan review should create no Factory triage proposal or run. No action needed.

  4. Repository owner deleted a comment from mast-factory on Oct 2, 2026
  5. ericlitman commented on Oct 4, 2026

    @ericlitman
    Owner

    Factory plan verdict: revise

    • Card: Delivery aebdac57, plan-review revision 7.
    • Plan reviewed: plan messages 60c5bd2f and 34049ccf, posted 2026-09-23 against release commit de67e6b.
    • Planner model: gpt-5.6-sol, from the plan session's message metadata.
    • Reviewer model: Claude Opus 5.5, reviewing in a separate context.
    • Rubric: the factory-adjudicate plan checklist.

    Why revise

    The plan predates PR #116, which merged on 2026-10-03. Two checklist gates fail on current main (be66d68).

    1. Conflicts with a settled decision (Phase 2). The plan says "Map Grok read-only to read_file,grep,list_dir."
    2. Stale anchors and stale prior art. These references no longer hold:

    What still holds

    These defects are still present on main, and the plan's design for them can stay:

    • parseGrok throws a generic grok reported an error result for a valid terminal failure (parse-output.ts:103). The runner then classifies the run as malformed-output/65 and loses the model, session and usage.
    • A nonzero child exit skips parsing.

    Keep Phases 3 and 4: the typed provider-result error, cancelled/130 and child-failed/70, metadata retention, and collision-safe stdout/stderr sidecars. Keep Phase 5's acceptance evidence.

    Build conditions for the revised plan

    • Base the branch on current main.
    • Do not change Grok permission mode, sandbox or tool lists.
    • Add no new receipt status and no schema bump unless the plan lists it under Open questions for the maintainer.
    • Add no implicit timeout and no weaker-model fallback.
    • Live gate: install the exact candidate and reproduce a Grok terminal failure, or a cancellation where one is still reachable, from both a Claude Code parent and a Codex parent. The receipt must show the right status, the exact reason and the provider model.
  6. ericlitman commented on Oct 4, 2026

    @ericlitman
    Owner

    Factory plan verdict: approve

    • Card: Delivery aebdac57, plan-review revision 10.
    • Plan reviewed: the revised plan that answers verdict 5976854582.
    • Planner model: gpt-6.1-sol, from the plan session's message metadata.
    • Reviewer model: Claude Opus 5.5, reviewing in a separate context.
    • Rubric: the factory-adjudicate plan checklist.

    Why approve

    Every gate passes, and Open questions is None.

    • The plan fixes both gaps from the revise verdict.
    • The scope matches the issue's own proposal: typed provider terminal failures (130 or 70), parsing before an ordinary nonzero exit, metadata and exact-reason retention, and complete stdout/stderr sidecars.
    • The receipt change is additive only: no new status and no schema bump.
    • Phase 1 rebuilt the baseline on main. Four focused reproductions fail and 159 tests pass, which replaces the stale 36/11 figure.
    • The live gate needs a real Grok terminal failure from both parents, and a blocked environment is reported, not simulated.

    Build conditions

    1. Coordinate with PR Prevent project startup configuration from overriding runner authentication [#25] #113 (Prevent pstack runner from auto-loading project env files #25).
    2. Sidecar redaction. The Risks line "redact public evidence" adds no redaction code to the runner. Sidecars and receipts are local files with private permissions. Anything published, such as PR evidence, quotes only what the operator chooses.
    3. Checks. Before opening the PR, run the acceptance commands in a Bun-enabled environment and report each exit status. If the build host lacks Bun, fix the host. Don't skip the checks.
  7. mast-factory commented on Oct 4, 2026

    @mast-factory

    Build handoff

    Implemented the revised #78 plan approved at plan-review revision 10. Factory remains in Build at revision 13 after PR linkage; no merge or stage transition was performed.

    • Branch: factory/issue-78, based on current main at be66d68.
    • Pushed HEAD: 21e134ffd993ab4f1952382dd1c2717e51b3c3cf.
    • PR: Preserve Grok terminal failures and complete runner evidence [#78] #126 (draft; verified head and base main).
    • Phase checkpoints, all reachable on the pushed branch:
      • 72019f4: failing regression checkpoint.
      • bdd51f6: typed Grok failures and retained metadata.
      • 19d6d5b: collision-safe complete private stream artifacts and regression coverage.
      • 21e134f: provider-dispatch contract documentation.

    Implemented contract

    Valid provider cancellations return cancelled/130; other well-formed provider failures return child-failed/70, including ordinary nonzero child exits. Invalid/incomplete terminal output remains malformed-output/65. Provider reason, model/session/usage/cost, and child exit code are retained. Launcher cancellation and timeout precedence and strict successful-model verification are preserved.

    Complete raw streams are saved in exclusively reserved 0600 <receipt>.stdout and <receipt>.stderr sidecars, with collision rejection, rollback, partial-write handling, descriptor cleanup, and storage-error termination. Receipts remain schema version 1 with nullable stream-path fields. Grok permissions/sandbox/tool lists are unchanged; #117 owns that policy.

    Actual verification at pushed HEAD

    Bun 1.4.0, from plugins/pstack/skills/poteto-mode/scripts:

    • bun install --frozen-lockfile: exit 0.
    • bun test runner/commands.test.ts runner/parse-output.test.ts runner/run.test.ts: 62 pass, 0 fail, 341 assertions.
    • bun run test: 179 pass, 0 fail, 835 assertions across 11 files.
    • bun run typecheck: exit 0.

    Repository root:

    • Bun JSON parsing of .claude-plugin/marketplace.json, .agents/plugins/marketplace.json, plugins/pstack/.claude-plugin/plugin.json, and plugins/pstack/.codex-plugin/plugin.json: exit 0.
    • PSTACK_STATIC_ONLY=1 bash tests/skill-collision-repro.sh: exit 0.
    • git diff --check origin/main...HEAD: exit 0.
    • Diff of commands.ts/commands.test.ts: empty.

    Local automated logs: /tmp/issue78-green.log, /tmp/issue78-manifests.log, /tmp/issue78-static.log. They are local artifacts, not public evidence links.

    Assumptions and remaining evidence

    • Added nullable receipt fields are additive within the approved schema-version-1 contract; no new status or schema bump was introduced.
    • PR Prevent project startup configuration from overriding runner authentication [#25] #113 remains open at 0be4b216a5c037642cc44b6313a8b01a056967a4. PR Preserve Grok terminal failures and complete runner evidence [#78] #126 explicitly records the shared run.test.ts coordination: whichever lands second must rebase in place and rerun acceptance without rewriting Prevent project startup configuration from overriding runner authentication [#25] #113's tests.
    • Exact-candidate installed live Grok failure checks from both Claude Code and Codex are not run: none of claude, codex, or grok is available in this sandbox. Fake CLI tests are not live evidence. Before merge, an authenticated operator must install this exact head in both parents, reproduce a terminal failure/cancellation, verify receipt status/exact reason/provider model and private sidecars, and publish a successful exact-head live-gate status linking operator-selected evidence. Every new head needs fresh live evidence.
    • Open questions: none about implementation; the installed live gate is the remaining operator-environment blocker. PR remains draft, with no merge/release/rollout request.

    Findings

    None

  8. added a commit that references this issue on Oct 4, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions