Skip to content

v3.0.0 refactor: share pool acquisition observation - #376

Merged
djh58 merged 2 commits into
3.x.xfrom
djh58/prism-352-shared-observer
Sep 15, 2026
Merged

djh58 merged 2 commits into
3.x.xfrom
djh58/prism-352-shared-observer

Conversation

@djh58

@djh58 djh58 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Ledger and collector pool acquisitions now use one observer. The shared observer uses Tokio monotonic time: real elapsed time in an unpaused runtime and the collector's existing controlled clock in paused tests; advisory-lock timing keeps its standard monotonic clock.

The observation starts at first poll, records one success/failure/cancellation result, and ends before SQL or BEGIN. An unpolled future records nothing, and a checkout without metrics reads no observation clock. Public metrics, labels, roles, results and deadlines stay unchanged.

Refs #352. This is the observer-consolidation follow-up to #368; remaining caller conversion and API-role coverage remain separate work.

Validation

Latest fix head: 4689b9e73cd3ce524296d4268b67494550556566.

  • 17 focused Rust tests passed: 10 shared-helper, 2 ledger/connect, 3 wait-metrics and 2 explicitly selected normally ignored collector/HTTP tests, with none skipped or ignored.
  • Real PostgreSQL coverage includes exhausted-pool waits, cancellation and recovery, concurrent recording, original error values, selected callers, SQL exclusion, and delayed/failed/cancelled SQLx Transaction::begin operations after checkout. All existing PostgreSQL test statements and assertions are unchanged.
  • Focused integration manifest: all 5 expected gates executed under required integration mode against disposable PostgreSQL. This is focused local qualification, not the full workspace suite.
  • Server build, strict all-target Clippy, formatting and diff whitespace checks passed. Exact source comparison confirms the timing implementation changed only by name/location and advisory-lock code is unchanged.
  • Current-head CI run 34986531965 reached terminal success after one unchanged diagnostic rerun: the initial incident-2 latency failure (397.34 ms against 250 ms) passed on retry at 12.56 ms against the same bound. Exact artifact provenance is verified, and the aggregate proof confirms all 272 expected integration gates executed. The original failure and its unresolved cause are retained in the public CI investigation ledger.
  • The previous head's local qualification also passed gate utility/input checks, metrics/alert generator freshness and the alert-deployment matrix; those earlier local results remain historical.

Review status

Independent medium and Codex adversarial reviews found no actionable regression/refutation on 9716467a32d97c7aa76871aa085978e4e39e18cc. The coordinator has confirmed the separate Fable adversarial review on that head is complete with no refutation found. The supplied thermo report found no correctness regression and requested structural follow-through.

The appended fix addresses thermo findings 1, 2 and 4: move/rename the shared timer beside metrics events, consolidate helper tests while retaining unique assertions, and remove the free ledger forwarding function. Finding 3 is declined within this acquisition-only PR because the proposed lock-guard conversion changes the retained standard clock contract under paused runtimes. Finding 5's PostgreSQL coverage is retained. See the public disposition and fix ledger for details.

Focused independent verification of 4689b9e73cd3ce524296d4268b67494550556566 remains a separate coordinator-owned lane. New-head CI is complete: 19 checks succeeded, the optional code automation check is skipped, and the exact downloaded artifact union proves 272/272 gated tests executed. The one unchanged retry did not identify the original latency cause, and no speculative fix or threshold change was made. Prior-head reviews are not promoted to the new head; overall merge readiness is not claimed and no merge is authorized.

Coverage audit

Independent behavioral estimate: 95% (19/20 scenarios), not measured line or branch coverage. No concrete regression found. The remaining nonblocking test gap is a direct paused-runtime assertion through Ledger::acquire; its delegation to the shared observer is verified in code, the observer has exact paused-clock tests, and the adapter has real PostgreSQL coverage.

Behavioral coverage map

Behavioral estimate: 19/20 reviewed contract scenarios covered (95%); not measured line/branch coverage.

Shared observer: metrics::time_pool_acquire (implemented in metrics/events.rs)
  [TESTED ***] Unpolled drop and delayed first poll produce no premature observation
  [TESTED ***] Some + success: same value, one success, elapsed duration
  [TESTED ***] Some + error: original error, one failure, elapsed duration
  [TESTED ***] Some + cancellation: one failure and acquisition resources dropped
  [TESTED ***] Tokio paused clock: exact success/error/cancel durations
  [TESTED ***] Observation ends before later work or later cancellation
  [TESTED ***] None + success/error: original results preserved
  [TESTED ***] None + cancellation: acquisition resources dropped
  [TESTED ***] Concurrent mixed results: all 32 outcomes counted once
Ledger checkout / SQLx transaction flows (real PostgreSQL)
  [TESTED ***] Exhausted pool -> delayed success includes the actual checkout wait
  [TESTED ***] Exhausted pool -> cancellation -> pool usable again
  [TESTED ***] Closed pool -> original PoolClosed failure, one observation
  [TESTED ***] Slow/failing/cancelled later SQL does not alter checkout metrics
  [TESTED ***] Delayed custom BEGIN leaves entire pool histogram unchanged
  [TESTED ***] Failed custom BEGIN preserves SQLSTATE and releases the sole pool slot
  [TESTED ***] Cancelled custom BEGIN leaves histogram unchanged; next BEGIN succeeds
  [GAP]        Ledger::acquire clock contract under a paused runtime is inferred
               from its shared-helper call; no direct adapter-level assertion
Retained lock / collector / operator flows
  [TESTED ***] Advisory-lock success/error/cancel outcomes and label mapping
  [TESTED ***] Collector success/failed read/acquire timeout/closed pool/recovery
  [TESTED ***] Live HTTP pool counts survive stalled publication and stale cache;
               failed/unknown collection recovers to a valid zero

*** = assertions cover behavior, boundary cases, and failure outcomes. Integration-worthy flows above have real PostgreSQL coverage; the live scrape uses HTTP. No LLM/eval paths apply. Coverage gate: PASS (95%, default target 80%). One nonblocking composition-level test gap; no concrete regression found.

Plan completion

Implementation, thermo dispositions and bounded fixes, local qualification, documentation, PR publication and final-head CI qualification are complete. Initial review reports are accounted for; final-head Fable delta verification remains separately owned by the coordinator. No remaining caller coverage or overall merge readiness is claimed by this slice, and the PR remains unmerged.

Documentation

The acquisition guide documents the shared ledger/collector observer, Tokio clock behavior in paused tests, and the unchanged advisory-lock clock. It retains the checkout-only timing boundary and explicit partial coverage of #352. Documentation sync found no additional changes needed.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Use one optional-metrics guard for ledger and collector checkout waits.
Choose Tokio monotonic time explicitly while retaining the existing
advisory-lock clock and all checkout, error, and cancellation boundaries.
Add first-poll, unattached cleanup, and SQLx BEGIN boundary regressions.

Refs #352
@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9716467. Configure here.

@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Qualification and review ledger for 9716467a32d97c7aa76871aa085978e4e39e18cc against d733ef9eb1c195bb9346e61c3078f61dc0f03fc7:

Lane Actual result
Independent medium code review Complete; no actionable regressions. Reviewed the identical patch before commit.
Independent Codex adversarial Complete; no refutation. Verified the committed diff matched the frozen patch and passed 14 relevant tests from the existing test binary.
Fable adversarial Required report outstanding; no pass claimed.
Thermo quality review Required report outstanding; no pass claimed.
Current-head CI Passed; proof confirms all 272 expected integration gates executed.
Bugbot Complete on this commit; no new issues.

All GitHub checks are terminal: 20 passed, with the optional code automation check skipped and autofix disabled. There are no inline findings or unresolved review threads. The completed independent lanes produced no actionable findings requiring a fix, deferral or rebuttal.

Local qualification separately passed 20 focused Rust tests, including real PostgreSQL and both explicitly selected ignored HTTP tests, plus server build, strict all-target Clippy, formatting, gate utility/input checks, metrics/alert generator checks and the alert-deployment matrix. The local integration manifest proves all five expected focused gates executed; the full 272-gate proof comes from CI.

The documented clock choice and checkout-before-SQL/BEGIN boundary remain unchanged from the qualified patch. Broader #352 caller conversion and API-role coverage are still outside this slice. The two outstanding independent reports remain review gates; merge readiness is not yet claimed.

@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Thermo review dispositions — PR #376

Reviewed head: 9716467a32d97c7aa76871aa085978e4e39e18cc. The supplied Claude Fable 5.1 thermo report found no correctness regression; its local library tests and Clippy passed, but it did not execute PostgreSQL tests. I verified each finding against the original code worktree.

Finding Disposition and evidence
1 — helper placement/name Accepted, fix in progress. Move the async timing boundary beside the recording API in metrics/events.rs, re-export it as metrics::time_pool_acquire, and keep the synchronous Metrics::observe_pool_acquire recording name. This is relocation and renaming only.
2 — duplicate helper tests Accepted, fix in progress. Consolidate in metrics/events/tests.rs; retain the ledger PostgreSQL tests. Preserve concurrency, attached and unattached cancellation cleanup, first-poll timing, exact paused-clock durations, original return allocation/error, and both unattached results. Inspection found these last assertions also need to survive consolidation; moving only the two cases named in the report would lose coverage.
3 — merge advisory-lock guard Declined within this acquisition-only PR. WaitGuard uses the explicitly documented standard monotonic clock; the shared checkout helper uses Tokio time. The suggested callback conversion changes that clock contract under paused runtimes and broadens the event boundary abstraction. Existing lock success/error/cancellation behavior is retained. This is a scope/semantic refutation, not a deferred correctness defect.
4 — pass-through free function Accepted, fix in progress. Have Ledger::acquire and transaction begin call time_pool_acquire directly, deleting the free forwarding function while preserving the checkout-before-BEGIN boundary and the acquisition test host.
5 — PostgreSQL BEGIN test size Coverage retained. Keep delayed, failed and cancelled custom BEGIN scenarios plus the single-slot recovery assertion. They verify SQLx transaction cleanup and the real PostgreSQL metric boundary; the review does not request removal.

The coordinator has now confirmed the separate initial Fable adversarial report on 9716467 is complete with no refutation found. That result is separate from the thermo lane and does not qualify the pending fix commit. The next update will identify the pushed fix head and its executed tests; independent final-head delta verification and new-head CI remain required. No merge readiness is claimed, no version bump is planned, and no merge is authorized.

Rename the async timing boundary to time_pool_acquire and expose it through
metrics while leaving the recording hook name unchanged. Consolidate helper
tests under events, retaining unique result, clock, cancellation cleanup and
concurrency assertions, and remove the ledger free forwarding function.

Preserve advisory-lock timing and every PostgreSQL checkout/BEGIN regression.

Refs #352
@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Thermo follow-through pushed — 4689b9e73cd3ce524296d4268b67494550556566

Verified dispositions are implemented in the appended fix commit.

Finding Final disposition
1 — helper placement/name Fixed. The unchanged async timing body now lives beside recording hooks in metrics/events.rs, exposed as metrics::time_pool_acquire; the recording method retains its distinct observe_pool_acquire name.
2 — test ownership Fixed. Ten helper tests now live in metrics/events/tests.rs; the ledger test module contains its PostgreSQL case and helpers. Consolidation retains the original allocation identity and I/O error, both unattached outcomes, attached/unattached cancellation cleanup, real/paused timing, first-poll behavior and 32-task mixed-outcome recording.
3 — merge advisory-lock guard Declined for this PR. The proposed conversion changes the explicitly retained standard clock under paused runtimes and expands the acquisition-only scope. Advisory-lock code is byte-for-byte unchanged. No correctness defect is deferred.
4 — forwarding function Fixed. Ledger::acquire and transaction begin call the shared helper directly; the free forwarding function is removed.
5 — BEGIN regressions Retained. Every PostgreSQL checkout/BEGIN test statement and assertion is unchanged, including custom delayed/failed/cancelled BEGIN and recovery of the single pool slot.

Executed validation on the fix

  • 17 focused tests passed; none failed or ignored: 10 shared-helper tests, 2 ledger/connect tests, 3 wait-metrics tests, and 2 explicitly selected normally ignored collector/HTTP tests.
  • The repository native-test harness provisioned disposable PostgreSQL instances with required integration mode. The manifest checker confirms all 5 expected focused integration gates executed, with no skip/failure decisions.
  • cargo clippy --locked -p qbit-prism-server --all-targets -- -D warnings, cargo build --locked -p qbit-prism-server, formatting and diff whitespace checks passed.
  • Direct source comparison proves the timing body changed only by its name/location; advisory-lock code and the entire PostgreSQL test body are unchanged. There is no version bump, new deadline, stored-format or public metric change.

Review status

The initial medium, Codex adversarial and coordinator-confirmed Fable adversarial reviews concern 9716467a32d97c7aa76871aa085978e4e39e18cc. The Fable adversarial result is no refutation found, independently of the supplied thermo report. Focused independent verification of 4689b9e73cd3ce524296d4268b67494550556566 has been requested through the coordinator, and new-head CI is running. The prior head's full CI proof remains historical evidence only. Final-head review qualification remains pending; no merge readiness is claimed and the PR remains unmerged.

@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

CI latency investigation — unchanged head 4689b9e

Attempt 1, shard 0 failed incident_2_ack_latency_stays_flat_while_a_frontend_solves_a_large_window: frontend 2 phase-B p99 was 397.34 ms, above the unchanged 250 ms limit (phase-A p99 12.01 ms, solve ACK 13.72 ms). Frontend 1 also had a phase-B tail increase; the existing logs do not isolate its cause. The manifest and summary failures were downstream of that actual latency failure.

Original attempt metadata, full job logs, all four shard artifacts and their digests were preserved before rerunning. The latency test, fixture, submit/rebuild path, thresholds and CI sharding are unchanged from merge-base d733ef9; no PR-caused mechanism has been demonstrated. One authorized unchanged failed-job rerun is now in progress on 4689b9e, and final shard/aggregate artifact provenance will be checked explicitly. A passing rerun alone will not establish an infrastructure root cause.

No source, threshold, gate, Git configuration, version or changelog change has been made for this investigation. Final-head Fable verification remains a separately running review lane; CI qualification is pending.

@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

CI latency investigation complete — 4689b9e73cd3ce524296d4268b67494550556566

The single authorized unchanged diagnostic rerun finished successfully: CI run 34986531965, attempt 2. No source, threshold, gate or Git configuration change was made. The PR remains open and unmerged.

Exact evidence Frontend-2 baseline p99 Frontend-2 phase-B p99 Solve ACK Outcome
Base d733ef9, run 34907861875 / shard 0 7.93 ms 25.28 ms 6.74 ms Passed
Prior PR head 9716467, run 34910685980 / shard 0 309.99 ms 17.01 ms 6.39 ms Passed
Current head, attempt 1 / job 104439948560 12.01 ms 397.34 ms 13.72 ms Failed the 250 ms bound
Same current head, attempt 2 / job 104443770873 11.92 ms 12.56 ms 7.40 ms Passed the unchanged 250 ms bound

The test/fixture, submit and candidate-rebuild paths, dependency lockfile, CI workflow and sharder have identical Git blobs on the base and current head. The observer remains reachable in the submit path, but review found no new wait, SQL, deadline, registry-lock duration or ownership change that explains the tail spike. The original failure affected both frontends during phase B. Its precise cause remains unisolated; a passing retry is not proof of infrastructure. The evidence does not demonstrate a PR regression, so no speculative fix is justified. Original logs, all initial artifacts and digests, and exact historical comparison logs were preserved before the retry.

Artifact provenance and final gates

The successful aggregate job 104445988739 explicitly selected new shard-0 artifact 10404695919, created at 15:24:54 UTC, with digest sha256:d757c2c46f281a609a2ae486ccf6c788edb27684c9dc21d5bb60666a9d03e1c5. Old failed-attempt shard-0 artifact 10403604368, created at 15:13:47 UTC, remains preserved and was not selected. The other selected artifacts were 10404021732 (shard 1), 10404051586 (shard 2), and 10404275838 (shard 3), all successful outputs from this same head.

The uploaded combined manifest (artifact 10403894378) is byte-identical to that exact four-artifact union. Re-running the repository checker against the downloaded manifest and logs confirms 272/272 expected gated tests executed, with 385 manifest lines and 41 repeated test IDs; no expected gate was skipped or missing. Combined manifest SHA256: ac14a80b508c9bf9046de9f6ad85cd351c148f4ef0c85a704b9c5f92af69dbd4.

All current GitHub checks are terminal: 19 successful, plus the optional skipped [code]smith check. Final Fable delta verification remains a separate coordinator-owned lane; this CI closeout does not claim its result or overall merge readiness.

@djh58
djh58 merged commit 387064c into 3.x.x Sep 15, 2026
36 of 39 checks passed
@djh58

djh58 commented Sep 15, 2026

Copy link
Copy Markdown
Member Author

Coordinator closeout: independent Fable final-delta verification of 9716467 to 4689b9e completed clean. It independently checked helper equivalence, all unique retained assertions, cancellation, clock boundaries and unchanged PostgreSQL BEGIN tests; focused tests plus disposable PostgreSQL verification, Clippy and formatting passed. This supersedes earlier text saying coordinator verification was pending. Final CI is green with 272/272 gates proved. Merged as 387064c; #352 remains open for the remaining caller and public-role coverage.

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