Skip to content

Commit 5d0d60d

Browse files
feat: add repoDrivenPermissionSyncIntervalMs and userDrivenPermissionSyncIntervalMs config settings
- Add `repoDrivenPermissionSyncIntervalMs` and `userDrivenPermissionSyncIntervalMs` to the config schema, deprecating the `experiment_` prefixed variants (still respected as fallbacks in getConfigSettings). - Update repoPermissionSyncer and accountPermissionSyncer to use the new setting names. - Add tests for getConfigSettings fallback behaviour. - Update docs and CHANGELOG. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dd6f825 commit 5d0d60d

File tree

13 files changed

+206
-24
lines changed

13 files changed

+206
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- [EE] Added multi-owner support with promote/demote actions. [#988](https://github.com/sourcebot-dev/sourcebot/pull/988)
1212
- [EE] Added `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` environment variable to enable/disable repo-driven permission syncing. [#989](https://github.com/sourcebot-dev/sourcebot/pull/989)
1313
- [EE] Added `enforcePermissions` per-connection flag to control whether repository permissions are enforced for a given connection. Defaults to the value of `PERMISSION_SYNC_ENABLED`. [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)
14+
- [EE] Added `repoDrivenPermissionSyncIntervalMs` and `userDrivenPermissionSyncIntervalMs` config settings, deprecating the `experiment_` prefixed variants (still respected as fallbacks). [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)
1415

1516
### Changed
1617
- [EE] Promoted `PERMISSION_SYNC_ENABLED` as the canonical env var for enabling permission syncing, deprecating `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` (still respected as a fallback). [#991](https://github.com/sourcebot-dev/sourcebot/pull/991)

docs/docs/configuration/config-file.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ The following are settings that can be provided in your config file to modify So
5050
| `repoGarbageCollectionGracePeriodMs` | number | 10 seconds | 1 | Grace period to avoid deleting shards while loading. |
5151
| `repoIndexTimeoutMs` | number | 2 hours | 1 | Timeout for a single repo‑indexing run. |
5252
| `enablePublicAccess` **(deprecated)** | boolean | false || Use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead. |
53-
| `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the repo permission syncer should run. |
54-
| `experiment_userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the user permission syncer should run. |
53+
| `repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the repo permission syncer should run. |
54+
| `userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the user permission syncer should run. |
55+
| `experiment_repoDrivenPermissionSyncIntervalMs` **(deprecated)** | number | 24 hours | 1 | Use `repoDrivenPermissionSyncIntervalMs` instead. |
56+
| `experiment_userDrivenPermissionSyncIntervalMs` **(deprecated)** | number | 24 hours | 1 | Use `userDrivenPermissionSyncIntervalMs` instead. |
5557
| `maxAccountPermissionSyncJobConcurrency` | number | 8 | 1 | Concurrent account permission sync jobs. |
5658
| `maxRepoPermissionSyncJobConcurrency` | number | 8 | 1 | Concurrent repo permission sync jobs. |
5759

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The following environment variables allow you to configure your Sourcebot deploy
4747
| `AUTH_EE_GCP_IAP_AUDIENCE` | - | <p>The GCP IAP audience to use when verifying JWT tokens. Must be set to enable GCP IAP JIT provisioning</p> |
4848
| `PERMISSION_SYNC_ENABLED` | `false` | <p>Enables [permission syncing](/docs/features/permission-syncing).</p> |
4949
| `PERMISSION_SYNC_REPO_DRIVEN_ENABLED` | `true` | <p>Enables/disables [repo-driven permission syncing](/docs/features/permission-syncing#how-it-works). Only applies when `PERMISSION_SYNC_ENABLED` is `true`.</p> |
50+
| `EXPERIMENT_EE_PERMISSION_SYNC_ENABLED` **(deprecated)** | `false` | <p>Deprecated. Use `PERMISSION_SYNC_ENABLED` instead.</p> |
5051
| `AUTH_EE_ALLOW_EMAIL_ACCOUNT_LINKING` | `true` | <p>When enabled, different SSO accounts with the same email address will automatically be linked.</p> |
5152

5253

docs/docs/features/permission-syncing.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ Permission syncing works with **Bitbucket Cloud**. OAuth tokens must assume the
9797
- Membership in the [project that contains the repository](https://support.atlassian.com/bitbucket-cloud/docs/configure-project-permissions-for-users-and-groups/)
9898
- Membership in a group that is part of a project containing the repository
9999

100-
These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all private repositories accessible to each authenticated user. However, there may be a delay between when a repository is added and when affected users gain access in Sourcebot (up to the `experiment_userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours).
100+
These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all private repositories accessible to each authenticated user. However, there may be a delay between when a repository is added and when affected users gain access in Sourcebot (up to the `userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours).
101101

102-
If your workspace relies heavily on group or project-level permissions rather than direct user grants, we recommend reducing the `experiment_userDrivenPermissionSyncIntervalMs` interval to limit the window of delay.
102+
If your workspace relies heavily on group or project-level permissions rather than direct user grants, we recommend reducing the `userDrivenPermissionSyncIntervalMs` interval to limit the window of delay.
103103
</Warning>
104104

105105
**Notes:**
@@ -120,9 +120,9 @@ Permission syncing works with **Bitbucket Data Center**. OAuth tokens must assum
120120
- Project-level permissions (inherited by all repos in the project)
121121
- Group membership
122122

123-
These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all repositories accessible to each authenticated user using the `REPO_READ` scope. However, there may be a delay between when access is granted and when affected users see the repository in Sourcebot (up to the `experiment_userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours).
123+
These users **will** still gain access via [user-driven syncing](/docs/features/permission-syncing#how-it-works), which fetches all repositories accessible to each authenticated user using the `REPO_READ` scope. However, there may be a delay between when access is granted and when affected users see the repository in Sourcebot (up to the `userDrivenPermissionSyncIntervalMs` interval, which defaults to 24 hours).
124124

125-
If your instance relies heavily on project or group-level permissions, we recommend reducing the `experiment_userDrivenPermissionSyncIntervalMs` interval to limit the window of delay.
125+
If your instance relies heavily on project or group-level permissions, we recommend reducing the `userDrivenPermissionSyncIntervalMs` interval to limit the window of delay.
126126
</Warning>
127127

128128
**Notes:**
@@ -194,5 +194,5 @@ The sync intervals can be configured using the following settings in the [config
194194

195195
| Setting | Type | Default | Minimum |
196196
|-------------------------------------------------|---------|------------|---------|
197-
| `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 |
198-
| `experiment_userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 |
197+
| `repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 |
198+
| `userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 |

docs/snippets/schemas/v3/index.schema.mdx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,28 @@
7070
"description": "This setting is deprecated. Please use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead.",
7171
"default": false
7272
},
73-
"experiment_repoDrivenPermissionSyncIntervalMs": {
73+
"repoDrivenPermissionSyncIntervalMs": {
7474
"type": "number",
7575
"description": "The interval (in milliseconds) at which the repo permission syncer should run. Defaults to 24 hours.",
7676
"minimum": 1
7777
},
78-
"experiment_userDrivenPermissionSyncIntervalMs": {
78+
"userDrivenPermissionSyncIntervalMs": {
7979
"type": "number",
8080
"description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.",
8181
"minimum": 1
8282
},
83+
"experiment_repoDrivenPermissionSyncIntervalMs": {
84+
"type": "number",
85+
"deprecated": true,
86+
"description": "Deprecated. Use `repoDrivenPermissionSyncIntervalMs` instead.",
87+
"minimum": 1
88+
},
89+
"experiment_userDrivenPermissionSyncIntervalMs": {
90+
"type": "number",
91+
"deprecated": true,
92+
"description": "Deprecated. Use `userDrivenPermissionSyncIntervalMs` instead.",
93+
"minimum": 1
94+
},
8395
"maxAccountPermissionSyncJobConcurrency": {
8496
"type": "number",
8597
"description": "The number of account permission sync jobs to run concurrently. Defaults to 8.",
@@ -216,16 +228,28 @@
216228
"description": "This setting is deprecated. Please use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead.",
217229
"default": false
218230
},
219-
"experiment_repoDrivenPermissionSyncIntervalMs": {
231+
"repoDrivenPermissionSyncIntervalMs": {
220232
"type": "number",
221233
"description": "The interval (in milliseconds) at which the repo permission syncer should run. Defaults to 24 hours.",
222234
"minimum": 1
223235
},
224-
"experiment_userDrivenPermissionSyncIntervalMs": {
236+
"userDrivenPermissionSyncIntervalMs": {
225237
"type": "number",
226238
"description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.",
227239
"minimum": 1
228240
},
241+
"experiment_repoDrivenPermissionSyncIntervalMs": {
242+
"type": "number",
243+
"deprecated": true,
244+
"description": "Deprecated. Use `repoDrivenPermissionSyncIntervalMs` instead.",
245+
"minimum": 1
246+
},
247+
"experiment_userDrivenPermissionSyncIntervalMs": {
248+
"type": "number",
249+
"deprecated": true,
250+
"description": "Deprecated. Use `userDrivenPermissionSyncIntervalMs` instead.",
251+
"minimum": 1
252+
},
229253
"maxAccountPermissionSyncJobConcurrency": {
230254
"type": "number",
231255
"description": "The number of account permission sync jobs to run concurrently. Defaults to 8.",

packages/backend/src/ee/accountPermissionSyncer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class AccountPermissionSyncer {
5757
logger.debug('Starting scheduler');
5858

5959
this.interval = setIntervalAsync(async () => {
60-
const thresholdDate = new Date(Date.now() - this.settings.experiment_userDrivenPermissionSyncIntervalMs);
60+
const thresholdDate = new Date(Date.now() - this.settings.userDrivenPermissionSyncIntervalMs);
6161

6262
const accounts = await this.db.account.findMany({
6363
where: {

packages/backend/src/ee/repoPermissionSyncer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class RepoPermissionSyncer {
5353

5454
this.interval = setIntervalAsync(async () => {
5555
// @todo: make this configurable
56-
const thresholdDate = new Date(Date.now() - this.settings.experiment_repoDrivenPermissionSyncIntervalMs);
56+
const thresholdDate = new Date(Date.now() - this.settings.repoDrivenPermissionSyncIntervalMs);
5757

5858
const repos = await this.db.repo.findMany({
5959
// Repos need their permissions to be synced against the code host when...
@@ -280,7 +280,7 @@ export class RepoPermissionSyncer {
280280
// granted access to this repository. Users who have access via a group added to the repo,
281281
// via project-level membership, or via a group in a project are NOT captured here.
282282
// These users will still gain access through user-driven syncing (accountPermissionSyncer),
283-
// but there may be a delay of up to `experiment_userDrivenPermissionSyncIntervalMs` before
283+
// but there may be a delay of up to `userDrivenPermissionSyncIntervalMs` before
284284
// they see the repository in Sourcebot.
285285
// @see: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-permissions-config-users-get
286286
const users = await getExplicitUserPermissionsForCloudRepo(client, workspace, repoSlug);

packages/schemas/src/v3/index.schema.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,28 @@ const schema = {
6969
"description": "This setting is deprecated. Please use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead.",
7070
"default": false
7171
},
72-
"experiment_repoDrivenPermissionSyncIntervalMs": {
72+
"repoDrivenPermissionSyncIntervalMs": {
7373
"type": "number",
7474
"description": "The interval (in milliseconds) at which the repo permission syncer should run. Defaults to 24 hours.",
7575
"minimum": 1
7676
},
77-
"experiment_userDrivenPermissionSyncIntervalMs": {
77+
"userDrivenPermissionSyncIntervalMs": {
7878
"type": "number",
7979
"description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.",
8080
"minimum": 1
8181
},
82+
"experiment_repoDrivenPermissionSyncIntervalMs": {
83+
"type": "number",
84+
"deprecated": true,
85+
"description": "Deprecated. Use `repoDrivenPermissionSyncIntervalMs` instead.",
86+
"minimum": 1
87+
},
88+
"experiment_userDrivenPermissionSyncIntervalMs": {
89+
"type": "number",
90+
"deprecated": true,
91+
"description": "Deprecated. Use `userDrivenPermissionSyncIntervalMs` instead.",
92+
"minimum": 1
93+
},
8294
"maxAccountPermissionSyncJobConcurrency": {
8395
"type": "number",
8496
"description": "The number of account permission sync jobs to run concurrently. Defaults to 8.",
@@ -215,16 +227,28 @@ const schema = {
215227
"description": "This setting is deprecated. Please use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead.",
216228
"default": false
217229
},
218-
"experiment_repoDrivenPermissionSyncIntervalMs": {
230+
"repoDrivenPermissionSyncIntervalMs": {
219231
"type": "number",
220232
"description": "The interval (in milliseconds) at which the repo permission syncer should run. Defaults to 24 hours.",
221233
"minimum": 1
222234
},
223-
"experiment_userDrivenPermissionSyncIntervalMs": {
235+
"userDrivenPermissionSyncIntervalMs": {
224236
"type": "number",
225237
"description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.",
226238
"minimum": 1
227239
},
240+
"experiment_repoDrivenPermissionSyncIntervalMs": {
241+
"type": "number",
242+
"deprecated": true,
243+
"description": "Deprecated. Use `repoDrivenPermissionSyncIntervalMs` instead.",
244+
"minimum": 1
245+
},
246+
"experiment_userDrivenPermissionSyncIntervalMs": {
247+
"type": "number",
248+
"deprecated": true,
249+
"description": "Deprecated. Use `userDrivenPermissionSyncIntervalMs` instead.",
250+
"minimum": 1
251+
},
228252
"maxAccountPermissionSyncJobConcurrency": {
229253
"type": "number",
230254
"description": "The number of account permission sync jobs to run concurrently. Defaults to 8.",

packages/schemas/src/v3/index.type.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,20 @@ export interface Settings {
126126
/**
127127
* The interval (in milliseconds) at which the repo permission syncer should run. Defaults to 24 hours.
128128
*/
129-
experiment_repoDrivenPermissionSyncIntervalMs?: number;
129+
repoDrivenPermissionSyncIntervalMs?: number;
130130
/**
131131
* The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.
132132
*/
133+
userDrivenPermissionSyncIntervalMs?: number;
134+
/**
135+
* @deprecated
136+
* Deprecated. Use `repoDrivenPermissionSyncIntervalMs` instead.
137+
*/
138+
experiment_repoDrivenPermissionSyncIntervalMs?: number;
139+
/**
140+
* @deprecated
141+
* Deprecated. Use `userDrivenPermissionSyncIntervalMs` instead.
142+
*/
133143
experiment_userDrivenPermissionSyncIntervalMs?: number;
134144
/**
135145
* The number of account permission sync jobs to run concurrently. Defaults to 8.

packages/shared/src/constants.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ export const DEFAULT_CONFIG_SETTINGS: ConfigSettings = {
3030
repoGarbageCollectionGracePeriodMs: 10 * 1000, // 10 seconds
3131
repoIndexTimeoutMs: 1000 * 60 * 60 * 2, // 2 hours
3232
enablePublicAccess: false, // deprected, use FORCE_ENABLE_ANONYMOUS_ACCESS instead
33-
experiment_repoDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours
34-
experiment_userDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours
33+
repoDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours
34+
userDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours
35+
experiment_repoDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours (deprecated)
36+
experiment_userDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours (deprecated)
3537
maxAccountPermissionSyncJobConcurrency: 8,
3638
maxRepoPermissionSyncJobConcurrency: 8,
3739
}

0 commit comments

Comments
 (0)