refactor(scheduler): deliver the deterministic tool via agent-compose workspace - #5
Merged
Merged
Conversation
…kspace Replace the base64-chunked-env-var smuggling of the compiled draft-pr/ issue-triage tool bundles with agent-compose's native git `workspace`, checked out fresh into every scheduler sandbox. Removes the mktemp/ base64-decode dance from both scheduler scripts in favor of invoking the tool directly from $WORKSPACE/workflow-repo, and commits the plain esbuild bundles (agents/*/tool/main.mjs) alongside the existing generated scheduler.js artifacts, checked for staleness the same way. workspace.ref is pinned to a commit SHA (unlike skills/scheduler.script, which stay on `main`) because workspace refs are re-resolved on every new sandbox rather than snapshotted once at `agent-compose up` - a moving ref could otherwise serve a different tool commit mid-workflow across a single Issue/PR's multi-day lifecycle. Adds scripts/pin-workspace-ref.ts to re-stamp both workspace.ref fields to HEAD before a deploy.
Accept the mid-workflow drift risk instead of pinning workspace.ref to a commit SHA: both agents' workspace now tracks main like skills and scheduler.script already do, removing the pin-workspace-ref manual pre-deploy step and its script.
… script Address findings from a /simplify pass over the workspace-tool-delivery diff: - Derive the WORKFLOW_TOOL_PATH baked into each scheduler.js from a single workspaceToolTarget constant + placeholder substitution (matching the existing WORKFLOW_POLICY_JSON pattern), instead of hand-typing the same "$WORKSPACE/workflow-repo/agents/<name>/tool/ main.mjs" literal separately in build-tools.ts and each scheduler source file. - Extract withGeneratedFileBanner() so renderSchedulerArtifact and renderToolArtifact stop duplicating the banner-wrapping expression. - Parallelize the schedulerSource/policySource reads in buildTarget with Promise.all, matching the existing writeOrCheck parallelism. Not changed: agent-compose.yml's workspace/skills/scheduler.script still declare the same repo URL/ref three times per agent (a review pass flagged this as a duplicate git checkout per sandbox) - fixing that would mean deciding whether `skills` and `workspace` can share one checkout, which needs deeper agent-compose provisioning behavior than the docs settle (skill refs resolve "during an agent run", which may or may not populate the sandbox filesystem the same way workspace does for plain scheduler.shell() calls). Left as a follow-up.
Add a pre-commit hook that reruns `npm run build` and re-stages agents/*/tool/main.mjs and agents/*/scheduler.js whenever staged src/ changes would make them stale, so contributors only need to edit the TypeScript sources by hand. CI's `build:check` remains the backstop for --no-verify commits or environments without the hook enabled. Wired up via package.json's "prepare" script so `npm install` sets core.hooksPath automatically. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
workspace(git-checked-out fresh into every sandbox), removing themktemp/base64-decode dance from both scheduler scripts.agents/{draft-pr,issue-triage}/tool/main.mjs) alongside the existing generatedscheduler.js, checked for staleness the same way (npm run build:check).workspace.reftracksmain(same asskills/scheduler.script) — the alternative of pinning to a commit SHA to avoid re-resolving the ref on every new sandbox was considered and deliberately not taken, accepting the small risk that a long-running Issue/PR lifecycle could span amainmove mid-workflow.$WORKSPACE/workflow-repo/agents/<name>/tool/main.mjspath so it's generated once (build-tools.ts) and injected into both scheduler sources via placeholder substitution, instead of being hand-typed as a literal in three places.Test plan
npm run typechecknpm run build/npm run build:check(deterministic, no drift)npm test(116/116 passing, updatedbuild-tools/scheduler-script/draft-pr-scheduler-scripttests to assert the new workspace-path invocation instead of the removed base64-chunk mechanism)npm run format:checkon all git-tracked filesagent-compose config/upprovisions$WORKSPACE/workflow-repo/agents/draft-pr/tool/main.mjsin a real sandbox andnode "$DRAFT_PR_TOOL" prepare ...runs end-to-end (not verifiable from source alone)🤖 Generated with Claude Code