Repository navigation
feat(platform): let admins reserve organization-wide skill sharing - #3801
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).
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.
A skill's creator was stored as a user id in its frontmatter and never shown, and only deletions reached the audit log, so nobody could tell who published a skill to the organization or changed it since. Every skill view now carries `origin` (builtin, release, member) and, via one organization-scoped member read per listing, `ownerName`; a departed or foreign id stays nameless and reads as "Former member". The app save, the ZIP upload, REST PUT and an automation package's carried skills record skill.created, skill.updated (with changed fields) and skill.sharing_changed (audience before and after) inside the writer lock, each with the resulting etag. "Last edited by" is the newest such row while its etag is still the stored one, so an out-of-band edit shows no editor rather than a wrong one; no sidecar file, no migration. The library gains a Created by column (searchable), the skill dialog Created by / Last edited by rows, and the agent skill picker a creator caption under each skill. REST contract 3.4.0 adds the fields.
The skill library now names each skill's creator and last editor and records skill writes in the audit log, so the EN/DE/FR skill pages say how Created by and Last edited by read (Built-in, Configuration release, Former member, left out after an edit outside Tale), where the audit entries appear, and list the `owner` frontmatter key. The agent skills page mentions the creator caption in the picker, and the API reference describes `origin`, `ownerName`, `updatedBy` and `updatedByName`.
SKILL-F16 to SKILL-F19 judge what a headless run cannot: the Created by column and dialog rows in three locales with a departed member and a release skill, Last edited by across an out-of-band edit, the creator caption in both agent skill pickers, and the audit rows each write door leaves under Governance > Logs. SKILL-F1 lists the new column and the creator search; the coverage map names the specs that own the rest. SKILL-F15 is left to the in-flight agent-skill-descriptions box.
The write-failure test kept a bare reference to the host's withSkillWriterLocks method, which the type-aware unbound-method rule refuses at error level and turns the workspace lint red. Binding it to the host keeps the wrapper's behaviour and satisfies the rule.
The first audit row takes the organization's audit-chain lock until the writer-lock transaction commits. Recording each carried skill right after its bundle held that lock while the remaining bundles were written to disk, stalling every other audited write in the organization behind the package install. The rows are now collected and written once the last bundle is on disk, still inside the same transaction; a failed install still keeps the rows of the skills written before it.
The builtin | release | member union was spelled out separately in the backend skill views, the attribution hook, the skills table and the REST spec. It now lives once in @tale/shared/schemas/skills as SKILL_ORIGINS and SkillOrigin, next to SKILL_VISIBILITIES, and every one of those imports it. The app's materialized wire contracts keep their inline literals, as they do for visibility.
Saving an agent checks its named skills against the project's capability listing, which now resolved every skill's creator and last editor: a DISTINCT ON over the audit log and a member join the check never reads. The listing takes an attribution option; the equipment check opts out, and the pickers keep the attributed default.
A skill reads as a configuration release when its frontmatter carries the release compiler's marker, and that marker is plain frontmatter any member's zip upload can include. Only the skill dialog named the member whose upload installed it; the library's Created by column and the agent skill pickers showed the bare label and hid the uploader. Every surface now reads Configuration release with the installing member's name, so a member cannot pass their own skill off as a managed release.
The Created by column and the agent skill picker now name the installing member beside Configuration release, not only the skill dialog.
SKILL-F16 and SKILL-F18 now expect Configuration release with the installing member in the table and the picker, and SKILL-F16 adds a member's zip that carries the release marker, which must still name that member.
GET /api/v1/skills/{slug} tags the answer with the SKILL.md hash, while
the body also carries canEdit and the creator and last-editor names.
Those can change under an unchanged tag, so a 304 does not revalidate
them. The operation now says so, instead of implying the tag covers the
whole answer.
An organization had no lever over who may share a skill with the whole organization: every member could. The new `skill_sharing` policy file takes one mode, `everyone`, `editors` or `admins`, and a missing file reads as `everyone`, so no organization's behaviour changes until an admin opts in. The modes are a general organization-wide audience set so other shareable resources can adopt the same rule later. Policies are org config files, so no database migration is needed.
Customer feedback asked that not every member can publish a skill to the
whole organization. With the `skill_sharing` policy in a restricted
mode, a member outside it (and without the new `tale:skills.publish`
capability an admin can grant under Competences) can no longer create an
organization-wide skill, widen one to the organization, or change one in
place. Team sharing, narrowing, identical saves and deletes stay open,
and existing organization-wide skills are never narrowed.
The rule lives once in `core/lib/audience.ts` beside the team assignment
rule (`mayChooseOrgWideAudience`, with `EDITOR_ROLES` moved there), and
every write door passes its answer to the file layer, which fails
closed: the app save, the app ZIP upload, `PUT /api/v1/skills/{slug}`
and an automation package's carried skills. A refusal answers 403
`SKILL_PUBLISH_FORBIDDEN` and is audited as `skill.publish_denied`. The
policy is read strictly, and an unreadable file counts as `admins`, so
broken configuration never widens who may publish. The library listing
answers the viewer's `publishing` verdict and `GET /api/v1/me` answers
`capabilities.skillPublish`; the REST contract moves to 3.5.0.
The create step now asks who sees a new skill, since it is shared from the moment it exists. Organization stays preselected while the viewer may publish to everyone; when the organization reserves that, Teams is preselected and Organization is disabled with the reason, and a member in no team is told whom to ask. The skill dialog explains why an organization-wide skill cannot be changed in place and keeps Save off until it is narrowed, and the upload preview flags an organization-wide bundle and does not send it. All of it reads the verdict the library listing answers, which is the rule the server enforces. Settings > Governance > Policies & Limits gains the Skill sharing control, the competence register offers Publish skills to the organization, and the audit log names a refused publish. English, German and French strings ship together; no Swiss override is needed.
The policies page describes the Skill sharing setting, its three modes, what a member outside it can still do, that existing organization-wide skills stay shared, and the deploy operator a managed release installs skills as. The competences page adds Publish skills to the organization, the skill library explains the audience asked at creation and what a reserved organization-wide audience means for its editor and uploads, and the API reference adds `capabilities.skillPublish` and `SKILL_PUBLISH_FORBIDDEN`. English, German and French change together.
SKILL-F20 checks the audience the create step asks for, SKILL-B5 a reserved organization-wide audience across create, edit, narrow, delete, upload, REST and the audit log, SKILL-B6 the roles and the capability that may publish anyway, and GOV-F35 the Policies & Limits control. The error-code register gains SKILL_PUBLISH_FORBIDDEN, the automation register the specs that own the rule, and the suite counts match the boxes again.
Two open pull requests already claim GOV-F35 and GOV-F36 in the governance suite. Git would merge all three boxes without a conflict and leave a duplicate ID that lint:manual refuses, so this box takes the next ID neither of them uses.
An automation package upload read the skill sharing policy, and maybe a competence grant, on every upload, even one carrying no skill or only team skills. An unreadable policy file then logged its error on uploads that wrote nothing organization-wide. The right is now read only when a carried skill is shared with the organization, still before the writer locks so it never takes a second pool connection under the held lock.
The skill form learns whether the viewer may share with the whole organization from the skills listing, and nothing refreshed it when an admin tightened the policy or revoked a grant after it loaded. A refused save then showed only generic copy, the upload the server's English sentence, and the form kept offering Organization. A SKILL_PUBLISH_FORBIDDEN refusal now refreshes the listing, so the form switches to its reserved state, and names the reason in the viewer's language: in the save action's toast and in the upload pane's toast.
…r-audience # Conflicts: # services/platform/tests/manual/readme.md
… into feat/skill-created-by # Conflicts: # services/platform/tests/manual/readme.md
…/skill-org-publish-policy # Conflicts: # services/platform/tests/manual/readme.md
… into feat/skill-created-by # Conflicts: # services/platform/tests/manual/suites/skills.md
…/skill-org-publish-policy # Conflicts: # services/platform/tests/manual/readme.md # services/platform/tests/manual/suites/skills.md
The base PR landed as a squash commit, so this merge takes main and keeps only this branch's own changes on top of it.
…/skill-org-publish-policy # Conflicts: # docs/de/platform/workspace/skills.md # docs/en/platform/workspace/skills.md # docs/fr/platform/workspace/skills.md # services/platform/tests/manual/reference/automation.md # services/platform/tests/manual/suites/governance.md
…h-policy The base PR landed as a squash commit, so this merge takes main and keeps only this branch's own changes on top of it; the two publish constants only publish.ts reads are file-local, as knip asks.
This was referenced Sep 29, 2026
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
Stacked on #3786; review only the top commits, from
feat(shared): add the skill sharing governance policyonwards.Customer feedback said that anyone can create skills visible to the whole organization and they don't want that. Since 0.4 any member may share a skill org-wide, and that stays the default. This PR adds an opt-in governed alternative:
skill_sharing(packages/shared/src/schemas/governance.ts), with one field,orgWide: everyone | editors | admins. A missing file meanseveryone, so nothing changes for any organization until an admin opts in. Policies are org config files, so there is no DB migration, per the create-migration contract. The mode set is named for an organization-wide audience in general, not skills only, so documents or projects can adopt it later.tale:skills.publish(lib/shared/competences.ts), lets an admin allow one member regardless of mode. It is granted, audited, expired and revoked like the othertale:capabilities.mayChooseOrgWideAudienceinbackend/core/lib/audience.ts, besideassertTeamsAssignable, decides with the role, the mode and a lazily read grant. Owners and admins always pass.editorsadmitsEDITOR_ROLES, which moved intoaudience.ts;core/projects/access.tsre-exports it. A disabled seat never passes. Thedomains/skills/publish.tsadapter reads the policy strictly. An unreadable file counts asadmins, so broken config never widens who may publish, and team sharing keeps working meanwhile.PUT /api/v1/skills/{slug}and an automation package's carried skills all resolve the answer and hand it to the file layer (saveSkillForViewer,prepareBundleWrite). The file layer fails closed when no answer is given. In a restricted mode, a non-publisher can't create an org-wide skill, widen a skill to org, or change an org-wide skill in place. They can still create team skills for their own teams, narrow a skill (edits can ride along in the same save), delete their own skills, and make a byte-identical save. An upload writes every file, so an org-wide bundle always needs the right. A carried skill that already matches what is stored is not a write, so it is not checked. The refusal isSKILL_PUBLISH_FORBIDDEN(403). It is registered inSKILL_ERROR_STATUS, in the REST error registry and in the OpenAPI spec, and it keeps its 403 on the package upload lane. It is audited asskill.publish_deniedwith statusdenied, in its own transaction.publishing: { mode, allowed }for the viewer.GET /api/v1/mereturnscapabilities.skillPublish. Owners and admins cost no policy or grant read./mecapability and a new error code, both additive. MCP has no skill tools and is unchanged.Checklist
bun run checkpasses: not run as one command; left to CI. The equivalent checks I ran are listed under Test plan.bun run lint:sastpasses: not run as a full scan; left to CI. The commit hook ran Opengrep on each commit's staged TS files.services/platform/messages/{en,de,fr}.yml:governance.skillSharing.*,governance.competences.capabilities.skillsPublish.*,skills.publishing.*andsettings.logs.audit.actionLabels.skill.publish_denied. German uses du and French uses tu. No de-CH override was needed because no new string contains ß.docs/{en,de,fr}/:platform/admin/governance/policies-and-limits.md(new "Decide who shares skills with everyone" section),platform/admin/governance/competences.md,platform/workspace/skills.md(audience at creation, a new "Who can share with everyone" section, upload) anddevelop/api-reference.md.services/docs/app/content/frontmatter.jsonwas regenerated.README.md/README.de.md/README.fr.md: N/A, nothing at README level changed.Test plan
The
@tale/platformserver suite (bun run test) ran in full: 889 files and 78,968 tests. The only red was oneerror-codes.test.tscase, caused by a backtickedDELETEin my spec text. I fixed it and re-ran the case, which is green along withscripts/openapi.The
@tale/platformUI suite (bun run test:ui) ran in full: 503 files and 4,289 tests, all green.@tale/sharedtests are green (620), plus typecheck and oxlint.@tale/platformtypecheck and the workspacebun run lint(oxlint type-aware) exit 0. Theservices/docstests pass (171) and so does its typecheck.bun run lint:manualis ok, andcheck-guide.tsis OK onsuites/skills.mdandsuites/governance.md.New or extended specs, covering each door × mode × role, the capability override and the unchanged default:
audience.test.ts: all 15 role × mode cases, including that the grant is read only when the role doesn't decide, a live grant overriding the mode, and a disabled seat.publish.test.ts: no policy means everyone; each mode by role; a grant; an unreadable policy reads asadmins; owners and admins short-circuit; the denied audit row, which is skipped for other errors and swallowed if the audit write itself fails.file_actions.test.ts: under a reserved mode, create (explicit and default org) is refused and writes nothing; a team create passes; widening is refused; an in-place edit is refused; an identical save passes; narrowing with an edit passes; delete passes; a publisher and an admin pass; a missing answer fails closed.prepareBundleWriterefuses org, unmarked and identical org re-uploads, and passes team uploads.routes.attribution.test.ts(app door: listingpublishing, save and upload answers, 403, and the denied audit throughapp/upload),upload.test.ts,errors.test.ts.v1-core.contract.test.ts: REST over a real config tree with a realskill-sharing.yml. A member is refused with 403 and an audit row and nothing is written; a team share passes; an Editor passes undereditors; a granted member passes.v1-core.test.ts:/meskillPublishwith no policy, by role, and with a grant.upload_impl.skills.test.ts(refused org and unmarked carried skills install nothing; a team skill installs; an unchanged org skill stays unchanged),upload.pool.test.tsandroutes.upload-status.test.ts(403 plus the denied audit throughautomation_package).hooks/mutations.test.ts,skill-create-pane.test.tsx,skill-detail-pane.test.tsx,skill-upload-pane.test.tsx,skill-sharing-policy-editor.test.tsx, plus the policies-limits loader test.New manual boxes: SKILL-F20, SKILL-B5, SKILL-B6 and GOV-F37. The error-codes register gains
SKILL_PUBLISH_FORBIDDEN, and the coverage map gains a row. The suite total in the manual readme now matches the real count (931).Review follow-up (three commits on top):
GOV-F37, notGOV-F35: open PRs fix(platform): apply the organization's custom instructions to agent runs #3774 and fix(platform): let admins cap any member's API key in the budget editor #3780 already claimGOV-F35andGOV-F36, and git would merge the duplicate ID without a conflict.lint:manualandcheck-guide.tspass on both suites.upload_impl.skills.test.tshas a case that failed before the change and passes after it. The automation server specs pass (55 files, 520 tests).SKILL_PUBLISH_FORBIDDENrefusal that the loaded listing still allowed now refreshes the skills listing, so the form switches to its reserved state. The reason is shown in the viewer's language through the newskills.publishing.refusedstring (en/de/fr): in the save action's toast (create step and skill dialog) and in the upload pane's toast, which showed the server's English sentence before. The newhooks/mutations.test.tsfailed before the change and passes after;skill-upload-pane.test.tsxgains the refusal case. The skills UI specs pass (7 files, 30 tests), and so do@tale/platformtypecheck, oxlint type-aware on the touched files, and thelib/i18nparity tests (185).Not verified:
backend:integrationwas not run, and no integration lane covers the policy yet.tale deployuploads release skills as the deploying operator through the app ZIP door, so a strict mode would refuse a release carrying an org-wide skill unless the operator is an Owner or Admin or holdstale:skills.publish. The policies page warns about this. Before a managed tenant switches toadmins, confirm the operator's role.everyone | adminsinstead of three modes, and whether non-publisher owners should keep in-place edits. I implemented the verdict's Phase 2 as briefed: three modes, and no in-place edits for non-publishers.Follow-ups:
governance-policies-limits.webpdoesn't show the new Skill sharing section, and there is no screenshot of the create dialog's new Visibility field. I didn't run the screenshot pipeline.upload-audience.integration.tsfor the policy across the real doors.