Skip to content

fix: expand {trackerInstructions} in the scheduled reference-watch prompt (#3140)#3149

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-3140
Jul 27, 2026
Merged

fix: expand {trackerInstructions} in the scheduled reference-watch prompt (#3140)#3149
atomantic merged 1 commit into
mainfrom
claim/issue-3140

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

reference-watch reaches an agent by two paths, and only the on-commit trigger (triggerReferenceAnalysis in server/services/referenceRepos.js) expanded the v3 prompt's {trackerInstructions} block. The WEEKLY scheduled path ran its own replace chain in buildImprovementTaskDescription (server/services/cosTaskGenerator.js) that did not include that token — so every scheduled run handed the agent a prompt whose ## Where to record proposals section 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.

  • resolveReferenceWatchBlock now also resolves the app's work tracker (resolveAppWorkTracker) and returns trackerInstructions (via the shared formatTrackerInstructions) plus the isFileTracker-derived worktreeChangesExpected. 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.
  • The generated task's metadata carries workTracker + worktreeChangesExpected off 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 an idle-no-changes failure. PR stop failing idle-out TUI runs whose work product isn't files (#3102) #3139 fixed that for the on-commit path only.
  • Non-reference-watch task types are untouched — the early return keeps the tracker resolution and the metadata stamp behind the existing type gate.
  • Doc comments in referenceRepos.js and workTracker.js updated: both now name both dispatch paths as consumers rather than only triggerReferenceAnalysis.

Test plan

  • New server/services/cosTaskGenerator.referenceWatch.test.js (9 cases): no literal {trackerInstructions} survives; the github block lands with its inner {appName}/{repoPath} expanded; workTracker + worktreeChangesExpected are stamped per tracker (github/gitlab/jirafalse, plantrue); a stale schedule-level worktreeChangesExpected override loses to the resolved tracker (the flag must not contradict the instructions the agent got); a non-reference-watch type resolves no tracker and stamps no metadata; the no-reviewable-commits skip still returns null.
  • Verified the new suite genuinely fails without the fix (reverting the one .replace line 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.
  • Full cd server && npx vitest run: 22693 passed, 8 failed. All 8 failures are pre-existing and reproduce identically on clean main — they assert hardcoded Claude model ids / a data-root path that the ambient session environment overrides, and are unrelated to this diff.

Closes #3140

…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.
@atomantic
atomantic merged commit 9998fe3 into main Jul 27, 2026
6 checks passed
@atomantic
atomantic deleted the claim/issue-3140 branch July 27, 2026 08:34
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.

scheduled reference-watch leaks a literal {trackerInstructions} into the agent prompt

1 participant