Skip to content

feat(orm): add BaseModel.sudo/withUser and remove Compute runAs#186

Merged
buke merged 9 commits into
mainfrom
feat/orm-sudo-withuser
Jul 25, 2026
Merged

feat(orm): add BaseModel.sudo/withUser and remove Compute runAs#186
buke merged 9 commits into
mainfrom
feat/orm-sudo-withuser

Conversation

@buke

@buke buke commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

  • Add BaseModel.sudo(fn) for scoped RecordRule + FieldRule bypass (company scope retained) with enter audit, sync/async friendly for virtual compute reads.
  • Add first-class BaseModel.withUser(userId, fn) with a userId override stack; getUserId() prefers the stack over identity.userId. withContext remains business-ctx only and does not switch authz user.
  • Remove author-facing @Compute({ runAs }) (decorator rejects it), metadata, and engine/search wrapping so compute/search elevation is only via method-body sudo / withUser (PR-P0-M1 / D1–D12).

Test plan

  • ./choysum test unit core --be
  • ./choysum test typecheck core
  • Spot-check: nested sudo + withUser composition; sync sudo inside @Compute body
  • Spot-check: @Compute({ runAs: 'sudo' }) fails at decorate time

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Added withUser for temporary user identity overrides, with correct nesting and safe async scope behavior (including overlap detection).
    • Added BaseModel.withUser(...) / instance withUser(...) and BaseModel.sudo(...) / instance sudo(...) for authorization scoping and elevation.
    • Added an authz bypass helper that works in both sync and async code with proper nesting and out-of-order completion handling.
    • Extended public API re-exports to include withUser.
  • Breaking Changes
    • Removed compute runAs support end-to-end, including metadata, handler contracts, and related audit behavior.

PR Type

Enhancement


Description

  • TypeScript modules (modules/core):

    • Added BaseModel.sudo for scoped rule bypass.
    • Added BaseModel.withUser identity override stack.
    • Removed author-facing @Compute({ runAs }) decorator option.
  • Go core: No changes outside modules/.

  • Added new source files with required SPDX headers.

  • Expanded TypeScript unit test coverage for sudo and user contexts.


File Walkthrough

Relevant files
Enhancement
9 files
model.ts
Expose sudo and withUser methods on BaseModel                       
+37/-0   
model_sudo.ts
Implement withModelSudo and enter audit recording               
+52/-0   
user.ts
Implement user override stack and withUser handler             
+114/-0 
compute.ts
Reject author-facing runAs option in Compute decorator     
+3/-6     
authz_runtime.ts
Add sync-friendly combined authz rule bypass wrapper         
+57/-18 
model_context_facade.ts
Bridge withUser and sudo through model context facade       
+20/-0   
context.ts
Re-export withUser from service api context entrypoint     
+1/-0     
index.ts
Re-export withUser in service api root index                         
+1/-0     
index.ts
Export getUserId and withUser from context user module     
+2/-1     
Tests
4 files
model_sudo.test.ts
Add unit tests for withModelSudo execution                             
+85/-0   
context.test.ts
Add unit tests for withUser context behavior                         
+45/-1   
compute.test.ts
Update Compute decorator tests for removed runAs option   
+3/-5     
authz_runtime.test.ts
Add tests for combined authz rule bypass wrapper                 
+28/-0   
Refactoring
7 files
engine.ts
Remove runAs execution wrapper from compute engine             
+2/-6     
search_rewrite.ts
Remove runAs wrapper from search rewrite logic                     
+2/-6     
runas.ts
Remove legacy compute runAs module file                                   
+0/-63   
compute.ts
Remove ComputeRunAs type and metadata properties                 
+0/-7     
field.ts
Remove runAs property from ColumnComputeSpec                         
+0/-2     
model.ts
Remove runAs from ComputeHandlerMeta interface                     
+0/-1     
storage.ts
Remove runAs field normalization from MetadataStorage       
+0/-1     
Additional files
9 files
index.test.ts +1/-0     
index.ts +0/-1     
storage.test.ts +0/-2     
model.test.ts +5/-0     
index.ts +1/-0     
condition_compiler.test.ts +6/-16   
engine.test.ts +3/-16   
runas.test.ts +0/-94   
source.ts +0/-8     

- Add scoped sudo for RR/FR bypass with enter audit while keeping company scope.

- Add withUser identity override stack so getUserId prefers the stack over identity.

- Remove author-facing @compute({ runAs }) and engine wrapping in favor of method-body sudo/withUser.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds scoped withUser and model-level sudo APIs, introduces synchronous/asynchronous authorization bypass handling with sudo auditing, and removes compute runAs metadata and execution wrappers.

Changes

Authorization and compute execution

Layer / File(s) Summary
User context override foundation
modules/core/service/runtime/context/*, modules/core/service/api/*
Adds request/process-scoped withUser, async-scope overlap tracking, reliable restoration, and API entrypoint exports.
Combined authorization bypass
modules/core/service/orm/repository/authz/*, modules/core/service/orm/model/model_sudo.*
Adds combined RecordRule and FieldRule bypassing, sync/async depth restoration, nested execution support, and sudo audit records.
Model user and sudo surface
modules/core/service/orm/model/model.ts, model_context_facade.ts, model.test.ts
Adds static and instance withUser and sudo methods backed by model context helpers.
Compute runAs contract removal
modules/core/service/orm/decorator/*, modules/core/service/orm/metadata/*
Removes ComputeRunAs and runAs from compute options, handler contexts, column specifications, normalized metadata, and related tests.
Resolved metadata and web contract cleanup
internal/parser/..., internal/module/artifact/generate/*, pkg/meta/*, modules/web/web/stores/*
Stops parser, intermediate metadata, generated field metadata, and web metadata views from propagating or exposing runAs.
Direct compute execution
modules/core/service/runtime/compute/*, modules/core/service/orm/repository/query/tests/*
Removes compute runAs wrappers from field evaluation and search rewriting while preserving result handling and updating runtime tests and search expectations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Model
  participant ContextFacade
  participant RuntimeContext
  participant AuthzRuntime
  participant ComputeEngine
  Model->>ContextFacade: withUser(userId, fn)
  ContextFacade->>RuntimeContext: push user override
  Model->>ContextFacade: sudo(fn)
  ContextFacade->>AuthzRuntime: bypass record and field rules
  ComputeEngine->>ComputeEngine: execute compute directly
  AuthzRuntime-->>Model: restore bypass depths
  RuntimeContext-->>Model: restore user override
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.24% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding BaseModel sudo/withUser and removing Compute runAs.
Description check ✅ Passed The description includes the required CLA note and adequately summarizes the change, tests, and scope.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/orm-sudo-withuser

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

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix out-of-order stack corruption in withUser

Restoring the userId override stack using .pop() causes context corruption if
concurrent async calls inside withUser complete out of order. Store unique entry
objects on the stack and remove the specific entry using indexOf and splice upon
cleanup.

modules/core/service/runtime/context/user.ts [75-84]

-let stack = jsCtx[USER_ID_OVERRIDE_KEY] as string[] | undefined;
+type OverrideEntry = { userId: string };
+let stack = jsCtx[USER_ID_OVERRIDE_KEY] as OverrideEntry[] | undefined;
 if (!Array.isArray(stack)) {
   stack = [];
   jsCtx[USER_ID_OVERRIDE_KEY] = stack;
 }
-stack.push(normalized);
+const entry: OverrideEntry = { userId: normalized };
+stack.push(entry);
 
 const restore = () => {
-  stack!.pop();
+  const idx = stack!.indexOf(entry);
+  if (idx !== -1) stack!.splice(idx, 1);
   if (stack!.length === 0) delete jsCtx[USER_ID_OVERRIDE_KEY];
 };
Suggestion importance[1-10]: 8

__

Why: Using pop() to restore the userId override stack causes stack corruption when concurrent async calls inside withUser complete out of order. Storing unique entry objects and removing the matching entry via indexOf and splice ensures safe cleanup across asynchronous executions.

Medium
Fix bypass depth restoration for concurrent requests

Resetting state[key] directly to previousDepth can prematurely revoke authz rule
bypasses if concurrent async tasks share the same request service state. Decrement
the current depth counter instead and delete the key only when depth drops to zero.

modules/core/service/orm/repository/authz/authz_runtime.ts [157-160]

-function restoreBypassDepth(state: RepositoryReqServiceState, key: 'recordRuleBypassDepth' | 'fieldRuleBypassDepth', previousDepth: number): void {
-  if (previousDepth > 0) state[key] = previousDepth;
+function restoreBypassDepth(state: RepositoryReqServiceState, key: 'recordRuleBypassDepth' | 'fieldRuleBypassDepth'): void {
+  const current = state[key] ?? 0;
+  if (current > 1) state[key] = current - 1;
   else delete state[key];
 }
Suggestion importance[1-10]: 8

__

Why: Restoring state[key] directly to previousDepth prematurely removes bypass permissions for concurrent async operations sharing the same request service state if an earlier task completes first. Decrementing the current depth counter prevents authz bypasses from being prematurely revoked.

Medium

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

- Remove WebFieldMetadata.runAs and getFieldMetadataView passthrough.

- Stop parsing, resolving, and codegen-emitting IrField/compute runAs.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts (1)

166-191: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test name says "nested" but only exercises two sequential (non-nested) calls.

Unlike the sibling tests for withRepositoryRecordRuleBypass/withRepositoryFieldRuleBypass (lines 116-122, 203-209) which nest a call inside another and assert depth reaches 2, this test for the combined withRepositoryAuthzRuleBypass never nests — it just calls the wrapper twice back-to-back. The PR objectives explicitly flag nested composition as a pending spot-check; this test doesn't close that gap despite its name.

✅ Suggested addition: actual nested case
       await withRepositoryAuthzRuleBypass(async () => {
         expect(getRepositoryRecordRuleBypassDepth()).toBe(1);
         expect(getRepositoryFieldRuleBypassDepth()).toBe(1);
+        await withRepositoryAuthzRuleBypass(async () => {
+          expect(getRepositoryRecordRuleBypassDepth()).toBe(2);
+          expect(getRepositoryFieldRuleBypassDepth()).toBe(2);
+        });
+        expect(getRepositoryRecordRuleBypassDepth()).toBe(1);
+        expect(getRepositoryFieldRuleBypassDepth()).toBe(1);
       });
       expect(getRepositoryFieldRuleBypassDepth()).toBe(0);
+      expect(getRepositoryRecordRuleBypassDepth()).toBe(0);
🤖 Prompt for 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.

In `@modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts` around
lines 166 - 191, Update the test withRepositoryAuthzRuleBypass scenario to
include an actual nested wrapper invocation, asserting both record-rule and
field-rule bypass depths reach 2 inside the inner callback and return to 1 after
it completes. Preserve the existing sync and async coverage, and retain
assertions that depths restore to 0 afterward.
🤖 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 `@modules/core/service/orm/model/model_sudo.ts`:
- Around line 16-43: Update resolveSudoAuditBucket to reset the global
__choysumComputeAudit bucket when a new request context begins, while preserving
the current sudoHits initialization and recordSudoEnterAudit behavior within
that request. Reuse the existing request-context identifier or lifecycle hook
visible in the surrounding implementation to ensure audit entries cannot
accumulate or leak across requests.

In `@modules/core/service/runtime/context/user.ts`:
- Around line 80-106: The mutable stacks in withUser and the process-level
fallback must not allow overlapping asynchronous scopes to restore the wrong
user. Replace the shared-stack async handling with task-local isolation, or
explicitly reject overlapping async withUser calls, covering both the
request-scoped jsCtx path and processLevelUserIdStack path; add tests where
overlapping calls complete in reverse order and verify getUserId() remains
associated with each scope.

---

Nitpick comments:
In `@modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts`:
- Around line 166-191: Update the test withRepositoryAuthzRuleBypass scenario to
include an actual nested wrapper invocation, asserting both record-rule and
field-rule bypass depths reach 2 inside the inner callback and return to 1 after
it completes. Preserve the existing sync and async coverage, and retain
assertions that depths restore to 0 afterward.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: e54c9678-321a-4e65-bec9-56a1b0e2a402

📥 Commits

Reviewing files that changed from the base of the PR and between 3bcf836 and 2d5880d.

📒 Files selected for processing (29)
  • modules/core/service/api/context.ts
  • modules/core/service/api/index.test.ts
  • modules/core/service/api/index.ts
  • modules/core/service/orm/decorator/compute.test.ts
  • modules/core/service/orm/decorator/compute.ts
  • modules/core/service/orm/metadata/compute.ts
  • modules/core/service/orm/metadata/field.ts
  • modules/core/service/orm/metadata/index.ts
  • modules/core/service/orm/metadata/model.ts
  • modules/core/service/orm/metadata/storage.test.ts
  • modules/core/service/orm/metadata/storage.ts
  • modules/core/service/orm/model/model.test.ts
  • modules/core/service/orm/model/model.ts
  • modules/core/service/orm/model/model_context_facade.ts
  • modules/core/service/orm/model/model_sudo.test.ts
  • modules/core/service/orm/model/model_sudo.ts
  • modules/core/service/orm/repository/authz/authz_runtime.ts
  • modules/core/service/orm/repository/authz/index.ts
  • modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts
  • modules/core/service/orm/repository/query/tests/condition_compiler.test.ts
  • modules/core/service/runtime/compute/engine.test.ts
  • modules/core/service/runtime/compute/engine.ts
  • modules/core/service/runtime/compute/runas.test.ts
  • modules/core/service/runtime/compute/runas.ts
  • modules/core/service/runtime/compute/search_rewrite.ts
  • modules/core/service/runtime/context/context.test.ts
  • modules/core/service/runtime/context/index.ts
  • modules/core/service/runtime/context/source.ts
  • modules/core/service/runtime/context/user.ts
💤 Files with no reviewable changes (9)
  • modules/core/service/runtime/compute/runas.test.ts
  • modules/core/service/runtime/context/source.ts
  • modules/core/service/orm/metadata/index.ts
  • modules/core/service/runtime/compute/runas.ts
  • modules/core/service/orm/metadata/model.ts
  • modules/core/service/orm/metadata/field.ts
  • modules/core/service/orm/metadata/storage.ts
  • modules/core/service/orm/metadata/storage.test.ts
  • modules/core/service/orm/metadata/compute.ts

Comment thread modules/core/service/orm/model/model_sudo.ts Outdated
Comment thread modules/core/service/runtime/context/user.ts Outdated
- Remove withUser override entries by identity so sibling async scopes do not LIFO-pop each other.

- Decrement shared RR/FR bypass depth on restore, matching withBypassDepths for out-of-order completion.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/parser/backendtsparser/parser_migration_test.go (1)

238-238: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Preserve negative coverage for the removed runAs contract.

The changed tests remove the old inputs and assertions but do not verify rejection or omission, allowing stale runAs propagation to regress unnoticed.

  • internal/parser/backendtsparser/parser_migration_test.go#L238-L238: add a legacy runAs fixture and assert decorate-time rejection.
  • pkg/meta/meta_field_test.go#L168-L171: assert serialized resolved metadata omits "runAs".
  • internal/module/artifact/generate/webapistore_test.go#L80-L81: assert generated store content omits the runAs key.
🤖 Prompt for 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.

In `@internal/parser/backendtsparser/parser_migration_test.go` at line 238,
Preserve negative coverage for the removed runAs contract: in
internal/parser/backendtsparser/parser_migration_test.go lines 238-238, add a
legacy runAs fixture and assert decorate-time rejection; in
pkg/meta/meta_field_test.go lines 168-171, assert serialized resolved metadata
omits "runAs"; and in internal/module/artifact/generate/webapistore_test.go
lines 80-81, assert generated store content omits the runAs key.
🤖 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.

Nitpick comments:
In `@internal/parser/backendtsparser/parser_migration_test.go`:
- Line 238: Preserve negative coverage for the removed runAs contract: in
internal/parser/backendtsparser/parser_migration_test.go lines 238-238, add a
legacy runAs fixture and assert decorate-time rejection; in
pkg/meta/meta_field_test.go lines 168-171, assert serialized resolved metadata
omits "runAs"; and in internal/module/artifact/generate/webapistore_test.go
lines 80-81, assert generated store content omits the runAs key.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d8ff6191-2ad5-4c56-9a5f-8f9ad2a15b86

📥 Commits

Reviewing files that changed from the base of the PR and between 2d5880d and d5ca6d6.

📒 Files selected for processing (9)
  • internal/module/artifact/generate/webapistore.go
  • internal/module/artifact/generate/webapistore.ts.tpl
  • internal/module/artifact/generate/webapistore_test.go
  • internal/parser/backendtsparser/field_resolved.go
  • internal/parser/backendtsparser/parser_migration_test.go
  • modules/web/web/stores/modelStore.test.ts
  • modules/web/web/stores/modelStore.ts
  • pkg/meta/meta_field.go
  • pkg/meta/meta_field_test.go
💤 Files with no reviewable changes (5)
  • internal/module/artifact/generate/webapistore.ts.tpl
  • modules/web/web/stores/modelStore.test.ts
  • internal/parser/backendtsparser/field_resolved.go
  • modules/web/web/stores/modelStore.ts
  • internal/module/artifact/generate/webapistore.go

- Store sudoHits on request service state so audit entries do not accumulate across requests.

- Exercise nested withRepositoryAuthzRuleBypass depth restore in unit coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@modules/core/service/orm/model/model_sudo.test.ts`:
- Around line 21-25: Update readSudoHits to return only the current request
state's sudoHits, using an empty array when the request state or field is
absent; remove the globalThis.__choysumComputeAudit fallback from this helper.
If no-request tests still require legacy behavior, move that fallback into a
separate helper and use it only in those tests.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: dfe9c4dd-f4df-4357-9285-7534ef9f6b97

📥 Commits

Reviewing files that changed from the base of the PR and between be94a64 and b4fe495.

📒 Files selected for processing (3)
  • modules/core/service/orm/model/model_sudo.test.ts
  • modules/core/service/orm/model/model_sudo.ts
  • modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/core/service/orm/model/model_sudo.ts
  • modules/core/service/orm/repository/authz/tests/authz_runtime.test.ts

Comment thread modules/core/service/orm/model/model_sudo.test.ts
buke and others added 2 commits July 25, 2026 16:06
- Share a pendingAsync/syncDepth guard so sibling Promise.all scopes fail fast.

- Keep sync nesting and sequential awaits; document yield-after-nest as unsupported without ALS.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Parse legacy @compute({ runAs }) fixtures and assert resolved JSON has no runAs.

- Assert IrField and webapistore outputs omit the removed runAs key.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@modules/core/service/runtime/context/scope.ts`:
- Around line 154-171: Update the cleanup logic in runWithAsyncScopeTracking to
track each context entry and remove the specific scope being settled rather than
restoring via LIFO branches. After removal, expose the latest remaining active
entry through CTX_OVERRIDE_KEY, preserving the correct context when detached
nested async withContext calls settle out of order. Add a regression test
covering this detached nested async scenario.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9dc0367-039f-4b12-bad1-ee7adb93444a

📥 Commits

Reviewing files that changed from the base of the PR and between b4fe495 and 51050ef.

📒 Files selected for processing (4)
  • modules/core/service/runtime/context/async_scope.ts
  • modules/core/service/runtime/context/context.test.ts
  • modules/core/service/runtime/context/scope.ts
  • modules/core/service/runtime/context/user.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/core/service/runtime/context/user.ts

Comment thread modules/core/service/runtime/context/scope.ts Outdated
@buke

buke commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

/improve

@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

buke and others added 3 commits July 25, 2026 16:29
- Drop the overlapping-async guard that also blocked legitimate nest-after-await used by repository update validation and bilingual write/read paths.

- Keep documenting concurrent sibling scopes as unsupported without AsyncLocalStorage, and cover nest-after-await in unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Exercise BaseModel static/instance withUser and sudo wrappers end to end.

- Cover sudo audit hint, process-bucket fallback, and audit disable env.

- Cover withUser process async/throw, legacy stack entries, and sibling restore.

- Cover authz bypass sync throw restore and no-req authz bypass; reject async @Search on sync rewrite.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Hit empty/null userId override stack tops so peekStackTop string branch is complete.

- Corrupt bypass depth to NaN/Infinity/non-number so restoreBypassDepth uses the zero fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
@buke
buke merged commit bd64bff into main Jul 25, 2026
43 checks passed
@buke
buke deleted the feat/orm-sudo-withuser branch July 25, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant