Skip to content

Conversation

ericallam
Copy link
Member

No description provided.

Copy link

changeset-bot bot commented Sep 25, 2025

⚠️ No Changeset found

Latest commit: 53d2ffc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Sep 25, 2025

Walkthrough

The changes modify internal logging and refactor part of the run-queue logic in internal-packages/run-engine/src/run-queue/index.ts. Several log statements are raised from debug to info and now include additional context fields (e.g., runIdsLength, completedRunIdsLength). A new private method, markRunsForAck, centralizes the logic for marking completed runs for acknowledgment. The existing processCurrentConcurrencyRunIds method now delegates to this helper. Control flow for cases with no completed runs remains, with logs occurring at info level.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description is currently empty and does not include any of the required template sections such as the issue reference, checklist, testing steps, changelog summary, or screenshots. Please populate the pull request description using the repository template by adding the issue number under “Closes #”, completing the checklist items, outlining the steps you took to test the changes, providing a brief changelog entry, and including screenshots if applicable.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title accurately and concisely describes the primary change of improving logging in the concurrency sweeper within the run-engine module, matching the core modifications in the pull request without extraneous detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ea-branch-92

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal-packages/run-engine/src/run-queue/index.ts (1)

2532-2551: Wire in markCompletedRunsForAck and add its typing
markCompletedRunsForAck is defined in internal-packages/run-engine/src/run-queue/index.ts (line 2532) but never invoked; call it where completed runs are acknowledged and provide its TypeScript signature.

🧹 Nitpick comments (8)
internal-packages/run-engine/src/run-queue/index.ts (8)

1865-1867: Add context to abort-path log (or demote to debug).

Info-level here can get noisy during shutdowns. At minimum, add service to the log payload for consistency.

-      this.logger.info("Abort signal received, skipping concurrency scan");
+      this.logger.info("Abort signal received, skipping concurrency scan", {
+        service: this.name,
+      });

1870-1871: Include service context in top-level sweep log.

Keeps logs consistent and easier to filter.

-    this.logger.info("Scanning concurrency sets for completed runs");
+    this.logger.info("Scanning concurrency sets for completed runs", {
+      service: this.name,
+    });

1923-1926: Cap payload size when logging concurrency keys.

Logging the full key list can explode log volume and cost. Log count plus a sample; include service for filtering.

-      this.logger.info("Processing concurrency keys from stream", {
-        keys: uniqueKeys,
-      });
+      const keysSample = uniqueKeys.slice(0, 10);
+      this.logger.info("Processing concurrency keys from stream", {
+        keyCount: uniqueKeys.length,
+        keysSample,
+        service: this.name,
+      });

1993-1997: LGTM: sampled runIds + count is good; add service for consistency.

Nice touch to cap at 5. Add service for easier log filtering.

     this.logger.info("Processing concurrency set with runs", {
       concurrencyKey,
-      runIds: runIds.slice(0, 5), // Log first 5 for debugging,
+      runIds: runIds.slice(0, 5), // Log first 5 for debugging
       runIdsLength: runIds.length,
+      service: this.name,
     });

2003-2010: Avoid duplicate “no completed runs” logs and skip when callback missing.

Unify the checks and prevent noisy info logs when no sweeper is configured.

-    // Call the callback to determine which runs are completed
-    const completedRuns = await this.options.concurrencySweeper?.callback(runIds);
-
-    if (!completedRuns) {
-      this.logger.info("No completed runs found in concurrency set", { concurrencyKey });
-      return;
-    }
-
-    if (completedRuns.length === 0) {
-      this.logger.info("No completed runs found in concurrency set", { concurrencyKey });
-      return;
-    }
+    // Call the callback to determine which runs are completed
+    const cb = this.options.concurrencySweeper?.callback;
+    if (!cb) {
+      this.logger.debug("Concurrency sweeper callback not configured; skipping", {
+        concurrencyKey,
+        service: this.name,
+      });
+      return;
+    }
+    const completedRuns = await cb(runIds);
+    if (!completedRuns?.length) {
+      this.logger.info("No completed runs found in concurrency set", {
+        concurrencyKey,
+        service: this.name,
+      });
+      return;
+    }

2012-2016: Include service context on “completed runs” log.

Helps correlate across services.

     this.logger.info("Found completed runs to mark for ack", {
       concurrencyKey,
       completedRunIds: completedRuns.map((r) => r.id).slice(0, 5),
       completedRunIdsLength: completedRuns.length,
+      service: this.name,
     });

2026-2043: Use server time via Lua command and reduce per-item info logs.

  • Prefer the existing Lua command (markCompletedRunsForAck) to avoid client clock skew and ensure atomic scoring with Redis TIME.
  • Demote per-run logs to debug; keep the aggregate info log.
-    // Prepare arguments: alternating orgId, messageId pairs
-    const args: Array<number | string> = [];
-    for (const run of completedRuns) {
-      this.logger.info("Marking run for acknowledgment", {
-        orgId: run.orgId,
-        runId: run.id,
-      });
-
-      args.push(Date.now());
-      args.push(`${run.orgId}:${run.id}`);
-    }
-
-    const count = await this.redis.zadd(markedForAckKey, ...args);
-
-    this.logger.info("Marked runs for acknowledgment", {
-      markedForAckKey,
-      count,
-    });
+    // Prepare args: alternating orgId, messageId pairs
+    const args: string[] = [];
+    for (const run of completedRuns) {
+      this.logger.debug("Marking run for acknowledgment", {
+        orgId: run.orgId,
+        runId: run.id,
+        service: this.name,
+      });
+      args.push(run.orgId, run.id);
+    }
+
+    const count = await this.redis.markCompletedRunsForAck(markedForAckKey, ...args);
+
+    this.logger.info("Marked runs for acknowledgment", {
+      markedForAckKey,
+      count,
+      service: this.name,
+    });

Add the command to the Redis typings to keep TS happy:

// In the declare module "@internal/redis" section
interface RedisCommander<Context> {
  markCompletedRunsForAck(
    markedForAckKey: string,
    ...args: string[] // alternating orgId, messageId pairs
  ): Result<number, Context>;
}

2039-2042: Avoid double-logging count without context.

If you keep the per-run logs at info, the aggregate log is redundant. Either demote the per-run logs (recommended above) or add context here (service already added in the diff).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e22c321 and 53d2ffc.

📒 Files selected for processing (1)
  • internal-packages/run-engine/src/run-queue/index.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • internal-packages/run-engine/src/run-queue/index.ts
🧬 Code graph analysis (1)
internal-packages/run-engine/src/run-queue/index.ts (1)
internal-packages/run-engine/src/engine/index.ts (1)
  • runIds (1438-1476)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)

@matt-aitken matt-aitken merged commit a3bdd3c into main Sep 25, 2025
31 checks passed
@matt-aitken matt-aitken deleted the ea-branch-92 branch September 25, 2025 15:43
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.

4 participants