Skip to content

feat(cloud): receive retained backup growth reports - #398

Open
Artexis10 wants to merge 4 commits into
mainfrom
feat/cloud-backup-growth
Open

Artexis10 wants to merge 4 commits into
mainfrom
feat/cloud-backup-growth

Conversation

@Artexis10

@Artexis10 Artexis10 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Accept retained backup growth reports from the key watcher. Keep the latest observation per cell and send one operator alert for newly crossed thresholds in a report.

A Cloud backup can keep hidden versions after a delete. The operator needs those bytes in the growth report and must be able to tell an incomplete scan from a recovery.

The PostgreSQL tests cover maximum-size reports, retry, expiry and incomplete batches. The Evermatter watcher also exercised crossing and recovery through the receiver over loopback.

This change adds the report tables. The watcher starts sending after both patches deploy and the pinned set names a ceiling. Remove that setting to stop reporting.

OpenSpec change

Separate PR: the growth receiver has its own schema and rollout.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: REQUEST_CHANGES
Head: 0bf8184
Base: f9d79ed
Patch: 1afd71823c0d3dc535a8257c291a9ee92a9e7286
Reviewer: security-reviewer, gpt-6.2-sol, xhigh
Blocking by round: 1
Net call: do not ship
Risk lens: yes
Pass: 4ed2179846e40a24

Do not ship this patch. The receiver bounds each report, while one publisher can still tie up shared database connections.

Weight: 412 changed product lines and 331 changed proof lines.

  • Medium, blocking. src/lib/exomem-hosted/backup-growth-receiver.ts:273. Every request from the key-watcher capability checks out an interactive PostgreSQL connection before taking the singleton lock. A malfunctioning publisher or someone holding its capability can sustain concurrent valid requests and fill the pool with lock waiters. The lock timeout limits one wait. The batch limit bounds one report, and a commit immediately allows another. Bound the publisher's resource use before it can exhaust shared connections.

C4 and C6 defects are absent. The unbounded contention is the scale and performance defect in this patch.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Quality report

be8a69c2 against base f9d79ed. Only the gate fails this check; the rest informs review. Why each check exists: PRACTICES.md.

Gate: passed

Nothing found by knip.

Proof weight

Product +437 lines against proof +376 lines (tooling, tests).

Measures on added lines

Check Result
New duplicate code, exact token clones (jscpd) 7 on added lines

New duplicate code, exact token clones (jscpd)

src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:40: Duplicates lib/exomem-hosted/__tests__/account-postgres.integration.test.ts:231
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:42: Duplicated code block (79 tokens), duplicated at [lib/exomem-hosted/__tests__/cloud-home-postgres.integration.test.ts:454](0)
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:42: Duplicated code block (63 tokens), duplicated at [lib/exomem-hosted/__tests__/email-delivery-postgres.integration.test.ts:155](0)
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:42: Duplicated code block (76 tokens), duplicated at [lib/exomem-hosted/__tests__/friend-invites-postgres.integration.test.ts:581](0)
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:42: Duplicated code block (60 tokens), duplicated at [lib/exomem-hosted/__tests__/service-notices-postgres.integration.test.ts:122](0)
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:44: Duplicated code block (55 tokens), duplicated at [lib/exomem-hosted/__tests__/cell-deletion-grants-postgres.integration.test.ts:165](0)
src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:62: Duplicated code block (51 tokens), duplicated at [lib/exomem-hosted/__tests__/cloud-cancellation-notice-postgres.integration.test.ts:125](0)

Test runtime

This run against the median of the last 5 successful main runs of this workflow on the same runner, from the GitHub Actions API.

Job This run Median on main Change
test 5m 30s 5m 13s (5 runs) +5%
onboarding end-to-end 10m 05s 12m 16s (5 runs) -18%

Every table: this run's summary.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: APPROVE
Head: 11e4f86
Base: f9d79ed
Patch: 40343c132212d20d99846b1804d2d2a0d0e53257
Reviewer: security-reviewer, gpt-6.2-sol, xhigh
Blocking by round: 1, 0
Net call: do not ship
Risk lens: yes
Pass: 5c53d45f99b63b9b

Ship the corrected patch. Each process admits one publisher request at a time. The shared rate limit follows the publisher across instances, and the window lock refuses contention immediately.

Weight: 441 changed product lines and 376 changed proof lines.

The resource contention finding is fixed in src/lib/exomem-hosted/backup-growth-receiver.ts. No new blocking findings. C4, C6, scale and performance defects are absent in the corrected patch.

@Artexis10

Copy link
Copy Markdown
Contributor Author

Automated review: REQUEST_CHANGES
Patch: 40343c132212d20d99846b1804d2d2a0d0e53257
Head: 11e4f86
Base: f9d79ed
Model: gpt-6.2-sol
Effort: xhigh
Worker: dfb5b4b269574fb7b4af673106343b7d
Pass: ffc764fc5a1341fc

Do not ship. The receiver correctly records growth evidence from the key watcher, but its admission and timeout controls leave tenant database capacity exposed.

Risk lens: yes

  1. P1 — Isolate growth work from tenant database capacity. Every valid request checks out a tenant transaction connection to take the rate limit, including requests that receive a 429. Requests that pass then check out a connection again before reaching the singleton lock. The in-flight guard applies per process, so it cannot protect the shared database across instances. Put a bounded growth workload budget ahead of shared database checkout and reserve capacity for tenant traffic. Include the scheduled cleanup in that budget. The contention test exercises one process and proves that the singleton lock refuses contention promptly. src/lib/exomem-hosted/backup-growth-receiver.ts:265, src/lib/exomem-hosted/db.ts:49, src/lib/exomem-hosted/db.ts:218, src/lib/exomem-hosted/__tests__/backup-growth-postgres.integration.test.ts:95
  2. P2 — Enforce the deadline through commit or rollback. The eight-second signal applies before checkout and during checkout. Once the receiver has a connection, each statement gets a fresh four-second timeout, and the transaction can continue after the signal expires. A valid report that spends most of its budget waiting for a connection can therefore commit after the watcher's ten-second HTTP timeout. Apply the remaining deadline to work on the checked-out connection and verify that a timed-out report releases it. src/lib/exomem-hosted/backup-growth-receiver.ts:270, src/lib/exomem-hosted/db.ts:163, src/lib/exomem-hosted/db.ts:218
  3. P2 — Keep the v1 report limits in one maintained contract. The sender's batch size and batch count are independent copies of the receiver's limits. The sender also uses its batch size to decide whether an active-cell page is valid. A one-sided change can cause the watcher to reject an ordinary page or send a report the receiver refuses. Derive both implementations from one versioned contract and exercise the shared boundary. src/lib/exomem-hosted/backup-growth-receiver.ts:13, src/lib/exomem-hosted/backup-growth-receiver.ts:137, companion infra/scripts/b2_backup_growth.py:44, infra/scripts/b2_backup_growth.py:88

Review coverage

  • Capability and inputs. Traced the URL capability and all 14 payload fields through the route and schema. Authentication, the streamed body bound, and shape validation precede SQL. Scheduler and Cloud deploy credentials are separate from the key-watcher ring. SQL values are parameterized. The alert renderer receives a generated UUID and count. The new regexes validate field formats and the action tags are fixed protocol values under C6.
  • State and compatibility. Checked four actions, three foreign keys, and the logical links that bind staging to the singleton, evidence to a cell, and the outbox entry to its run. PostgreSQL checks passed for expiry, conflicting and incomplete batches, receipt replay across a successor's open, and preservation of earlier coverage gaps. Acceptance commits observations, crossing evidence, and the outbox together. Searches by function name and SQL shape found one alert-insert implementation, reused by the existing callers. No replaced path or orphaned test surfaced.
  • Proof and scale. The exact candidate passed 16 focused PostgreSQL checks and 54 existing alert checks. The exact companion publisher drove synthetic crossing, incomplete coverage, and recovery over loopback. EXPLAIN ANALYZE covered 14 statements, including a full 20,000-observation report and 10,000 existing cell rows. Active and evidence pages used indexes. The acceptance join compares the staged measurements with prior state, and staging deduplication scans a bounded window. The measured report fit the ten-second test budget on disposable PostgreSQL. Tenant latency under concurrent load remains unverified. The diff adds 437 product lines and removes 4, with 376 proof lines. The six new cases exercise distinct receiver failures and outcomes.
  • Release and scope. Migration 0101 applied locally and adds tables without rewriting tenant data. The existing production build applies migrations before serving. The companion D6 contract and PR text agree on deploying both sides before enabling the ceiling. The separate schema and activation sequence support the Separate PR: reason. I checked the nine changed files, four commit messages, and supplied PR body for private records and found none. The diff changes no application screen text, evaluation material, Git-based trust decision, or command-text guard.
  • Unchecked. The local CI snapshot shows passing checks, but does not bind them to the reviewed head. Live CI, production telemetry and tenant latency, and email delivery were outside the isolated review. The loopback check verified the durable outbox entry. The review worktree stayed clean and the disposable database and scratch copy were removed.

Blocking: 3
Verdict: REQUEST_CHANGES

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