Skip to content

feat(mfa): live-tenant MFA CLI eval + framework-injected platform context - #182

Merged
sanchitmehtagit merged 4 commits into
mainfrom
eval/mfa-tenant-cli
Aug 11, 2026
Merged

feat(mfa): live-tenant MFA CLI eval + framework-injected platform context#182
sanchitmehtagit merged 4 commits into
mainfrom
eval/mfa-tenant-cli

Conversation

@sanchitmehtagit

@sanchitmehtagit sanchitmehtagit commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

What

Two related changes:

  1. New eval mfa_tenant_cli — a goal-only CLI eval that configures MFA on a real, throwaway Auth0 tenant (requested via provision: auth0-tenant frontmatter), rather than a mocked Guardian surface. Enable an MFA factor, then enforce MFA via guardian/policies using the pre-authenticated auth0 CLI. Live-tenant style from feat(evals): add auth0 CLI B2B organization setup eval #178; MFA scenario from feat(mfa): MFA Leg 2 (tenant config: CLI) #83.

  2. Framework: inject provisioned-env platform context into the agent context file. The eval originally carried a ## System platform preamble ("you are a platform engineer, use auth0 api ..."). But ## System only feeds baseline mode — agent runners receive only ## Task, so that context never reached the agent in agent mode (the mode this eval targets). This adds a proper mechanism to inject it.

Framework design (mechanism in framework, text in consumer)

evals-core stays provider-agnostic:

  • Loader parses the provision frontmatter field onto EvalDefinition.
  • writeAgentGuidance now takes { compileCommand?, extraContext? } and appends extraContext after the base guidance (order: base guidance → extraContext → compile guidance).
  • FrameworkConfig.provisionContext: Record<string,string> (empty default). run.ts resolves evalDef.provision against it and passes the text as extraContext, so the platform context lands in the agent's context file (CLAUDE.md/AGENTS.md/…) on both local and Docker-sandbox paths (written before dispatch on the bind-mounted workspace).
  • The Auth0-specific wording lives in eval.config.js provisionContext['auth0-tenant'], mirroring scoring.docUrlSources.

Grading (unchanged, trace-based)

  • L4 ranCommandOneOf(['guardian/factors/otp','push','sms']) — enabled a factor
  • L4 ranCommand('guardian/policies', ['all-applications']) — enforced MFA
  • L4 ranCommandsInOrder([...factors, 'guardian/policies']) — factor before enforcement
  • Holistic judge with includeCommandTrace: true

Tests

  • Loader parses provision (present/absent).
  • writeAgentGuidance injects extraContext and orders sections correctly (base → extra → compile); existing call sites updated to the options object.

Verification

  • npm run build && npm run lint && npm run format && npm test — all pass (loader + workspace suites include the new cases).
  • End-to-end: loadConfig reads app provisionContext, loader surfaces provision: auth0-tenant, and the platform-engineer + auth0 api text lands in the workspace CLAUDE.md alongside the base guidance — proving the context now reaches the agent.
  • A real grader pass still needs the eval-runner repo's provisioned tenant; locally the trace graders fail with an empty trace, as expected.

Notes

  • No verify.js (deferred).
  • Docs updated: docs/ADDING_EVALS.md frontmatter table (provision), AGENTS.md context-injection note + docs-map row.

Summary by CodeRabbit

  • New Features

    • Added support for evaluations requiring provisioned environments and provider-specific CLI guidance.
    • Added Auth0 tenant CLI guidance for authenticated, non-interactive MFA configuration.
    • Added an MFA evaluation covering factor enablement, enforcement, command ordering, and CLI-only compliance.
  • Documentation

    • Documented provisioned environments, CLI context guidance, and related grading exclusions.
  • Tests

    • Added coverage for provision metadata and CLI guidance injection behavior.

Adds mfa_tenant_cli, a goal-only CLI eval that configures MFA on a real
throwaway Auth0 tenant (requested via 'provision: auth0-tenant' in PROMPT.md
frontmatter, which the eval runner reads; the framework loader ignores it).
The agent enables an MFA factor and enforces MFA via guardian/policies using
the pre-authenticated auth0 CLI — the live-tenant analogue of the mocked
Guardian scenario, exercising the real Management API instead of a mock.

The eval writes no files, so grading is trace-based: ranCommandOneOf (enable
factor), ranCommand guardian/policies all-applications (enforce),
ranCommandsInOrder (enable before enforce), plus a holistic trace-aware judge.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds provision-aware CLI guidance to eval execution and introduces a tenant MFA CLI evaluation. The evaluation requires MFA factor enablement followed by all-application enforcement. Graders validate command order and reject dashboard or Terraform configuration.

Changes

Tenant CLI MFA evaluation

Layer / File(s) Summary
Provision-aware CLI guidance
packages/evals-core/src/types/eval.ts, packages/evals-core/src/loader.ts, packages/evals-core/src/config/*, packages/evals-core/src/workspace/workspace.ts, packages/evals/src/cli/run.ts, packages/evals-core/tests/*, docs/ADDING_EVALS.md, AGENTS.md
Eval definitions now support provision. Framework configuration maps provision kinds to cliContext. Agent guidance combines base, CLI, and compile guidance in that order. Tests and documentation cover the new behavior.
CLI MFA evaluation prompt
apps/auth0-evals/src/evals/mfa/tenant-cli/PROMPT.md
Defines an Auth0 CLI task to enable an MFA factor and enforce MFA for tenant users.
CLI trace validation
apps/auth0-evals/src/evals/mfa/tenant-cli/graders.ts, apps/auth0-evals/eval.config.js
Adds tenant MFA graders for factor enablement, all-applications enforcement through guardian/policies, command ordering, and CLI-only configuration. The auth0-tenant context supplies authenticated, non-interactive CLI instructions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant Auth0CLI
  participant Tenant
  participant MFAGraders
  Agent->>Auth0CLI: enable required MFA factor
  Auth0CLI->>Tenant: update MFA factor
  Agent->>Auth0CLI: enforce MFA for all applications
  Auth0CLI->>Tenant: update guardian/policies
  MFAGraders->>Tenant: inspect events and command trace
  MFAGraders-->>Agent: validate order and CLI-only compliance
Loading

Possibly related PRs

  • auth0/auth0-evals#176: Shares CLI-platform guidance, provisioning, and context injection infrastructure.

Suggested reviewers: frederikprijck

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both main changes: the live-tenant MFA CLI evaluation and framework-injected platform context.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch eval/mfa-tenant-cli

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.

@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

🤖 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 `@apps/auth0-evals/src/evals/mfa/tenant-cli/graders.ts`:
- Around line 17-43: The existing event graders only match command substrings
and do not verify successful MFA writes or final state. Strengthen the graders
around ranCommandOneOf, ranCommand, and ranCommandsInOrder to reject
read/disabled or partial/contradictory writes, validate the resulting enabled
factor and all-applications policy (using a verify.js/final-state check if
supported), and add deterministic notContains checks for dashboard and Terraform
configuration.

In `@apps/auth0-evals/src/evals/mfa/tenant-cli/PROMPT.md`:
- Around line 23-27: Update the MFA tenant CLI prompt to explicitly require the
all-applications enforcement policy, matching the guardian/policies expectation
in the grader. Keep the instructions focused on enabling the required factor and
enforcing MFA for all applications via non-interactive Auth0 CLI commands.
🪄 Autofix

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 Plus

Run ID: 49278d0d-b331-43a7-85a1-6667711cebe2

📥 Commits

Reviewing files that changed from the base of the PR and between 20037dd and b725edd.

📒 Files selected for processing (2)
  • apps/auth0-evals/src/evals/mfa/tenant-cli/PROMPT.md
  • apps/auth0-evals/src/evals/mfa/tenant-cli/graders.ts

Comment thread apps/auth0-evals/src/evals/mfa/tenant-cli/graders.ts
Comment thread apps/auth0-evals/src/evals/mfa/tenant-cli/PROMPT.md Outdated
…ontext file

The mfa_tenant_cli eval carried a '## System' platform preamble (you are a
platform engineer, use 'auth0 api ...'), but '## System' only feeds baseline
mode — agent runners receive only '## Task', so that context never reached the
agent in agent mode, which is the mode the eval targets.

Add a framework mechanism to inject it, keeping evals-core provider-agnostic:

- Loader parses the 'provision' frontmatter field onto EvalDefinition.
- writeAgentGuidance takes an options object { compileCommand?, extraContext? }
  and appends extraContext after the base guidance (order: base guidance →
  extraContext → compile guidance).
- FrameworkConfig gains provisionContext: Record<string,string> (empty default);
  run.ts resolves evalDef.provision against it and passes the text as
  extraContext, so the platform context lands in the agent's context file
  (CLAUDE.md / AGENTS.md / ...) on both local and sandbox paths.
- The Auth0-specific wording moves to eval.config.js provisionContext
  ['auth0-tenant'], mirroring scoring.docUrlSources: mechanism in the framework,
  provider text in the app.
- Drop the '## System' section from the eval; it's now framework-injected.

Tests: loader parses provision (present/absent); writeAgentGuidance injects and
orders extraContext correctly. Docs: ADDING_EVALS frontmatter table + AGENTS.md
context-injection note.
@sanchitmehtagit sanchitmehtagit changed the title feat(mfa): add live-tenant MFA tenant-config CLI eval feat(mfa): live-tenant MFA CLI eval + framework-injected platform context Aug 10, 2026
…injected text

- Rename the config field FrameworkConfig.provisionContext -> cliContext: the
  name should describe what it holds (CLI/platform context) rather than the
  provision trigger. Renamed everywhere (defaults, run.ts, eval.config.js, docs).
- Rename the writeAgentGuidance option extraContext -> cliContext and keep
  AgentGuidanceOptions internal (unexported) — compileCommand is a per-run
  framework detail, not public API.
- Trim the injected auth0-tenant context: drop the 'platform engineer' persona
  (no behavioral value) and the 'not IaC/not dashboard' line (a task constraint
  that already lives in the eval's ## Task). Keep the facts the agent genuinely
  can't discover — the shell is already authenticated to a live tenant, don't
  re-login, don't hardcode/look up domain/client-id/secret, stay
  non-interactive, never print secrets — plus the generic 'auth0 api' Management
  API passthrough affordance (many resources have no dedicated subcommand). No
  MFA/B2B endpoints, so the graded answer isn't leaked.
Comment thread apps/auth0-evals/eval.config.js Outdated
'CLI (`auth0 login` has already run and that tenant is active). Do not run `auth0 login`, ' +
'and do not hardcode or look up the tenant domain, client ID, or client secret — the CLI ' +
'is already authenticated. Run commands non-interactively and never print or store secrets.' +
'\n\nTenant configuration that has no dedicated `auth0` subcommand can be done through the ' +

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tenant configuration that has no dedicated auth0 subcommand can be done through the ' +
"Management API passthrough, which takes an HTTP method and a Management API path:\n\n" +

this should not be added

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 3d0245f — removed the auth0 api <METHOD> <path> passthrough hint from cliContext; the agent discovers the CLI command surface itself.

// resources have no dedicated subcommand; the specific paths are the agent's
// to find.
cliContext: {
'auth0-tenant':

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do we need to map this to auth0 tenant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Keeping cliContext keyed by provision kind. The key is the same value the eval already declares in frontmatter (provision: auth0-tenant), and run.ts resolves cliContext[evalDef.provision] — so an eval with no provision injects nothing, and a future second environment kind (e.g. a different tenant type or a mock) maps to its own context instead of reusing this one. Costs one line of nesting; no new concept. No code change.


Using the Auth0 CLI, enable the required MFA factor on the tenant and then enforce MFA so it is required for users. Work out the commands yourself. Run everything non-interactively (no interactive prompts should block you). If a command errors, read the message and adjust. Never print or store any client secret.

Do not configure the tenant through the dashboard or Terraform — the change must be made via the Auth0 CLI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Work out the commands yourself. Run everything non-interactively (no interactive prompts should block you). If a command errors, read the message and adjust. Never print or store any client secret.Do not configure the tenant through the dashboard or Terraform — the change must be made via the Auth0 CLI.
this is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 3d0245f — trimmed the prompt to the goal-only requirement. The non-interactive / never-print-secrets / no-dashboard-or-Terraform guidance is now injected via cliContext, so it no longer needs to live in the prompt.

- Drop the auth0 api Management API passthrough hint from cliContext (leave the
  CLI command surface for the agent to discover).
- Trim the eval prompt to the goal-only requirement; the non-interactive /
  no-secrets / no-dashboard-or-Terraform guidance is already injected via
  cliContext.

@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 `@packages/evals/src/cli/run.ts`:
- Around line 137-145: Add Vitest coverage in the packages/evals tests directory
for the runAgentJob cliContext resolution: verify a matching evalDef.provision
passes the configured context to writeAgentGuidance, while missing and unmapped
provision keys pass undefined. Mock or spy on writeAgentGuidance and
getFrameworkConfig as needed, covering each branch introduced in the
runner-level logic.
🪄 Autofix

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 Plus

Run ID: 71140709-8ad5-4f0b-93d8-2448dc499e91

📥 Commits

Reviewing files that changed from the base of the PR and between b725edd and 3d0245f.

📒 Files selected for processing (12)
  • AGENTS.md
  • apps/auth0-evals/eval.config.js
  • apps/auth0-evals/src/evals/mfa/tenant-cli/PROMPT.md
  • docs/ADDING_EVALS.md
  • packages/evals-core/src/config/defaults.ts
  • packages/evals-core/src/config/framework.ts
  • packages/evals-core/src/loader.ts
  • packages/evals-core/src/types/eval.ts
  • packages/evals-core/src/workspace/workspace.ts
  • packages/evals-core/tests/loader.test.ts
  • packages/evals-core/tests/workspace.test.ts
  • packages/evals/src/cli/run.ts

Comment on lines +137 to +145
// local execution paths so every runner picks it up. When the eval declares a
// `provision` kind, also inject the app-configured platform context for it —
// the `## System` section only feeds baseline mode, so this is how that
// guidance reaches the agent.
const cliContext = evalDef.provision ? getFrameworkConfig().cliContext?.[evalDef.provision] : undefined;
writeAgentGuidance(workspace, agentType, {
compileCommand: evalDef.compileCommand,
cliContext,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add runner-level coverage for cliContext resolution.

Add Vitest coverage in the packages/evals package. Test a matching provision key, no provision key, and an unmapped provision key. The current core-package tests do not verify that runAgentJob passes the configured context to writeAgentGuidance.

As per coding guidelines, “Every new function and every logic change must be accompanied by Vitest tests in the package's own tests/ directory” and non-trivial logic changes must cover each new branch.

🤖 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 `@packages/evals/src/cli/run.ts` around lines 137 - 145, Add Vitest coverage in
the packages/evals tests directory for the runAgentJob cliContext resolution:
verify a matching evalDef.provision passes the configured context to
writeAgentGuidance, while missing and unmapped provision keys pass undefined.
Mock or spy on writeAgentGuidance and getFrameworkConfig as needed, covering
each branch introduced in the runner-level logic.

Source: Coding guidelines

@developerkunal developerkunal 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.

LGTM

@sanchitmehtagit
sanchitmehtagit merged commit 52b45da into main Aug 11, 2026
6 checks passed
@sanchitmehtagit
sanchitmehtagit deleted the eval/mfa-tenant-cli branch August 11, 2026 07:09
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