← Back to Pull requests

fix: defer background services to gateway_start hook #72

Closed
xDarkicex closed this pull request without merging on May 04, 2026 08:20 UTC
View on GitHub
xDarkicex xDarkicex commented on May 03, 2026 09:10 UTC
Author

Summary


  • Moves markdown ingestion and dream promotion start() calls from fire-and-forget during register() into a gateway_start hook

  • Ensures background services start after the gateway is fully initialized, matching the documented plugin lifecycle

  • The existing gateway_stop hook already handles graceful shutdown of both services
  • Test plan


  • npx tsc --noEmit passes with zero errors

  • gateway_stop hook still calls runtime.shutdown() which drains onShutdown tasks (markdown/dream stop)
  • Diff: 12 lines (+7 / -5) across 1 files Reviewer: fuller-stack-dev Review duration: 1389m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.18) × (1 − Review Confidence (0.83)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.18 · 12 lines diff across 1 files
    0.18
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.73 · 4 substantive comment(s)
    0.73
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.153
    Real PR Conversation Timeline
    6 items
    coderabbitai[bot] coderabbitai[bot] commented on May 03, 2026 09:10 UTC
    Bot

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- This is an auto-generated comment: rate limited by coderabbit.ai -->

    [!WARNING]

    ## Rate limit exceeded

    > @xDarkicex has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 37 seconds before requesting another review.

    > To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

    > <details>

    <summary>⌛ How to resolve this issue?</summary>

    > After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

    > We recommend that you space out your commits to avoid hitting the rate limit.

    > </details>

    >

    <details>

    <summary>🚦 How do rate limits work?</summary>

    > CodeRabbit enforces hourly rate limits for each developer per organization.

    > Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

    > Please see our FAQ for further information.

    > </details>

    > <details>

    <summary>ℹ️ Review info</summary>

    > <details>

    <summary>⚙️ Run configuration</summary>

    > Configuration used: defaults

    > Review profile: CHILL

    > Plan: Pro

    > Run ID: 56bc518e-8d2a-4fd6-a37a-353692a565f7

    > </details>

    > <details>

    <summary>📥 Commits</summary>

    > Reviewing files that changed from the base of the PR and between eb1e0fcebbb4241c99745c42722017257b37e328 and f957a2da305ba0368ace18af824fb52e4f34a3cd.

    > </details>

    > <details>

    <summary>📒 Files selected for processing (1)</summary>

    > * src/index.ts

    > </details>

    > </details>

    <!-- end of auto-generated comment: rate limited by coderabbit.ai -->

    <!-- finishing_touch_checkbox_start -->

    <details>
    <summary>✨ Finishing Touches</summary>

    <details>
    <summary>🧪 Generate unit tests (beta)</summary>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests

  • <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch fix/defer-services-to-gateway-start
  • </details>

    </details>

    <!-- finishing_touch_checkbox_end -->

    <!-- tips_start -->

    ---

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>
    <!-- review_rate_limit_status_start -->
    <sub>Review rate limit: 0/1 reviews remaining, refill in 7 minutes and 37 seconds.</sub>
    <!-- review_rate_limit_status_end -->

    <sub>Comment @coderabbitai help to get the list of available commands and usage tips.</sub>

    <!-- tips_end -->

    compoodment compoodment commented on May 03, 2026 13:00 UTC
    Contributor

    Heads up: this, #73, and #75 all modify adjacent regions of src/index.ts. If this merges after #73 or #75 (or vice versa), there will be merge conflicts in the api.on(...) registration block. Recommend merging this first and rebasing the others.

    Also worth noting: switching from void fire-and-forget to await inside gateway_start is correct — it means startup errors in markdownIngestion.start() or dreamPromotion.start() will now propagate instead of being silently swallowed. That's an improvement, but it could change observable behavior if either service was previously failing silently on some installs.

    fuller-stack-dev fuller-stack-dev commented on code on May 04, 2026 03:27 UTC
    Code Review
    src/index.ts:1
    @@ -119,11 +119,13 @@ export function register(api: OpenClawPluginApi) {
         await dreamPromotion.stop();
       });
     
    -  void markdownIngestion.start().catch((error) => {
    -    api.logger?.warn?.(`LibraVDB markdown ingestion failed to start: ${error instanceof Error ? error.message : String(error)}`);
    -  });
    -  void dreamPromotion.start().catch((error) => {
    -    api.logger?.warn?.(`LibraVDB dream promotion failed to start: ${error instanceof Error ? error.message : String(error)}`);
    +  api.on("gateway_start", async () => {

    Required: this PR is based on the pre-registerService startup code. Current main already starts/stops markdown ingestion and dream promotion through api.registerService with named services and non-fatal startup handling. Reintroducing a gateway_start hook here conflicts with that path and would lose the service-registry semantics once rebased. Please rebase onto main and either close this as superseded or adapt the current registerService implementation instead.

    fuller-stack-dev fuller-stack-dev requested changes on May 04, 2026 03:27 UTC
    Changes Requested Reviewer

    Requested changes: this branch is stale against main and the lifecycle change is now superseded by the service registry path.

    xDarkicex xDarkicex commented on May 04, 2026 08:20 UTC
    Author

    fixed in PR #75 closed

    Assignees
    xDarkicex xDarkicex
    Labels
    risk: low confidence: 82.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 18.3% (LOW) · Higher = larger blast radius
    18.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82.8% · Lower = rushed or shallow review
    82.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.1% · Safe to merge
    3.1%