From f38710767d158494b71d8378f055fa98d04ec785 Mon Sep 17 00:00:00 2001 From: Loning Date: Sat, 20 Jun 2026 23:27:22 +0800 Subject: [PATCH] refactor(saga): convert sync_scan to std.saga.department MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert github-devloop sync_scan to std.saga.department: done=false, act = old pipeline body byte-for-byte, wrap=core.wrap_pipeline_failure name="sync_scan". The FULL spec is preserved: consumes, produces, fanout = { "devloop_branch_tick" }, and stall_window (applying the fanout-preservation lesson from the prior slice's review). saga-handler.allowlist (G10 2->1). Also widens the slicer dry-run test assertion from r"- selected_count: [02]" to r"- selected_count: [0-2]\b": selected_count = min(slice_size=2, remaining_count), and draining saga-handler to 1 remaining entry makes the dry-run select 1 site. The \b anchor keeps it from matching multi-digit values (e.g. 20). sshx-reviewed (architecture approve, quality/quality comment, no reject); full test 9 packages 0 failed. ⟦AI:FKST⟧ Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_0163uaeg6woT12QeZE1cAkn6 --- migration/saga-handler.allowlist | 1 - .../departments/sync_scan/main.lua | 20 ++++++++++++------- scripts/ratchet_migration_slicer_test.py | 5 ++++- 3 files changed, 17 insertions(+), 9 deletions(-) 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: