Skip to content

fix(delegation-watchdog): resolve merge conflicts and address review feedback#456

Merged
jaeko44 merged 22 commits intomainfrom
repair/pr437
Mar 30, 2026
Merged

fix(delegation-watchdog): resolve merge conflicts and address review feedback#456
jaeko44 merged 22 commits intomainfrom
repair/pr437

Conversation

@jaeko44
Copy link
Copy Markdown
Member

@jaeko44 jaeko44 commented Mar 26, 2026

  • Add "Select source port" placeholder option to source port select in ui/tabs/workflows.js
  • Add "Select target port" placeholder option to target port select in ui/tabs/workflows.js
  • Both failing tests now pass (workflow-run-history-ui-regression.test.mjs and workflow-heavy-runner-integration.test.mjs)
  • Syntax check passes

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI review requested due to automatic review settings March 26, 2026 10:05
@github-actions github-actions bot added bosun-pr-public PR observed by Bosun but not trusted for high-risk automation bosun-attached Bosun PR attachment marker labels Mar 26, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

Bosun CI signal: Bosun-created PR currently has failing checks.

@jaeko44 jaeko44 added bosun-pr-bosun-created PR created by Bosun and eligible for Bosun automation and removed bosun-pr-public PR observed by Bosun but not trusted for high-risk automation labels Mar 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a “delegation watchdog” concept intended to detect/recover from stalled delegated workflows (especially non-task delegations), and updates workflow templates/tests to support the new behavior and Bosun-created PR detection.

Changes:

  • Added delegation watchdog defaults/config plumbing in action.run_agent, task lifecycle variables, and GitHub templates.
  • Added engine-side watchdog-based decisioning during interrupted-run recovery (resumeInterruptedRuns()).
  • Updated/added tests and mocks around templates and delegation recovery behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
workflow/workflow-nodes/actions.mjs Adds delegation watchdog config and retry loop to action.run_agent (but appears not wired into the main node registration path).
workflow/workflow-engine.mjs Adds env-backed defaults + watchdog-based retry/exhaust decision during interrupted-run recovery.
workflow-templates/task-lifecycle.mjs Adds watchdog variables + passes them into agentPhase(...) config.
workflow-templates/github.mjs Expands “Bosun-created PR” detection to include body marker/phrase checks.
tests/workflow-templates.test.mjs Loosens template-variable “is referenced” detection logic.
tests/workflow-templates-e2e.test.mjs Extends child_process mock to include execFileSync.
tests/workflow-task-lifecycle.test.mjs Adds an assertion test for newly installed watchdog defaults.
tests/workflow-run-history-ui-regression.test.mjs Updates UI regression expectations for run-history labels/copy.
tests/workflow-engine.test.mjs Adds engine watchdog recovery tests and action.run_agent stall recovery tests (currently contains a syntax-breaking stray block).
Comments suppressed due to low confidence (1)

workflow/workflow-nodes/actions.mjs:322

  • workflow/workflow-nodes/actions.mjs does not appear to be imported/used anywhere in the repo (tests and runtime import workflow/workflow-nodes.mjs). As a result, the new delegation watchdog behavior and schema here likely won't take effect, and the new watchdog tests will still run against the implementation in workflow/workflow-nodes.mjs. Please mirror these changes into workflow/workflow-nodes.mjs (or wire this module into the registration path) so there's a single authoritative action.run_agent implementation.
      delegationWatchdogTimeoutMs: { type: "number", default: 300000, description: "Stall threshold for delegated non-task workflows in ms" },
      delegationWatchdogMaxRecoveries: { type: "number", default: 1, description: "Maximum watchdog recovery retries for delegated workflows" },
    },
    required: ["prompt"],
  },
  async execute(node, ctx, engine) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 184 to +196
agentPhase("run-agent-plan", "Agent Plan",
"{{_taskPrompt}}\n\nExecution phase: planning. Produce a concrete implementation plan and identify required tests. Do not make code changes in this phase.",
{}, { x: 200, y: 1740 }),
{ delegationWatchdogTimeoutMs: "{{delegationWatchdogTimeoutMs}}", delegationWatchdogMaxRecoveries: "{{delegationWatchdogMaxRecoveries}}" }, { x: 200, y: 1740 }),

// ── Execute agent (phase 2: tests-first) ────────────────────────────
agentPhase("run-agent-tests", "Agent Tests",
"{{_taskPrompt}}\n\nExecution phase: tests. Write or update tests first for the target behavior, then validate failures/pass criteria before implementation changes.",
{}, { x: 200, y: 1545 }),
{ delegationWatchdogTimeoutMs: "{{delegationWatchdogTimeoutMs}}", delegationWatchdogMaxRecoveries: "{{delegationWatchdogMaxRecoveries}}" }, { x: 200, y: 1545 }),

// ── Execute agent (phase 3: implementation + verification) ──────────
agentPhase("run-agent-implement", "Agent Implement",
"{{_taskPrompt}}\n\nExecution phase: implementation. Complete implementation after tests exist, run required verification (tests/lint/build), then commit, push, and create/update PR.",
{}, { x: 200, y: 1610 }),
{ delegationWatchdogTimeoutMs: "{{delegationWatchdogTimeoutMs}}", delegationWatchdogMaxRecoveries: "{{delegationWatchdogMaxRecoveries}}" }, { x: 200, y: 1610 }),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workflow template changes here will affect the generated demo defaults bundle. The repo has a sync test that expects ui/demo-defaults.js and site/ui/demo-defaults.js to match the output of node tools/generate-demo-defaults.mjs, so these files likely need to be regenerated and committed as part of this PR.

Copilot uses AI. Check for mistakes.
Comment on lines +373 to +378
const used = strings.some((text) =>
text.includes(`{{${key}}}`) ||
text.includes(`$data?.${key}`) ||
text.includes(`$data.${key}`),
text.includes(`$data.${key}`) ||
text.includes(`?.${key}`) ||
text.includes(`.${key}`),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding the “variable is referenced” check to text.includes(?.${key}) / text.includes(.${key}) makes the test prone to false positives (e.g. a variable named id, sdk, timeoutMs will match many non-variable property accesses or JSON snippets). This weakens the guardrail and can let genuinely unused template variables slip through. Prefer a more targeted pattern (e.g. regex for {{key}} or $data access paths that end in the key) rather than any .${key} substring.

Copilot uses AI. Check for mistakes.
Comment on lines +4505 to +4510
const mockEngine = {
list: vi.fn().mockReturnValue([
{
id: "wf-backend",
name: "Backend Agent",
enabled: true,
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block leaves a stray const mockEngine = { ... } outside of any it(...)/function scope, which will cause a syntax/runtime error and prevent the test suite from running. Remove the orphaned block or wrap it in the intended test case (and ensure braces/parentheses are balanced).

Copilot uses AI. Check for mistakes.
Comment on lines +205 to +215
Math.trunc(Number(
watchdog.maxRecoveries
?? watchdog.delegationWatchdogMaxRecoveries
?? detail?.data?.delegationWatchdogMaxRecoveries
?? DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES,
) || DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES),
);
const recoveryAttempts = Math.max(
0,
Math.trunc(Number(watchdog.recoveryAttempts)
|| (watchdog.recoveryAttempted === true ? 1 : 0)),
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildDelegationWatchdogDecision() currently uses Number(...) || DEFAULT... when parsing maxRecoveries and recoveryAttempts. That means explicit 0 values are ignored (e.g. setting maxRecoveries: 0 will be treated as the default, not "disable retries"). Use nullish coalescing / explicit Number.isFinite checks so 0 is honored and only null/undefined/NaN fall back to defaults.

Suggested change
Math.trunc(Number(
watchdog.maxRecoveries
?? watchdog.delegationWatchdogMaxRecoveries
?? detail?.data?.delegationWatchdogMaxRecoveries
?? DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES,
) || DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES),
);
const recoveryAttempts = Math.max(
0,
Math.trunc(Number(watchdog.recoveryAttempts)
|| (watchdog.recoveryAttempted === true ? 1 : 0)),
Math.trunc(
(() => {
const raw = watchdog.maxRecoveries
?? watchdog.delegationWatchdogMaxRecoveries
?? detail?.data?.delegationWatchdogMaxRecoveries
?? DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES;
const parsed = Number(raw);
return Number.isFinite(parsed)
? parsed
: DEFAULT_DELEGATION_WATCHDOG_MAX_RECOVERIES;
})(),
),
);
const recoveryAttempts = Math.max(
0,
Math.trunc(
(() => {
const parsed = Number(watchdog.recoveryAttempts);
if (Number.isFinite(parsed)) return parsed;
return watchdog.recoveryAttempted === true ? 1 : 0;
})(),
),

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot added the bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair label Mar 26, 2026
@github-actions
Copy link
Copy Markdown

Bosun PR classification: Bosun-created.
This PR is tracked by Bosun attachment automation.

  • PR class label: bosun-pr-bosun-created
  • Attach label: bosun-attached (yes, because Bosun-created PRs remain attached regardless of human PR attach mode)
  • Attach mode policy: all
  • Trusted author: no
  • Bosun-created label present: yes
  • Automation scope: Eligible for Bosun repair and merge automation (Bosun-created PR).
  • CI failure signal label: bosun-needs-fix
  • CI failure marker:
  • Trigger: pull_request_target / synchronize

jaeko44 added 2 commits March 26, 2026 23:40
Co-authored-by: bosun-ve[bot] <262908237+bosun-ve[bot]@users.noreply.github.com>
Co-authored-by: bosun-ve[bot] <262908237+bosun-ve[bot]@users.noreply.github.com>
@jaeko44 jaeko44 removed the bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair label Mar 26, 2026
@github-actions github-actions bot added the bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair label Mar 26, 2026
@jaeko44 jaeko44 removed the bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair label Mar 26, 2026
@jaeko44 jaeko44 added bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair and removed bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair labels Mar 27, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jaeko44
Copy link
Copy Markdown
Member Author

jaeko44 commented Mar 30, 2026

@copilot This branch has conflicts that must be resolved
Use the web editor or the command line to resolve conflicts before continuing.

tests/workflow-engine.test.mjs
workflow-templates/github.mjs
workflow/workflow-engine.mjs
workflow/workflow-nodes/actions.mjs

Resolve the above conflicts

Co-authored-by: jaeko44 <9289791+jaeko44@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

@copilot This branch has conflicts that must be resolved
Use the web editor or the command line to resolve conflicts before continuing.

...

Conflicts in all 4 files have been resolved in commit 39059d6. In addition to the conflict resolution, the following reviewer feedback was addressed: Number.isFinite checks in buildDelegationWatchdogDecision, tighter variable reference pattern in the template test, removal of unused watchdog variables from template-bosun-pr-watchdog, fixed stray const mockEngine orphan block in the test file, and demo-defaults regenerated. All 318 affected tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bosun-attached Bosun PR attachment marker bosun-needs-fix Attached PR with failing CI that Bosun should pick up for repair bosun-pr-bosun-created PR created by Bosun and eligible for Bosun automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants