DL-024.1: Async Exec unification — pi adopts run-api - #44
Merged
Conversation
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
marked this pull request as ready for review
August 27, 2026 11:18
This was referenced Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The first extraction from DL-024: widen dld-core's
Execto async, and migrate the pi extension ontorun-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 privaterunScript/MutationEnvelopeand duplicatedactiveRun/resumableRunline-for-line. The duplication had already drifted into bugs: pi's verify treated any non-zero exit as a test failure (noinfrastructurebranch), pi's start left a half-populated run ACTIVE on add-item failure, and pi's pause/resume/stop wrote no events soactiveMinutesover-counted.What changed
Execwidened toExecResult | Promise<ExecResult>; all run-api functions async. OpenCode awaits every call.NextItem.blockedcarries the script's reason string.runScript/MutationEnvelope/resolveSlugand call run-api directly.infrastructureverify branch (timeout ≠ failed attempt), the start-path rollback toblocked, lifecycle events on pause/resume/stop.Test coverage
All 104 bun tests pass, 305 bats pass, tsc clean, tessl lint valid. The existing
loop.test.tssuite (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.