Repository navigation
fix(platform): hold skill uploads to the owner and team-audience rules - #3776
Merged
Merged
Conversation
The editor's save checks a team skill's teams against the organization and, for a non-admin, against the saver's own teams. Neither upload door did: a member could upload a zip whose SKILL.md shared the skill with a team they are not in, or with an id that is no team at all, and an automation package wrote its carried skills verbatim — declared owner, sharing and all — so a package could install a skill in another member's name. Both doors now write through one step, prepareBundleWrite: the owner and private-retired rules normalizedBundleFiles already applied to zips, then the team-audience rule, checked when the team list is new or changed (an unchanged re-upload never fails on a team deleted since). The package lane judges each carried skill as it would be written, so re-uploading an unchanged package still reports its skills as unchanged, and it checks every team before writing any skill. The package door answers team refusals with the skill door's codes (TEAM_NOT_IN_ORG, TEAM_ACCESS_DENIED).
The editor's save checks a team skill's teams against the organization and, for a non-admin, against the saver's own teams. Neither upload door did: a member could upload a zip whose SKILL.md shared the skill with a team they are not in, or with an id that is no team at all, and an automation package wrote its carried skills verbatim — declared owner, sharing and all — so a package could install a skill in another member's name. Both doors now write through one step, prepareBundleWrite: the owner and private-retired rules normalizedBundleFiles already applied to zips, then the team-audience rule, checked when the team list is new or changed (an unchanged re-upload never fails on a team deleted since). The package lane judges each carried skill as it would be written, so re-uploading an unchanged package still reports its skills as unchanged, and it checks every team before writing any skill. The package door answers team refusals with the skill door's codes (TEAM_NOT_IN_ORG, TEAM_ACCESS_DENIED).
yannickmonney
force-pushed
the
fix/skill-upload-owner-audience
branch
from
September 28, 2026 22:46
cc8e605 to
63cc9b3
Compare
Before carried skills followed the owner rule, the package lane wrote their SKILL.md as the package carried it, usually with no owner. The plan compared the stored bundle only with the owner-stamped rewrite, so re-uploading the same package no longer matched: a Developer, who cannot edit an ownerless shared skill, was refused, and an Admin got an overwrite prompt whose confirmation silently adopted the skill. A stored bundle that still equals the carried files byte for byte now counts as unchanged too, since nothing on disk would change. The refusal for a differing bundle no longer claims another member owns the skill, which is false for an ownerless one.
The automation route's error handler looked every coded refusal up in the skill door's status map, which also moved the package lane's own STORAGE_NOT_FOUND from 400 to 404 while leaving other refusals at 400. Only the team-audience refusals (TEAM_NOT_IN_ORG, TEAM_ACCESS_DENIED) need the skill door's statuses, so both upload lanes agree on them; every other refusal of the lane keeps its 400.
The refusal a team-audience upload answers says the caller cannot share with that team; it does not name the team, whose id only travels in the error data neither upload dialog reads. A tester following the box would have logged a false failure.
This was referenced Sep 28, 2026
…r-audience # Conflicts: # services/platform/tests/manual/readme.md
…r-audience # Conflicts: # services/platform/backend/domains/automations/routes.ts # services/platform/tests/manual/reference/automation.md
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.
Summary
Skill ZIP uploads and skills carried by automation packages now apply the library's owner and team-assignment rules through one
prepareBundleWritestep. New bundles belong to the uploader; shared replacements require the owner or an administrator and keep the current owner. An ownerless replacement keeps the existing upload rule and adopts its uploader. Members can upload their own skills; automation package upload remains an Admin/Developer action. This answers customer feedback about skill governance.Both upload doors normalize team IDs using the editor's rules and authorize the audience that will actually be stored. Unchanged audiences can remain after a team is deleted, but normalizing a legacy padded ID into a visible audience requires authorization, including on a body-only editor save. Carried bundles are compared after normalization, so an identical package re-upload stays unchanged. A carried skill installed before this change was written exactly as the package carried it (usually with no owner); a re-upload of that same package still matches it byte for byte and is also reported unchanged, with no adoption, no overwrite prompt and no refusal for a Developer. Changing such an ownerless skill still needs an administrator, and the refusal now says the caller cannot edit it rather than that another member owns it.
Automation packages hold every carried skill's existing PostgreSQL writer mutex from planning through file installation, in deterministic lock order. All required team checks finish before any bundle is written. ZIP, package, editor, REST and delete paths use the held connection for SQL work, preventing pool exhaustion while a writer waits for another connection. On the automation upload route only the team-audience refusals (
TEAM_NOT_IN_ORG400,TEAM_ACCESS_DENIED403) take the skill door's statuses; every other coded refusal of that route stays a 400 as before.Permission/audience preflight refusals install no carried skills. Existing behavior remains: a later filesystem or automation-save failure can leave earlier skill installs in place; re-uploading compares them as unchanged. No database migration or permission-role expansion.
Checklist
bun run checkpasses — N/A as a single run: not run locally (CI runs it). Instead: full platform typecheck, type-aware oxlint on the touched backend folders, and the focused test runs below.bun run lint:sastpasses — N/A as a full run: the commit hook ran Opengrep on the staged files of every commit; the full scan is left to CI.docs/{en,de,fr}/— EN/DE/FR skill upload and package catalog pages say uploaded and carried skills follow the owner and team rules.README.md/README.de.md/README.fr.md— N/A: no README-level behavior.Test plan
bun run --filter @tale/platform test -- backend/core/automations backend/core/skills backend/domains/automations backend/domains/skills backend/rest— 90 files, 1666 tests green after the review fixes.unchangedand writes nothing (before:SKILL_CONFLICT_FORBIDDEN); a Developer changing such a skill is still refused with the corrected message;POST /api/app/automations/uploadanswersTEAM_ACCESS_DENIED403,TEAM_NOT_IN_ORG400, and keepsSTORAGE_NOT_FOUNDandSKILL_CONFLICT_FORBIDDENat 400 (before:STORAGE_NOT_FOUND404). Earlier negative controls reproduce the missing writer lock, pool reservation failures and legacy-audience normalization bypass before correction.upload-audience.integration.ts), including ZIP upload, package upload, editor save and deletion with a one-connection app pool. The four selected lanes finished with 58/59 overall checks: the sole failure is the native toolchain's missingpg_searchBM25 boot probe; all selected domain behavior checks pass. No claim of a full integration-suite pass. That integration run predates the review fixes; the legacy ownerless re-upload and the route statuses are proven by the unit tests above, not by a real-Postgres run.SKILL-B4(skills suite) covers both upload lanes; its team-refusal judgment now matches the actual message (the refusal says you cannot share with that team; it does not name it).bun run lint:manualandcheck-guide.tson the suite pass. The box has not been walked by hand in a browser.