feat: Plan 6 PR B — score recompute scheduler + live CI - #13
Conversation
Add single-flight RecomputeScheduler with dirty latch and deterministic shutdown drain, hook markDirty after attestation ingest, and require trust-engine in control-plane integration CI for score-recompute tests. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughAdds a single-flight score recomputation scheduler, triggers it after attestation persistence, integrates startup and shutdown lifecycle handling, adds score recomputation integration tests, and runs the trust-engine service in CI. ChangesScore recomputation
Sequence Diagram(s)sequenceDiagram
participant Client
participant AttestationService
participant RecomputeScheduler
participant trust-engine
participant Database
Client->>AttestationService: Submit attestation
AttestationService->>Database: Commit attestation
AttestationService->>RecomputeScheduler: markDirty()
RecomputeScheduler->>trust-engine: RunVeriRank
trust-engine-->>RecomputeScheduler: Score result
RecomputeScheduler->>Database: Upsert or delete network scores
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
PR Summary by QodoAdd single-flight score recompute scheduler and require live trust-engine in CI
AI Description
Diagram
High-Level Assessment
Files changed (12)
|
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@control-plane/src/__tests__/integration/score-recompute.test.ts`:
- Around line 202-216: Replace the fixed sleeps with deadline-bounded polling in
both scheduler test sites:
control-plane/src/__tests__/integration/score-recompute.test.ts lines 202-216
should poll until calls.length reaches at least 2 before stopping the scheduler,
then retain the upper-bound assertion;
control-plane/src/domains/graph/recomputeScheduler.test.ts lines 49-52 should
use the same polling approach before asserting calls.length equals 2. Anchor the
changes to the scheduler test flow and preserve the existing assertions.
In `@control-plane/src/db/client.ts`:
- Around line 21-24: Update recreatePool() so it verifies the existing pool is
ended before replacing the singleton; reject or otherwise fail immediately when
pool is still active, and only call createPool() after the invariant is
satisfied.
In `@control-plane/src/domains/attestation/attestationService.ts`:
- Around line 234-236: Move the getRecomputeScheduler().markDirty() post-commit
call outside the try block that maps attestation write errors, while preserving
the existing row return and error mapping for the durable write. Ensure any
scheduling failure cannot be translated into CONFLICT or cause an
already-successful submission to be reported as failed.
In `@control-plane/src/domains/graph/recomputeScheduler.test.ts`:
- Around line 49-52: In the test around the first scheduled recomputation,
replace the fixed `delay(20)` wait and immediate `calls.length` assertion with
deadline-based polling. Repeatedly check until `calls.length` reaches 2 or the
timeout expires, then retain the assertion that two calls occurred.
In `@control-plane/src/domains/graph/recomputeScheduler.ts`:
- Around line 87-102: Update Scheduler.runLoop so every follow-up iteration
triggered by this.dirty waits for the configured debounce interval before
calling recompute again. Preserve the existing stopping check and error
handling, and ensure the initial run is not unnecessarily delayed.
In `@control-plane/src/index.ts`:
- Around line 39-43: Move the forced-shutdown watchdog setup before the awaited
scheduler.stop() call in the shutdown handler, so it starts before the recompute
drain and still forces exit if that drain hangs. Preserve the existing
scheduler.stop error logging and normal shutdown behavior.
In `@docs/superpowers/plans/HANDOVER.md`:
- Around line 109-110: Update the integration-test instructions around the
trust-engine startup command so the server runs in the background, then export
TRUST_ENGINE_ADDR before invoking control-plane’s npm run test:integration
command. Preserve the required startup ordering and ensure the environment
variable is available to the test process.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8cc95e87-cd26-46e3-93a6-26088a29880a
📒 Files selected for processing (12)
.github/workflows/ci.ymlcontrol-plane/src/__tests__/integration/score-recompute.test.tscontrol-plane/src/db/client.tscontrol-plane/src/db/transaction.tscontrol-plane/src/domains/attestation/attestationService.tscontrol-plane/src/domains/graph/recomputeScheduler.test.tscontrol-plane/src/domains/graph/recomputeScheduler.tscontrol-plane/src/index.tscontrol-plane/src/testutil/appHarness.tscontrol-plane/src/testutil/seedData.tscontrol-plane/src/testutil/testDb.tsdocs/superpowers/plans/HANDOVER.md
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Poll for scheduler follow-up runs instead of fixed sleeps; guard recreatePool; isolate markDirty from write-path errors; arm shutdown watchdog before drain; clarify trust-engine test docs. Skip debounce-between-follow-ups: Plan 6 Decision 2 requires immediate dirty latch reruns (spacing remains via idle debounce only). Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed CodeRabbit actionable findings except the dirty-follow-up debounce spacing (locked Plan 6 Decision 2 — immediate latch rerun). Reply left on that thread. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Set dirty when scheduling debounce so stop drains cancelled idle work, unref debounce timers, cancel debounce on kick, and load score modules via dynamic import after env defaults. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
RecomputeSchedulerwith debounced ingest dirty latch, hourly tick, and deterministic shutdown (finish active + drain ≤1 dirty)markDirty()after successful attestation ingest; start/stop wired in control-planeindex.tsRunVeriRankintegration (score-recompute.test.ts) + CI startscmd/trust-enginewithTRUST_ENGINE_ADDRTest plan
cd control-plane && npm run test:unitTRUST_ENGINE_ADDR=… npm run test:integration(14/14)@coderabbitai reviewand address findingsSummary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation