Skip to content

test(state): bound the summary lists by bytes received, not wall time - #2431

Merged
freeqaz merged 3 commits into
mainfrom
test-bounds-1014
Oct 14, 2026
Merged

freeqaz merged 3 commits into
mainfrom
test-bounds-1014

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The summary-list check added with #2415 in postgres-platform-state.test.mjs ("PostgreSQL platform state satisfies memory adapter ownership, immutability, and atomicity") asserts that the fastest of three reads of the 64 x 0.9 MB revision page and Preset list is under 1 s. That is an absolute wall-clock bound on a shared runner, and CI keeps no record of the time on passing runs (diagnostics are dropped), so a near miss is invisible until it flakes. The 10-14 flake sweep flagged it as the one absolute bound to watch.

Change

Test code only. The test now counts the bytes the database sends for one read instead of timing it. A list that reads the full documents receives about 64 x 0.9 MB; a summary list receives a few hundred bytes a row. Each list must receive more than zero bytes and less than one stored document (the 0.9 MB value the test seeds). The count comes from the bytesRead of every pool client the read checks out (pool acquire event). No runner speed changes this count. The diagnostic and the failure message report bytes and milliseconds. One read per list replaces three, so the test does four fewer heavy reads.

Inventory of the other wall-clock assertions added or changed since 10-13, left as they are:

Test Bound Measured Margin
#2359 URL userinfo budget (configuration-controller), 13 cases < 500 ms each CI max 47 ms per case (51 runs) ~10x; the exact budget refusal message is asserted too
#2400 64-variable Preset save < 5 s CI max 0.02 s > 200x
#2407 native admin status, fastest of 3 < 1 s 37-41 ms at 2 CPUs; 98 ms worst with 4 copies sharing 2 CPUs >= 10x
#2418 Slack / status readback bounded reads < 4 s / < 5 s CI max 139 ms / 28 ms >= 29x
#2410 ci-cleanup inherited pipes < 2.5 s from test start 0.6-0.9 s at 2 CPUs and with 4 copies sharing 2 CPUs; CI test max 1.14 s 700 ms of it is the fixed 500 ms timeout and 200 ms grace; the variable part is ~200 ms against 1.6 s of slack
#2338 ci-runner cleanup window < allowance + 8 s CI 10.016-10.036 s test time (51 runs) 8 s slack over a 20 ms spread
#2405 roster, #2414 harness, #2412 listing ratios against a same-run baseline roster 2.96-3.08 of 6 with 4 copies sharing 2 CPUs ratio, load-independent

Verification

  • prettier --check and eslint on the touched file: clean. The file loads and skips locally without PostgreSQL.
  • Regression probe 1: branch test-bounds-1014-probe adds one commit on top of this one that makes both summary reads also select the full snapshot / template again (p.admitted_spec, p.template), as a full list did. CI run https://github.com/openclaw/openclaw-enterprise/actions/runs/38582227039, PostgreSQL Platform failed as intended: revision summary page received 66556857 bytes in 1591 ms (bound: under 898,891 bytes). The same read took only 1.6 s on that runner, so the old 1 s time bound would have caught this by a factor of 1.6; the byte bound catches it by a factor of 74.
  • Regression probe 2: only the Preset summary read selects p.template. CI run https://github.com/openclaw/openclaw-enterprise/actions/runs/38583048256, PostgreSQL Platform failed as intended: Preset summaries received 66501303 bytes in 2231 ms.
  • Probe 3, unchanged product, the test forced to fail with its numbers: CI run https://github.com/openclaw/openclaw-enterprise/actions/runs/38583981232: revision page 19747 bytes in 21 ms; Preset summaries 9505 bytes in 1 ms (64 rows). The bound sits 45x / 94x above the normal counts and 74x below the regression.
  • The probe branches are deleted; none of their commits are in this PR.
  • CI on this PR: CI Required and PostgreSQL Platform green on c57e983 (the changed test passed).

Risks

Low. Test code only. The byte count reads client.connection.stream.bytesRead, a field of the pg client that this repo's pinned pg 8.23 exposes. CI connects over plain TCP; under TLS the count would include encryption overhead, still far from either side of the bound. The > 0 half of the assertion fails loudly if the count ever stops observing the read. The test no longer catches a regression that keeps the bytes small but makes the database query itself slow. The 1 s bound had little power there too: a summary page still opens each row's snapshot in the database.

…ot wall time

The summary-list check in the PostgreSQL platform state test asserted the
fastest of three reads under 1 s. That is an absolute wall-clock bound on a
shared runner, and CI keeps no record of how close passing runs come.

Count the bytes the database sends for one read instead: a list that reads
the full documents receives about 64 x 0.9 MB, a summary list a few hundred
bytes a row. Each list must receive less than one stored document. The
measured bytes and time go into the diagnostic and the failure message.
@freeqaz
freeqaz requested a review from a team as a code owner October 14, 2026 14:38
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

Review nit: PostgreSQL's jsonb text output is longer than the compact JSON
the test seeds, so a single document on the wire exceeds the bound.
@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces summary-list timing assertions with bounds on bytes received from PostgreSQL.

Example: The fixture contains 64 revisions and 64 Presets with approximately 0.9 MB documents.

  • Before: Each list must complete its fastest of three reads within 1,000 ms.
  • After: Each list runs once and must receive more than zero but fewer than 898,891 bytes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused test maintenance with native PostgreSQL validation and credible negative controls; evidence exercises the integration harness rather than a shipped entry point.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored, test-only scope changes no shipped entry point; PostgreSQL CI and negative controls support the oracle, while inspected historical UI screenshots concern earlier pagination behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Shared-runner contention can fail the summary-list regression check despite lightweight database results.
Reason: The focused replacement tests the intended storage projection through real PostgreSQL, and supplied maintainer-authorship context establishes direction.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for maintainer triage: it provides a focused test reliability improvement, and no actionable introduced defect was found.

Priority: P3
Reviewed head: 90158125c40e66efa8a06e8f1e07178fcf076d6f

Before merge

None.

Findings

None.

Agent review details

How this fits together

OCC list operations use PostgreSQL State repositories to return lightweight summaries; the integration test measures database socket traffic around those repository reads.

flowchart LR
  Controller[OCC list operations] --> State[PostgreSQL State repositories]
  Test[Integration fixture] --> Counter[Socket byte counter]
  Counter --> State
  State --> Database[PostgreSQL]
  Database --> Summaries[Summary rows]
  Summaries --> Counter
Loading

Technical review

Best possible solution:

Retain the transfer-volume bound alongside the existing summary-content and ordering assertions.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms the absolute timing threshold; an actual runner-contention flake was not reproduced during this read-only review.

Is this the best way to solve the issue?

Counting real database traffic directly protects against fetching full documents without depending on runner speed, while deliberately relinquishing a database-latency bound.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b7d4bde5ad55.

Provenance checked

  • Summary-list regression assertions changes intended behavior with a stated reason (2a55afc: Detect expensive listing of large revision snapshots and Preset templates; the PR explains why transferred bytes provide a more stable oracle than elapsed time.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Free Wortley: Raw commit 2a55afc adds tests/integration/postgres-platform-state.test.mjs:1312 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2a55afc62607; files: tests/integration/postgres-platform-state.test.mjs)

Review metrics

Metric Value Why it matters
Change scope Production +0/-0; integration test +36/-12 Replaces an existing assertion without adding production hooks or duplicate tests.
Measured reads 6 to 2 One read per list replaces three attempts while preserving result checks.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: Focused test reliability maintenance with no production behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-14T14:50:00.887Z sha c57e983 :: needs maintainer review before merge. :: none

Reviewed October 14, 2026, 10:58 AM ET / 14:58 UTC (Revision 2).

@freeqaz-openai

Copy link
Copy Markdown
Collaborator

Independent test-oracle check:

  • The PostgreSQL Platform job for c57e9830eb7b47d8fe252bbd51bcbd2a1d7a95ff passed, including the changed test. Its tested merge tree matched that head.
  • Both negative controls reached the intended assertions: the revision probe received 66,556,857 bytes, and the Preset-only probe received 66,501,303 bytes. The overall first probe workflow was subsequently cancelled; the individual PostgreSQL job had already failed at the assertion.
  • The current rebased head 90158125c40e66efa8a06e8f1e07178fcf076d6f has the identical test patch; the State adapter and lockfile checked for this review are unchanged. The new base adds a separate PostgreSQL test, so current-head CI remains the evidence for the combined tree.

This checks transferred bytes, as the PR describes; it does not establish a bound on database-side CPU or latency.

@freeqaz
freeqaz merged commit 1383bef into main Oct 14, 2026
40 of 42 checks passed
@freeqaz
freeqaz deleted the test-bounds-1014 branch October 14, 2026 15:08

This branch had an error being deployed

1 failed deployment
integration-qa-pr — 90158125 Deployed Oct 14, 2026 by freeqaz via QA advisory (compose) #893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants