Skip to content

feat(platform): cap what a project spends with a Project budget rule - #4505

Merged
yannickmonney merged 41 commits into
mainfrom
feat/project-budget-scope
Oct 8, 2026
Merged

yannickmonney merged 41 commits into
mainfrom
feat/project-budget-scope

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What

A budget rule can now cap a project: Settings > Governance > Policies & Limits → Add rule → Scope: Project, then pick the project.

A project's cap measures everything spent in that project, whoever spends it:

  • the project's chats — replies, their titles, answers read aloud, and the assistant's tool calls;
  • the turns of the project's agents and the agent steps of automations run in it, with the images they generate;
  • calls made with the project's own API keys (the model endpoints).

It applies on top of the spender's own limits — a run a schedule started included — and never to work outside the project. An automation counts toward the project its run names; a run that names none, of an automation installed in several projects, counts toward each of them and must fit each one's cap, as a member's spend counts toward each of their teams; an automation installed in no project counts toward the organization alone. Chat replies and agent turns still running in the project hold what they may spend against the cap, so requests sent at the same moment cannot pass a nearly reached project cap together. A project cap warns no one before it is reached, so the dialog offers no warning threshold for it.

A chat send the cap refuses now says so — "This project's usage limit has been reached. It applies only to the work in this project, and your administrator can raise it." — on every path: the send itself, edits and regenerations, the arena, and the transcript rows a parked or REST-queued send leaves. The generic copy pointed members at Settings > Usage, which never lists a project's cap. A REST 429 BUDGET_EXCEEDED names it as data.scope: project (contract 3.22.0).

Not counted toward a project: transcribed recordings and video ingestion (booked to the person who added them). Stated in the docs and the spec's Not yet.

How

  • Migration 0155_project_usage: app.project_usage — the project's own daily/weekly/monthly buckets — and sandbox_session_ops.project_ids (an op of a run installed in several projects is in each). incrementUsageLedger books each project's share there beside the ledger row; a new table because the ledger's upsert conflict target cannot gain a column mid-roll.
  • Gate (budget-gate.ts, budget_enforcement.ts): a project bucket beside the team and organization buckets; holds count toward it through the thread (app.generations → thread_metadata.project_id) or the projects an op's reservation or image hold stamped (summed per project, like the team holds). A project's own key always spends in its project.
  • Lanes naming the project: chat turns (app, REST, arena, forks, parked sends), chat titles, voice output, the assistant's tool bookkeeping, agent and automation agent turns and their images (resolveSessionOpAttribution: an automation run's own project, else every project its automation is bound to), model-endpoint requests.
  • Moving a conversation to another project now moves its hidden edit/regenerate branches and arena column too — later turns run on those rows, so they used to keep spending in the project the conversation had left.
  • Config: project caps live in the budgets file's projectRules, never in rules. An image from before this change still parses the file and keeps every other cap; a project scope inside rules would have made the whole file unreadable to it — and an unreadable budgets file means no cap at all.
  • Editor: switching a rule's scope drops the previous scope's target (a user's id saved as a project cap matched nothing); the table keeps the saved order, so Edit/Delete keep naming the same row after the save lands; an archived project carries its badge, a deleted one reads Deleted project with a hint in the dialog.
  • Retention ages the project buckets with the ledger; deleting the organization removes them like every org-keyed table.
  • Docs (en/de/fr): policies and limits (with a new screenshot, governance-budget-project-rule), usage attribution, member usage, API keys, rate limits, the editor guide. Spec GOV-R14; APIKEY-R9 points at it. Manual box GOV-F54. Governance README rule 9 and lane table.

Found, fixed in #4507

An automation's llm step was admitted against no budget and booked to no ledger — not the organization's, a person's, a key's or a project's (core/automations/llm_call.ts). It predates this PR; #4507, stacked on it, checks each call against the run's limits and books it under the run's subject and projects.

Verification

  • Unit/component: platform server + PII suites (82,851), UI suite (6,262), shared schemas, guards, knip, tsc, oxlint, lint:links, lint:manual, docs tests.
  • Real Postgres: ITEST_LANES=checkProjectBudgets,checkRetentionAuditTrail — 26/26: bookings land in the project's buckets beside the ledger; a scheduled run of an automation installed in two projects stamps both on its op, holds in both and books into both; a send in the project's thread is admitted, then refused once a turn in flight fills the cap, while a thread outside the project is admitted; a model request at the cap is refused, and once there is room it stamps its project and its hold counts toward the project; refiling a conversation out of the project and back moves its hidden branch both times; retention ages the buckets.
  • Browser (fresh stack, mock provider): added a Project · Website relaunch · Monthly · 2 requests rule — the file got projectRules beside the untouched rules, and the row survives a reload. A first message in the project booked the reply and its title to the project (2 requests); the next send was refused with the project toast; a chat outside the project still answered and left the project's buckets unchanged; Settings > Usage is unchanged.
  • Three independent reviews (enforcement, booking lanes, UI/docs); their findings are fixed in the follow-up commits.

Rolling deploy

Additive: a new table and a nullable column the previous image never reads. During the roll, the previous image books no project share, so a project's period that spans the deploy undercounts it, and it ignores projectRules. An Admin who saves the budget rules on a previous-image pod mid-roll writes the file without projectRules, dropping the project caps; re-add them after the roll.

Stacked on #4501.

DatePicker takes minDate/maxDate (days outside are disabled and read
"Not available" in the UI language) and forwards id, aria-labelledby
and aria-describedby to its trigger, which dropped them before.
The create dialog offered 7/30/90 days, a year or never, and the date a
key stopped working was shown nowhere. Expiration now adds Custom date,
a calendar bounded to tomorrow through a year from today (the api-key
plugin's window), and names the day the key expires under the field.
The keys table gets an Expires column: the date, Never, or Expired for a
key that ran out while the list was open.
Nothing outside the expiry helpers reads the 365-day ceiling, and Knip refuses an export no module imports.
Owners and Admins can now make an API key for another member, a team, a
project or the organization itself. A member's key acts as that member, in
this organization only; the member is notified, sees it and can revoke it.
A team's, a project's or the organization's key is not a person: it acts as
its own identity with the role chosen under Acts as (never above the
maker's), keeps working when its maker leaves, and works in its one
organization. A team's key sees what the team sees; a project's key reaches
its project alone, and any other REST route answers 403
API_KEY_SCOPE_FORBIDDEN.

Such a key spends under its own name: no personal, role or default limit
binds it, the organization's limits and the key's own rules do, and a
team's key counts toward and is held to its team's caps. Usage analytics
shows it as its own row, never an active user. A key ends with what it
belongs to: deleting the team or the project, removing the member or
deleting the organization revokes it, audited as the system.

The binding lives in app.api_key_owners (0154). The REST door reads it on
every keyed request, GET /me answers key.owner (contract 3.18.0), and the
api-key plugin's update and delete refuse a key an organization manages.
The keys table gains a Belongs to column.
API keys, policies and limits, usage attribution and the API reference say who a key made for someone else acts as, what it reaches and whose limits its spend counts toward, in English, German and French. The Create API key screenshot shows Belongs to, and a second one shows the organization's own key acting as a Developer.
A run a team's, project's or organization's key started through a REST comment books under the key's identity without naming the key, so the key's own cap never saw it. The key's bucket now counts the identity's bookings and holds too. The budget gate also reads a revoked binding: the work a key started before its revocation keeps spending as the key instead of being measured as a person with the default cap.
The capability dispatch behind POST /api/v1/mcp read the member table directly, so a team's or the organization's own key passed the door and was refused there. It now reads the acting member, and refuses a project's key, which reaches its project alone.
A review found ways a key made for someone else could reach further than
its owner meant:

- A project's key could read the organization's contacts, products,
  websites and inbox through the chat assistant, and hub document titles
  through its file listing. The chat tools now give it its project's files
  and tasks alone.
- A key made for a member authenticated as the member, so an image that
  does not read the binding (mid-roll or after a rollback) let it act as
  the member in every organization. Every bound key now authenticates as an
  identity of its own, and only the binding says whom it acts as.
- A member's key outlived its maker's authority: an admin could demote a
  peer, make a key for them and promote them back. The key now acts only
  while its maker is an Owner or Admin above the member, and the keys a
  member made end when they leave.
- An expired key's identity kept acting in runs it had started, a key
  identity could be made a member, a member's key carried the member's
  standing in other organizations into the browser-session gate, and a
  key could be bound to a target removed while it was minted. Each is
  closed: acting needs a live key row, the members door refuses key
  identities, the gate reads the bound membership alone, and the binding
  transaction checks its target again.
The team's delete confirmation now counts the API keys that belong to the
team, which stop working with it.

The key dialogs also say what they could not before: a picker for whom a
key belongs to names why Create stays off when nothing is picked, a search
that matches nobody says so instead of claiming there is no one to pick,
a key made for someone else is not "your" key on the success view, a key
of a deleted team or project reads as such, and a failed revocation is
reported once, with the refusal's own words.
Owners and Admins see and revoke the keys made here for others, never a member's own keys. A member's key stops when its maker no longer outranks the member; deleting a team or a project, or removing a member, revokes keys, while deleting the organization deletes them. A project's key reads none of the organization's contacts, products, websites or inbox through the chat assistant, and keys made for others have their own rate-limit budget. The team and member pages, usage analytics and the API reference say so, and the manual boxes and error-code rows match.
A budget rule can now cap one project: everything spent in it, whoever
spends it — its chats (titles, read-aloud answers and the assistant's
tool calls included), its agents' and automations' turns with their
images, and its own API keys at the model endpoints. A project's cap
binds work in the project on top of the spender's own caps, a run a
schedule started included, and nothing outside it.

Bookings that name a project land in the project's own period buckets,
app.project_usage (0155), beside the ledger row; holds in flight count
toward the project through their thread or the project their op stamped.
Project caps live in the budgets file's projectRules, so an image from
before them still parses the file and keeps every other cap. Retention
ages the buckets with the ledger. A REST 429 BUDGET_EXCEEDED names such
a cap as data.scope project (contract 3.19.0).
…chat

The budget editor offers a Project scope with a picker of the active
projects; a rule keeps naming its project after the project is archived,
and is saved into the file's projectRules. A chat send a project's cap
refuses says so — the project's limit, which Settings > Usage does not
list — instead of pointing the member at their own usage. The arena
door names the refusing cap as the send door does.
Policies and limits, usage attribution and API keys (en/de/fr) say what
a project's budget caps and how it combines with the other limits; the
governance suite gains GOV-F54 and the automation reference names the
specs that own the rest.
A project's cap warns no one, so the threshold the dialog offered for it limited nothing. The field is gone for the Project scope, and switching a rule to it drops its threshold.
A new capture of the Add budget rule dialog with a project chosen illustrates the project budget on Policies and limits (en/de/fr), and the rate-limit and editor guides list a project's cap among those a 429 BUDGET_EXCEEDED can name.
…hanges

Switching a rule's scope now drops the previous scope's target, which used to save a project cap naming a user or a role and matching nothing. The table keeps the order the saved file reads back, so a row's Edit and Delete keep naming the same rule when the save lands. A rule's project shows the Archived badge when it is archived and reads Deleted project, with a hint in the dialog, once it is gone.
A parked send the worker fires, an arena column refused after the pair was admitted, and a REST-queued turn now store whose cap stopped them beside the budget_exceeded code, so their transcript rows read as the project's limit rather than pointing at Settings > Usage, which never lists it. The toast no longer promises that chats outside the project work: another cap may be spent too.
Runs a schedule started are held to a project's cap when they run in one; Settings > Usage does not list a project's limit; GOV-F54 now expects the toast the app shows and the reply plus title as the project's two requests; the REST send and BUDGET_EXCEEDED scope descriptions read plainly.
…on image holds

Moving a conversation to another project now moves its hidden edit and regenerate branches and its arena column too: the app runs later turns on those rows, so a turn on a branch kept spending in, and being capped by, the project the conversation had left — a way past a project's cap. An image's hold on an agent turn whose op its reservation did not stamp (a subscription turn's) now records the turn's project, so concurrent images in a project count against its cap together.
A project's budget counts the agent steps of automations run in it, not their model steps, which no limit admits or books yet (spec Not yet). Chat replies and agent turns hold against it while they run; voice output is checked but holds nothing; a refused chat message says the project's limit was reached.
…oject cap

A run a schedule or an event starts for an automation installed in more than one project runs in none of them today, so no project's budget binds it; the governance spec records which project such a run should spend in as an open question.
…e lineage test

The toast and the transcript chose a reached cap's hint in two ternaries, which the i18n usage guard could not trace to the chat catalog; budgetExceededI18nKey in lib/shared/chat-errors.ts now owns the choice. The refiling test's fake row takes a branch's root id.
The project-budget lane files a conversation with a hidden branch out of its project and back over the real chat door, and checks the branch follows both moves on the real schema.
An automation run belongs to the project it names; one that names none belongs to every project its automation is bound to — the set its language context, skills and session reach already act in — and an automation bound to none spends in no project. Such a run now counts toward each of its projects and must fit each one's cap, as a member's spend counts toward each of their teams.

A budget subject, a booking and an op's hold carry a set of projects (projectIds); sandbox_session_ops stamps project_ids (0155, not yet on main); holds count toward every project they name, and each project's buckets are booked once per call.
An automation counts toward the project it runs in; a run that names none counts toward every project its automation is installed in and must fit each budget; an automation installed in none counts toward the organization alone (en/de/fr).
@yannickmonney

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES — review of f3ac1c52e8ca513eb589e813aae26e2753a1c22d only (TALE-1170). I did not author this implementation. The live PR is now at 50ab8b3e7dbed01fcc3639d38a7082bf520449d4; this comment does not approve or assess the two later commits.

  1. Blocking scope mismatch against the assigned merge base. Comparing 4e5a70b648e761393594f500e206da9f4f49d2b1 to the reviewed head returns 24 commits and 240 changed files, including the 11 commits from acbc9156c772a09d903989fadda412fd2c8aa546 through 1ed6561c9b09ac64fe44d2105669e90e4534de76 for date-picker/API-key ownership and expiry work. The task explicitly requires every commit to belong to the project-budget feature. The PR describes a stack on feat(platform): make API keys for members, teams, projects and the org #4501, so this is an identifiable prerequisite stack rather than unexplained carry-over; it nevertheless fails the assigned scope gate. Land/reconcile the prerequisite and provide the resulting immutable base/head and complete scope for independent review.

  2. Project voice spending can race past the cap. In services/platform/backend/domains/tts/service.ts:442, reserveChunk checks the project's booked usage plus only this chunk's prospective cost/request. Its advisory lock at lines 305–308 is per message/chunk, and the provider runs before markChunkReady books the spend (lines 587–604). checkTtsBudget calls checkOrgBudget without in-flight reservations; the shared reservations reader accounts only for generations and sandbox ops, not pending TTS chunks. With 3 requests remaining below a cap, four distinct chunks can each see the same booked total, pass the +1 check, and then book four requests. The new project attribution therefore does not meet the task's concurrent-cap requirement on a claimed spend path. Reserve TTS spend under the shared admission discipline, count pending holds, and settle/release them atomically; add a real-Postgres concurrent regression. This is source-derived evidence; I did not run that reproduction.

CI snapshot at the reviewed SHA:

Aggregator Observed result Check ID
CI ready (Checks) UNAVAILABLE — absent at this head —
CI ready (Commitlint) UNAVAILABLE — absent at this head —
CI ready (SAST) completed / success 113010690144
CI ready (Security) UNAVAILABLE — absent at this head —
CI ready (CLI) completed / success 113013007319
CI ready (E2E) UNAVAILABLE — absent at this head —
CI ready (Build) UNAVAILABLE — absent at this head —

Only 16 check runs were returned, on one complete page. Missing checks are unavailable, not passing or pending. No unfinished CI-ready aggregator was observed. Successful terminal statuses are metadata only; dependency logs/cache artifacts were not audited.

This is a bounded negative source audit, with incomplete coverage of both review parts. Observed: policy writes require organization-admin authorization at the governance route; project bucket reads/writes include org ID; migration 0155 is additive; the central writer adds three project upserts per attributed call; shared chat/op holds use an organization admission lock. These observations are not complete tenant, runtime, migration or performance proof. UI rendering/accessibility/responsiveness, locale parity, docs behavior, remaining spend consumers, deployment/recovery and test artifacts remain unverified. No clone, test, install, build, push or merge was performed.

The exact-head diff has 240 files rather than the brief's 101. Files with incomplete or no file-level review are listed below (even where a targeted region was inspected):

Uncovered file scope
  • docs/de/develop/api-reference.md
  • docs/de/develop/rate-limits.md
  • docs/de/develop/use-tale-from-your-editor.md
  • docs/de/get-started/developers.md
  • docs/de/platform/admin/api-keys.md
  • docs/de/platform/admin/governance/policies-and-limits.md
  • docs/de/platform/admin/governance/usage-analytics.md
  • docs/de/platform/admin/governance/usage-attribution.md
  • docs/de/platform/admin/members-and-roles.md
  • docs/de/platform/admin/teams.md
  • docs/de/platform/member/preferences.md
  • docs/de/tutorials/developer/call-tale-from-a-script.md
  • docs/en/develop/api-reference.md
  • docs/en/develop/rate-limits.md
  • docs/en/develop/use-tale-from-your-editor.md
  • docs/en/get-started/developers.md
  • docs/en/platform/admin/api-keys.md
  • docs/en/platform/admin/governance/policies-and-limits.md
  • docs/en/platform/admin/governance/usage-analytics.md
  • docs/en/platform/admin/governance/usage-attribution.md
  • docs/en/platform/admin/members-and-roles.md
  • docs/en/platform/admin/teams.md
  • docs/en/platform/member/preferences.md
  • docs/en/tutorials/developer/call-tale-from-a-script.md
  • docs/fr/develop/api-reference.md
  • docs/fr/develop/rate-limits.md
  • docs/fr/develop/use-tale-from-your-editor.md
  • docs/fr/get-started/developers.md
  • docs/fr/platform/admin/api-keys.md
  • docs/fr/platform/admin/governance/policies-and-limits.md
  • docs/fr/platform/admin/governance/usage-analytics.md
  • docs/fr/platform/admin/governance/usage-attribution.md
  • docs/fr/platform/admin/members-and-roles.md
  • docs/fr/platform/admin/teams.md
  • docs/fr/platform/member/preferences.md
  • docs/fr/tutorials/developer/call-tale-from-a-script.md
  • packages/shared/src/schemas/governance-budgets.test.ts
  • packages/shared/src/schemas/governance.ts
  • packages/ui/src/components/forms/date-picker.test.tsx
  • packages/ui/src/components/forms/date-picker.tsx
  • packages/ui/src/i18n/messages/de.yml
  • packages/ui/src/i18n/messages/en.yml
  • packages/ui/src/i18n/messages/fr.yml
  • services/docs/public/images/get-started/settings-api-keys.webp
  • services/docs/public/images/manifest.json
  • services/docs/public/images/platform/governance-budget-project-rule.webp
  • services/docs/public/images/platform/settings-api-keys-organization.webp
  • services/platform/app/features/analytics/usage/users-table.tsx
  • services/platform/app/features/chat/components/chat-surface.tsx
  • services/platform/app/features/chat/data/arena-actions.ts
  • services/platform/app/features/chat/data/branch-actions.test.tsx
  • services/platform/app/features/chat/data/branch-actions.ts
  • services/platform/app/features/chat/data/chat-backend.ts
  • services/platform/app/features/chat/utils/classify-refusal.test.ts
  • services/platform/app/features/chat/utils/classify-refusal.ts
  • services/platform/app/features/chat/utils/sanitize-chat-error.test.ts
  • services/platform/app/features/chat/utils/sanitize-chat-error.ts
  • services/platform/app/features/chat/utils/turn-error-toast.test.ts
  • services/platform/app/features/chat/utils/turn-error-toast.ts
  • services/platform/app/features/settings/api-keys/components/api-key-create-dialog.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-create-dialog.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-dialog-refusal.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-expires-cell.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-expires-cell.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-expiry-field.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-owner-cell.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-owner-cell.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-owner-field.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-revoke-dialog.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-revoke-dialog.tsx
  • services/platform/app/features/settings/api-keys/components/api-key-row-actions.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-keys-table.browser.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-keys-table.test.tsx
  • services/platform/app/features/settings/api-keys/components/api-keys-table.tsx
  • services/platform/app/features/settings/api-keys/hooks/use-api-keys-table-config.test.tsx
  • services/platform/app/features/settings/api-keys/hooks/use-api-keys-table-config.tsx
  • services/platform/app/features/settings/api-keys/hooks/use-api-keys.test.tsx
  • services/platform/app/features/settings/api-keys/hooks/use-api-keys.ts
  • services/platform/app/features/settings/api-keys/lib/expiry.test.ts
  • services/platform/app/features/settings/api-keys/lib/expiry.ts
  • services/platform/app/features/settings/api-keys/types.ts
  • services/platform/app/features/settings/governance/components/budget-editor.test.tsx
  • services/platform/app/features/settings/governance/components/budget-editor.tsx
  • services/platform/app/features/settings/teams/components/team-delete-dialog.test.tsx
  • services/platform/app/features/settings/teams/components/team-delete-dialog.tsx
  • services/platform/app/lib/backend/budget-refusal.ts
  • services/platform/app/lib/backend/chat.test.ts
  • services/platform/app/lib/backend/chat.ts
  • services/platform/app/lib/backend/contract/governance.ts
  • services/platform/app/lib/backend/contract/team-members.ts
  • services/platform/app/routes/dashboard/$id/settings/api/rest.loader.test.ts
  • services/platform/app/routes/dashboard/$id/settings/api/rest.tsx
  • services/platform/backend/app.ts
  • services/platform/backend/auth/api-key-create-gate.ts
  • services/platform/backend/auth/auth.api-key-audit.test.ts
  • services/platform/backend/auth/auth.api-key-bound.test.ts
  • services/platform/backend/auth/auth.ts
  • services/platform/backend/auth/membership.teams.test.ts
  • services/platform/backend/auth/membership.ts
  • services/platform/backend/core/chat/assistant_tools.test.ts
  • services/platform/backend/core/chat/assistant_tools.ts
  • services/platform/backend/core/chat/turn_action.ts
  • services/platform/backend/core/collab/types.ts
  • services/platform/backend/core/governance/budget_enforcement.test.ts
  • services/platform/backend/core/governance/budget_enforcement.ts
  • services/platform/backend/core/governance/get_org_usage_metrics.ts
  • services/platform/backend/core/notifications/notification_link_cases.ts
  • services/platform/backend/core/notifications/personal_notification_url.ts
  • services/platform/backend/core/tasks/agent_run_host.connector_caller.test.ts
  • services/platform/backend/db/migrations/0154_api_key_owners.sql
  • services/platform/backend/domains/api_keys/owners.integration.ts
  • services/platform/backend/domains/api_keys/owners.test.ts
  • services/platform/backend/domains/api_keys/owners.ts
  • services/platform/backend/domains/api_keys/retire.test.ts
  • services/platform/backend/domains/api_keys/retire.ts
  • services/platform/backend/domains/api_keys/routes.test.ts
  • services/platform/backend/domains/api_keys/routes.ts
  • services/platform/backend/domains/api_keys/service.test.ts
  • services/platform/backend/domains/api_keys/service.ts
  • services/platform/backend/domains/api_keys/spec.md
  • services/platform/backend/domains/browser_sessions/service.ts
  • services/platform/backend/domains/chat/budget-admission.test.ts
  • services/platform/backend/domains/chat/budget-admission.ts
  • services/platform/backend/domains/chat/capabilities.test.ts
  • services/platform/backend/domains/chat/capabilities.ts
  • services/platform/backend/domains/chat/deferred-sends.ts
  • services/platform/backend/domains/chat/rest-turn.ts
  • services/platform/backend/domains/chat/routes.test.ts
  • services/platform/backend/domains/chat/routes.ts
  • services/platform/backend/domains/chat/service.ts
  • services/platform/backend/domains/chat/shim.knowledge-scope.test.ts
  • services/platform/backend/domains/chat/shim.ts
  • services/platform/backend/domains/chat/store.test.ts
  • services/platform/backend/domains/chat/store.ts
  • services/platform/backend/domains/chat/threads.test.ts
  • services/platform/backend/domains/chat/threads.ts
  • services/platform/backend/domains/collab/email-sink.ts
  • services/platform/backend/domains/connectors/bridge-routes.test.ts
  • services/platform/backend/domains/connectors/bridge-routes.ts
  • services/platform/backend/domains/conversations/search-chat.privacy.test.ts
  • services/platform/backend/domains/conversations/search-chat.ts
  • services/platform/backend/domains/files/access.ts
  • services/platform/backend/domains/governance/README.md
  • services/platform/backend/domains/governance/api-keys.ts
  • services/platform/backend/domains/governance/budget-gate.test.ts
  • services/platform/backend/domains/governance/budget-gate.ts
  • services/platform/backend/domains/governance/budget-refusal.ts
  • services/platform/backend/domains/governance/budget-reservations.test.ts
  • services/platform/backend/domains/governance/project-budget.integration.ts
  • services/platform/backend/domains/governance/routes.api-keys.test.ts
  • services/platform/backend/domains/governance/routes.test.ts
  • services/platform/backend/domains/governance/routes.ts
  • services/platform/backend/domains/governance/service.test.ts
  • services/platform/backend/domains/governance/spec.md
  • services/platform/backend/domains/governance/usage-ledger.test.ts
  • services/platform/backend/domains/governance/usage-metrics.test.ts
  • services/platform/backend/domains/governance/usage-metrics.ts
  • services/platform/backend/domains/knowledge/service.retrievable-caller.test.ts
  • services/platform/backend/domains/knowledge/service.ts
  • services/platform/backend/domains/members/service.add-member.test.ts
  • services/platform/backend/domains/members/service.ts
  • services/platform/backend/domains/organizations/service.test.ts
  • services/platform/backend/domains/organizations/service.ts
  • services/platform/backend/domains/projects/service.ts
  • services/platform/backend/domains/retention/audit-trail.integration.ts
  • services/platform/backend/domains/retention/service.audit.test.ts
  • services/platform/backend/domains/retention/service.ts
  • services/platform/backend/domains/sandbox/image-generation.test.ts
  • services/platform/backend/domains/sandbox/image-generation.ts
  • services/platform/backend/domains/sandbox/op-attribution.test.ts
  • services/platform/backend/domains/sandbox/spend-settlement.test.ts
  • services/platform/backend/domains/sandbox/spend-settlement.ts
  • services/platform/backend/domains/sandbox/turn-budget.test.ts
  • services/platform/backend/domains/tasks/run-authority.ts
  • services/platform/backend/domains/tasks/service.ts
  • services/platform/backend/domains/teams/service.test.ts
  • services/platform/backend/domains/teams/service.ts
  • services/platform/backend/domains/tts/service.project-budget.test.ts
  • services/platform/backend/domains/tts/service.ts
  • services/platform/backend/domains/users/create-member.test.ts
  • services/platform/backend/integration-check.ts
  • services/platform/backend/jobs/task-list.agent-retry.test.ts
  • services/platform/backend/jobs/task-list.generate-title.test.ts
  • services/platform/backend/jobs/task-list.ts
  • services/platform/backend/rest/api-key-scope.test.ts
  • services/platform/backend/rest/api-key-scope.ts
  • services/platform/backend/rest/bound-key.test.ts
  • services/platform/backend/rest/bound-key.ts
  • services/platform/backend/rest/error-codes.test.ts
  • services/platform/backend/rest/error-codes.ts
  • services/platform/backend/rest/shared.ts
  • services/platform/backend/rest/v1-browser-sessions.test.ts
  • services/platform/backend/rest/v1-browser-sessions.ts
  • services/platform/backend/rest/v1-core.crm.test.ts
  • services/platform/backend/rest/v1-core.test.ts
  • services/platform/backend/rest/v1-core.ts
  • services/platform/backend/rest/v1-mcp.ts
  • services/platform/backend/rest/v1-threads.test.ts
  • services/platform/backend/rest/v1-threads.ts
  • services/platform/backend/rest/v1.test.ts
  • services/platform/backend/rest/v1.ts
  • services/platform/backend/telemetry.ts
  • services/platform/lib/chat/turn.test.ts
  • services/platform/lib/chat/turn.ts
  • services/platform/lib/i18n/keys-dynamic.yml
  • services/platform/lib/shared/chat-errors.test.ts
  • services/platform/lib/shared/chat-errors.ts
  • services/platform/lib/shared/constants/api-contract.ts
  • services/platform/lib/shared/notifications/target.ts
  • services/platform/lib/shared/role-rank.ts
  • services/platform/messages/de/analytics.yml
  • services/platform/messages/de/chat.yml
  • services/platform/messages/de/governance.yml
  • services/platform/messages/de/inbox.yml
  • services/platform/messages/de/settings.yml
  • services/platform/messages/en/analytics.yml
  • services/platform/messages/en/chat.yml
  • services/platform/messages/en/governance.yml
  • services/platform/messages/en/inbox.yml
  • services/platform/messages/en/settings.yml
  • services/platform/messages/fr/analytics.yml
  • services/platform/messages/fr/chat.yml
  • services/platform/messages/fr/governance.yml
  • services/platform/messages/fr/inbox.yml
  • services/platform/messages/fr/settings.yml
  • services/platform/public/openapi.json
  • services/platform/scripts/openapi/contract-fingerprint.json
  • services/platform/scripts/openapi/spec.ts
  • services/platform/tests/docs-screenshots/manifest.ts
  • services/platform/tests/manual/readme.md
  • services/platform/tests/manual/reference/automation.md
  • services/platform/tests/manual/reference/error-codes.md
  • services/platform/tests/manual/suites/governance.md
  • services/platform/tests/manual/suites/settings.md
  • tools/cli/turbo.json

@yannickmonney

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES — API-only re-review of 50ab8b3e7dbed01fcc3639d38a7082bf520449d4 (TALE-1172), independent of the implementation. This assesses the two prior findings in comment 6047220759 and the complete 37-file delta from f3ac1c52e8ca513eb589e813aae26e2753a1c22d.

Prior finding 1: CLOSED for the current PR base. The live base and compare merge base are now 1ed6561c9b09ac64fe44d2105669e90e4534de76; that comparison contains 15 commits and 101 files. The commit list starts at a0b0553f0a10a9ef2a9dc3090183626cdb0cfbd4 and contains project-budget implementation/docs/tests, ending at the quoted head. The prerequisite date-picker/API-key commits are no longer in the PR range. Comparing against the old assigned base 4e5a70b648e761393594f500e206da9f4f49d2b1 still returns 26 commits / 240 files; the closure is the reconciled current PR range, not a claim that the old comparison changed. This is a history/metadata finding, so commit and merge-base IDs are its exact evidence rather than source lines.

  1. Prior finding 2: still OPEN — voice admissions can exceed the project cap. services/platform/backend/domains/tts/service.ts:305–308 serializes only a message/chunk pair. At :430–446, the change merely passes [projectId] to the subject before the same prospective check. checkTtsBudget at :246–254 delegates to checkOrgBudget; domains/governance/budget-gate.ts:584–587 passes no reservations. The in-flight reader at domains/governance/budget-reservations.ts:126–154 still reads only generations and sandbox ops, not pending TTS chunks. Voice calls the provider at tts/service.ts:776 and books usage afterwards at :587–605. With three requests of room, four different chunks can each pass against the same booked total and later book four requests. Even sequential reservations before any provider finishes can do this; the rate limiter does not reserve the project budget. There is no shared admission/hold concurrency guarantee for this path. The changed service.project-budget.test.ts:145–190 covers attribution and an already-spent cap using scripted SQL; it is not a concurrent PostgreSQL regression and would not detect this race. Reserve/count pending voice spend under the shared budget admission discipline and settle/release it atomically. Add a real-Postgres regression with distinct chunks and delayed provider completion that exceeds the cap on the old implementation and refuses the excess admission on the repair. No such old-fails/new-passes proof was observed.

  2. New DATA finding — multi-project settlement can charge a different set from admission. domains/sandbox/op-attribution.ts:101–119 reads the automation's current bindings on every resolution. turn-budget.ts:150–173 stamps the admitted set onto the op, and budget-reservations.ts:143–184 counts that stamped set. But spend-settlement.ts:211–241 resolves attribution again; the live workflow-run branch returns before the stamped fallback at op-attribution.ts:146–166. If an unscoped run reserves in projects A/B, then B is unbound while its provider work runs, settlement books only A and marks the op settled, removing B's hold without replacing it with usage. Conversely, binding C before settlement charges C without checking C's cap. Bindings are mutable: domains/automations/store.ts:1002–1022 replaces the set, and :1080–1091 removes one installation while retaining run history. Settle the project attribution captured by the reservation, or provide an atomic transfer/re-admission mechanism if live rebinding is intended. Add a real-Postgres reserve → binding change → settle regression for removal and addition. The new stable-binding integration scenario at domains/governance/project-budget.integration.ts:277–359 does not exercise this case. This is source-derived evidence; no runtime reproduction was run.

SECURITY / DATA / PERFORMANCE delta disposition: all 37 delta patches were read, with surrounding admission, ledger, attribution, settlement and binding-mutation source inspected. New binding lookup and project-usage queries are organization-scoped and parameterized; no new secret, egress or dependency surface was found in the delta. Deduplication avoids duplicate project bookings, and the op settlement stamp remains transactional. The two data findings above block acceptance. Multi-project accounting expands one billed call to three ledger upserts plus three upserts per distinct project; cap reads and hold unnesting also scale with project count. No measured performance regression is asserted. Tenant execution, migration/rolling-upgrade behavior, benchmarks, full audit artifacts and runtime behavior remain unverified. The source tests were inspected, not executed.

CICD snapshot at the quoted head: 16 latest check runs, one complete page. No unfinished CI-ready aggregator was returned.

Aggregator Observed result Check ID
CI ready (Checks) UNAVAILABLE — absent —
CI ready (Commitlint) UNAVAILABLE — absent —
CI ready (SAST) completed / success 113026617383
CI ready (Security) UNAVAILABLE — absent —
CI ready (CLI) completed / success 113027973945
CI ready (E2E) UNAVAILABLE — absent —
CI ready (Build) UNAVAILABLE — absent —

Missing aggregators are not passing or pending. Successful check metadata does not establish dependency execution/cache provenance. .github/CI.md:750–793 requires applicable dependencies and holds missing readiness evidence. Logs/cache/artifacts were not audited; this is not complete CI or merge readiness.

This completes the assigned bounded negative source re-review, not both full platform review parts or approval of the remaining PR scope. No delta file was left without patch inspection. UI rendering, accessibility, responsive behavior, actual localized journeys, deployment/recovery and platform-wide recurring coverage were not performed. No clone, test, install, build, push or merge was performed. Source-bound API evidence, the complete delta, source hashes and the 37-file coverage table are retained in TALE-1172 outputs.

# Conflicts:
#	services/platform/backend/domains/organizations/service.ts
#	services/platform/lib/shared/constants/api-contract.ts
#	services/platform/public/openapi.json
#	services/platform/scripts/openapi/contract-fingerprint.json
# Conflicts:
#	services/platform/lib/shared/constants/api-contract.ts
#	services/platform/public/openapi.json
#	services/platform/scripts/openapi/contract-fingerprint.json
# Conflicts:
#	services/platform/tests/manual/readme.md
# Conflicts:
#	docs/de/platform/admin/api-keys.md
#	docs/en/platform/admin/api-keys.md
#	docs/fr/platform/admin/api-keys.md
#	services/platform/app/features/settings/api-keys/components/api-key-create-dialog.test.tsx
#	services/platform/app/features/settings/api-keys/components/api-key-create-dialog.tsx
#	services/platform/app/features/settings/api-keys/hooks/use-api-keys-table-config.test.tsx
#	services/platform/app/features/settings/api-keys/hooks/use-api-keys-table-config.tsx
#	services/platform/app/features/settings/api-keys/lib/expiry.test.ts
#	services/platform/messages/de/settings.yml
#	services/platform/messages/en/settings.yml
#	services/platform/messages/fr/settings.yml
#	services/platform/tests/manual/readme.md
#	services/platform/tests/manual/suites/settings.md
# Conflicts:
#	services/platform/backend/domains/chat/deferred-sends.ts
Base automatically changed from feat/api-key-owners to main October 8, 2026 21:51
…cope

# Conflicts:
#	docs/de/platform/admin/api-keys.md
#	docs/de/platform/admin/governance/policies-and-limits.md
#	docs/de/platform/admin/governance/usage-attribution.md
#	docs/en/platform/admin/api-keys.md
#	docs/en/platform/admin/governance/policies-and-limits.md
#	docs/en/platform/admin/governance/usage-attribution.md
#	docs/fr/platform/admin/api-keys.md
#	docs/fr/platform/admin/governance/policies-and-limits.md
#	docs/fr/platform/admin/governance/usage-attribution.md
#	services/platform/backend/domains/api_keys/spec.md
#	services/platform/backend/domains/governance/README.md
#	services/platform/backend/domains/governance/budget-gate.test.ts
#	services/platform/backend/domains/governance/budget-gate.ts
#	services/platform/backend/domains/governance/budget-reservations.test.ts
#	services/platform/backend/domains/governance/budget-reservations.ts
#	services/platform/backend/integration-check.ts
#	services/platform/lib/shared/constants/api-contract.ts
#	services/platform/public/openapi.json
#	services/platform/scripts/openapi/contract-fingerprint.json
#	services/platform/tests/manual/suites/governance.md
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