fix: expand {trackerInstructions} in the scheduled reference-watch prompt (#3140)#3149
Merged
Conversation
…ompt (#3140) `reference-watch` reaches an agent by two paths and only the on-commit trigger (`triggerReferenceAnalysis`) substituted the v3 prompt's `{trackerInstructions}` block. The WEEKLY scheduled path ran its own replace chain in `buildImprovementTaskDescription` that never included that token, so every scheduled run handed the agent a prompt whose "## Where to record proposals" section was the literal string `{trackerInstructions}` — no instruction for where to file, and on a forge-tracker app the agent would default back to the PLAN.md edit the v3 prompt was written to stop. `resolveReferenceWatchBlock` now also resolves the app's work tracker and returns the `formatTrackerInstructions` block plus the `isFileTracker`-derived `worktreeChangesExpected` flag, reusing the on-commit path's helpers rather than restating the block table. `{trackerInstructions}` is substituted BEFORE `{appName}`/`{repoPath}` so the injected block's own placeholders expand. Stamping the flag from the same resolved value also fixes the scheduled half of #3102: a forge-tracker run that files issues and edits no code leaves a clean worktree, which the TUI idle-complete gate otherwise records as an `idle-no-changes` failure. PR #3139 fixed that for the on-commit path only.
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
reference-watchreaches an agent by two paths, and only the on-commit trigger (triggerReferenceAnalysisinserver/services/referenceRepos.js) expanded the v3 prompt's{trackerInstructions}block. The WEEKLY scheduled path ran its own replace chain inbuildImprovementTaskDescription(server/services/cosTaskGenerator.js) that did not include that token — so every scheduled run handed the agent a prompt whose## Where to record proposalssection was the literal string{trackerInstructions}. With no instruction for where to file, the agent had to guess, and on a GitHub/GitLab/JIRA-tracker app it would fall back to editing PLAN.md — exactly what the v3 prompt was written to stop.resolveReferenceWatchBlocknow also resolves the app's work tracker (resolveAppWorkTracker) and returnstrackerInstructions(via the sharedformatTrackerInstructions) plus theisFileTracker-derivedworktreeChangesExpected. Both helpers are reused rather than restated, so the block table and the flag keep one source of truth.{trackerInstructions}is substituted before{appName}/{repoPath}, so the injected block's own inner placeholders get expanded — the same load-bearing ordering the on-commit path documents.workTracker+worktreeChangesExpectedoff that same resolved value. This is the scheduled half of idle-no-changes fails reference-watch runs whose work tracker isn't the filesystem #3102: a forge-tracker run that files issues and edits no application code leaves a clean worktree, which the TUI idle-complete gate otherwise records as anidle-no-changesfailure. PR stop failing idle-out TUI runs whose work product isn't files (#3102) #3139 fixed that for the on-commit path only.reference-watchtask types are untouched — the early return keeps the tracker resolution and the metadata stamp behind the existing type gate.referenceRepos.jsandworkTracker.jsupdated: both now name both dispatch paths as consumers rather than onlytriggerReferenceAnalysis.Test plan
server/services/cosTaskGenerator.referenceWatch.test.js(9 cases): no literal{trackerInstructions}survives; the github block lands with its inner{appName}/{repoPath}expanded;workTracker+worktreeChangesExpectedare stamped per tracker (github/gitlab/jira→false,plan→true); a stale schedule-levelworktreeChangesExpectedoverride loses to the resolved tracker (the flag must not contradict the instructions the agent got); a non-reference-watchtype resolves no tracker and stamps no metadata; the no-reviewable-commits skip still returns null..replaceline fails 2 assertions on the literal token).server/services/cosTaskGenerator*.test.js,referenceRepos.test.js,workTracker.test.js,cos.test.js,taskSchedule.test.js,cosValidation.test.js— 325 passed.cd server && npx vitest run: 22693 passed, 8 failed. All 8 failures are pre-existing and reproduce identically on cleanmain— they assert hardcoded Claude model ids / a data-root path that the ambient session environment overrides, and are unrelated to this diff.Closes #3140