Skip to content

fix(workflows): pass globalSearchPath to all discoverWorkflowsWithConfig callers#1257

Draft
coleam00 wants to merge 3 commits intodevfrom
archon/task-fix-1138-global-workflows
Draft

fix(workflows): pass globalSearchPath to all discoverWorkflowsWithConfig callers#1257
coleam00 wants to merge 3 commits intodevfrom
archon/task-fix-1138-global-workflows

Conversation

@coleam00
Copy link
Copy Markdown
Owner

Summary

  • Problem: Global workflows placed in ~/.archon/.archon/workflows/ were invisible to GitHub webhook commands and the Web UI because discoverWorkflowsWithConfig was called without the globalSearchPath option at 4 call sites.
  • Why it matters: Users who configured global workflows had no way to trigger them via chat platforms or the web UI — a documented feature that silently did not work with no workaround except symlinking.
  • What changed: Added getArchonHome import to command-handler.ts and passed { globalSearchPath: getArchonHome() } at 3 call sites in command-handler.ts and 1 call site in api.ts (GET /api/workflows). Updated 2 existing tests that asserted the exact call signature.
  • What did not change: discoverWorkflowsWithConfig itself, the CLI (already correct), the orchestrator, and all other API routes.

UX Journey

Before

User (GitHub)          command-handler.ts         discoverWorkflowsWithConfig
─────────────          ──────────────────         ───────────────────────────
/workflow list ──────▶ discoverWorkflowsWithConfig(cwd, loadConfig)
                                                   searches: bundled + repo-local
                                                   SKIPS: ~/.archon/.archon/workflows/
               ◀────── returns list (global workflows missing)
user sees no global workflows listed

After

User (GitHub)          command-handler.ts         discoverWorkflowsWithConfig
─────────────          ──────────────────         ───────────────────────────
/workflow list ──────▶ discoverWorkflowsWithConfig(cwd, loadConfig, { globalSearchPath })
                                                   searches: bundled + global + repo-local
                                                   [~] NOW INCLUDES: ~/.archon/.archon/workflows/
               ◀────── returns list (global workflows included)
user sees global workflows listed

Architecture Diagram

Before

CLI workflow.ts              command-handler.ts         api.ts (GET /api/workflows)
───────────────              ──────────────────         ──────────────────────────
discoverWorkflowsWithConfig  discoverWorkflowsWithConfig discoverWorkflowsWithConfig
  (cwd, cfg, {               (cwd, cfg)                 (cwd, cfg)
   globalSearchPath})        ^^^^ MISSING               ^^^^ MISSING

After

CLI workflow.ts              command-handler.ts [~]     api.ts [~]
───────────────              ──────────────────         ──────────────────────────
discoverWorkflowsWithConfig  discoverWorkflowsWithConfig discoverWorkflowsWithConfig
  (cwd, cfg, {               (cwd, cfg, {               (cwd, cfg, {
   globalSearchPath})         globalSearchPath})          globalSearchPath})

Connection inventory:

From To Status Notes
command-handler.ts discoverWorkflowsWithConfig modified Now passes globalSearchPath (3 call sites)
api.ts discoverWorkflowsWithConfig modified Now passes globalSearchPath (1 call site)
command-handler.ts getArchonHome new Added import from @archon/paths

Label Snapshot

  • Risk: risk: low
  • Size: size: XS
  • Scope: core, server
  • Module: core:command-handler, server:api

Change Metadata

  • Change type: bug
  • Primary scope: multi

Linked Issue

Validation Evidence (required)

bun run validate
  • Type check: ✅ Pass — all 10 packages (@archon/paths, git, isolation, providers, workflows, core, adapters, web, server, cli)
  • Lint: ✅ Pass — 0 errors, 0 warnings (--max-warnings 0)
  • Format: ✅ Pass — all files match Prettier code style
  • Tests: ✅ Pass — all packages, 0 failures across all test batches

Notable test counts: @archon/web 101 pass, @archon/core 68+97+2 pass, @archon/workflows multiple batches all passing.

No commands skipped.

Security Impact (required)

  • New permissions/capabilities? No
  • New external network calls? No
  • Secrets/tokens handling changed? No
  • File system access scope changed? No — getArchonHome() already used by CLI at these same call sites; this aligns server/handler paths with existing CLI behavior.

Compatibility / Migration

  • Backward compatible? Yes — purely additive; globalSearchPath was optional before and remains so in the function signature
  • Config/env changes? No
  • Database migration needed? No

Human Verification (required)

  • Verified scenarios: Code review confirms the 4 added globalSearchPath args exactly mirror the CLI pattern in packages/cli/src/commands/workflow.ts:123
  • Edge cases checked: Non-existent global path (gracefully handled by discoverWorkflowsWithConfig — returns empty, no error); duplicate names between global and repo-local (existing load-priority logic already resolves in favor of repo-local)
  • What was not verified: Live manual test placing a YAML in ~/.archon/.archon/workflows/ and hitting the API — all automated checks pass

Side Effects / Blast Radius (required)

  • Affected subsystems/workflows: GitHub webhook /workflow list, /workflow reload, /workflow run commands; Web UI Workflows tab (GET /api/workflows)
  • Potential unintended effects: None — if ~/.archon/.archon/workflows/ does not exist, discoverWorkflowsWithConfig silently skips it (existing behavior for the global path)
  • Guardrails/monitoring: Existing /workflow list output now includes global workflows; no new monitoring needed

Rollback Plan (required)

  • Fast rollback command/path: git revert HEAD — single commit, 4 one-line removals
  • Feature flags or config toggles: None
  • Observable failure symptoms: If global workflows appear duplicated or break load order, revert and investigate discoverWorkflowsWithConfig priority logic

Risks and Mitigations

  • Risk: A user with global workflow names that collide with bundled/repo workflows sees unexpected overrides
    • Mitigation: Load priority is already defined (bundled < global < repo); existing behavior, not changed by this PR

…fig callers (#1138)

Global workflows in ~/.archon/.archon/workflows/ were invisible to webhook
commands and the web UI because 4 call sites omitted the globalSearchPath
option that the CLI already passes correctly.

Changes:
- Add getArchonHome import to command-handler.ts
- Pass { globalSearchPath: getArchonHome() } at 3 call sites in command-handler.ts (list, reload, run)
- Pass { globalSearchPath: getArchonHome() } at 1 call site in api.ts (GET /api/workflows)
- Update tests to expect the new globalSearchPath argument

Fixes #1138

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fdd696c1-4e63-40db-8a9f-f032a17b3126

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch archon/task-fix-1138-global-workflows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coleam00
Copy link
Copy Markdown
Owner Author

🔍 Comprehensive PR Review

PR: #1257 — fix(workflows): pass globalSearchPath to all discoverWorkflowsWithConfig callers
Reviewed by: 2 specialized agents (code-review, test-coverage)
Date: 2026-04-16


Summary

This is a minimal, targeted fix that threads { globalSearchPath: getArchonHome() } to four previously-missing discoverWorkflowsWithConfig call sites — three in command-handler.ts (list, reload, run) and one in api.ts (GET /api/workflows). The fix is correct, surgical, and consistent with the existing CLI reference pattern. Tests are properly updated.

Verdict: ✅ APPROVE

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 3 (test improvements + 2 pre-existing out-of-scope gaps)
🟢 LOW 2 (informational)

🟡 Medium Issues (No Blockers — Follow-up Recommended)

1. Pre-existing gap: validate.ts missing globalSearchPath

📍 packages/cli/src/commands/validate.ts:90-93

archon validate workflows calls discoverWorkflowsWithConfig without globalSearchPath, so global workflows in ~/.archon/.archon/workflows/ are silently excluded from validation output. Same root cause as #1138. Out of scope for this PR — recommend a follow-up issue.

View suggested fix
const { workflows: workflowEntries, errors: loadErrors } = await discoverWorkflowsWithConfig(
  cwd,
  loadConfig,
  { globalSearchPath: getArchonHome() }  // getArchonHome already imported nearby
);

2. Pre-existing gap: orchestrator-agent.ts:1434 no-codebase fallback missing globalSearchPath

📍 packages/core/src/orchestrator/orchestrator-agent.ts:1434

Inside handleWorkflowRunCommand, the "no project, exactly one codebase" fallback calls discoverWorkflowsWithConfig without globalSearchPath. A global workflow invoked through this narrow path would fail to resolve (returns undefined). Bounded impact: only fires when conversation has no codebase_id AND exactly one codebase is registered. Out of scope — follow-up.

View suggested fix
discovery = await discoverWorkflowsWithConfig(workflowCwd, loadConfig, {
  globalSearchPath: getArchonHome(), // already imported
});

3. Test assertions use expect.any(String) instead of pinning the actual getArchonHome() value

📍 command-handler.test.ts:1044, api.workflows.test.ts:119

The CLI reference test at workflow.test.ts:313 demonstrates the tighter pattern — mock getArchonHome to a fixed path and assert that exact value. The @archon/paths mock in command-handler.test.ts doesn't export getArchonHome, so a regression to an empty/wrong path wouldn't be caught. Also, only the list call site has a signature-assertion test; reload and run don't.

View suggested improvements
// 1. Add to @archon/paths mock block (~line 194 in command-handler.test.ts):
getArchonHome: mock(() => '/home/test/.archon'),

// 2. Tighten existing list assertion:
expect(spyDiscoverWorkflows).toHaveBeenCalledWith(
  expect.any(String),
  expect.any(Function),
  { globalSearchPath: '/home/test/.archon' }
);

// 3. Add reload + run signature tests (same pattern):
test('should pass globalSearchPath on reload', async () => {
  await handleCommand(conversationWithCodebase, '/workflow reload');
  expect(spyDiscoverWorkflows).toHaveBeenCalledWith(
    expect.any(String), expect.any(Function), { globalSearchPath: '/home/test/.archon' }
  );
});

✅ What's Good

  • Correct scope discipline: Only the 4 broken call sites were touched; CLI and orchestrator global paths were not disturbed.
  • Import hygiene: getArchonHome added cleanly to existing @archon/paths import in command-handler.ts; no duplicate import needed in api.ts (already there).
  • Test updates are accurate: Both test assertions correctly extend to 3-arg form — will catch structural regressions.
  • No type regressions: Zero as any, full type safety via the optional third param.
  • Consistent style: All 4 updated call sites use identical 3-line format matching CLI reference.
  • Pre-existing @archon/workflows integration test: loader.test.ts exercises discoverWorkflowsWithConfig with a real globalSearchPath directory — strong confidence in underlying behavior.

📋 Suggested Follow-up Issues

Title Priority
fix(workflows): pass globalSearchPath to validate.ts and orchestrator-agent.ts:1434 P2
test(workflows): pin getArchonHome mock value in command-handler and api tests P3

Next Steps

  1. ✅ This PR is ready to approve and merge — no blocking issues
  2. 📝 Create follow-up issue for validate.ts + orchestrator-agent.ts:1434 (same root cause as Global workflows invisible to webhook commands and web UI #1138)
  3. 🎯 Optionally tighten test assertions in this PR or defer to the follow-up

Reviewed by Archon comprehensive-pr-review workflow
Artifacts: ~/.archon/workspaces/coleam00/Archon/artifacts/runs/bd4c902d9ec93a1b33751c278b909d8e/review/

Pass globalSearchPath to validate.ts and orchestrator-agent.ts:1434 call
sites (same root cause as #1138), add getArchonHome mock to
command-handler tests and pin path assertions, add signature-assertion
tests for reload and run call sites, and update orchestrator.test.ts
assertion to match new 3-arg signature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coleam00
Copy link
Copy Markdown
Owner Author

Self-Fix Report (Aggressive)

Status: COMPLETE
Pushed: Changes pushed to archon/task-fix-1138-global-workflows
Commit: ecd0640
Philosophy: Fix everything unless clearly a new concern


Fixes Applied (5 total)

Severity Finding Location Fix
MEDIUM validate.ts missing globalSearchPath packages/cli/src/commands/validate.ts:90 Added import + passed { globalSearchPath: getArchonHome() }
MEDIUM orchestrator-agent.ts:1434 missing globalSearchPath (no-codebase fallback) packages/core/src/orchestrator/orchestrator-agent.ts:1434 Passed { globalSearchPath: getArchonHome() } (already imported)
MEDIUM Test assertions use expect.any(String) not pinned to actual value command-handler.test.ts Added getArchonHome: mock(() => '/home/test/.archon') to @archon/paths mock; tightened list assertion to exact value
MEDIUM Missing signature-assertion tests for reload and run call sites command-handler.test.ts Added 2 new tests pinning globalSearchPath: '/home/test/.archon'
(bonus) orchestrator.test.ts expected 2-arg call, now 3-arg orchestrator.test.ts:556 Updated assertion to match new 3-arg signature (caught as test failure)

Validation

Type check | Lint | Tests
✅ | ✅ | ✅ All packages pass

Self-fix by Archon · aggressive mode

The comment "Discover workflows with error handling" describes exactly
what the surrounding try/catch and discoverWorkflowsWithConfig call
already make clear without it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coleam00
Copy link
Copy Markdown
Owner Author

Archon PR Validation Report

Verdict: APPROVE

Summary

Global workflows in ~/.archon/.archon/workflows/ were confirmed invisible on the Web UI and webhook commands (main branch). The fix — adding { globalSearchPath: getArchonHome() } to 6 call sites — resolves the issue completely. E2E testing verified the fix across Web UI grid display, search, and direct API response with no regressions.

Bug Confirmation

Claim Main Feature
Global workflow missing from Workflows tab BUG REPRODUCED (26 workflows) FIXED (27 workflows, global visible)
Search "global" returns nothing BUG REPRODUCED ("No workflows match") FIXED ("Test Global E2e" found)
GET /api/workflows omits global workflows BUG REPRODUCED (26 results) FIXED (27 results, includes global)

Fix Quality

  • Code: 5/5 — mechanical, minimal, mirrors existing CLI pattern exactly
  • Tests: 3 test files updated, 2 new tests added
  • Audit: All 7 discoverWorkflowsWithConfig call sites verified, no remaining gaps

Issues

No blocking issues found.


Validated by archon-validate-pr workflow

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.

Global workflows invisible to webhook commands and web UI

1 participant