fix(smithy): sf task merge honors workspace merge.targetBranch config (#63)#111
Open
komoreka wants to merge 1 commit into
Open
fix(smithy): sf task merge honors workspace merge.targetBranch config (#63)#111komoreka wants to merge 1 commit into
komoreka wants to merge 1 commit into
Conversation
The `merge.targetBranch` value in `.stoneforge/config.yaml` was previously only consumed by prompt-builders (sessions, steward scheduler, dispatch daemon) to populate WorkflowPresetContext for agent system prompts. The actual git tooling in the `sf task` CLI commands never loaded it, so setting `merge.target_branch: dev` told agents about the target in their prompts but the merge operations themselves still defaulted to git origin/HEAD (typically `main`). Resolution chain across all merge-related paths is now: task.targetBranch → config.merge.targetBranch → git origin/HEAD → main Wired in: - packages/smithy/src/cli/commands/task.ts (merge handler, sync handler, update --status merged verify path) - packages/smithy/src/services/task-assignment-service.ts (MR-creation path used by sf task complete) A new exported `loadConfigTargetBranch()` helper centralises the config read with safe handling of missing config, missing merge block, null values, and empty strings. Six unit tests in task-target-branch.bun.test.ts cover those cases. Stewards (which cannot own a targetBranch field per the agent type contract) finally have a config-only path to set a project-wide target. Refs stoneforge-ai#63.
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
Closes #63.
merge.targetBranchin.stoneforge/config.yamlwas previously consumed only by prompt-builders (sessions, steward scheduler, dispatch daemon) which feed it intoWorkflowPresetContextfor agent system prompts. The actual git tooling insf taskCLI commands and the MR-creation path never loaded it. So settingmerge.target_branch: devtold agents about the target in their prompts, butsf task merge,sf task complete,sf task sync, andsf task update --status mergedall still defaulted to git origin/HEAD (typicallymain) when no per-tasktargetBranchwas set.This PR wires the config value into all merge-related code paths. Resolution chain across the affected commands is now:
This unblocks the steward case from #63: stewards cannot own a
targetBranchfield per the agent-type contract (the API rejects PATCH attempts), so a workspace-level config has always been the only path available to them. Now it actually flows through to git.What changed
packages/smithy/src/cli/commands/task.ts— exportsloadConfigTargetBranch()helper; threads it into themergeTaskHandler(mergeBranchcall + post-merge verify), the sync handler, and theupdate --status mergedverify path.packages/smithy/src/services/task-assignment-service.ts— same fallback in the MR-creation path used bysf task complete.packages/smithy/src/cli/commands/task-target-branch.bun.test.ts(new) — 6 unit tests for the helper covering: value present, missing config file, missingmergeblock, null value, empty string, slash-bearing branch names.Test plan
bun test src/cli/commands/task-target-branch.bun.test.ts— 6/6 passbun test src(full smithy suite) — 1574 pass, 0 fail, 19 skipturbo run typecheck— 16/16 passpnpm build— 13/13 passbun testoncore(2737/0/22),storage(137/0/0),quarry(4260/0/1),smithy(1574/0/19) — total 8708 passing, 0 failing.stoneforge/config.yaml— confirmed the helper resolvesnull, plain values (dev), and slash-bearing values (release/v2) correctly when called from inside the workspace.Out of scope (deferred)
dispatch-daemon.ts:2890-2896propagates the director'stargetBranchonto a task only duringassignTaskToWorker, which means tasks not yet worker-dispatched (or whereresolveOwningDirectorfails) never get it. Worth a follow-up issue/PR if desired; happy to file separately. This PR closes the user-visible symptom by making the config workaround actually work end-to-end.