diff --git a/migration/saga-handler.allowlist b/migration/saga-handler.allowlist index 1d28fdf9..889cb6f9 100644 --- a/migration/saga-handler.allowlist +++ b/migration/saga-handler.allowlist @@ -1,2 +1 @@ packages/github-devloop/departments/sync_conflict/main.lua -packages/github-devloop/departments/sync_scan/main.lua diff --git a/packages/github-devloop/departments/sync_scan/main.lua b/packages/github-devloop/departments/sync_scan/main.lua index 0f524cb2..401448fc 100644 --- a/packages/github-devloop/departments/sync_scan/main.lua +++ b/packages/github-devloop/departments/sync_scan/main.lua @@ -1,14 +1,17 @@ local core = require("core") +local saga = require("std.saga") -local M = {} - -M.spec = { +local spec = { consumes = { "devloop_branch_tick" }, produces = { "devloop_sync_conflict" }, fanout = { "devloop_branch_tick" }, stall_window = "10m", } +local function done(_event) + return false +end + local function require_repo(repo) local value = tostring(repo or "") if value == "" or core.safe_repo(value) ~= value then @@ -167,7 +170,7 @@ local function fast_forward_sync(repo, upstream, integration, upstream_sha, inte end) end -function pipeline(event) +local function act(event) core.log_entry("sync_scan", event, "branch-sync", event and event.queue or "") local branches = core.branch_config() local cfg = core.devloop_config() @@ -218,6 +221,9 @@ function pipeline(event) end) end -pipeline = core.wrap_pipeline_failure("sync_scan", pipeline) - -return M +return saga.department(spec, { + done = done, + act = act, + wrap = core.wrap_pipeline_failure, + name = "sync_scan", +}) diff --git a/scripts/ratchet_migration_slicer_test.py b/scripts/ratchet_migration_slicer_test.py index 112c289a..d0245dd2 100644 --- a/scripts/ratchet_migration_slicer_test.py +++ b/scripts/ratchet_migration_slicer_test.py @@ -885,7 +885,10 @@ def test_current_repo_parents_print_dry_run_bodies(self) -> None: self.assertEqual(result.returncode, 0, result.stderr) self.assertIn(f"- ratchet: `{ratchet}`", result.stdout) self.assertIn("- migration_kind: `allowlist`", result.stdout) - self.assertRegex(result.stdout, r"- selected_count: [02]") + # selected_count = min(slice_size=2, remaining_count); as a ratchet is + # drained toward zero its remaining count can be 1 (< slice_size), so the + # dry-run selects 1 site. Accept 0-2 instead of hard-coding 0 or 2. + self.assertRegex(result.stdout, r"- selected_count: [0-2]\b") self.assertIn("## Acceptance Criteria", result.stdout) def test_current_repo_ratchets_print_json_schema(self) -> None: