fix(quarry): external-sync now propagates closed task state to remote#108
Open
fnnzzz wants to merge 1 commit into
Open
fix(quarry): external-sync now propagates closed task state to remote#108fnnzzz wants to merge 1 commit into
fnnzzz wants to merge 1 commit into
Conversation
pushSingleElement was unconditionally skipping every element whose status was 'closed', leaving linked GitHub issues OPEN forever after the Stoneforge task was closed and never updating their sf:status:* labels. Remove 'closed' from the early-skip guard so the close transition reaches the remote. Downstream hash and event checks in pushElement/pushDocument already dedupe subsequent pushes, so this is safe and self-throttling. Tombstones and archived documents remain in the skip guard as terminal states.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pushSingleElementinpackages/quarry/src/external-sync/sync-engine.tsskipped every element whose status wasclosed, with a comment claiming "they're done and shouldn't sync". That's wrong — the close transition itself is what needs to be pushed. As a result, GitHub issues linked via auto-link stayed OPEN forever after the corresponding Stoneforge task was closed, and theirsf:status:openlabel was never replaced withsf:status:closed.Root cause
packages/quarry/src/external-sync/sync-engine.ts(pre-fix), insidepushSingleElement:'closed'short-circuited the push beforepushElementcould compare hashes or query events, so the close transition never reached the adapter.Fix
Remove
closedfrom the early-skip guard. The downstreamlastPushedHashcomparison andlistEvents({ eventType: ['updated', 'closed', 'reopened'], after: lastPushedAt })query inpushElement/pushDocumentalready dedupe subsequent pushes, so the change is safe and self-throttling — a closed task is pushed exactly once per close transition, not on every subsequent sync. Tombstones (deleted tasks) and archived documents stay in the skip guard as terminal states that shouldn't generate any further sync traffic. The surrounding comment is updated to explain why closed tasks must still push.Test coverage
packages/quarry/src/external-sync/sync-engine.bun.test.ts:push propagates closed tasks so the close-event reaches the remote— replaces the previous test that asserted the buggy behavior. Verifies the adapter'supdateIssueis called and that the captured payload'sstateis'closed', so the linked GitHub issue closes and itssf:status:*label updates.push skips tombstone tasks— unchanged. Verifies tombstone tasks are still excluded from push.skips archived documents on push— unchanged (in the document push describe block). Verifies archived documents are still excluded.push closed task: idempotent — skipped when lastPushedHash matches current hash— new. Computes the actual content hash of a closed task, setslastPushedHashto that value, asserts the push is skipped via the downstream hash check (proving dedupe still works after the early-skip removal).push closed task: skipped when no updated/closed/reopened events since lastPushedAt— new. Verifies that a closed task with no relevant events since the last push is skipped via the downstreamlistEventsguard.push resumes syncing when task is reopened (status no longer closed/tombstone)— unchanged. Verifies that reopening a previously-closed task pushes again.Full quarry suite:
bun test src→ 4262 pass, 1 skip, 0 fail (95 files).pnpm run typecheckandpnpm run buildclean.Manual verification
End-to-end on a temporary workspace:
sf inita fresh workspace; auto-link a Stoneforge task to a GitHub issue (sf external-sync link <task-id> <issue-url>).sf:status:open.sf task complete <task-id>(closes the task).sf external-sync push <task-id>.sf:status:openlabel has been replaced withsf:status:closed, and the local task's_externalSync.lastPushedAt/lastPushedHashare updated.sf external-sync push <task-id>immediately. Observe: the task is reported asskipped(downstream hash dedupe), confirming the fix is self-throttling.