Skip to content

feat(platform): let admins reserve organization-wide skill sharing - #3801

Merged
yannickmonney merged 38 commits into
mainfrom
feat/skill-org-publish-policy
Sep 29, 2026
Merged

yannickmonney merged 38 commits into
mainfrom
feat/skill-org-publish-policy

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #3786; review only the top commits, from feat(shared): add the skill sharing governance policy onwards.

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:

  • Policy. A new governance policy file, skill_sharing (packages/shared/src/schemas/governance.ts), with one field, orgWide: everyone | editors | admins. A missing file means everyone, 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.
  • Capability. A new closed platform capability, 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 other tale: capabilities.
  • One rule. mayChooseOrgWideAudience in backend/core/lib/audience.ts, beside assertTeamsAssignable, decides with the role, the mode and a lazily read grant. Owners and admins always pass. editors admits EDITOR_ROLES, which moved into audience.ts; core/projects/access.ts re-exports it. A disabled seat never passes. The domains/skills/publish.ts adapter reads the policy strictly. An unreadable file counts as admins, so broken config never widens who may publish, and team sharing keeps working meanwhile.
  • Every write door. The app save, the app ZIP upload, 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 is SKILL_PUBLISH_FORBIDDEN (403). It is registered in SKILL_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 as skill.publish_denied with status denied, in its own transaction.
  • Existing org-wide skills are never narrowed. A non-publisher owner can still read, narrow or delete theirs.
  • Pre-flight. The app's skill listing returns publishing: { mode, allowed } for the viewer. GET /api/v1/me returns capabilities.skillPublish. Owners and admins cost no policy or grant read.
  • UI. Settings > Governance > Policies & Limits gets a Skill sharing control that uses the page's Save/Discard cluster. The skill create step now asks for the audience: Organization is preselected when the viewer may publish; otherwise Teams is preselected and Organization is disabled with the reason. A member in no team is told whom to ask. The skill dialog explains why an org-wide skill can't be changed in place and keeps Save off until the skill is narrowed. The upload preview flags an org-wide bundle and won't send it. The competence register offers Publish skills to the organization, and the audit log labels the refusal.
  • Contract. REST goes to 3.5.0 over the stacked 3.4.0: a new /me capability and a new error code, both additive. MCP has no skill tools and is unchanged.

Checklist

  • bun run check passes: not run as one command; left to CI. The equivalent checks I ran are listed under Test plan.
  • bun run lint:sast passes: not run as a full scan; left to CI. The commit hook ran Opengrep on each commit's staged TS files.
  • Translations updated in services/platform/messages/{en,de,fr}.yml: governance.skillSharing.*, governance.competences.capabilities.skillsPublish.*, skills.publishing.* and settings.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 updated in 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) and develop/api-reference.md. services/docs/app/content/frontmatter.json was regenerated.
  • README.md / README.de.md / README.fr.md: N/A, nothing at README level changed.

Test plan

  • The @tale/platform server suite (bun run test) ran in full: 889 files and 78,968 tests. The only red was one error-codes.test.ts case, caused by a backticked DELETE in my spec text. I fixed it and re-ran the case, which is green along with scripts/openapi.

  • The @tale/platform UI suite (bun run test:ui) ran in full: 503 files and 4,289 tests, all green.

  • @tale/shared tests are green (620), plus typecheck and oxlint. @tale/platform typecheck and the workspace bun run lint (oxlint type-aware) exit 0. The services/docs tests pass (171) and so does its typecheck. bun run lint:manual is ok, and check-guide.ts is OK on suites/skills.md and suites/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 as admins; 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. prepareBundleWrite refuses org, unmarked and identical org re-uploads, and passes team uploads.
    • routes.attribution.test.ts (app door: listing publishing, save and upload answers, 403, and the denied audit through app/upload), upload.test.ts, errors.test.ts.
    • v1-core.contract.test.ts: REST over a real config tree with a real skill-sharing.yml. A member is refused with 403 and an audit row and nothing is written; a team share passes; an Editor passes under editors; a granted member passes.
    • v1-core.test.ts: /me skillPublish with no policy, by role, and with a grant.
    • Package lane: 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.ts and routes.upload-status.test.ts (403 plus the denied audit through automation_package).
    • UI: 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):

    • The governance box is GOV-F37, not GOV-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 claim GOV-F35 and GOV-F36, and git would merge the duplicate ID without a conflict. lint:manual and check-guide.ts pass on both suites.
    • An automation package upload reads the publish right only when a carried skill is shared with the whole organization (an unmarked one included), still before the writer locks. A package with only team skills, or none, no longer reads the policy or logs an unreadable-policy error. upload_impl.skills.test.ts has a case that failed before the change and passes after it. The automation server specs pass (55 files, 520 tests).
    • A SKILL_PUBLISH_FORBIDDEN refusal 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 new skills.publishing.refused string (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 new hooks/mutations.test.ts failed before the change and passes after; skill-upload-pane.test.tsx gains the refusal case. The skills UI specs pass (7 files, 30 tests), and so do @tale/platform typecheck, oxlint type-aware on the touched files, and the lib/i18n parity tests (185).

Not verified:

  • I didn't bring up a stack or open a browser, so the flows are unobserved in a real browser session and against real Postgres: the grant read, the audit hash chain, and the new section's layout in German and French. SKILL-B5, SKILL-B6, SKILL-F20 and GOV-F37 cover them. backend:integration was not run, and no integration lane covers the policy yet.
  • The managed-deploy interaction is documented but untested. tale deploy uploads 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 holds tale:skills.publish. The policies page warns about this. Before a managed tenant switches to admins, confirm the operator's role.
  • The founder may still want to decide between two alternatives: offering only everyone | admins instead 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:

  • Screenshots: governance-policies-limits.webp doesn'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.
  • An integration lane in upload-audience.integration.ts for the policy across the real doors.

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
Base automatically changed from feat/skill-created-by to main September 29, 2026 04:06
…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.
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