Skip to content

[ee] feat: let a role without code use the Hub scripts an admin allows - #12701

Draft
AlexRV12 wants to merge 10 commits into
mainfrom
alexandre/win-2824-let-a-role-without-code-use-the-hub
Draft

AlexRV12 wants to merge 10 commits into
mainfrom
alexandre/win-2824-let-a-role-without-code-use-the-hub

Conversation

@AlexRV12

@AlexRV12 AlexRV12 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A workspace role without code may not name a Hub script anywhere: not in a run, a flow or agent step, an app, a trigger or a schedule. This PR lets an admin allow those roles the approved Hub scripts of chosen integrations, per integration, at read (only the scripts an approver marked read-only on the Hub, a flag on the whole script that the Hub reports on each of its versions) or write (any approved version). The rule is enforced on the server where a path is chosen; the instance and workspace settings hold the list.

Builds on windmill-labs/windmillhub#244 (merged), which adds the read-only flag and the lookup the rule reads (GET /scripts/access_meta). A Hub without it refuses every script where some are allowed, saying the Hub needs an update; where none are, a script is still refused, without that lookup. The public Hub serves it. The flags are synced from script.json by windmill-labs/windmill-integrations#319 (merged).

Fixes WIN-2824.

Changes

Where it is set

  • A list of Hub integrations, each read or write, the same for every role without code. The instance has one (hub_access global setting) and a workspace may replace it as a whole (workspace_settings.hub_access, new column): NULL follows the instance's, an own list does not merge with it, and an empty one allows nothing. So a workspace with its own list keeps an integration the instance later removes, as with AI settings.
  • License: as for workspace roles, the instance list needs one and the workspace list does not. Without a license a stored instance list keeps applying on an EE build, frozen, and can always be cleared; a CE build never applies the instance list, as for instance roles, and its settings say so. The check is on the per-key, bulk and declarative config writes.
  • Keys are read lowercased (the workspace endpoint stores them so, the instance setting is stored as written), because the Hub holds both "Slack" and "slack"; an empty or repeated key, or one containing / (reserved for per-script entries), is refused.
  • The list that applies is put on RoleCapabilities.hub of each role without code when the workspace's roles are loaded, so the rule reads it from the caller and needs no query, and a per-role layer could be added there later. It is not in RoleCapabilitiesPatch. The roles of a workspace share one list (SharedHubAccess, an Arc), since a request copies the caller's capabilities 5 to 7 times: with all 250 public integrations allowed, a copy of the list costs about 5 µs, a shared one a pointer. RoleCapabilities is no longer Copy, which needs a few .clone() calls, one of them in EE (companion windmill-labs/windmill-ee-private#1019).
  • POST /w/{workspace}/workspaces/hub_access, and the two lists on GET .../roles. Forks and renames copy the workspace's list, and it is a hub_access key of the settings document (settings.yaml, managed only when stated).

The rule (check_can_name_runnables)

  • For a role without code, a Hub script is allowed when the Hub knows the version, the integration the Hub reports (never the path's text) is listed at write, or at read and the script is read-only, and the script is approved now and that version was ever approved. Hub flows still need code; preset handlers stay exempt.
  • Each refusal says why, and one the list does not allow says to ask an admin to allow it or a developer to deploy the script: nothing allowed, integration not allowed, script can write but is allowed at read, version not approved, version not on the Hub, Hub unreachable, Hub too old.
  • The rule takes a list, so a save asks the Hub about the Hub scripts it checks together in one request. In a save by a role without code, a Hub flow is refused before the Hub is asked anything. A lookup that falls back to the public Hub makes a second request, more than 100 ids go in chunks, and creating several HTTP routes at once still checks them one route at a time, before its transaction.
  • It runs when a path is chosen, never when something saved fires: a saved flow, trigger or schedule keeps running after an integration is withdrawn or a script is unapproved.

Hub lookup (hub_script_meta)

  • 5-minute cache per version and configured Hub, 5 s timeout, chunks of 100, and the script fetch's fallback to the public Hub for ids below PRIVATE_HUB_MIN_VERSION. Unknown versions are not cached.
  • It takes no pool connection, because it runs inside save transactions. The X-uid it sends is the license id, else the instance uid if some other read has put it in memory, else none.

Settings

  • The same "Hub scripts" editor under the roles on both sides: Instance settings > Workspace roles, and Workspace settings > Users. It sits in the page: a search and a view menu (All integrations, Allowed, Not allowed, Changed) over a list that scrolls in a box of fixed height, one row per Hub integration with None / Read / Write, and the saved level struck through next to a row that differs from it. A line under it sums up what is allowed and what changed.
  • Selecting works as on Home: a row's icon turns into its checkbox on hover, or on every row once one is ticked (shift-click for a range, Ctrl/⌘+A in the list for all shown, Escape to clear). A bar floating over the list then reads "N selected | Set to None / Read / Write | All ✕", as Home's does the level pressed when every ticked row has it. In the workspace settings, the settings pages' "Discard changes" next to Save puts back what is saved, the switch included, and appears only while something differs; on the instance page, the page's own Discard does it. A row's name opens the integration's page on the Hub.
  • In a workspace, "Save Hub scripts" sits next to the section title, as for Workspace roles, and "Use the instance list" shows that list read-only; turning it off edits a copy of it, and either change is applied by Save. In the instance settings, edits go into the page and are saved by its own review, like every instance setting.
  • The rows come from the Hub's integration list (GET /integrations/hub/list). With disable_hub set, or the Hub unreachable, only the integrations already listed are shown, and they can still be changed.

Docs: the list and its refusal reasons are in docs/workspace-roles.md; docs/operator-write-rights.md and docs/operator-builder-rights.md follow.

Out of scope: the flow, app and schedule pickers and the AI chat (MCP instructions included) still follow code alone, so the UI offers less than the server allows until a follow-up PR. On a run by path, the arguments are parsed before the rule runs, and parsing them reads the Hub script, so an id the Hub does not know can answer with that read's error instead of the rule's reason; this is already so on main. Hub scripts stay cached on disk by version number alone, as on main: an instance switched to another private Hub that numbers its scripts alike keeps running the old Hub's copies, while the rule reads the new Hub, until an admin clears the cache.

Follow-ups

  • Revoking a single version on the Hub: the rule allows a version of a script approved now if that version was ever approved, so a version can only be withdrawn by unapproving the whole script. Once the Hub can revoke one version, its lookup reports it unapproved and nothing changes here.
  • When an integration is set to None or lowered to Read, list the saved flows, apps, schedules and triggers that use its Hub scripts, since the rule does not run when they fire.
  • Showing an admin which scripts Read allows: the Hub shows a script's read-only flag only to approvers, on the script's page, and reports no counts per integration.

Proposed telemetry (not wired)

Feature hub_script, each pair to be registered in FEATURE_USAGE_KINDS:

  • grant, key read or write: which level admins allow.
  • granted_name, key <integration>:<level>: which integrations roles without code use.
  • granted_refused, key the reason (a closed list): why they are refused.

granted_name sends an integration name, which on a private Hub can be the instance's own, so it should be limited to public integrations or dropped.

Screenshots

The workspace's section following the instance's list (Gmail at Read), with an unsaved switch:

workspace-follows-instance

The workspace's own list:

workspace-own-list

A selection with its floating bar:

workspace-selection-bar

The Changed view after a bulk Write, saved levels struck through:

workspace-changed-view

The instance settings' section:

instance-hub-scripts

Test plan

Automated:

  • Rust unit test: which list applies, lowercasing, refused keys.
  • The workspace endpoint: admins only, lowercased, an empty list stored as one, null back to the instance's. The license lock: the instance list cannot change but can be cleared, and keeps applying.
  • hub_named_path.rs, with a stub Hub: a granted run over HTTP; each refusal reason, each approval flag failing on its own; no Hub call with nothing allowed.
  • hub_composed_step.rs: with the only connection of a pool held, as a save's transaction holds it, the check of two granted steps passes with one Hub request, and one with a step that can write is refused, naming it. (A whole flow save on one connection cannot pass on an EE build: queuing its dependency job takes a second connection, on main too.)
  • Each of these fails with the code it guards broken: a connection held during the lookup, the read-only check, each approval flag, one request per step.

On a running instance, against a private Hub built from windmillhub main with #244, as an operator, with slack: read:

  • Runs of read-only Slack scripts are accepted; a script that can write, an unapproved version and Gmail are refused with their reasons; so is everything with the Hub down. A Hub script that runs is executed on a worker. With gmail: read too, an older approved version of a read-only script is accepted while a later version is the approved one, and a version never approved is refused. The Hub ran on its own test database, filled with test scripts.
  • A flow, a schedule, an app and an HTTP trigger: the script that can write is refused at save; the flow, schedule, app and HTTP trigger save with a read-only one.
  • Several HTTP routes created at once, one naming a script that can write: refused, naming that route, and none is created; with read-only scripts they are all created.
  • EE: the instance list applies to a workspace without its own; an own list replaces it, an empty one refuses everything, and following the instance again brings it back. Set through the per-key endpoint, the bulk config and the UI; refused keys are refused on each.
  • Only admins write the workspace list; the legacy operator_settings write leaves it; a fork gets it; the settings document reads, applies and clears it.
  • Both settings screens, saved from the browser; the instance one read-only with a Clear button when the frontend sees no license; unsaved edits of one section survive saving the other, and do not follow a switch to another workspace.
  • The editor, with the public Hub's 250 integrations served by a stub: each view, search, the hover checkboxes and floating bar, every bulk level and the level it shows pressed, Ctrl+A and Escape, Discard (after row clicks, a bulk change and the switch), a level control following a bulk change after a row click, the Hub links, the saved level struck through, saving the workspace's own list and following the instance's again (null), a reload keeping what was saved, the Hub unreachable, and an instance edit enabling the page's review. Also at phone width and in dark mode.
  • A flow with five Hub steps on a Hub answering in 2 s: saved in 2.0 s with one request (10.0 s and five before batching).
  • A public script through the private Hub's fallback to the public Hub, which now has chore(deps): bump lettre from 0.10.0 to 0.10.1 in /backend #244: one that can write (28472, Slack's "Send error to slack channel") is refused at Read and accepted at Write. With the public Hub configured directly, one marked read-only by windmill-labs/windmill-integrations#323 (28464, "List Users") is accepted at Read while the one that can write and a private version id are refused (the latter as not on the Hub). The public Hub now marks 647 approved scripts read-only.

After the rebase on main that took in the merged Hub: the Hub integration tests (hub_named_path, hub_composed_step) pass, and the running-instance steps above ran against the merged Hub.

After the latest rebase on main, retested by hand from a browser:

  • Rows without counts, each name opening the integration's Hub page.
  • A bulk Write over all 16 rows applied at once, without a dialog. Discard restores the saved list, and a bulk level a row already has changes nothing.
  • Saving the workspace list, and the instance list through Review changes, kept after a reload.
  • The operator's runs and refusals against the merged Hub, including an older approved version of a read-only script.
  • The instance pointed at hub.windmill.dev: both editors list its 252 integrations, search works, and the read-only and can-write public Slack scripts behave as above.

🤖 Generated with Claude Code

@AlexRV12

Copy link
Copy Markdown
Collaborator Author

/review

@claude

claude Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @AlexRV12's task in 2m 21s —— View job


Good to merge

Review of #12701: Hub scripts for roles without code

  • Read AGENTS.md / review policy
  • Review backend diff (roles, jobs rule, Hub lookup, settings, migration)
  • Review frontend diff
  • Post findings

I found no P0, P1 or P2 issues introduced by this PR. Here is what I checked and why each part holds up.

The rule (windmill-common/src/jobs.rs, check_can_name_runnables)

  • A role with code still returns before the Hub is asked, and so do preset handlers and paths outside hub/.
  • Hub flows are always refused.
  • An empty list refuses before any HTTP call.
  • The integration is taken from the Hub's own meta.app (lowercased), never from the text of the path.
  • A missing read_only deserializes to false, so a version with no flag counts as able to write. That is the safe default.
  • Both script_approved and version_ever_approved are required.
  • Hub errors (BadGateway) become PermissionDenied. A save fails closed when the Hub is down or too old.

Where the capabilities come from

  • caller_capabilities is computed again on every request in auth.rs:270, after the AUTH_CACHE lookup. So the only staleness is the 60 s WORKSPACE_ROLES cache.
  • That cache is dropped on every path that writes a list:
    • update_hub_access: notify_role_overrides_change inside the transaction, then invalidate_workspace_roles_cache.
    • Instance setting writes: the post-write hook.
    • Other replicas: the notify listener in main.rs.
  • hub is not in RoleCapabilitiesPatch, and RoleDefinition/RoleOverride deserialize only the patch. So no admin-supplied role JSON can set it.
  • workspace_roles_on overwrites hub on every role without code, and diff_capabilities ignores it. The legacy update_operator_settings therefore cannot persist it into role_overrides.
  • is_restricted still compares against FULL correctly: a role with code always has an empty hub.

License and validation

  • validate_instance_hub_access_write is wired into the per-key pre-write hook and the declarative sync (upserts only, so a delete or clear passes).
  • An unlicensed write can only clear the list or write it back unchanged.
  • update_hub_access calls require_admin, and the deserialize_with = "Option::deserialize" trick means a body without the key is refused rather than read as null.
  • parse_hub_access refuses empty keys, keys containing /, and keys that collide once lowercased.

Hub lookup and on-disk cache

  • hub_script_meta takes no DB connection, so it is safe inside save transactions.
  • The meta cache key includes the configured Hub URL. Entries found through the public-Hub fallback are stored under the configured Hub's key, which matches the script fetch's own fallback.
  • On disk, only ids at or above PRIVATE_HUB_MIN_VERSION get the Hub-URL hash suffix, so the public ids that images ship are still found.
  • Batching keeps transaction-held saves to one lookup (one request per 100 ids). The trigger and schedule path only checks paths that were added (check_new_hub_paths), and an app collects all of its Hub paths before one check.

Plumbing

  • The new hub_access column is copied on fork (copy_workspace_roles) and on rename (change_workspace_id).
  • hub_access is in the settings document (KNOWN_KEYS, the entries array is now 34, and the plan normalizes it through parse_hub_access).
  • The new endpoint and the WorkspaceRoles fields are in the OpenAPI spec.

Frontend

  • WorkspaceHubAccess keeps the draft across a reload of the roles, since it only resets when the stored list changes.
  • The {#key $workspaceStore} wrapper stops unsaved edits from following a workspace switch.
  • HubAccessSetting turns an emptied list into an unset key, so removing the last integration clears the setting.
  • The pickers' comments now say plainly that the UI offers less than the server allows, which the PR lists as out of scope.

AGENTS.md compliance

  • Migration added with cargo sqlx migrate add -r (up and down), and the .sqlx cache is updated.
  • Generated files are refreshed (instructions.json, skills.gen.ts, system_prompts/auto-generated/) after the system_prompts/base/workspace-settings.md change.
  • Telemetry is proposed in the PR body and not wired, as docs/feature-telemetry.md asks.
  • docs/workspace-roles.md matches the code, and operator-*-rights.md are updated.
  • Comments record constraints, not drafting history.

Test coverage

Backend. Coverage fits the risk:

  • A unit test for parsing and for which list applies (roles.rs).
  • A license-lock test (workspace_roles_license.rs).
  • Stub-Hub integration tests (hub_named_path.rs) for each refusal reason, each approval flag on its own, no Hub call when nothing is allowed, and two Hubs sharing a version id.
  • hub_composed_step.rs checks that a batched lookup works with the pool's only connection held.

The one gap is the one the PR already names: no automated test covers the public-Hub fallback for low ids through a private Hub, because the public Hub does not have /scripts/access_meta yet.

Frontend. Only Svelte components changed, with no new pure-logic utility, so no tests are expected.

Manual checks still worth doing before merge

  • Public fallback. Once windmillhub#238 is deployed to the public Hub, configure a private Hub and, as an operator with slack: read, run a public read-only Slack script with an id below PRIVATE_HUB_MIN_VERSION. It should be accepted, and a Slack script that can write should be refused with the "can write to slack" reason.
  • Hub too old. Run the same check against a Hub without the endpoint and confirm every Hub script is refused with "needs an update", not left unchecked.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1e9a7a5
Status: ✅  Deploy successful!
Preview URL: https://54978961.windmill.pages.dev
Branch Preview URL: https://alexandre-win-2824-let-a-rol.windmill.pages.dev

View logs

@github-actions

Copy link
Copy Markdown
Contributor

Codex Review

Good to merge

No introduced bugs, security issues, or clear AGENTS.md violations found in the 57-file diff ending at e9f1c4fe6c.

Test coverage

Added Rust unit and API/DB integration tests exercise list resolution, validation, licensing, authorization, approval checks, batching, connection usage, and private-Hub cache separation. The PR reports worker and browser verification. Svelte component tests are not expected; documentation/config changes need no separate automated tests.

I ran git diff --check, which passed. I did not rerun builds or runtime suites.

Rerun the backend integration tests after the rebase. Once the public Hub supports the lookup, exercise a public script through a private Hub’s fallback and confirm the worker executes the expected script.

@github-actions

Copy link
Copy Markdown
Contributor

Pi Review

Good to merge

I reviewed the full diff: the backend rule (check_can_name_runnables in jobs.rs), the Hub lookup (hub_script_meta / fetch_hub_script_meta in utils.rs), the per-Hub cache naming (scripts.rs), the RoleCapabilities.hub plumbing (roles.rs), the new endpoint (workspace_roles.rs), the license/declarative-config gates, the settings document, and the new Svelte editor (HubAccessEditor.svelte, WorkspaceHubAccess.svelte, HubAccessSetting.svelte). No blocking issues and no nits worth surfacing.

Considered and dismissed

  • WorkspaceHubAccess.svelte assigns to a $derived (draft) in three event handlers, which is non-idiomatic Svelte 5. I traced the generated code and Svelte 5.55.7's runtime: draft = v compiles to $.set(...), and internal_set's DERIVED branch stores the value and marks the source CLEAN, so the edit persists; because the derived still tracks stored, it resets when the saved list changes (exactly the "reset only when stored changed" comment). It works, but it leans on an undocumented runtime detail rather than the usual $state + $effect reset. Not a functional bug, so not flagged.

  • member_is_restricted rewritten from .map(|r| r.capabilities).unwrap_or(NONE).is_restricted() to .map_or(true, ...) — RoleCapabilities::NONE.is_restricted() is true, so the two forms are equivalent.

  • validate_instance_hub_access_write is only called for diff.upserts in sync_global_settings_declarative, not diff.deletes — a key absent from the declarative document becomes a delete, i.e. clearing, which is explicitly allowed without a license, so there is nothing to validate on that path.

  • The workspace hub_access list is applied without a license and on CE builds — intentional per the PR body ("the instance list needs one and the workspace list does not"); load_hub_access filters only the instance list through custom_roles_built(), matching instance_roles_on.

  • hub_script_meta stores the public-Hub fallback answer under the private-Hub cache key — semantically correct (that answer is what applies for the configured Hub); the only consequence is up to 5 minutes of staleness if a private Hub later starts serving a low id, which is the documented cache TTL.

  • caller_capabilities could take a pool connection on a cold role cache inside a save transaction — capabilities are re-resolved per request at auth time (get_opt_job_authed_lazy_ip), so caller_capabilities returns authed.capabilities() without touching the DB; this call also predates the PR. The new test the_hub_check_needs_no_second_connection pins that the new lookup takes no connection.

  • X-uid sent to the Hub is the license id, not the instance uid — LICENSE_KEY_ID is the public id returned by validate_license_key, not the secret LICENSE_KEY, and it goes to the configured (customer's own) Hub. Not a secret leak.

  • Frontend FULL_CAPABILITIES / OPERATOR_CAPABILITIES omit the new hub field — capabilitiesRestricted never inspects hub, and hub is non-empty only for roles with code=false (already restricted), so the omission changes no outcome.

Test coverage

  • Backend (Rust): strong. Unit test for list precedence/lowercasing/refused keys (roles.rs), integration coverage in hub_named_path.rs (each refusal reason, approval flags individually, no Hub call with nothing allowed, two Hubs sharing a version id), hub_composed_step.rs (single-connection-pool save path, one request per batch), workspace_roles_license.rs (freeze/clear/unchanged-write semantics), and the endpoint admin/lowercase/null tests. A .sqlx metadata refresh accompanies the new column.
  • Frontend (Svelte/TS): no component tests expected per this repo's conventions; the new code is components, not pure-logic utilities with sibling *.test.ts.
  • Docs / CLI / generated prompts: no automated tests expected; the system_prompts and cli generated files were regenerated consistently with the source edits.

Manual verification still outstanding

The only item the PR's test plan leaves open is "public script through a private Hub's fallback", which needs the public Hub to ship windmillhub#238 before it can be exercised against the real Hub; everything else in the plan is already checked against a stub Hub and a running instance. This PR also depends on three external repos (windmillhub#238 for /scripts/access_meta and the integration counts, windmill-integrations#319 for the read-only flags, and the EE companion windmill-ee-private#1019 for the RoleCapabilities clone call), so the merge should be sequenced with those landing first — a Hub without the new lookup refuses every allowed script with "needs an update", as documented.

@AlexRV12
AlexRV12 force-pushed the alexandre/win-2824-let-a-role-without-code-use-the-hub branch from 34914ca to c1600e1 Compare December 2, 2026 10:54
@AlexRV12
AlexRV12 force-pushed the alexandre/win-2824-let-a-role-without-code-use-the-hub branch from ee60807 to 82f299b Compare December 3, 2026 10:32
@AlexRV12

AlexRV12 commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @AlexRV12's task in 48s —— View job


Good to merge

Re-review of #12701: what changed since the review on 2026-11-27

  • Look at what changed since the last review (6 commits, 2026-11-30 to 2026-12-03)
  • Re-check the backend rule and the Hub lookup
  • Re-check the frontend editor
  • Post findings

I found no P0, P1 or P2 issues in the new commits. The earlier review of the rule, the capabilities plumbing, the license lock and the endpoint still holds, and I re-read those parts against the current diff.

c9513a1: Hub scripts are cached on disk by version again

  • hub_cache_name is gone. get_full_hub_script_by_id and fetch_hub_script in scripts.rs are back to what main has, so scripts.rs is no longer in the diff.
  • The tests that seeded 999000x ids go back to main's 990000x ids.
  • The two-Hub assertion in hub_named_path.rs was dropped along with the code it tested.
  • One effect: the rule asks the configured Hub, but the worker can still run a copy cached from a different Hub that uses the same version id. The PR body lists this under "Out of scope", main already behaves this way, and docs/workspace-roles.md makes no claim about the on-disk cache. So I'm not flagging it. Only the metadata cache (HUB_SCRIPT_META) is still keyed by the Hub URL, and that is correct.

0243ba4, db3e6b6, 82f299b: changes to the editor

  • No per-integration counts are left in HubAccessEditor.svelte.
  • The confirmation before a large bulk Write was removed, together with its bulkControlKey remount.
  • apply(selection, to) now runs even when nothing changes. It rebuilds an identical object, and the PR's manual tests confirm that a bulk level a row already has changes nothing.
  • Only shown rows can be selected (selection is filtered through shown), so a bulk change still cannot reach a hidden row.

Things I checked again in the full diff

  • check_can_name_runnables:
    • A caller with code, a preset handler and a path outside hub/ all return before the Hub is asked.
    • A Hub flow, or an empty list, is refused before any HTTP call.
    • The integration comes from the Hub's meta.app, lowercased.
    • A missing read_only counts as able to write.
    • Both approval flags are required.
    • BadGateway becomes PermissionDenied, so a save is refused when the Hub cannot be checked.
  • hub_script_meta takes no pool connection. Unknown ids are not cached. The public-Hub fallback runs under the same condition as the script fetch (hub != DEFAULT_HUB_BASE_URL && id < PRIVATE_HUB_MIN_VERSION).
  • update_hub_access:
    • It calls require_admin.
    • A body without the key is refused (Option::deserialize).
    • The notify goes out inside the transaction, and the local cache is dropped after commit.
  • validate_instance_hub_access_write: without a license, a write can only clear the list or store it back unchanged.
  • update_operator_settings now starts from a clone of the role, which includes hub. diff_capabilities ignores hub, so the legacy write still cannot store it into role_overrides.

AGENTS.md compliance

  • The migration has both up and down files, and the .sqlx cache matches.
  • The generated prompt and skill files were regenerated after the system_prompts/base change.
  • Telemetry is proposed in the PR body and not wired.
  • The docs match the code after the cache revert.

Test coverage

Backend. Coverage is still adequate. The latest commits removed only assertions for code that was itself removed (the per-Hub file name) and two checks that duplicate other tests. What remains:

  • The roles.rs unit test.
  • workspace_roles_license.rs.
  • hub_named_path.rs: each refusal reason, each approval flag on its own, and no Hub call when nothing is allowed.
  • hub_composed_step.rs: one request while the pool's only connection is held.

Frontend. The new code is Svelte components with no new pure-logic utility, so no tests are expected.

Manual verification before merge. The PR's checklist already covers the public-Hub fallback against hub.windmill.dev and the editor after the latest rebase. There is one scenario left that the cache revert makes worth checking. Point an instance at a private Hub. As an operator allowed slack: read, run a read-only Slack script, then a script that can write. The first should be accepted and executed on a worker. The second should be refused with the "can write to slack" reason.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Codex Review

Good to merge

No introduced bugs, security issues, or clear AGENTS.md violations found in the diff ending at a44848eaf9, including the latest editor simplifications and test removals.

Test coverage

Rust unit and integration tests cover list resolution, validation, licensing, authorization, approval flags, batching, and connection usage. Svelte component tests are not expected; docs and generated metadata need no separate tests.

git diff --check passed. I did not rerun builds, Rust suites, or runtime scenarios; the PR records browser and worker verification.

For an independent smoke check, bulk-edit and discard permissions in both settings screens, save and reload, then run read-only and writing Hub scripts as an operator with Read access. Only the read-only script should run.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Pi Review

Good to merge

I reviewed the full diff (backend rule and Hub lookup in jobs.rs / utils.rs, the RoleCapabilities.hub plumbing in roles.rs, the endpoint and settings-document writes, the license/declarative gates, the migration and .sqlx cache, and the Svelte editor components). The three prior reviews (Claude, Codex, Pi) all approved, and the six commits since then are refactors/tests whose claims I re-verified against the current diff. I found no P0, P1, or P2 issues.

Considered and dismissed

  • RoleCapabilities is no longer Copy, so Authable::capabilities() and friends now .clone() on every call (5–7 per request). Not a regression: the clone copies a handful of bools plus a SharedHubAccess pointer bump (Option<Arc<HubAccessList>>), which is exactly why the PR wraps the list in an Arc — the alternative was copying up to 250 entries each time. The PR body documents this tradeoff and the design addresses it.

  • is_restricted now builds Self { visibility: ALL, fork: true, ..self.clone() } and compares against FULL with hub in the equation. Safe: hub is populated only on roles with code=false (the workspace_roles_on filter), and FULL/OPERATOR/NONE all carry hub: EMPTY, so a full-author role still compares equal to FULL and is not restricted. resolve and apply never touch hub, and diff_capabilities ignores it, so no role-override or legacy operator_settings path can persist it.

  • member_is_restricted rewritten from .map(|r| r.capabilities).unwrap_or(NONE).is_restricted() to .map_or(true, …). Equivalent: RoleCapabilities::NONE.is_restricted() is true.

  • WorkspaceHubAccess.svelte assigns to a $derived.by (draft = v) in three handlers. Non-idiomatic, but functional: the assignment compiles to a set on the derived, and the derived only recomputes when stored (a canonicalized string of the saved list) changes, so an unrelated data reload keeps the user's edits while a real change to the saved list resets the draft — exactly the "reset only when stored changed" comment. Not a bug (and the prior Pi review already traced this to the same conclusion).

  • X-uid sent to the Hub is LICENSE_KEY_ID, falling back to the instance uid. LICENSE_KEY_ID is the public id returned by validate_license_key (stored in backend/src/ee.rs), not the secret LICENSE_KEY, and it goes to the customer's own configured Hub. INSTANCE_UID is a OnceLock populated by get_instance_uid; a fresh server that hasn't read its uid yet simply omits the header, which the doc comment states.

  • Public-Hub fallback answers are cached under the configured (private) Hub's key. Semantically correct — that answer is what applies for the configured Hub; the only consequence is ≤5 min of staleness if the private Hub later starts serving a low id, which is the documented cache TTL. The on-disk script cache staying keyed by version alone is pre-existing main behavior, listed under "Out of scope" in the PR body.

  • validate_instance_hub_access_write is only called for diff.upserts, not diff.deletes, in sync_global_settings_declarative. A key absent from the declarative document is a delete = clearing, which the validator explicitly allows without a license (and there is nothing to parse on a delete). No gap.

  • The workspace hub_access list applies on CE builds and without a license. Intentional per the PR body and docs/workspace-roles.md: only the instance list is gated (compile-time custom_roles_built() filter on read, runtime license on write); the workspace list is not. load_hub_access mirrors instance_roles_on's CE handling.

  • parse_hub_access accepts only lowercase read/write values (serde rename_all = "snake_case" is case-sensitive). This is a validation choice, not a bug: the UI, the endpoint, the settings document, and the docs all emit lowercase, and a stored value that fails to parse is logged and treated as an empty list (fail closed) in load_hub_access.

  • Hub-down / Hub-too-old becomes Error::PermissionDenied on save (BadGateway mapped in check_can_name_runnables), so a save is refused rather than half-applied when approvals can't be checked. Fails closed, as intended; the 404-before-error_for_status ordering in fetch_hub_script_meta is correct.

  • hub_access in the settings document: server always=true (always written) combined with the CLI's SETTINGS_MANAGED_ONLY_WHEN_PRESENT mirrors role_overrides exactly, and plan_document normalizes the value through parse_hub_access so a list spelled differently from the endpoint's canonical form reads as no change. null (follow instance) vs {} (allow nothing) round-trips correctly through managed/simple.

  • Frontend FULL_CAPABILITIES / OPERATOR_CAPABILITIES omit hub. capabilitiesRestricted never inspects hub, and hub is non-empty only for roles that are already restricted (code=false), so the omission changes no outcome.

Test coverage

Backend (Rust). Strong and appropriately targeted: roles.rs unit test for list precedence/lowercasing/refused keys; hub_named_path.rs for each refusal reason, each approval flag individually, the no-Hub-call-with-empty-list case, and the unreachable/too-old Hub paths; hub_composed_step.rs for the single-connection-pool save path and one-request-per-batch batching; workspace_roles_license.rs for the freeze/clear/unchanged-write license semantics; plus endpoint admin/lowercase/null round-trip tests. The migration has up/down files and the .sqlx cache matches. The latest commit only dropped two assertions that duplicate other tests.

Frontend (Svelte/TS). The new code is Svelte components and an inline canonical helper, with no new pure-logic utility of the kind that carries a sibling *.test.ts in this repo, so no component tests are expected.

Generated files / docs / CLI / OpenAPI. The system_prompts/skills, openapi.yaml, and ai_session_tools/gen/instructions.json were regenerated per the PR body; no automated tests are expected for these.

Manual verification. The PR's checklist already records running-instance verification (operator run/refusal flows against a private and the public Hub, EE vs CE instance-list behavior, endpoint/bulk/YAML writes, fork/settings-document round-trips, and the editor at desktop/phone widths). The one path I'd still want a human to confirm on a live EE instance is the instance-settings screen with no license: the alert should show the stored list as read-only, and "Clear the list" should succeed while any other edit is refused by the server — that exercises the validate_instance_hub_access_write freeze/clear branch through the real UI rather than the API test.

…t-a-role-without-code-use-the-hub

# Conflicts:
#	backend/ee-repo-ref.txt
#	backend/windmill-api-workspaces/src/workspace_roles.rs
#	backend/windmill-api/openapi.yaml
#	backend/windmill-api/src/ai_session_tools/gen/instructions.json
#	backend/windmill-common/src/roles.rs
#	backend/windmill-common/tests/workspace_roles_license.rs
#	cli/src/guidance/skills.gen.ts
#	frontend/src/lib/components/instanceSettings/WorkspaceRolesSetting.svelte
#	system_prompts/auto-generated/prompts.ts
#	system_prompts/auto-generated/skills/workspace-settings/SKILL.md
#	system_prompts/base/workspace-settings.md
…t-a-role-without-code-use-the-hub

# Conflicts:
#	backend/ee-repo-ref.txt
#	backend/windmill-api-workspaces/src/workspaces_extra.rs
#	backend/windmill-api/src/ai_session_tools/gen/instructions.json
@hugocasa

hugocasa commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

A few things to look at:

  • Hub lookup inside save transactions. On a cache miss, flow saves and trigger/schedule edits wait on the Hub while their transaction is open. Could we resolve the Hub data before the transaction and only decide inside it?
  • Keep the list off RoleCapabilities. Attaching it makes every request carry it and costs Copy (plus the EE change), while only the Hub check reads it. Reading it lazily in the rule, from a cache keyed by workspace, seems simpler.
  • Pickers. Roles without code still never see the Hub in the flow pickers, so they can't use what an admin allowed from the UI. Worth closing that soon, even in a basic form.
  • Editor. The UI is nice and bulk selection makes sense with this many integrations, but the selection behaviour and the floating bar duplicate Home's. Sharing them would keep both consistent. Also, the bulk Write confirmation and the per-integration counts don't match the PR description.
  • Telemetry. A plain "is it used" signal is enough. I'd skip sending integration names.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants