Skip to content

fix(platform): hold skill uploads to the owner and team-audience rules - #3776

Merged
yannickmonney merged 12 commits into
mainfrom
fix/skill-upload-owner-audience
Sep 29, 2026
Merged

yannickmonney merged 12 commits into
mainfrom
fix/skill-upload-owner-audience

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Skill ZIP uploads and skills carried by automation packages now apply the library's owner and team-assignment rules through one prepareBundleWrite step. 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_ORG 400, TEAM_ACCESS_DENIED 403) 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 check passes — 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:sast passes — 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.
  • Translations — N/A: no message catalog keys changed; the changed refusal text is a server message.
  • Docs updated in 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

  • Focused platform server and REST tests: 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.
  • New regressions, each shown failing before its fix: a Developer re-uploading a package whose carried skill was installed ownerless reports unchanged and writes nothing (before: SKILL_CONFLICT_FORBIDDEN); a Developer changing such a skill is still refused with the corrected message; POST /api/app/automations/upload answers TEAM_ACCESS_DENIED 403, TEAM_NOT_IN_ORG 400, and keeps STORAGE_NOT_FOUND and SKILL_CONFLICT_FORBIDDEN at 400 (before: STORAGE_NOT_FOUND 404). Earlier negative controls reproduce the missing writer lock, pool reservation failures and legacy-audience normalization bypass before correction.
  • Full platform typecheck and type-aware oxlint on the touched folders; commit hooks (oxfmt, Opengrep) on every commit.
  • Real PostgreSQL, signed-session HTTP, MinIO and file probes covered 25 upload cases before a local Docker outage. A fresh isolated native PostgreSQL run with a Moto S3 HTTP fixture covers all 26 cases (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 missing pg_search BM25 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.
  • EN/DE/FR upload and package documentation; 171 docs tests; 12 rendered locale/page/viewport checks.
  • Manual box 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:manual and check-guide.ts on the suite pass. The box has not been walked by hand in a browser.

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
yannickmonney force-pushed the fix/skill-upload-owner-audience branch from cc8e605 to 63cc9b3 Compare September 28, 2026 22:46
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.
…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
@yannickmonney
yannickmonney merged commit e8a277e into main Sep 29, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the fix/skill-upload-owner-audience branch September 29, 2026 03:32
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.

1 participant