Skip to content

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Jan 30, 2026

Summary by CodeRabbit

  • Refactor
    • CLI command execution now runs within a managed execution context to ensure consistent request/permission handling and operational stability.
  • Chores
    • Environment configuration validation expanded to accept additional optional wallet-related variables for deployment and funding workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@baktun14 baktun14 requested a review from a team as a code owner January 30, 2026 20:33
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Wraps CLI handlers in an execution context (ExecutionContextService) that seeds a synthetic CURRENT_USER and sets a CASL MongoAbility before invoking handlers; also extends billing env validation schema with three optional mnemonic variables.

Changes

Cohort / File(s) Summary
CLI Execution Context Integration
apps/api/src/app/console.ts
Wraps CLI handlers by resolving ExecutionContextService, calling runWithContext to seed a synthetic CURRENT_USER and setting ABILITY using createMongoAbility<MongoAbility> before executing the original handler. Error handling unchanged.
Billing env schema
apps/api/src/billing/config/env.config.ts
Adds three optional string env schema fields: OLD_MASTER_WALLET_MNEMONIC, FUNDING_WALLET_MNEMONIC, and DERIVATION_WALLET_MNEMONIC to the exported envSchema validation object.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI (console)
  participant Console as Console.ts wrapper
  participant ECS as ExecutionContextService
  participant CASL as CASL (createMongoAbility)
  participant Handler as Original CLI handler

  CLI->>Console: invoke command
  Console->>ECS: resolve ExecutionContextService
  Console->>ECS: runWithContext(fn)
  ECS->>ECS: seed CURRENT_USER (synthetic)
  ECS->>CASL: createMongoAbility<MongoAbility>(...)
  CASL-->>ECS: ability instance
  ECS->>Console: context ready (includes ABILITY)
  Console->>Handler: call original handler within context
  Handler-->>Console: result / throw
  Console-->>CLI: return result / propagate error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
Hopping into the console's bright light,
I seed a small user to guide each byte,
Abilities set, the commands now align,
Secure little hops through each CLI line. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: integrating execution context service and MongoAbility in CLI handlers, which is demonstrated in the console.ts file modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/top-up-error

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: 1

🤖 Fix all issues with AI agents
In `@apps/api/src/app/console.ts`:
- Around line 84-106: Replace the deny-all ability created with
createMongoAbility by injecting AbilityService and building a super-user ability
for the CLI user: after setting CURRENT_USER on ExecutionContextService, call
abilityService.getAbilityFor("SUPER_USER", currentUser) and set that result via
executionContextService.set("ABILITY", ...). Ensure AbilityService is resolved
from the same DI container used here (or passed in) and use the same change in
the analogous place in JobQueueService where createMongoAbility is used (the
method around the job queue execution block).

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.14%. Comparing base (164eeb5) to head (5061551).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2630      +/-   ##
==========================================
- Coverage   50.91%   50.14%   -0.77%     
==========================================
  Files        1054     1020      -34     
  Lines       29725    28950     -775     
  Branches     6692     6606      -86     
==========================================
- Hits        15133    14517     -616     
+ Misses      14242    14091     -151     
+ Partials      350      342       -8     
Flag Coverage Δ *Carryforward flag
api 78.27% <ø> (-0.18%) ⬇️
deploy-web 32.24% <ø> (ø) Carriedforward from 164eeb5
log-collector ?
notifications 87.94% <ø> (ø) Carriedforward from 164eeb5
provider-console 81.48% <ø> (ø) Carriedforward from 164eeb5
provider-proxy 84.35% <ø> (ø) Carriedforward from 164eeb5
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
apps/api/src/billing/config/env.config.ts 100.00% <ø> (ø)

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@baktun14 baktun14 merged commit cbf18ce into main Jan 30, 2026
72 of 73 checks passed
@baktun14 baktun14 deleted the fix/top-up-error branch January 30, 2026 22:41
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.

2 participants