Skip to content

Commit f79b234

Browse files
mzxchandraclaude
andcommitted
refactor(forks): stop projecting a column the source query already pins
`listDeployedWorkflows` filters on `fork_sync_excluded = false` and then selected the same column, so every row it returned carried `false` by construction - `SELECT x ... WHERE x = false`. The field only ever varied while `includeSyncExcluded` could make that predicate drop out, which the previous commit removed, so it is scaffolding from the reverted override rather than anything load-bearing. Keeping it would not have been defensive either. If someone widens that predicate they have to revisit the projection anyway, and a constant field hides the coupling between the two instead of enforcing it. Dropped from the query and from `DeployedWorkflowSummary`. The two write sites now state the invariant they actually mean: a copy is not a new workflow, so it is written synced and never takes the target workspace's new-workflow default - which in an opt-out lineage would land a deliberately synced workflow unsynced on the other side. That explicit write is kept precisely because it is a semantic claim, not a read of something the query had already decided. Untouched: the target-side read in `promote-plan.ts`, which queries target workflows with no exclusion filter and genuinely varies. That is what keeps a promote from overwriting a target the user unchecked. Dropped the copy test for an unsynced source, an input no caller can now produce, and renamed its sibling to the property that still holds. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 3362008 commit f79b234

4 files changed

Lines changed: 18 additions & 22 deletions

File tree

‎apps/sim/ee/workspace-forking/lib/copy/copy-workflows.test.ts‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,14 @@ describe('copyWorkflowStateIntoTarget fork-sync inheritance', () => {
696696
})
697697

698698
/**
699-
* The regression the whole opt-in feature hinges on. A copy is the same logical workflow
700-
* in another workspace, so it must inherit the SOURCE's participation - never the target
701-
* workspace's new-workflow default. In an opt-in workspace the default is "excluded", so
702-
* taking it here would land an explicitly-selected source's copy already excluded and
703-
* sync would never update it again.
699+
* The regression the whole opt-in feature hinges on. A copy is not a new workflow, so it
700+
* must never take the TARGET workspace's new-workflow default. In an opt-out lineage that
701+
* default is "excluded", so taking it here would land a deliberately synced workflow's
702+
* copy already excluded, and sync would never update it again.
704703
*/
705-
it('inherits a synced source so the copy keeps syncing', async () => {
704+
it('writes a synced copy rather than taking the target workspace default', async () => {
706705
const rows: Record<string, unknown>[] = []
707706
await copyWorkflowStateIntoTarget({ ...createParams(false), tx: stubCreateTx(rows) } as never)
708707
expect(rows[0].forkSyncExcluded).toBe(false)
709708
})
710-
711-
it('inherits an unsynced source so an overridden copy does not start syncing back', async () => {
712-
const rows: Record<string, unknown>[] = []
713-
await copyWorkflowStateIntoTarget({ ...createParams(true), tx: stubCreateTx(rows) } as never)
714-
expect(rows[0].forkSyncExcluded).toBe(true)
715-
})
716709
})

‎apps/sim/ee/workspace-forking/lib/copy/deploy-bridge.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ export interface DeployedWorkflowSummary {
3636
sortOrder: number
3737
/** Whether the deployed API accepts unauthenticated calls; carried onto sync targets. */
3838
isPublicApi: boolean
39-
/**
40-
* The source's own fork-sync participation. A copy inherits it verbatim
41-
* (`copy-workflows.ts`), because a copied workflow is the same logical workflow in
42-
* another workspace - never the workspace's new-workflow default.
43-
*/
44-
forkSyncExcluded: boolean
4539
}
4640

4741
/**
@@ -68,7 +62,6 @@ export async function listDeployedWorkflows(
6862
folderId: workflow.folderId,
6963
sortOrder: workflow.sortOrder,
7064
isPublicApi: workflow.isPublicApi,
71-
forkSyncExcluded: workflow.forkSyncExcluded,
7265
})
7366
.from(workflow)
7467
.where(

‎apps/sim/ee/workspace-forking/lib/create-fork.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,11 @@ export async function createFork(params: CreateForkParams): Promise<CreateForkRe
472472
description: wf.description,
473473
folderId: wf.folderId,
474474
sortOrder: wf.sortOrder,
475-
forkSyncExcluded: wf.forkSyncExcluded,
475+
// A copy, not a new workflow, so it must not take the child's new-workflow
476+
// default. `listDeployedWorkflows` admits only synced sources, so a copy is
477+
// synced too - stated here rather than read back from a projection the source
478+
// query has already pinned to false.
479+
forkSyncExcluded: false,
476480
},
477481
workflowIdMap,
478482
folderIdMap,

‎apps/sim/ee/workspace-forking/lib/promote/promote-plan.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ export interface ForkPromotePlanItem {
4242
sortOrder: number
4343
/** Source's public-API flag, carried onto the written target (see copyWorkflowStateIntoTarget). */
4444
isPublicApi: boolean
45-
/** Source's fork-sync participation, inherited by a promote-created target. */
45+
/**
46+
* The sync participation a promote-created target is written with. Always false:
47+
* `listDeployedWorkflows` admits only synced sources, so a promoted workflow is one.
48+
* Stated explicitly so a created target can never take the TARGET workspace's
49+
* new-workflow default, which in an opt-out lineage would land a deliberately synced
50+
* workflow unsynced on the other side.
51+
*/
4652
forkSyncExcluded: boolean
4753
}
4854
}
@@ -215,7 +221,7 @@ export function buildForkPromotePlanItems(params: {
215221
folderId: source.folderId,
216222
sortOrder: source.sortOrder,
217223
isPublicApi: source.isPublicApi,
218-
forkSyncExcluded: source.forkSyncExcluded,
224+
forkSyncExcluded: false,
219225
},
220226
})
221227
}

0 commit comments

Comments
 (0)