Skip to content

DL-024.1: Async Exec unification — pi adopts run-api - #44

Merged
jimutt merged 2 commits into
v1from
feat/dld-core-deepening
Aug 27, 2026
Merged

DL-024.1: Async Exec unification — pi adopts run-api#44
jimutt merged 2 commits into
v1from
feat/dld-core-deepening

Conversation

@jimutt

@jimutt jimutt commented Aug 27, 2026

Copy link
Copy Markdown
Owner

What

The first extraction from DL-024: widen dld-core's Exec to async, and migrate the pi extension onto run-api.ts (the mutation half it had never adopted).

Why

DL-022 created dld-core with a sync Exec (execFileSync). Pi's exec is async — so pi's extension re-implemented the seam with a private runScript/MutationEnvelope and duplicated activeRun/resumableRun line-for-line. The duplication had already drifted into bugs: pi's verify treated any non-zero exit as a test failure (no infrastructure branch), pi's start left a half-populated run ACTIVE on add-item failure, and pi's pause/resume/stop wrote no events so activeMinutes over-counted.

What changed

  • Exec widened to ExecResult | Promise<ExecResult>; all run-api functions async. OpenCode awaits every call.
  • NextItem.blocked carries the script's reason string.
  • Pi's loop.ts and index.ts delete runScript/MutationEnvelope/resolveSlug and call run-api directly.
  • Pi gains: the infrastructure verify branch (timeout ≠ failed attempt), the start-path rollback to blocked, lifecycle events on pause/resume/stop.
  • loop.ts 420→306 lines, index.ts 700→367 lines.

Test coverage

All 104 bun tests pass, 305 bats pass, tsc clean, tessl lint valid. The existing loop.test.ts suite (96 tests with a stateful fake-pi) pins the loop's behavior through the migration.

Stacks on v1. Items 2-7 of DL-024 follow as stacked PRs.

jimutt and others added 2 commits August 27, 2026 11:08
Co-Authored-By: Kimi K3 <noreply@pi.dev>
Generated-By: pi 0.84.2
…le transitions

The first extraction from DL-024.

- Exec widened to allow Promise<ExecResult>; all run-api functions
  are async. OpenCode's server.ts awaits every call (they were sync
  before). NextItem's blocked variant carries the script's reason.

- Pi's loop.ts deletes runScript/MutationEnvelope and calls run-api
  directly: activeRun, nextItem, setRunStatus, setItemStatus,
  verifyItem, repinItem, blockItem, appendRunEvent. The infrastructure
  branch on verify is now consumed — a timeout no longer burns an
  attempt.

- Pi's index.ts deletes its runScript and resolveSlug duplicates.
  The start path gains the half-populated rollback (set blocked on
  add-item failure). Pause/resume/stop now append their events, so
  activeMinutes derives correctly.

- Pi's loop gains the infrastructure branch on verify failure.

loop.ts 420→306, index.ts 700→367. All suites green.

Co-Authored-By: Kimi K3 <noreply@pi.dev>
Generated-By: pi 0.84.2
@jimutt
jimutt marked this pull request as ready for review August 27, 2026 11:18
@jimutt
jimutt merged commit 49d3007 into v1 Aug 27, 2026
2 checks passed
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.

1 participant