Skip to content

User Context vs System Context 🟑 BETA

Identify which execution context a script or handler uses, and keep system-context power out of user-triggered paths.

Admin guide Β· execution context runbook

When to use Before you start Steps Verify Roll back
Reviewing a tool or scheduled job, investigating unexpected access Source checkout, test identity Find the context source, probe one action User action stays scoped Restore the previous script or handler

When to use

Use this runbook when an action taken by a user appears to run with broader rights, or when a scheduled job must use a service identity.

Before you start

  • User context is scoped to the acting user and tenant; it is the default for chat and web sessions. System context is a service identity used for tasks such as scheduled jobs.
  • The role scope variable comes from the resolved user, not from the script text. Tools are gated in start.bas and enforced at execution.
  • RBAC membership is resolved from the directory identity; a client-supplied role is never authoritative.
  • A system-context action must not assume it inherited the user's consent; use the consent gate for VM actions.

Steps

# 1. Find where the context is chosen.
grep -RIn "system_context\|SystemContext\|user_context\|resolve_user_role" \
  botserver/src botserver/crates --include='*.rs' | head -40

# 2. Inspect the tool's entry script for role gating.
git -C <bot-repo> show HEAD:.gbdialog/start.bas

# 3. Run one action as a standard user and inspect its audit line.
grep -E "AUDIT|permission|role" botserver.log | tail -20

Verify

Check Surface Pass condition
User context test session scoped to user and tenant
System context scheduled job uses the service identity only
Role variable start.bas guard derived from resolved role
Tool execution standard-user probe admin tool refused
Tenant cross-tenant probe refused
Audit server log context recorded

Roll back

πŸ”΄ Restore the previous script in the bot's ALM repository or revert the handler through version control and redeploy with the deploy runbook. An unintended system-context action is an incident under incident response.