Bound the account-wide listings, and drop the boost aggregate

Merged
JE
4mo ago
+1224-582

Soaking v0.8.0-rc.1 against a ~80-project production account showed the account-wide listings unusable at real scale. The cause was a contract decision rather than a bug: ACCOUNT-WIDE-LISTINGS.md I5 pinned each command's account-wide default to its project-scoped default — but project-scoped "all" is one project's items and account-wide "all" is the whole account. The same word bought very different amounts of work.

I5 also blessed "fetch page 0, then truncate", which made --limit useless exactly when it mattered: cards list --limit 3 fetched all 2142 cards before trimming.

What changed

accountWideCollect — one bounded walk over positive pages, shared by all eight paths (todos, comment, messages, cards, checkins, forwards, files, boost). It stops on an empty page, a page that adds no items, the cap, or the server's declared total. Two rules callers must obey are stated on the helper:

  • Meta.TotalCount compares against len(items) — top-level elements, which on a grouped payload are the groups, never the inner-item counter.
  • It does not trim. It overshoots to the page boundary and every caller cuts to the exact cap.

Uniform default cap of 100; --all is how you ask for the account. Changes the default for cards, checkins, forwards, files. Project-scoped defaults untouched.

Pagination flags for bare files list — --limit/-n, --page, --all. A listing with no escape hatch cannot recover from a server error mid-crawl, which is exactly how the files 500 became unrecoverable. Project-scoped files list has no pagination to thread, so it rejects all three by name rather than accepting and ignoring them.

The account-wide boost listing is withdrawn. /boosts.json turned out to be an easter egg — unlinked from the web UI, ~2,250 req/30d globally, with this CLI its only known consumer. BC5 is withdrawing it (basecamp/bc3#12464) because the query's cost is proportional to the account's accessible recordings rather than its boosts, which is what produced ~44s per page and a flat cost curve (basecamp/bc3#12458).

boost list now requires an item ID and carries no --all-projects/--limit/--page/--all. Seven commands list account-wide, not eight.

The feed is expected back later on a boost-proportional query via a boosts.bucket_id denormalization (basecamp/bc3#12463), public notice at basecamp/bc-api#427 — the docs and boost.go mark where the account-wide branch goes back. In the meantime the endpoint is genuinely gone, so the SDK is dropping Everything().Boosts() as well. This PR carries zero references to that aggregate, verified across code and tests, so whichever SDK release removes it lands here as a no-op.

Landing this before v0.8.0 stable is the point — otherwise the release ships a command that 404s.

Both overdue paths now accept --all and reject --page. They are unpaginated, so --page addresses nothing; but capping at 100 and rejecting --all had left item 101 unreachable by any combination of flags.

Soak results (account 2914079)

Commandrc.1this branch
cards list --all-projects --status completedtimeout at 94s24.9s, 1 request
checkins answers --all-projectstimeout1.5s, 4 requests
cards list --limit 316s (fetched 2142, trimmed)1.2s, 1 request
forwards list --all-projects—1.6s, 4 requests
comments list --all-projects—2.1s, 4 requests
messages list --all-projects—2.6s, 4 requests

No default or --limit request omits page= any more. --all still omits it deliberately — that is the spelling for the full traversal.

What this does not fix

One listing remains broken for a server-side reason, filed and holding the release (basecamp-cli#589):

  • basecamp/bc3#12459 — files.json 500s on any page holding an attachment whose parent is an autolinked image. The bounded default does not dodge it: GearedPagination ramps page sizes (15, 30, 50, …), so the first 100 items span pages 1–4 and the walk lands on the failing page.

The other blocker, basecamp/bc3#12458 (boosts.json at ~44s/page), is resolved here by removing the caller — see above. e2e/boost.bats needed no change; it covers help only.

Merging this is independent of #12459; the release is what waits on it.

Notes for review

  • accountWideRespOpts lost its moreFlag parameter. It existed so the two flagless commands would not be advised to use an --all they did not have — they have one now, and the linter caught the parameter going constant.
  • The stub transport grew page-awareness (stubRoute.pages). Without it a fixture serves the same body for every page number, so a bounded walk never sees an empty page and runs to the cap — which would have hidden the behavior under test.
  • Unit tests cover each guard, the TotalCount-vs-len(items) rule, page-boundary overshoot, the exact-cap case (TotalCount == limit is complete, not truncated), and a total present only on page 1.
  • .surface: 21 additive lines (3 flags × 7 files-family spellings). Boost contributes the only removals — --all-projects and the argument going optional → required, both of which shipped in v0.8.0-rc.1, so both are acknowledged in .surface-breaking. The --limit/--page/--all this branch briefly gave boost never shipped, so they are rewound out of the baseline rather than recorded as breaks that never happened. Net change against rc.1 is exactly the two real ones.

Summary by cubic

Bound account-wide listings to a fast, bounded page walk with a 100-item default cap, replacing full-account crawls and making --limit effective, and fixed sparse-page truncation with consistent [] empty results. Removed the account-wide boosts aggregate; boost list is now item-scoped only and requires <id|url>, and agent docs now scope --page off overdue listings.

  • New Features

    • Shared bounded page walker across todos, comments, messages, cards, checkins, forwards, and account-wide files; walks positive pages and stops on empty page, no new items, cap, or known total; adds a page ceiling for runaway backstop.
    • Uniform 100-item default cap for account-wide lists; use --all for the whole account. Project-scoped defaults unchanged.
    • Added --limit, --page, --all to account-wide files list; project-scoped files list rejects these. Overdue listings accept --all and reject --page.
    • Removed the account-wide boosts feed; boost list now requires <id|url>. The CLI no longer calls Everything().Boosts() and the SDK will drop it; docs note the CLI will surface 16/16 aggregates once pinned.
  • Bug Fixes

    • Fixed a bug that stopped after a sparse grouped page; the walk now continues and only stops on an empty page. Hitting the page ceiling reports as capped.
    • --limit no longer fetches everything before trimming; callers trim after a page-boundary overshoot.
    • Correct Meta.TotalCount handling (use first-page totals), avoid false truncation when total equals the limit, don’t switch the bound off mid-walk, and ensure messages and comments surface truncation when totals are absent.
    • Empty account-wide results now serialize to [] (not null).
    • Corrected notices and help: cap notice defers to server totals, “drop --limit for more” messaging fixed, and flag help for cards, checkins, and forwards now reflects the 100-item account-wide default. Agent guidance in skills/basecamp/SKILL.md now states overdue listings reject --page and accept --all/--limit.
    • Removed the now-constant moreFlag; tests and stub transport are page-aware to validate bounded walks.