-
Notifications
You must be signed in to change notification settings - Fork 78
feat: integrate execution context service and MongoAbility in CLI han… #2630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughWraps 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
c310919 to
5061551
Compare
There was a problem hiding this 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 Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.