Repository navigation
feat(COD-302): integrate runner and approval workflow - #7
Merged
Merged
Conversation
imtahirabatool
left a comment
Collaborator
There was a problem hiding this comment.
Nice work. The event saving with its own seq, the command receipts, the provider_status preflight and approve/reject through canTransition are all in the right shape. A few things before this can merge:
Blocking
@codehands/runnerpath only works on your machine.daemon/package.jsonhasfile:../codehands-agent/runner, which resolves tocodehands-backend/codehands-agent/runner. That folder isn't in the repo, sonpm installfails for anyone else. The same goes for the../../codehands-contracts/src/...imports. Let's agree on one layout (sibling folders:file:../../codehands-agent/runner) and put it in the README. Also, the runner'smainisdist/index.js, so it needs a build (itspreparerunstscon install).- The real runner never runs.
runneris alwayscreateFakeRunner(...). WithoutCODEHANDS_FAKE_RUNNER=1, tasks are claimed and stayqueuedforever, and every command is refused with "Real runner is not connected yet". The PR title says it integrates the runner. Either wirecreateRunner()(orcreateEngine()) for real mode, or retitle it as the fake-mode step and fail the session in real mode instead of leaving it queued. agent: "codehands"(the engine) is rejected.isSupportedAgentandstart-options.tsonly allowcodexandclaude-code. Contracts v0.2.0 hasAgentKind = "claude-code" | "codex" | "codehands", and Milestone 1 runs through the engine (createEnginefrom@codehands/runner). Please allowcodehands. Preflight for it is the same asclaude-code.- The DB file and env var were renamed.
state.dbbecamecodehands.db, andCODEHANDS_DBbecameCODEHANDS_DB_PATH. The migration header, the README and the apps all use~/.codehands/state.db, so after this change the daemon and the app read different databases. Please revert, or rename it everywhere in the same PR. - Merge conflicts with
main.watcher.tschanged onmainin PR #8/#9, so this needs a rebase.
Should fix
- Restart doesn't clean up the runner.
recoverSessions()marksrunningsessions asfailedin SQLite, but the runner still has its own session file and worktree for them. Callrunner.recover()once at startup (it's on the typecreateRunner()returns). Later, for crash resume (Milestone 1), this becomesengine.recover(), and itsresumablesessions get resumed instead of failed. I'll send the exact code. - A stream that ends with no result leaves the session
runningforever. After thefor awaitinconsumeRunnerEvents, if the session is stillrunning(noapproval.requested,task.failedortask.stoppedarrived), move it tofailedwith a reason like "runner ended without a result". - Missing
budgetUsd.buildStartOptionsdoesn't pass it, and that's what caps Claude Code's spend. Please pass it from the task (or a default like 0.5). Passingmodels(the per-step map) too would let the engine use the task's models. - The approve commit message is always "Approved by user". The runner uses this as the commit message on the branch. Use the task prompt (or a title) instead.
- Preflight blocks the loop, and may be wrong on Windows.
spawnSyncwithshell: falsecan't findclaude.cmd/codex.cmdwhen they're npm shims, so they'd show asnot_installed. It also blocks the 500 ms loop for up to 10 s for every task. Please checkclaude auth statusactually exists in the installed version, and think about caching the result for a minute.
Tidy-ups
daemon/src/fake-runner.tsisn't used (the watcher uses the runner package'screateFakeRunner). It also skipsapproval.requested, and its resume restartsseqat 1. Please delete it.- The
provider_statusupsert appears 4 times (preflight.ts,provider-events.tsand twice inwatcher.ts). Keep one function and use it everywhere.saveProviderStatusandsaveProviderEventaren't called anywhere. saveRunnerEvent,buildStartOptionsand the preflight helpers open a new DB connection on every call (one per event). Pass the watcher'sdbin instead.- There are no automated tests. A couple of watcher tests with the fake runner would help a lot: claim → running → awaiting_approval → approve, and stop/resume. Use a temp DB via the env var.
Happy to pair on 2, 3 and 6 since they touch the runner/engine. 🙌
…y, apply review fixes
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.
Summary
Integrates the runner with the daemon for COD-302.
Changes
task.finished→approval.requestedworkflow.Testing
approved.