Skip to content

fix(harness): persist compaction, fail-closed spill, cassette tools, recovery, exec - #184

Merged
undivisible merged 2 commits into
mainfrom
cursor/harness-should-fixes-ab3d
Sep 8, 2026
Merged

undivisible merged 2 commits into
mainfrom
cursor/harness-should-fixes-ab3d

Conversation

@undivisible

Copy link
Copy Markdown
Contributor

Post-merge harness should-fixes. Hosts can forward Event::Recovery themselves; this PR only lands the engine surface.

Changes

  1. Semantic compaction survives the next provider request

    • Session stores an append-only projection ledger (summary + archived_ids).
    • request_messages() / serialize_provider_request / JSONL replay apply that ledger.
    • Repeated compact() uses live (unarchived) turns, so the same dropped turns are not re-archived.
  2. Tool-output spill is UTF-8 safe and fail-closed

    • preview_body truncates on a character boundary.
    • Spill dir/write failure still returns a bounded preview.
    • Typed SpillStatus / Event::ToolSpill / ToolResult.spill so hosts do not parse locator text.
  3. Cassette replay emits recorded tool_calls

    • ReplayProvider::stream emits CassetteTurn.tool_calls.
    • detect_tool_divergence plus Agent::enable_cassette_replay simulate recorded tools instead of executing them.
  4. Typed recovery host event

    • Empty-turn Prefill/Nudge and stuck-tool recovery emit Event::Recovery { action, reason }.
    • RecoveryKind is a stable serde-tagged variant (prefill / nudge / retry / halt).
  5. Unified exec is usable

    • stdout/stderr are drained to avoid pipe-fill deadlock.
    • Thin exec tool (spawn / stdin / wait / kill) is registered with the builtin loadout.
    • ProcessStart / ProcessEnd lifecycle events (plus existing ProcessStdin).

Nit

  • RepoMap::with_cache_root for workspace-safe tests.
  • save_cache no longer reports success when the cache path cannot be written.

Out of scope

Host adapter forwarding of Event::Recovery (separate follow-up). Do not merge until review.

Validation

  • cargo fmt --check
  • Focused tests for session projection, spill, cassette, recovery, exec, and repomap
Open in Web Open in Cursor 

Persist semantic compaction on the session projection ledger so the next
provider request still sees the summary, and skip re-archiving dropped
turns. Bound tool-output previews on UTF-8 boundaries and fail closed with
a typed spill notice. Replay recorded cassette tool_calls through a
no-op executor. Emit typed Event::Recovery for empty-turn and stuck-tool
actions. Drain unified exec pipes, register the exec tool, and emit
process lifecycle events. Make repomap cache roots injectable and honest
on write failure.

Co-authored-by: Max Carter 祁明思 <max@tsc.hk>
Co-authored-by: Max Carter 祁明思 <max@tsc.hk>
@undivisible
undivisible marked this pull request as ready for review September 8, 2026 04:20
@undivisible
undivisible merged commit e2d9ee1 into main Sep 8, 2026
2 checks passed
@undivisible
undivisible deleted the cursor/harness-should-fixes-ab3d branch September 8, 2026 04:20
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a8297b38-fd40-4b9c-8277-cc4c87fe9c16)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants