Skip to content

v3.0.0 feat: time selected direct ledger pool acquisitions - #368

Merged
djh58 merged 6 commits into
3.x.xfrom
djh58/prism-b352-acquire-scope
Sep 14, 2026
Merged

djh58 merged 6 commits into
3.x.xfrom
djh58/prism-b352-acquire-scope

Conversation

@djh58

@djh58 djh58 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Direct ledger queries previously checked out connections outside the acquisition histogram. Add Ledger::acquire() using the existing cancellation guard, route both transaction entrypoints through it, and instrument eight direct callers: owner-reservation release, payout revision, worker difficulty, accepted-share timestamp, CPFP package/funding reads, heartbeat, and attached fatal-state reads.

A polled acquisition records exactly one success/error/cancellation sample; an unpolled future records none. Query text, values/errors, deadlines and statement-scoped connection release are preserved. SQL and BEGIN follow the acquisition timer. The live HTTP test permits independent publisher acquisitions while isolated tests assert exact per-attempt counts.

Refs #352 — partial delivery. Remaining job/coordinator, audit and block-reconciliation, migration/startup, cleanup, tools and rollup callsites remain tracked there. Observer consolidation requires explicit compatibility tests for the collector's Tokio clock and ledger's standard clock; both clocks are preserved here. API/read-pool coverage and public-role export policy remain separate decisions. This is not a complete acquisition census, and _count is not request throughput.

Integration with 3.x.x

Append-only merge 9d2afc8 incorporates the actual remote base 12fda81. Both branches appended test gates at the same location; the sole textual conflict was resolved as the exact sorted union of all 271 upstream gates plus the acquire gate, 272 unique entries. The acquire test supplies fixed keys for the upstream Ledger::configure signer-key argument. Automatic merges retain upstream fingerprint/signing validation alongside the reviewed acquisition behavior; the resolution changes no observer clock or production timing semantics.

Test plan

  • Fresh merged-tree PostgreSQL qualification: 7 acquire + 3 ledger-wait + 2 explicitly enabled ignored observability tests passed, zero failed/ignored. The five registered database gates in this subset all executed.
  • 20 gate-utility tests passed; the full manifest is sorted, duplicate-free and exactly the union of both parents.
  • Strict all-target Clippy, formatting, gate-input validation, both generators, frozen-snapshot verification and all 10 deployment-render combinations passed.
  • Current-head CI checks: 16 successful, [code]smith skipped, none active/failed. The downloaded PostgreSQL/multi-instance manifest proves 272/272 expected gates executed, with no failed/skipped gates.

Earlier implementation evidence remains distinct: 332 selected tests passed at d7947cd with real PostgreSQL and zero ignored tests. The exact-head bed69c7 reviewer independently reran all seven acquire tests and both ignored observability tests, plus generator checks and PromQL (28 expressions, 73 scenarios, 145 expression assertions, 86 alert assertions). That reviewer did not repeat the entire 332-test suite. An initial parallel ledger run hit fixture advisory-lock timeouts; the complete serial run passed. The HTTP oracle regression was reproduced before correction.

Review and coverage

The medium report's request to migrate all remaining callers is outside this expressly partial slice. Codex identified and confirmed fixes for the aggregate HTTP oracle and stale coverage wording, then found no refutation through d7947cd. Fable adversarial and thermo reviewed exact head bed69c7 with no refutation or blocking finding. All nine findings/suggestions have written dispositions: two fixed, one approved #352 deferral, six rejected change requests. The merge resolution received focused overlap review and fresh qualification; it was mechanical and did not require duplicate broad lanes.

Bugbot found no new issues at exact head 9d2afc8; GitHub has no review threads or change-request review. No pass is claimed for skipped checks or Tenki/Codex-on-GitHub, which produced no report. The final review ledger in this PR contains the complete per-finding evidence and dispositions.

Tests cover first-poll arming, unpolled/absent telemetry, success/error identity, cancellation cleanup and exactly-once counts, concurrent outcomes, real pool exhaustion/recovery, all eight callers on a one-slot pool, a following transaction, and slow/error/cancelled SQL exclusion. A delayed/failed/cancelled BEGIN round trip remains an explicit empirical regression-test gap: source ordering stops the timer before BEGIN, but that delay/failure itself is not simulated. The earlier 21/22 behavioral-group assessment is an estimate, not measured line/branch coverage.

Documentation and completion

Canonical/manual/generated guidance describes selected direct-query coverage and the remaining #352 work without changing metric identity or alert expressions, thresholds or roles. Implementation, focused tests, gate registration, documentation and review dispositions are complete for the bounded slice. Full #352 integration remains follow-up work. No version, changelog or signing-configuration changes were made.

Ready for maintainer merge of the bounded slice; not merged. GitHub reports mergeable/clean at 9d2afc8. A read-only merge-tree check also succeeds against the newer remote 3.x.x tip ba52d4b, which changes CI/test tooling and landed while qualification ran. No additional base merge was needed to resolve a conflict.

djh58 and others added 5 commits September 14, 2026 17:06
Reuse the existing cancellation-safe wait guard for a shared Ledger::acquire boundary and eight direct query paths. Preserve SQL and transaction behavior, and qualify elapsed timing, cancellation, and checkout release against PostgreSQL.

Refs #352.
The HTTP exhaustion test observes the aggregate pool histogram, now including payout-revision and heartbeat waits. Require every explicit cancellation to remain visible while preserving exact per-attempt assertions in the isolated tests.
Refresh canonical metric and alert guidance and regenerate the inventory and review-only provisioning patch from the checksum-pinned source snapshot. Alert expressions, thresholds and role exports are unchanged.
@djh58

djh58 commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

Bounded review dispositions at bed69c7:

  • Fixed — aggregate HTTP test oracle: reproduced the failure caused by newly observed publisher acquisitions, then fixed 230b98d. The HTTP test requires every explicit cancellation to remain visible; isolated helper/database tests retain exact per-attempt counts. Both actual ignored HTTP tests pass.
  • Fixed — stale coverage descriptions: d7947cd, ad565e0, and bed69c7 state selected direct-query coverage and remaining 3.x.x: Pool-acquire timing covers transactions only; non-transactional acquisitions are unmeasured #352 work in canonical/manual/generated guidance. Metric identity, alert expressions, thresholds, roles, and replacement decisions are unchanged; generator and deployment-render checks pass.
  • Rejected as a blocking regression — all remaining callers must migrate in this PR: this is an explicitly partial delivery, with future job/coordinator/audit/startup/cleanup/rollup integrations tracked in 3.x.x: Pool-acquire timing covers transactions only; non-transactional acquisitions are unmeasured #352. The helper adds coverage and does not remove existing observations or claim a complete acquisition census.

The final Codex adversarial report found no refutation across the full implementation diff at d7947cd; subsequent commits only update documentation. All 332 selected tests passed with real PostgreSQL and zero ignored tests. Delayed/failed/cancelled BEGIN itself is not directly simulated; source ordering stops the timer before BEGIN, and transaction SQL exclusion is tested. Additional independent review lanes and CI/bot review remain pending.

@djh58

djh58 commented Sep 14, 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.

Stale Bugbot comment from a previous run.

@djh58

djh58 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member Author

Final review ledger for current head 9d2afc8106e28d4ec454e9abe3559ebe8c7e6c80, including the append-only merge of 12fda81 from 3.x.x. The original review battery covers bed69c7; the integration resolution and fresh verification are recorded below.

Source / finding Disposition and evidence
Medium: migrate every remaining ledger caller in this PR Rejected as a requirement for this slice. Coverage remains partial and is explicitly documented; the remaining integrations stay in #352. No existing observation was removed and no complete census is claimed.
Codex: live HTTP aggregate oracle excludes newly observed publisher acquisitions Fixed in 230b98d. The original failure was reproduced, then both ignored HTTP tests passed. Aggregate lower bounds include every explicit cancellation while permitting publisher attempts.
Codex: stale canonical coverage wording Fixed in d7947cd, ad565e0 and bed69c7. Canonical/manual/generated descriptions agree on selected direct-query coverage. Metric identity, alert expressions, thresholds and roles are unchanged.
Fable F1: consider an upper bound on aggregate HTTP counts Rejected as a required change. Publisher attempts depend on scheduling; a cadence-derived bound would make this aggregate test timing-sensitive. Exactly-once behavior is asserted separately by isolated helper/collector tests and the real PostgreSQL test, including eight caller acquisitions followed by one transaction acquisition.
Fable F2: name every excluded category in the focused document Rejected as a correctness change. The prose explicitly says partial coverage and makes no exhaustive-list claim. The remaining #352 inventory also includes block reconciliation and migration-source/audit-export reads.
Thermo T1: consolidate the two observation implementations Deferred to #352 with approval and an explicit follow-up recorded there. Collector timing uses Tokio's clock; ledger timing uses the existing standard clock. Consolidation requires a deliberate clock choice and paused-time/real-time compatibility tests before further caller expansion; this reviewed slice preserves both clocks.
Thermo T2: replace the fatal-state acquisition future parameter with a connection parameter Rejected as a required refactor. The typed future shares one SQL reader between attached and operator-only acquisition paths, and releases its statement-local checkout before JSON decoration. Existing results, errors and connection scope are tested; changing that boundary offers no correctness fix.
Thermo T3: use one spelling of acquisition followed by BEGIN Rejected as a required refactor. Both entrypoints use the same timed acquire implementation and run BEGIN afterwards. The free helper serves startup before Ledger construction; the method serves existing ledger callers without restructuring startup validation.
Thermo T5: share the rendered-series test parser Rejected as a required refactor. The local parser asserts a unique rendered family/label; library child tests and integration binaries have distinct test visibility. Sharing support code is optional and adds scope without strengthening these assertions.

All nine ledger entries are terminal: 2 fixed, 1 approved deferral, 6 rejected change requests. Thermo T4 was a positive layering assessment, not an additional finding. Remaining #352 work now explicitly records observer consolidation, clock compatibility and ownership constraints.

Review evidence verified by reading the actual reports:

  • Medium report present and reconciled above. Final Codex adversarial report found no refutation across the implementation diff through d7947cd; it ran static/generator checks, not Cargo/PostgreSQL tests. Subsequent commits only changed documentation/generated descriptions.
  • Fable adversarial and thermo reports cover the full diff at exact head bed69c7: no refutation / no blocking finding. The reviewer actually executed all seven acquire tests with the PostgreSQL gate required, both live HTTP tests with --ignored, and alert-generator checks. Its PromQL run passed 28 expressions, 73 scenarios, 145 expression assertions and 86 alert assertions; the old rule failed its two required positive scenarios as expected.
  • Earlier implementation qualification passed 332 tests with real PostgreSQL, zero failures/ignored tests, plus strict all-target Clippy, formatting/build, generators and deployment-render checks. That evidence is at d7947cd, whose source is unchanged at this head; the exact-head reviewer did not repeat that entire suite.
  • Current-head GitHub checks: 16 successful, one skipped ([code]smith), none running or failed. The downloaded PostgreSQL/multi-instance execution manifest independently verifies all 272 expected gated tests executed (385 manifest lines, no failed/skipped gates). Bugbot found no new issues at exact head 9d2afc8. GitHub has zero review threads and no change-request review. No pass is claimed for skipped checks or for Tenki/Codex-on-GitHub, which produced no report.

The timer starts on first poll and ends at checkout completion/cancellation, before SQL or BEGIN; cancellation drops the operation and records one elapsed failure, and unpolled operations record nothing. Values/errors, connection lifetimes and deadlines remain unchanged. Slow/error/cancelled SQL exclusion is exercised; a delayed/failed/cancelled BEGIN round trip is still an explicit empirical test gap, with source ordering inspected and no known defect.

Integration resolution at 9d2afc8:

  • The only textual merge conflict was test/prism-gated-tests.txt, where both branches appended entries at the same location. The sorted union retains all 271 upstream gates plus the acquire gate: 272 unique entries.
  • The acquire test supplies fixed signer keys for the new upstream Ledger::configure parameter. The connect.rs and observability_database.rs automatic merges retain upstream fingerprint/signing validation and the previously reviewed acquisition boundaries, clocks and aggregate expectations. The resolution introduces no custom production behavior.
  • Fresh merged-tree qualification passed 7 acquire, 3 ledger-wait and 2 explicitly enabled ignored observability tests, zero failed/ignored, and 20 gate-utility tests. All five registered gates in that focused subset executed; the other tests do not require a database gate. Strict all-target Clippy, formatting, gate-input validation, both generators, frozen-snapshot verification and all ten deployment-render combinations passed.
  • The prior medium/Codex/Fable/thermo reports were retained. A focused review checked the combined production semantics and mechanical fixture/list resolution; no nonmechanical resolution required another independent lane. Neither review coverage nor old-head CI is represented as a new full review of upstream changes.

Ready for maintainer merge of this bounded partial slice; not merged. GitHub reports mergeable/clean at 9d2afc8, and a read-only merge-tree check also succeeds against the latest remote 3.x.x tip ba52d4b (CI/test-tooling changes landed while qualification ran). No known blocking review finding or active check remains. Full #352 caller coverage, observer consolidation with clock compatibility tests and public-role policy remain follow-up work.

@djh58

djh58 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member Author

Conflict resolution pushed as 9d2afc8106e28d4ec454e9abe3559ebe8c7e6c80, an append-only merge of the actual 3.x.x tip 12fda81.

  • Both branches appended entries near the same position in test/prism-gated-tests.txt. The resolution is the exact sorted union: all 271 upstream gates plus the acquire gate, 272 unique entries, with no dropped or duplicate IDs.
  • Upstream added a signer-key argument to Ledger::configure; the acquire test now supplies fixed test keys. The automatic connect.rs merge preserves upstream fingerprint/signing validation and the reviewed acquire routing. The HTTP test preserves upstream setup and the intentional aggregate lower bounds. Neither observer clock nor timing, outcome, deadline or connection-lifetime behavior was changed by the resolution.
  • Qualification on the merged tree passed 7 acquire + 3 ledger-wait + 2 explicitly enabled ignored HTTP tests, zero failed/ignored; the execution manifest proves all 5 registered gates in that focused subset ran. Also passed: 20 gate-utility tests, strict all-target Clippy, formatting, gate-input validation, both generators, frozen-snapshot verification and all 10 deployment-render combinations.

The existing medium, Codex, Fable and thermo reports remain the review evidence for the prior implementation; this mechanical integration received a focused overlap review and fresh tests, without repeating broad lanes. The earlier base SHA shown in the pull-request response was stale; the true remote tip reproduced the manifest conflict and is now integrated. Current-head CI and Bugbot are complete: 16 successful checks, one skipped check, all 272 expected gated tests verified from the downloaded manifest, and no new Bugbot issues or review threads. GitHub reports mergeable/clean; a read-only merge-tree also succeeds against the newer remote base ba52d4b. The bounded slice is ready for maintainer merge, with no reliance on old-head checks. #352 retains the explicitly recorded observer/clock and remaining-caller work; this PR is not merged. See the complete final ledger in this PR.

@djh58

djh58 commented Sep 14, 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 9d2afc8. Configure here.

@djh58
djh58 merged commit d733ef9 into 3.x.x Sep 14, 2026
17 checks passed
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