fix(cli): stop spurious has_on_behalf_of/has_permissioned_as diffs on pull (WIN-2201)#10188
Conversation
…n pull With syncBehavior v1 the pull strips the user-specific on_behalf_of_email / permissioned_as from metadata and keeps a boolean marker so a later push can preserve remote ownership. The marker was written unconditionally as `!!<field>`, so every ownerless script, flow, schedule and trigger (the vast majority) got a `has_on_behalf_of: false` / `has_permissioned_as: false` line, producing a spurious diff on every pull. Absence of the marker already means "no owner" everywhere it's read on push, so only emit the key when true. Fixes WIN-2201 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
/review |
|
I'll analyze this and get back to you. |
|
Claude finished @rubenfiszel's task in 1m 13s —— View job ReviewGood to merge — no blocking issues. I traced every place the four markers are read on push to confirm the "behavior-preserving" claim holds. Absence of the key and an explicit
The fix is correct, minimal, and the comments capture exactly the non-obvious constraint (why a bare AGENTS.md compliance
Test coverageCLI/TS change with an integration-style regression test ( Worth noting (not blocking): the test exercises only the script transform. The flow / schedule / trigger transforms are structurally identical one-liners, so a single guard is a reasonable choice per the "ship only the tests the PR needs" guidance — I wouldn't add three more near-duplicate integration tests just for symmetry. Manual verification: none strictly required given the automated guard. If you want extra confidence on the migration path, pull a workspace that already has committed |
Pi ReviewGood to merge — no blocking issues. I independently verified the behavior-preserving claim at every read site. The four transforms are correct and the reasoning in the PR body holds:
The comments follow the AGENTS.md "Comments record constraints, not narration" rule — each states why emitting a Test coverageCLI/TS change with an integration-style regression test ( Manual verification: none strictly required given the automated guard. An optional sanity check: on a workspace with existing committed |

Problem
wmill sync pull(withsyncBehavior: v1) produced a spurioushas_on_behalf_of: falseline in the metadata of nearly every script and flow, causing endless noise in git diffs.Why the marker exists
With
syncBehavior: v1the pull deliberately stripson_behalf_of_emailfrom the committed metadata — the owner's email is user-specific and committing it causes ownership churn between whoever pulls. But on the next push the CLI still needs to know whether the item had an owner so it can sendpreserve_on_behalf_of: trueand keep the remote ownership instead of clobbering it. Once the email is stripped, a boolean marker (has_on_behalf_offor scripts/flows,has_permissioned_asfor schedules/triggers) is the only residual signal of "this has an owner."So the marker is not implicit from
on_behalf_of_emailonce that field is gone — but it is only meaningful when true. The code wrote it unconditionally as!!<field>, so every ownerless item (the overwhelming majority) got...: falsewritten on pull.Fix
Emit the marker only when an owner exists. Absence of the key already means "no owner" everywhere it's read on push (
typed?.has_on_behalf_of ?? !!typed?.on_behalf_of_email→false; schedules/triggers delete the marker before push and never read it), so dropping thefalseline is behavior-preserving.Applied consistently to the four pull transforms in
cli/src/commands/sync/sync.ts:has_on_behalf_ofhas_on_behalf_ofhas_permissioned_ashas_permissioned_asExisting files that already carry a
...: falseline will show a one-time cleanup diff on the next pull (the redundant line removed), then stay stable.Testing
cli/test/pull_on_behalf_of_marker.test.ts— new regression test: creates an ownerless script via the API, runssync pullwithsyncBehavior: v1, and asserts the pulled.script.yamlcontains neitherhas_on_behalf_ofnoron_behalf_of_email. Verified it fails on the pre-fix code (receivedhas_on_behalf_of: false) and passes with the fix.bunx tsc --noEmit: no new type errors (16 pre-existing, unchanged).🤖 Generated with Claude Code
Summary by cubic
Stop writing
has_on_behalf_of: falseandhas_permissioned_as: falseonwmill sync pullwithsyncBehavior: v1. Only emit these markers when true to remove noisy diffs for ownerless items. Fixes WIN-2201.has_on_behalf_of/has_permissioned_asonly when an owner exists; behavior on push is unchanged.falselines.on_behalf_of_email.Written for commit ac3f2a8. Summary will update on new commits.