Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/symphony/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ async def _on_tick(self) -> None:
log.info("workspace_root_changed", new=str(cfg.workspace_root))
self._workspace_manager = WorkspaceManager(cfg.workspace_root, cfg.hooks, workflow_dir=cfg.workflow_path.parent)
elif self._workspace_manager is not None:
self._workspace_manager.update_hooks(cfg.hooks)
self._workspace_manager.update_hooks(cfg.hooks, workflow_dir=cfg.workflow_path.parent)

await self._reconcile_running(cfg)

Expand Down
6 changes: 5 additions & 1 deletion src/symphony/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ def __init__(self, root: Path, hooks: HooksConfig, *, workflow_dir: Path | None
def root(self) -> Path:
return self._root

def update_hooks(self, hooks: HooksConfig) -> None:
def update_hooks(
self, hooks: HooksConfig, *, workflow_dir: Path | None = None
) -> None:
# §6.2 — apply reloaded hooks to future executions.
self._hooks = hooks
if workflow_dir is not None:
self._workflow_dir = workflow_dir

def path_for(self, identifier: str) -> Path:
key = workspace_key(identifier)
Expand Down
56 changes: 53 additions & 3 deletions tests/test_orchestrator_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
from datetime import datetime, timezone
from pathlib import Path

import pytest

from symphony.issue import BlockerRef, Issue, sort_for_dispatch
from symphony.orchestrator import Orchestrator, RunningEntry
from symphony.workspace import WorkspaceManager
from symphony.workflow import (
AgentConfig,
ClaudeConfig,
Expand All @@ -25,11 +28,14 @@ def _make_config(
*,
max_concurrent: int = 5,
per_state: dict[str, int] | None = None,
workflow_path: Path = Path("/tmp/WORKFLOW.md"),
workspace_root: Path = Path("/tmp/ws"),
hooks: HooksConfig | None = None,
) -> ServiceConfig:
return ServiceConfig(
workflow_path=Path("/tmp/WORKFLOW.md"),
workflow_path=workflow_path,
poll_interval_ms=30_000,
workspace_root=Path("/tmp/ws"),
workspace_root=workspace_root,
tracker=TrackerConfig(
kind="linear",
endpoint="https://api.linear.app/graphql",
Expand All @@ -38,7 +44,7 @@ def _make_config(
active_states=("Todo", "In Progress"),
terminal_states=("Done", "Cancelled"),
),
hooks=HooksConfig(None, None, None, None, 60_000),
hooks=hooks or HooksConfig(None, None, None, None, 60_000),
agent=AgentConfig(
kind="codex",
max_concurrent_agents=max_concurrent,
Expand Down Expand Up @@ -167,3 +173,47 @@ def test_sort_for_dispatch_ties_by_identifier():
b = _issue("MT-1", priority=1)
out = [i.identifier for i in sort_for_dispatch([a, b])]
assert out == ["MT-1", "MT-2"]


@pytest.mark.asyncio
async def test_reload_refreshes_workflow_dir_for_existing_workspace_manager(
tmp_path, monkeypatch
):
workspace_root = tmp_path / "ws"
old_cfg = _make_config(
workflow_path=tmp_path / "old" / "WORKFLOW.md",
workspace_root=workspace_root,
)
new_cfg = _make_config(
workflow_path=tmp_path / "new" / "WORKFLOW.md",
workspace_root=workspace_root,
hooks=HooksConfig(
after_create='echo "$SYMPHONY_WORKFLOW_DIR" > wfdir',
before_run=None,
after_run=None,
before_remove=None,
timeout_ms=30_000,
),
)
state = WorkflowState(tmp_path / "unused.md")
monkeypatch.setattr(state, "reload", lambda: (new_cfg, None))

orch = Orchestrator(state)
orch._workspace_manager = WorkspaceManager(
old_cfg.workspace_root,
old_cfg.hooks,
workflow_dir=old_cfg.workflow_path.parent,
)

async def no_candidates(_cfg):
return []

monkeypatch.setattr(orch, "_fetch_candidates", no_candidates)

await orch._on_tick()

assert orch._workspace_manager is not None
ws = await orch._workspace_manager.create_or_reuse("MT-WFDIR")
assert (ws.path / "wfdir").read_text().strip() == str(
new_cfg.workflow_path.parent
)