Skip to content

fix(platform): scope automation runs to the projects the viewer can see - #3772

Merged
yannickmonney merged 10 commits into
mainfrom
fix/automation-runs-project-scope
Sep 29, 2026
Merged

yannickmonney merged 10 commits into
mainfrom
fix/automation-runs-project-scope

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This confidentiality fix makes app automation runs follow project visibility. Previously, every organization member could read a hidden project's run input, output, trace and pending question, cancel its runs and answer its questions, and binding lists disclosed hidden project IDs. This came up in customer feedback.

Organization runs stay readable by every member; project runs need read access to the project. A hidden run answers like a missing one: 404 on read, {ask: null}, {cancelled: false} and HUMAN_ASK_NOT_FOUND on answer. Scoped lists hide inaccessible projects, and the app, engine/MCP and REST binding lists read one shared visibility helper.

Admission and ownership:

  • A missing question is refused before answering, and every accepted app answer is pinned to the run whose visibility was checked.
  • On the app door, omitting projectId cannot infer a hidden sole binding or start an organization run across hidden bindings. Admission checks the bindings it actually resolves, including a binding committed while the request waits. An app start whose sole binding is an archived project gets the same PROJECT_ARCHIVED refusal as a named archived project.
  • The inferred-project checks apply only to the app door. Trigger, task and REST callers keep the scope they inferred before, unchecked. An earlier revision applied them to every caller. An event dispatch starts every listening automation in one savepoint without a per-trigger catch, so an automation whose sole binding was an archived project would have rolled back every other automation's run for that event, and its schedule would have been stamped start_refused.

Partial views of bindings (review round 2):

  • The editor's Projects section posts back only the bindings it was shown. A save used to replace the whole set, so a Developer outside a team silently deleted that team's bindings, and clearing the only visible binding turned a confidential automation into an organization one. The app save now replaces only the part of the set the author can read, keeps every binding outside it, and treats a hidden project that is not already bound as missing.
  • An automation bound only to hidden projects was listed with projectIds: [], which every client reads as organization scope. The app listing and the engine/MCP list now leave it out.
  • The start pre-check's hidden-project refusal now returns the same { error, message } body as the store's refusal, so the toast shows a sentence.

The latest main is merged in, including OAuth migration 0131. There is no schema change.

Checklist

  • bun run check passes (format, lint, typecheck, all tests). Not run as a whole; CI runs it. The targeted runs are listed under the test plan.
  • bun run lint:sast passes (Opengrep). Only the commit hook's local Opengrep pass ran, on the staged TypeScript files. The full repository scan is left to CI.
  • Translations: N/A. There are no new or changed UI strings or locale keys.
  • Docs updated in docs/{en,de,fr}/: platform/automations/execution-logs.md (which runs and questions a member sees), catalog.md (Projects offers only readable projects, a save keeps hidden bindings, and a hidden-only automation is left out of the list), and editor.md (the switcher leaves out hidden-only automations).
  • README: N/A. Nothing in the READMEs is affected.

Test plan

Round-2 fixes. Each new regression test failed on the previous head and passes now. The failing tests were checked by stashing the runtime changes and rerunning them.

  • store.bindings-visibility.test.ts: a save within a partial view deletes only readable bindings, keeps a hidden binding that is already bound without re-inserting it, refuses an unbound hidden project with AUTOMATION_PROJECT_UNKNOWN and writes nothing, and replaces the whole set when no view is given.
  • store.project-archived.test.ts: an app start whose sole binding is archived is refused, and a trigger start keeps its inferred archived binding.
  • routes.project-scope.test.ts: a Developer's binding save carries their readable projects, a hidden-only automation is left out of the listing, and the hidden start refusal carries the message.
  • dispatch-store.project-scope.test.ts: the engine/MCP list leaves out a hidden-only automation and keeps organization automations.

Checks run:

  • bun run --filter @tale/platform test -- backend/domains/automations backend/rest: 61 files, 1282 tests pass.
  • bun run --filter @tale/platform typecheck and bunx oxlint --type-aware on the automations domain and the REST automations router pass. oxfmt --check is clean.
  • services/docs tests pass: 35 files, 171 tests, including the EN/DE/FR docs parity and language checks.
  • bun run lint:manual passes with 1261 boxes. check-guide.ts passes on suites/automations.md.

Real PostgreSQL: checkAutomationProjectVisibility (in backend:integration) now also asserts four more things:

  • A hidden-only automation is absent from the app listing and the engine list.
  • A trigger start keeps its inferred archived sole binding.
  • A binding save within a partial view keeps the hidden binding.
  • An unbound hidden project is refused.

These round-2 additions typecheck and lint, but they were not executed: the local Docker daemon did not respond this round. The 59 checks reported for the earlier head ran against fresh PostgreSQL. The new assertions still need one backend:integration run.

Not verified: no live browser or two-session UI round (AUTO-B8, AUTO-B9 browser halves), no external vendor execution, no docs screenshot changes. No documented screenshot shows the affected states.

Existing policy boundaries and follow-ups

  • Any member who can see a run may still cancel it through the app. REST keeps its developer capability requirement.
  • /metrics still reports organization-wide aggregates per automation name.
  • REST GET /automations has done this since before this PR: it lists an automation bound only to hidden projects with projectIds: []. Changing it changes the versioned REST contract, so it is left as a follow-up.

The app door of /api/app/automations answered every run in the organization
to every member: the runs list without a project filter, a run by id, its
pending question, cancelling it and answering it, whatever project the run
belonged to. A member outside a team-restricted project could read that
project's run input, output and trace, stop its runs and answer its
questions, while the REST and engine doors already hid them.

Runs, questions and binding lists on the app door now follow the project read
rule the other doors use: organization runs stay visible to every member, a
project run needs read access to its project, and a hidden run answers like a
missing one (404, no question, nothing to cancel). A project-scoped listing or
start names a hidden project as not found. The rule lives in one module,
project-visibility.ts, which the engine door's store now uses too instead of
its private copy.

Who may cancel a visible run is unchanged (any member who can see it); the
run metrics endpoint still counts runs organization-wide by automation name.
…-scope-3772

# Conflicts:
#	services/platform/tests/manual/readme.md
Admission sent an inferred sole binding through the ownership, archived
and binding checks for every caller of beginRunInTx. An event dispatch
starts every listening automation inside one savepoint without a
per-trigger catch, so one automation sole-bound to an archived project
threw PROJECT_ARCHIVED and rolled back the runs and trigger stamps of
every other automation listening for the same event; its schedule was
also stamped start_refused on every occurrence.

Only the app door passes the viewer's readable projects, so the inferred
project is now checked only then. Trigger, task and REST callers keep the
scope they inferred before, unchecked, as on main.
Binding lists now answer only the projects the viewer can read, which
left two holes for someone who cannot read every bound project.

The editor seeds its Projects selection from that filtered list and posts
the whole set back, and the save replaced every binding. A Developer
outside a team therefore silently deleted the bindings to that team's
projects, and clearing the only binding they could see turned a
confidential automation into an organization one. The app save now
passes the author's readable projects: it replaces only that part of the
set, keeps every binding outside it, and answers a hidden project that
is not already bound like a missing one.

An automation bound only to hidden projects was still listed, with no
bindings, which every client reads as organization scope: the switcher
grouped it with organization automations, the list routed it to the
organization URL and a start there failed. The app listing and the
engine/MCP list now leave such an automation out.

The real-Postgres visibility check covers both, plus a trigger start that
keeps its inferred sole binding.
The app start's hidden-project pre-check answered a bare
{ error: 'PROJECT_NOT_FOUND' }, while the same refusal from admission
carries the message the app's toast reads. It now throws the store's
AutomationError through the shared error mapping, so both paths answer
the same body.

REST kept its own copy of the readable-project lookup beside the shared
project visibility helper; it now reads the helper, so every door
filters bindings through one rule.
The platform pages still described the Runs tab as the latest 50 runs
and the switcher as every automation in the organization. Runs,
questions and bindings now follow project visibility, so the pages say
so in EN, DE and FR: organization runs are visible to every member, a
project's runs and questions only to people who can open it, Projects
offers only readable projects and a save keeps the hidden bindings, and
an automation bound only to hidden projects is left out of the list and
the switcher.
AUTO-B9 checks that a Developer outside a team keeps that team's
bindings when saving an automation's projects, and does not see an
automation bound only to the team's project as an organization one. The
automation coverage row names the specs that own its backend half.
…roject-scope

# Conflicts:
#	services/platform/tests/manual/readme.md
…roject-scope

# Conflicts:
#	services/platform/tests/manual/readme.md
@yannickmonney
yannickmonney merged commit 380ae08 into main Sep 29, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the fix/automation-runs-project-scope branch September 29, 2026 02:33
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