Skip to content

[ML-70351] [l] Resolve one profile across CLI and local agent - #694

Open
elainewang-db wants to merge 24 commits into
databricks:mainfrom
elainewang-db:ml-70351-profile-resolution
Open

elainewang-db wants to merge 24 commits into
databricks:mainfrom
elainewang-db:ml-70351-profile-resolution

Conversation

@elainewang-db

@elainewang-db elainewang-db commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Agent Bricks commands and the local agent could use different Databricks profiles, and unauthenticated workspace commands could hang on browser consent. This PR resolves one profile per project command, passes it to the local agent, and checks authentication before dev or deploy starts work. Addresses ML-70351.

Behavior

  • Profile order inside a project: -p, then the project's .env (the --source project's when given), then a saved agentbricks login default, then DATABRICKS_CONFIG_PROFILE, then SDK default authentication. Exported SDK credential variables keep their SDK precedence.
  • The profile is chosen once per command, before it runs, and the API client is built from that choice.
  • The CLI reads .env with python-dotenv, the same parser the agent uses, so both see the same profile.
  • init pins a profile in .env unless environment authentication is in use.
  • auth switch changes the project's profile, auth describe reports it, and auth login signs in. With no profile, auth login hands off to databricks auth login's picker. The existing login and logout commands continue to save and clear the default profile.
  • deploy fails fast on invalid authentication. dev does the same for scaffolded agents or explicitly selected project profiles, while local-only projects can run offline despite unrelated ambient workspace settings. Project .env credentials take precedence over a stale child CLI profile. dev and deploy do not start browser consent for a rejected external-browser profile; legacy login continues to accept valid cached browser credentials.
  • Text output shows one workspace notice with the profile and the host actually used.

Code layout

  • projects/profiles.py: profile resolution and ~/.databrickscfg lookups.
  • projects/env_file.py: reads .env with dotenv and rewrites actual profile bindings atomically, preserving unrelated multiline values and rejecting names that change on readback.
  • services/workspace_auth.py: auth checks with a time limit, and error classification.
  • clients/databricks_cli.py: runs databricks auth login.
  • cli/auth.py: the auth and compatible login/logout commands. cli/app.py: chooses the profile per command.
  • presentation/profile.py: workspace notices and profile warnings.

Reading order
projects/profiles.py, then projects/env_file.py, services/workspace_auth.py, cli/app.py (CliContext.select_profile) and cli/auth.py, then cli/init.py, cli/dev.py and cli/deploy.py. Docs last.

Testing

  • On 54d5f4e, focused auth, dotenv, workspace auth, dev, deploy, CLI and telemetry tests passed: 466 passed. Ruff lint and format, and type checking of edited Python files passed. A real CLI journey confirmed that an interpolated profile name is rejected without changing .env. The full local suite stopped at a sandbox PermissionError when an unrelated test attempted to bind a loopback socket. Current-head CI passed 57/57 checks, including Agent Bricks unit tests on Python 3.10 and fake-workspace end-to-end suites on Ubuntu and macOS.
  • Local end-to-end tests on commit 3786c31: tests/functional/dev_runtime_test.py passed 6/6. Fresh LangGraph and OpenAI projects booted and answered an invocation across the built-in server (with and without chat UI) and custom server, using a fake model-serving endpoint.
  • Isolated CLI journeys on the same commit passed: init pinned an explicit or SDK-default profile; environment credentials left .env absent; auth describe reported the selected workspace; trailing -p overrode it; auth switch persisted the new profile; and dev rejected an external-browser profile before agent startup with a login hint.
  • Those earlier end-to-end runs were local. On b359398, a CLI journey confirmed saved-profile selection, logout, and environment fallback. On 6ed67d9, another CLI journey confirmed nested init uses the saved profile and a second init fails without changing it. Live workspace deployment and invocation were not rerun without a test profile or App URL.
  • Live checks on ml and e2-dogfood before the latest changes:
    • Unknown or rejected profiles failed in about 1 second with the login hint.
    • dev served HTTP 200.
    • init sign-in worked.
    • init with token-only environment auth wrote no .env.

The bundled agent workflow skill needs no change: it does not specify profile priority or legacy command behavior.

Legacy login retains cached external-browser credentials. Extending browser-cache probing to the noninteractive dev and deploy preflight remains a separate follow-up.

This pull request and its description were written by Isaac.

@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 21 times, most recently from 19b4d91 to 13efa11 Compare October 13, 2026 00:31
@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 2 times, most recently from ae65708 to 4e5e859 Compare October 13, 2026 17:02
@elainewang-db
elainewang-db requested a review from shivam5 October 13, 2026 17:10

@shivam5 shivam5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agentbricks profile login --profile - this might sound weird

We could do what databricks cli does:
agentbricks auth describe/login/logout/profiles/switch

Can we quickly ask others for opinion on the rename in the channel?

@elainewang-db
elainewang-db force-pushed the ml-70351-profile-resolution branch 4 times, most recently from 1b635b8 to 6d359c2 Compare October 13, 2026 20:48
elainewang-db and others added 5 commits October 21, 2026 23:24
Co-authored-by: Isaac <no-reply@databricks.com>
…lution

# Conflicts:
#	integrations/agentbricks/src/databricks_agentbricks/cli/deploy.py
#	integrations/agentbricks/src/databricks_agentbricks/clients/apps_client.py
#	integrations/agentbricks/src/databricks_agentbricks/presentation/deploy.py
#	integrations/agentbricks/src/databricks_agentbricks/services/dev_service.py
elainewang-db and others added 2 commits October 26, 2026 17:31
…lution

# Conflicts:
#	integrations/agentbricks/tests/unit_tests/models_cli_test.py
…as unreachable, and rewrite interpolated profiles on switch

Co-authored-by: Isaac <no-reply@databricks.com>
@elainewang-db
elainewang-db requested a review from shivam5 October 26, 2026 20:32
…lution

# Conflicts:
#	integrations/agentbricks/src/databricks_agentbricks/cli/app.py
#	integrations/agentbricks/src/databricks_agentbricks/cli/deploy.py
elainewang-db and others added 2 commits October 30, 2026 22:15
Resolve conflicts with databricks#785, databricks#809, databricks#812 and databricks#818:

- cli/dev.py: announce the agent's profile, then databricks#812's "starting"
  line; the success panel still waits for the agent (on_ready).
- clients/databricks_cli.py, presentation/dev.py: keep both sides
  (run_databricks_login and _run_until_ready; announce_agent_profile
  and announce_starting).
- cli/endpoint.py: keep the workspace notice under databricks#785's renamed
  build_endpoint_service, and give `endpoint loadtest <app>` the same
  notice.
- cli/app.py, cli.md: take databricks#818's --profile help.
- cli/auth.py, presentation/help.py, cli.md: keep this branch's
  `auth login`/`auth switch`; drop databricks#818's edits to the removed
  `login`/`logout`.
- tests/functional: accept databricks#809's deletion.
- tests/unit_tests/cli_test.py: keep both assertions.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Automatic push review attempt 3/3 reserved. Failed attempts count toward this limit. After the limit, comment /review to request another review. Latest attempt

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentBricksReviewer left 7 inline comment(s) on 5f3a3b4. The score and summary are in the review comment.

@github-actions

Copy link
Copy Markdown
Contributor

AgentBricksReviewer

Review score: 61/100 · reviewers: 2/2 · Change risk: HIGH · risk:high

Summary

Blocking issues

  • HIGH · app.py:203 — Existing login and logout commands now fail
  • HIGH · app.py:180 — Existing saved profiles silently stop selecting the workspace
  • HIGH · workspace_auth.py:157 — Rejected browser authentication can still open a browser

Non-blocking notes

  • MEDIUM · env_file.py:67 — Switching profiles can overwrite unrelated multiline configuration
  • MEDIUM · profiles.py:28 — Host-free Azure authentication can be rejected
  • MEDIUM · workspace_auth.py:167 — Permission failures are reported as missing authentication

Uncertain findings

  • MEDIUM · dev.py:123 — Complete dotenv credentials may retain the shell’s profile

Approach: The single resolved profile and lazy client provider are sound, but the implementation duplicates authentication and dotenv semantics at boundaries where consistency matters most. More in Details.

Risk

This changes workspace targeting, credential resolution, authentication subprocesses, and persistent project .env state. A wrong selection can redirect workspace operations. The unit-test additions are substantial, but the reported suites were not independently executed, and several failure paths remain uncovered. Reverting code would not undo project configuration already rewritten.

AI approval

Review checks not passed; not eligible for auto-approval. To unblock:

  • Fix the blocking issues and uncertain findings above, or reply explaining why they don't apply, then comment /review (the score must reach 95).
  • Split the PR to at most 500 changed lines (it has 3217).
  • Dependency manifests or lockfiles can't be auto-approved; move them to a separate PR (integrations/agentbricks/pyproject.toml).
  • Credential or auth code files can't be auto-approved; move them to a separate PR (integrations/agentbricks/src/databricks_agentbricks/cli/auth.py, integrations/agentbricks/src/databricks_agentbricks/services/workspace_auth.py, integrations/agentbricks/tests/unit_tests/auth_test.py, integrations/agentbricks/tests/unit_tests/workspace_auth_test.py).

Or ask a maintainer to approve.

Details

Approach: The single resolved profile and lazy client provider are sound, but the implementation duplicates authentication and dotenv semantics at boundaries where consistency matters most. Use one classification-to-error mapping for preflight and login, dotenv binding-aware updates for persistence, and a shared noninteractive-auth policy that also covers telemetry. These changes address the identified failures without expanding the command-wrapper machinery.

Review rules: REVIEW.md, integrations/agentbricks/REVIEW.md at base e50cab552e74baf87d6cbc4a77bb9e51f50828fa · checked: BRIDGE-001–010, AGENTBRICKS-001–003; dependency-floor, optional-import, lockfile, release-workflow, template-API, and framework checks were inapplicable or produced no findings · gaps: no live validation or independent head-suite execution.

Diff size (computed): 44 files; +2730 / -487 lines (3217 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 18 1103 219 41.1%
Documentation 2 175 55 7.1%
Dependencies and lockfiles 1 2 0 0.1%
Implementation / other 23 1450 213 51.7%

Changes

The intended outcome is consistent workspace selection across project commands and the local agent, with early authentication failures instead of unexpected consent flows. The diff includes profile resolution, dotenv persistence, authentication services and commands, local-runtime propagation, presentation changes, a declared dotenv dependency, documentation, and extensive test updates. There are no changed lockfile pins or generated assets.

Most of the size supports that outcome. It could be reduced by retaining compatibility shims instead of removing established commands, consolidating duplicated authentication-error handling, and keeping detailed dotenv cases in the focused writer tests.

The unchanged bundled workflow guidance was inspected and no obsolete login invocation was found. Please add the AGENTBRICKS-001 explanation for why its guidance needs no update. The generated-project init rerun behavior at integrations/agentbricks/src/databricks_agentbricks/cli/init.py:543 is adjacent UX expansion; explaining its connection would clarify scope.

Tests

Test-by-test assessment

Both reviewers performed static head-commit review. One also ran an isolated third-party dotenv parser experiment, without executing repository code. No head test suite, lint, typecheck, SDK authentication, or live workspace journey was executed; the PR’s reported pass counts remain author-provided evidence.

“Component” below means local CLI/filesystem composition with external boundaries mocked.

Test / case Behavior protected Layer Needed? Action / rationale
integrations/agentbricks/tests/unit_tests/agent_details_test.py Deployment details and workspace links Component keep Auth stubbing preserves the tests’ focus, but does not establish auth safety.
integrations/agentbricks/tests/unit_tests/apps_client_test.py Actionable authentication hints Unit keep Focused adapter-level coverage.
integrations/agentbricks/tests/unit_tests/auth_test.py Profile order, project discovery, auth commands, notices, JSON Component keep Add legacy-selection migration coverage; keep detailed rewrite edge cases in the writer tests.
integrations/agentbricks/tests/unit_tests/cli_test.py Registration, help, hidden legacy commands Unit/component keep Current assertions codify removal rather than protect compatibility.
integrations/agentbricks/tests/unit_tests/client_test.py Retries and authentication hints Unit keep Local sleep replacement keeps retry tests isolated.
integrations/agentbricks/tests/unit_tests/conftest.py Deterministic environment, home, terminal state, auth fakes Support keep Retain isolation; ensure credential-related environment variables cannot alter cases unintentionally.
integrations/agentbricks/tests/unit_tests/deploy_bugfix_test.py Existing deployment validation regressions Component keep Updated context supports existing focused regressions.
integrations/agentbricks/tests/unit_tests/deploy_test.py Profile selection, host notices, deployment operations Component keep Add a complete command-level preflight failure path.
integrations/agentbricks/tests/unit_tests/deploy_wait_test.py Background submission and wait contracts Component keep Successful-auth stubs are appropriate for these scenarios.
integrations/agentbricks/tests/unit_tests/dev_service_test.py Local profile injection without modifying deployable configuration Unit keep Appropriate smallest layer for manifest merging.
integrations/agentbricks/tests/unit_tests/dev_test.py Runtime profile propagation, credential handling, startup rejection Component keep Add telemetry-enabled rejection and inherited-environment cases; successful auth fixtures limit offline-failure coverage.
integrations/agentbricks/tests/unit_tests/endpoint_test.py Invocation and load-test behavior Component keep Context updates preserve existing coverage; add a focused announcement assertion separately.
integrations/agentbricks/tests/unit_tests/env_file_test.py Parsing, rewriting, duplicate removal, interpolation, idempotence Unit keep Add multiline-binding preservation, quoted profile names, and replacement-failure preservation.
integrations/agentbricks/tests/unit_tests/init_test.py Profile seeding, environment auth, cwd independence, sign-in Component keep Add resource-ID authentication, generated-project reruns, and failed sign-in persistence cases.
integrations/agentbricks/tests/unit_tests/runtime_store_deploy_test.py Runtime Store deletion and actionable failure output Component keep Context and hint updates retain the existing contract tests.
integrations/agentbricks/tests/unit_tests/telemetry_test.py Command outcomes and deployment attribution Component keep Add external-browser preflight rejection with telemetry enabled and fresh client construction prohibited.
integrations/agentbricks/tests/unit_tests/tracing_test.py Tracing behavior after announcement integration Component keep Assert workspace operations announce while local-only operations do not.
integrations/agentbricks/tests/unit_tests/workspace_auth_test.py Profile lookup, bounded validation, login decisions, subprocess errors Unit keep Add permission-denied diagnostics and SDK-supported environment-auth cases.

Existing tests are useful but insufficient for the failures above. Each verified defect can be guarded at a local unit or component layer without live credentials.

Scope

No clearly unrelated change was found. Implementation, dependency, documentation, and test changes generally support the stated profile-consistency outcome. Removing legacy commands and abandoning saved selections are not necessary to achieve that outcome and introduce the compatibility breaks identified above.


Automated review by AgentBricksReviewer for 5f3a3b4 · workflow run · comment /review to re-run

@github-actions github-actions Bot added the risk:high Change risk assessed by AgentBricksReviewer: high label Nov 18, 2026
@github-actions github-actions Bot removed the risk:high Change risk assessed by AgentBricksReviewer: high label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentBricksReviewer left 5 inline comment(s) on b359398. The score and summary are in the review comment.

@github-actions

Copy link
Copy Markdown
Contributor

AgentBricksReviewer

Review score: 75/100 · reviewers: 2/2 · Change risk: HIGH · risk:high

Summary

Blocking issues

  • HIGH · dev.py:140 — Credential-free local development now requires workspace authentication
  • HIGH · init.py:553 — Existing-project collisions now let deployment scripts continue

Non-blocking notes

  • MEDIUM · init.py:191 — Nested initialization loses the saved login default
  • LOW · auth.py:125 — Switching profiles can persist a different profile name
  • LOW · deploy.py:339 — Background deployment repeats the foreground authentication request

Approach: The module separation is sound, but initialization should reuse the shared resolution policy and local startup should retain its credential-free path. More in Details.

Risk

This changes credential/profile selection across CLI commands, local-agent startup, and deployment. It also persists workspace choices in project .env files. Choosing a different profile can redirect later operations to another workspace. The diff includes substantial unit coverage, but neither reviewer executed tests; author-reported runs include earlier revisions. Profile edits are reversible, but reverting code does not restore previous .env values or undo subsequent workspace operations.

AI approval

Review checks not passed; not eligible for auto-approval. To unblock:

  • Fix the blocking issues above, or reply explaining why they don't apply, then comment /review (the score must reach 95).
  • Split the PR to at most 500 changed lines (it has 3397).
  • Dependency manifests or lockfiles can't be auto-approved; move them to a separate PR (integrations/agentbricks/pyproject.toml).
  • Credential or auth code files can't be auto-approved; move them to a separate PR (integrations/agentbricks/src/databricks_agentbricks/cli/auth.py, integrations/agentbricks/src/databricks_agentbricks/services/workspace_auth.py, integrations/agentbricks/tests/unit_tests/auth_test.py, integrations/agentbricks/tests/unit_tests/workspace_auth_test.py).

Or ask a maintainer to approve.

Details

Approach: The module separation is sound, but initialization should reuse the shared resolution policy and local startup should retain its credential-free path. Separating dotenv persistence, profile lookup, authentication, and presentation is reasonable. The main avoidable complexity is reconstructing profile fallback inside initialization and retaining duplicate authentication after introducing preflight validation.

Review rules: REVIEW.md, integrations/agentbricks/REVIEW.md at e50cab552e74baf87d6cbc4a77bb9e51f50828fa · checked: BRIDGE-001–010, AGENTBRICKS-001–003, with relevance and exceptions considered · gaps: no test execution or independent verification of live-workspace results.

Diff size (computed): 45 files; +2926 / -471 lines (3397 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 18 1219 217 42.3%
Documentation 2 199 55 7.5%
Dependencies and lockfiles 1 2 0 0.1%
Implementation / other 24 1506 199 50.2%

Changes

The intended outcome is consistent workspace selection between project commands and the local agent, with actionable authentication failures before development or deployment starts. The diff includes profile resolution, atomic dotenv rewriting, authentication services and commands, runtime/client wiring, notices, documentation, dependency declarations, and unit-test adaptations.

Most breadth is justified because the shared CLI context affects many commands. The change could be smaller by deferring the separate initialization-rerun behavior and consolidating duplicated resolution logic rather than maintaining two fallback policies.

Tests

Test-by-test assessment

Both reviewers performed static review only. No tests, lint, type checks, or live-workspace operations were executed during this review; the PR description's reported results are not independently verified.

Test / case Behavior protected Layer Needed? Action / rationale
integrations/agentbricks/tests/unit_tests/agent_details_test.py Deployment details, workspace links, output, and bounded lookups Unit/component keep Authentication and notice stubs preserve isolation; existing assertions remain relevant.
integrations/agentbricks/tests/unit_tests/apps_client_test.py Diagnostic details and actionable authentication guidance Client unit keep Updated login-hint assertion protects changed user-facing behavior.
integrations/agentbricks/tests/unit_tests/auth_test.py Profile precedence, authentication commands, trailing flags, notices, and legacy commands CLI unit keep Core command coverage; restore explicit assertions for legacy login JSON fields.
integrations/agentbricks/tests/unit_tests/cli_test.py Command registration, compatibility aliases, help, and setup guidance CLI/help unit keep Protects the public command surface and continued visibility of legacy commands.
integrations/agentbricks/tests/unit_tests/client_test.py Request/retry behavior and authentication guidance Transport unit keep Updated guidance assertion is relevant; localized sleep mocking retains retry isolation.
integrations/agentbricks/tests/unit_tests/conftest.py Isolation from ambient credentials, configuration, and interactive state Test support keep Necessary for deterministic profile-resolution tests.
integrations/agentbricks/tests/unit_tests/deploy_bugfix_test.py Deployment-name validation, prefixing, and filtering Domain/CLI unit keep Context adaptations retain existing regression coverage.
integrations/agentbricks/tests/unit_tests/deploy_test.py Deployment composition, source/flag selection, workspace notices, and output CLI/component keep Command wiring cannot be established by resolver-only tests.
integrations/agentbricks/tests/unit_tests/deploy_wait_test.py Background handoff, option forwarding, readiness, and exit behavior CLI/component keep Keep orchestration isolation; add an assertion that foreground identity validation occurs only once.
integrations/agentbricks/tests/unit_tests/dev_service_test.py Selected profile reaches the temporary manifest without changing deployable configuration Service/filesystem unit keep Checks the produced manifest rather than only mock interactions.
integrations/agentbricks/tests/unit_tests/dev_test.py Profile propagation, explicit credentials, startup ordering, and offline development CLI/component keep Make the offline regression run without the successful-authentication fixture.
integrations/agentbricks/tests/unit_tests/endpoint_test.py Invocation, OAuth selection, streaming, validation, and output Endpoint/CLI unit keep Notice-context adaptation preserves existing endpoint assertions.
integrations/agentbricks/tests/unit_tests/env_file_test.py Dotenv parsing, duplicate bindings, multiline preservation, and atomic updates Filesystem unit keep Add profile-name round trips with hash characters, whitespace, quotes, and escapes.
integrations/agentbricks/tests/unit_tests/init_test.py Profile pinning, environment authentication, and interactive/noninteractive setup CLI unit keep Add saved-default fallback inside a parent project and existing-generated-project collision cases.
integrations/agentbricks/tests/unit_tests/runtime_store_deploy_test.py Runtime-store deployment and authorization orchestration Deployment unit/component keep Retain isolation from the new authentication boundary while protecting store behavior.
integrations/agentbricks/tests/unit_tests/telemetry_test.py Deploy telemetry and avoiding browser-auth client construction Unit keep Browser-profile guard coverage is relevant; collaborator adaptations support existing scenarios.
integrations/agentbricks/tests/unit_tests/tracing_test.py Tracing commands under the workspace-notice context contract CLI unit keep Context adaptation is necessary; it does not independently verify notice behavior.
integrations/agentbricks/tests/unit_tests/workspace_auth_test.py Resolution order, configuration lookup, authentication failure classes, timeout, and login retries Service unit keep Appropriate boundary coverage for the new authentication service.

Existing tests provide substantial coverage, but do not suffice for the reported edge cases. In particular, the offline-development test's authentication stub hides a regression, and initialization needs tests for both fallback selection and its changed collision behavior.

Scope

No clearly unrelated changes were found. Authentication commands, dotenv persistence, client/runtime wiring, notices, documentation, and test adaptations support the stated outcome under BRIDGE-009. The initialization no-op behavior is adjacent but separable, and could be deferred to reduce compatibility impact.


Automated review by AgentBricksReviewer for b359398 · workflow run · comment /review to re-run

@github-actions github-actions Bot added the risk:high Change risk assessed by AgentBricksReviewer: high label Nov 18, 2026
@github-actions github-actions Bot removed the risk:high Change risk assessed by AgentBricksReviewer: high label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AgentBricksReviewer left 5 inline comment(s) on 6ed67d9. The score and summary are in the review comment.

@github-actions

Copy link
Copy Markdown
Contributor

AgentBricksReviewer

Review score: 74/100 · reviewers: 3/3 · Change risk: HIGH · risk:high

Summary

Blocking issues

  • High · workspace_auth.py:183 — Cached browser credentials no longer work with legacy login
  • High · dev.py:143 — Unrelated workspace configuration blocks offline local agents

Non-blocking notes

  • Medium · conftest.py:48 — Auth tests can overwrite the developer’s saved configuration
  • Medium · env_file.py:52 — Profile switching can persist a different name than requested

Uncertain findings

  • Medium · dev.py:131 — Dotenv credentials may still encounter stale child-CLI authentication

Approach: Centralizing profile resolution and reusing validated clients is sound, but authentication gates need to preserve working cached and offline flows. More in Details.

Risk

This changes credential selection and workspace targeting across CLI commands, adds authentication gates to local development and deployment, and persists profile choices in project .env files. It also changes login subprocess behavior and adds a dependency. The diff contains substantial offline test coverage, but this review did not execute tests or live authentication. Reverting code does not automatically restore persisted profile selections.

AI approval

Review checks not passed; not eligible for auto-approval. To unblock:

  • Fix the blocking issues and uncertain findings above, or reply explaining why they don't apply, then comment /review (the score must reach 95).
  • Split the PR to at most 500 changed lines (it has 3465).
  • Dependency manifests or lockfiles can't be auto-approved; move them to a separate PR (integrations/agentbricks/pyproject.toml).
  • Credential or auth code files can't be auto-approved; move them to a separate PR (integrations/agentbricks/src/databricks_agentbricks/cli/auth.py, integrations/agentbricks/src/databricks_agentbricks/services/workspace_auth.py, integrations/agentbricks/tests/unit_tests/auth_test.py, integrations/agentbricks/tests/unit_tests/workspace_auth_test.py).

Or ask a maintainer to approve.

Details

Approach: Centralizing profile resolution and reusing validated clients is sound, but authentication gates need to preserve working cached and offline flows. The shared dotenv parser and separated resolution, persistence, authentication, and presentation responsibilities are reasonable; no materially simpler existing repository pattern was identified.

Review rules: REVIEW.md and integrations/agentbricks/REVIEW.md at base e50cab552e74baf87d6cbc4a77bb9e51f50828fa · checked: BRIDGE-001–010, AGENTBRICKS-001–003 · gaps: runtime verification and child Databricks CLI behavior were not exercised; no additional scoped review files were found.

Diff size (computed): 45 files; +2977 / -488 lines (3465 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 18 1282 225 43.5%
Documentation 2 202 57 7.5%
Dependencies and lockfiles 1 2 0 0.1%
Implementation / other 24 1491 206 49.0%

Changes

The intended outcome is one consistent profile across project commands and the local agent, with actionable authentication failures before workspace-dependent work starts.

The diff includes profile/config resolution, atomic dotenv rewriting, authentication services, CLI commands and wiring, client reuse, local-agent environment propagation, documentation, a python-dotenv dependency declaration, and updates to 18 test/support files. There are no lockfile changes. The breadth is largely justified by the cross-command behavior; no clearly unrelated feature was found. Shared notice/auth fixtures can keep mechanical test updates smaller, but resolution, persistence, and authentication should remain separately testable.

Three reviewers delivered reports: one Claude reviewer and two Codex reviewers. Every lens was considered. Findings were checked against head source; review was otherwise static, except for the standalone dotenv-parser reproduction.

Tests

Test-by-test assessment
Test / case Behavior protected Layer Needed? Action / rationale
integrations/agentbricks/tests/unit_tests/agent_details_test.py Details links, workspace identity, feature gates CLI/service component keep Auth stubs isolate existing details behavior.
integrations/agentbricks/tests/unit_tests/apps_client_test.py Existence-probe failures and login hints Client unit keep Retains focused diagnostic assertions.
integrations/agentbricks/tests/unit_tests/auth_test.py Precedence, routing, notices, legacy persistence CLI/filesystem component keep Exercises real persistence; fix configuration isolation.
integrations/agentbricks/tests/unit_tests/cli_test.py Registration, help, command discovery CLI contract keep Protects legacy command visibility and new auth discovery.
integrations/agentbricks/tests/unit_tests/client_test.py Transport failures, retries, routing Client unit keep Narrower sleep mocking preserves retry assertions.
integrations/agentbricks/tests/unit_tests/conftest.py Credential and configuration isolation Test support keep Also isolate AGENTBRICKS_CONFIG_HOME.
integrations/agentbricks/tests/unit_tests/deploy_bugfix_test.py Name validation and JSON regressions CLI/client component keep Notice stubs retain existing regression assertions.
integrations/agentbricks/tests/unit_tests/deploy_test.py Deployment composition, profiles, output CLI/service component keep Add real-provider coverage for validated-client adoption.
integrations/agentbricks/tests/unit_tests/deploy_wait_test.py Detached deployment, failures, waiting CLI/process component keep New failure boundary is covered; successful-auth stubs limit ordering checks.
integrations/agentbricks/tests/unit_tests/dev_service_test.py Manifest merging, tracing, original preservation Service/filesystem unit keep Tests actual local manifest output without workspace access.
integrations/agentbricks/tests/unit_tests/dev_test.py Profile propagation and startup gates CLI/service component keep Add unrelated ambient-workspace coverage; mocked runner leaves child authentication uncertain.
integrations/agentbricks/tests/unit_tests/endpoint_test.py Invocation and load-test contracts CLI/service unit keep Narrow notice stubs preserve endpoint assertions.
integrations/agentbricks/tests/unit_tests/env_file_test.py Parsing, duplicates, multiline preservation, idempotency Parser/filesystem unit keep Add literal interpolation-sensitive profile-name round trips.
integrations/agentbricks/tests/unit_tests/init_test.py Scaffolding, profile pinning, environment-auth fallback CLI/filesystem component keep Assertions inspect resulting project files.
integrations/agentbricks/tests/unit_tests/runtime_store_deploy_test.py Managed deletion and failure reporting CLI/service component keep Existing deletion-result assertions remain useful.
integrations/agentbricks/tests/unit_tests/telemetry_test.py Failure attribution and browser-auth suppression Offline component keep Suppression assertions matter; provider stubs do not verify client adoption.
integrations/agentbricks/tests/unit_tests/tracing_test.py Tracking selection and tracing commands CLI/client unit keep Notice collaborator changes remain narrow.
integrations/agentbricks/tests/unit_tests/workspace_auth_test.py Resolution, config lookup, timeout, login decisions Unit/filesystem keep Distinguish valid cached browser credentials from consent-required authentication.

Existing tests cover substantial offline composition, but do not suffice for cached-browser compatibility, local-only development with unrelated ambient authentication, or child-CLI behavior. No tests, lint, or type checking were run during this review. Earlier results in the PR description are not independently verified evidence for this head.

Scope

All reviewed changes support profile alignment, authentication behavior, or their documentation and tests. No clearly unrelated changes were found. The bundled workflow guidance was inspected, and the description explains why no workflow-skill update is needed under AGENTBRICKS-001.


Automated review by AgentBricksReviewer for 6ed67d9 · workflow run · comment /review to re-run

This branch has not been deployed

No deployments
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.

3 participants