feat(account-management): add child_count to tenant read shape#4
feat(account-management): add child_count to tenant read shape#4diffora wants to merge 1 commit into
Conversation
|
Warning Review limit reached
More reviews will be available in 37 minutes and 41 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
98c7c52 to
e4e3713
Compare
Surface the number of direct children visible to the caller on every tenant read shape — listChildren page rows and the single-tenant get/update/lifecycle responses. - repo: count_children_grouped — one scope-filtered `COUNT ... GROUP BY parent_id` per page (no N+1). Excludes the AM-internal Provisioning status; includes soft-Deleted children. Distinct from the delete-saga count_children guard (allow_all, always counts Provisioning), which is left untouched. - service: lower_to_tenant / lower_to_tenant_page now take the caller scope and fill child_count; list_children passes the original barrier-respecting scope (not the relaxed one) so a self-managed child's own subtree stays scope-filtered and counts to 0. - sdk/REST: child_count: u32 on Tenant + TenantDto, plus the OpenAPI schema and the regenerated docs/api/api.json (make openapi). - tests: grouped-count repo integration (provisioning excluded, deleted included, empty input) + per-child service coverage + dto wire-shape. Signed-off-by: Diffora <ddiffora@gmail.com>
e4e3713 to
25cd58b
Compare
What
Adds a
child_countfield to the public tenant read shape — the number of direct children visible to the caller. It is filled on every read path that returns aTenant:listChildrenpage rows, and the single-tenantget/update/suspend/unsuspend/delete/createresponses.Behavior
child_count=, for the tenant in the response, the number of its direct children that the caller may see:AccessScopeviaSecureORM. A self-managed child's own subtree stays behind its barrier, so itschild_countcollapses to0for an outside caller (same visibility rule the rest of the read surface obeys).Provisioning— AM-internal rows have no public representation anywhere on the SDK boundary.Deleted— they remain reachable via$filter=status eq 'deleted'.0for a leaf. Derived field — not part of$filter/$orderby(not a stored column).Design notes
count_children_grouped(scope, parent_ids)runs one scope-filteredCOUNT ... GROUP BY parent_idfor the whole page — no N+1 across rows. Parents with no matching child are absent from the map (callers default to0).count_children/ChildCountFiltermachinery, which is an internal delete-saga guard (allow_all, always countsProvisioning) — left untouched.list_childrenpasses the original barrier-respecting scope into lowering (not therelaxedone used to surface direct self-managed children), so grandchild counts stay scope-filtered.Files
repo:count_children_grouped(trait +reads.rsimpl + delegate + fake mock)service:lower_to_tenant/lower_to_tenant_pagetake scope + fillchild_count; all 7 call sites updatedsdk/REST:child_count: u32onTenant+TenantDto+from_sdk_tenantdocs:account-management-v1.yamlTenant schema (properties + required)Tests & gates
count_children_grouped_excludes_provisioning_includes_deleted,count_children_grouped_empty_input_is_empty(repo integration, real SQLite),list_children_reports_direct_child_count_per_child(service); updated DTO wire-shape test.cargo fmt,cargo clippy --all-targets -D warnings(default and--all-features --locked),cargo test(777 lib + integration, 0 failed),cargo dylint --all(custom DDD/GTS lints).Compatibility
child_countis#[serde(default)]on the SDKTenant, so existing payloads without the field still deserialize (→0).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
child_countfield displaying the number of direct child tenants visible to the caller, with soft-deleted children included.Documentation
child_countfield, noting it is read-only, computed at request time, and unavailable for filtering or sorting operations.