Skip to content

refactor(scheduler): deliver the deterministic tool via agent-compose workspace - #5

Merged
winterfx merged 4 commits into
mainfrom
refactor/workspace-tool-delivery
Aug 13, 2026
Merged

refactor(scheduler): deliver the deterministic tool via agent-compose workspace#5
winterfx merged 4 commits into
mainfrom
refactor/workspace-tool-delivery

Conversation

@winterfx

Copy link
Copy Markdown
Owner

Summary

  • Replace the base64-chunked-env-var mechanism for smuggling the compiled draft-pr/issue-triage tool bundle into ephemeral sandboxes with agent-compose's native workspace (git-checked-out fresh into every sandbox), removing the mktemp/base64-decode dance from both scheduler scripts.
  • Commit the plain esbuild bundles (agents/{draft-pr,issue-triage}/tool/main.mjs) alongside the existing generated scheduler.js, checked for staleness the same way (npm run build:check).
  • workspace.ref tracks main (same as skills/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 a main move mid-workflow.
  • Centralize the $WORKSPACE/workflow-repo/agents/<name>/tool/main.mjs path 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 typecheck
  • npm run build / npm run build:check (deterministic, no drift)
  • npm test (116/116 passing, updated build-tools/scheduler-script/draft-pr-scheduler-script tests to assert the new workspace-path invocation instead of the removed base64-chunk mechanism)
  • npm run format:check on all git-tracked files
  • Manual: after merge, confirm a live agent-compose config/up provisions $WORKSPACE/workflow-repo/agents/draft-pr/tool/main.mjs in a real sandbox and node "$DRAFT_PR_TOOL" prepare ... runs end-to-end (not verifiable from source alone)

🤖 Generated with Claude Code

winterfx and others added 4 commits August 13, 2026 10:00
…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>
@winterfx
winterfx merged commit 0a654bc into main Aug 13, 2026
1 check 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