Skip to content

Collection admins can configure spend caps and warnings - #1066

Open
zlareb1 wants to merge 14 commits into
mainfrom
feat/collection-budget-policy
Open

zlareb1 wants to merge 14 commits into
mainfrom
feat/collection-budget-policy

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Related: #1077
Related: #1085

Changelog category (leave one):

  • Improvement

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Collection admins can set collection and per-user spend caps and a budget warning inbox from the Library.

Why

Budget enforcement reads collection policies, but collections have no operation to change them. namespace.register correctly rejects collection changes. Add a collection-specific operation and an admin control that save only the requested budget fields.

Scope and risk

The branch contains #1065, which is already merged. The merge result adds no worker diagnostic changes. The erasure lease fixture in #1077 is already merged. The close-test clock fixture in #1085 must land independently before this PR merges.

collection.budget_set requires admin access to the addressed collection and is audited. It rejects personal, missing and retired collections, and warning inboxes owned elsewhere. The directory claim covers the read and write; the stored row carries every unrelated field forward. Existing spend accounting, grant checks, enforcement thresholds and the namespace.register guard keep their current behavior.

The Library reads the current policy before saving, retains failed drafts and closes the form on scope or role changes. The SDKs, operation reference and reach manifest are generated from the operation declaration.

Compatibility, rollout and rollback

  • Wire: adds collection.budget_set with optional daily_cost_cap_usd, daily_user_cost_cap_usd and budget_alert_inbox. Omission preserves the stored field; explicit null is rejected. A zero cap inherits the deployment default; an empty inbox disables warnings.
  • Operator steps: none. Existing policy columns and budget enforcement are reused; there is no migration, new setting or dependency.
  • Rollback: removes the operation and Library control. Stored policy values remain understood and enforced by earlier builds.

Tests

  • Causal backend test failed before the operation existed. The focused module then passed 24 cases; its remaining caller-fixture case passed after correcting the fixture. Tests cover full-row preservation, active-collection checks, inbox ownership, finite caps, omission/default semantics and the unchanged namespace guard.
  • All seven focused Library dialog tests passed, covering changed-field saves, failed reads/writes, admin access, role changes and keyboard-reachable unavailable controls for viewers and writers. A separate existing Library assertion passed with the visible disabled Budget control and unchanged Move/Delete visibility. A failed-read network regression confirms that a policy read cannot imply a possibly committed save; save failures retain write uncertainty. A deferred-save/navigation regression failed before the fix and passed afterward: an old save cannot close another collection's form or discard its draft.
  • Namespace-writer inventory and full-row classification preservation checks passed. The new writer copies the complete stored row.
  • Three scope-contract checks passed: the warning-inbox declaration names the existing same-scope ownership check.
  • All five required SDK, reference and reach generators passed. The SDK public-surface snapshot adds only CollectionOps.budget_set.
  • Three collection-create read-count assertions failed in CI. Deterministic regressions reproduced requests from canceled deferred callbacks and a lower-priority creation refresh arriving after the opening reload. The collection reader checks its lifetime before starting, and the creation announcement commits its invalidation at the opening reload’s priority. Both regressions and the original three cases passed together. Their expected counts remain one; current-head CI must confirm the full-job result.
  • Integration CI passed the named caller's per-user cap, identity, complete policy readback and restoration assertions, then reached an incorrect expectation for the directory route. The test requires the existing end-user directory refusal and verifies that no row changes. The separate handler test retains the collection-kind validation refusal. The corrected integration case awaits current-head CI.
  • Scoped Ruff, Biome, Prettier and diff checks passed. The corrected integration case and a single focused guard check were not run locally; the focused check was refused before execution. Integration authorization/readback/restoration coverage runs in hosted CI. Full suites run in PR CI and must pass before merge.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex. Source review checked the write authorization, policy preservation, generated changes and focused regressions; fresh independent review runs on the pushed head.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated from their source.
  • No migration or plugin file changes are included.
  • The frontend builds and its tests pass in CI.
  • Docs describe the operation, stored policy and operator steps.
  • Repository text carries no deployment-specific evidence.
  • Commits are signed off.

Keep OS return codes distinct from pytest status and label observations taken after existing worker teardown. Retain bounded artifacts and job-log evidence without changing test outcomes.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Add a collection budget operation and Library control while preserving the namespace registration guard and existing budget enforcement.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 20, 2026 11:46pm UTC

Request Review

Keep the unavailable action discoverable and declare the existing inbox ownership check in the scope contract.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Loading a policy cannot have committed a save, so reserve write uncertainty for failed updates.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Keep classification and unknown columns through the existing full-row read. Retain failed read-count assertions and include request details for diagnosis.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Fenced memory inserts require a lease table in the selected schema. Give each fixture database its own Keeper root while preserving the replicated content checks.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
(cherry picked from commit 96be03c)
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Keep all four submissions in the same logical window so the test exercises
close flushing pending writes before the transport closes. Preserve the
existing inputs, scheduling yields and result assertion.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
(cherry picked from commit 5a15b56)
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
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