Scope --sync-saml-orgs to the set run's selected users#35
Merged
Conversation
Org sync now mirrors the permission-sync mode of the same run: - Org names gain a synced- ownership prefix (synced-<configID>-<group>); the sync only ever modifies orgs carrying it, so manually created orgs are never touched. - Additive set modes (--users, --users-without-explicit-perms, --created-after) with --sync-saml-orgs run a SCOPED org sync: per-user additions AND removals computed from each selected user's own SAML assertion and org list. Other users are never touched, and no full user stream or org member pages are loaded — API traffic stays proportional to the selection. User org memberships ride along inline in the existing user queries (zero extra requests). - Full org sync (standalone sync-saml-orgs, set --full / --repos*) discovers every synced org in one search request (replacing per-name lookups) and now also empties — but never deletes — synced orgs whose SAML group disappeared. - Org snapshots record their scope (schema_version 2); scoped applies validate by re-reading just the scoped users' org lists via aliased batch lookups. - The fixture fake gains organizations/currentUser support; new local cases cover scoped add+remove with an out-of-scope canary member, scoped idempotence, and full-mode orphan cleanup. Amp-Thread-ID: https://ampcode.com/threads/T-019ebdc3-c01c-72cb-aa46-52a0183c2ab1 Co-authored-by: Amp <amp@ampcode.com>
The standalone command now requires an explicit mode — bare sync-saml-orgs is rejected: - --full keeps the existing whole-instance sync (with orphaned synced-org cleanup). - --users / --users-without-explicit-perms / --created-after run a scoped per-user sync (additions AND removals for the selected users only), reusing the get/set user-selection pipeline; accountData and each user's org list ride along in the same queries. - Artifact names carry the mode (sync-saml-orgs-full-apply, sync-saml-orgs-users-dry-run, ...). - cmd_get's user loader is now load_selected_users, shared by the standalone scoped org-sync modes. - Rejection matrix updated: bare invocation, --full + user-filter conflicts, and repo filters are rejected; live cases pass --full. Amp-Thread-ID: https://ampcode.com/threads/T-019ebdc3-c01c-72cb-aa46-52a0183c2ab1 Co-authored-by: Amp <amp@ampcode.com>
d99aed9 to
6d24d87
Compare
A scoped org sync whose selection is empty (e.g. set --created-after 2099-01-01 --sync-saml-orgs) returned before the dry-run completion line, so operators (and the live set-created-after-sync-saml-orgs case) lost the run-finished marker. Log it on the nothing-to-sync path; --apply runs still return quietly after their own summary. Amp-Thread-ID: https://ampcode.com/threads/T-019ebdc3-c01c-72cb-aa46-52a0183c2ab1 Co-authored-by: Amp <amp@ampcode.com>
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.
Org sync now mirrors the permission-sync mode of the same run:
Amp-Thread-ID: https://ampcode.com/threads/T-019ebdc3-c01c-72cb-aa46-52a0183c2ab1