Skip to content

fix(onboard): preserve tier-default brave/tavily on re-onboard reuse - #6855

Closed
yanyunl1991 wants to merge 1 commit into
mainfrom
fix/6844-brave-tier-default-reuse
Closed

fix(onboard): preserve tier-default brave/tavily on re-onboard reuse#6855
yanyunl1991 wants to merge 1 commit into
mainfrom
fix/6844-brave-tier-default-reuse

Conversation

@yanyunl1991

@yanyunl1991 yanyunl1991 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

On the re-onboard reuse path, the Balanced-tier default preset brave (Brave Search API access) was silently dropped even when the policy tier (Balanced) and the web-search choice (No web search) were unchanged from the initial onboard. The other four Balanced defaults (npm, pypi, huggingface, brew) persisted — only brave was narrowed out of the reapplied set, removing its egress (api.search.brave.com).

Fixes #6844.

Root cause

isStaleBuiltinWebSearchPolicyPreset treats brave/tavily as a stale web-search leftover whenever no matching web-search provider is configured. It did not account for the case where the same preset is also a default egress preset of the tier being applied. On reuse, preparePolicyPresetResumeSelection pruned brave under this rule, which flipped recordedPolicyPresetsNeedReconcile to true and drove a reapply whose set omitted brave.

Fix

  • Add a tierDefaultPresetNames exemption to isStaleBuiltinWebSearchPolicyPreset: a preset that is a default of the tier being applied is a tier egress default, not a stale web-search leftover, so it is kept regardless of the web-search provider choice.
  • Thread the recorded tier's defaults through both prune sites on the reuse path: the resume-selection prune (preparePolicyPresetResumeSelection) and the reuse reapply prune (createUnavailablePolicyPresetPruner via the pruning options).

The change is scoped to the reuse/resume path; fresh-onboard suggestion behavior is unchanged.

Behavior preserved

  • Restricted tier lists no brave/tavily default, so a genuinely stale preset there still prunes.
  • Provider switch (brave → tavily) still replaces the stale provider and adds the newly active one.

Testing

  • New unit tests in policy-resume-selection.test.ts: brave preserved on Balanced reuse with web search off (no reconcile); still pruned on Restricted; kept on Balanced alongside a switched-in tavily.
  • Full onboard policy/tier/preset test suites pass (118 tests across 12 files); build:cli + typecheck green.
  • End-to-end on our Ubuntu 24.04 x86_64 test host (no GPU): onboarded a Balanced sandbox with brave applied, then re-onboarded via the reuse path.
    • Before the fix: reapply set = npm, pypi, huggingface, brewRemoved preset: brave → brave inactive.
    • After the fix: reapply set = npm, pypi, huggingface, brew, brave → brave stays active ([from balanced tier]), no egress narrowing.

The reporter's environment is DGX Station (aarch64); the reapply logic is platform-independent (verified byte-identical on the paths exercised), but cross-arch confirmation on aarch64 was not separately run.

Summary by CodeRabbit

  • Bug Fixes

    • Preserved tier-default web-search presets during onboarding and re-onboarding.
    • Prevented default Brave or Tavily presets from being incorrectly removed when web-search settings differ.
    • Improved policy preset reconciliation for resumed tier selections.
  • Tests

    • Added coverage for preserving or pruning presets across Balanced and Restricted tier scenarios.

On the re-onboard reuse path, a Balanced-tier default preset that doubles
as a built-in web-search provider preset (`brave`, `tavily`) was silently
dropped even when the policy tier and web-search choice were unchanged. The
other tier defaults (`npm`, `pypi`, `huggingface`, `brew`) persisted, so
only the search-provider egress (e.g. `api.search.brave.com`) was narrowed
out of the reapplied set.

Root cause: `isStaleBuiltinWebSearchPolicyPreset` treats `brave`/`tavily` as
a stale web-search leftover whenever no matching web-search provider is
configured, without distinguishing the case where the same preset is a
default egress preset of the tier being applied. `preparePolicyPresetResume-
Selection` pruned it, which forced a reconcile and a reapply that dropped it.

Fix: add a `tierDefaultPresetNames` exemption to the staleness predicate and
thread the recorded tier's defaults through the resume-selection prune and
the reuse reapply prune. A preset that is a default of the applied tier is a
tier egress default, not a stale web-search leftover, so it is preserved
regardless of the web-search provider choice. The Restricted tier lists no
such default, so a genuinely stale `brave`/`tavily` there still prunes, and
provider-switch replacement (brave -> tavily) still adds the active provider.

Fixes #6844

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2eb35942-b5d1-4c91-8c87-6e36b303ed43

📥 Commits

Reviewing files that changed from the base of the PR and between 33d55b0 and 2dc4421.

📒 Files selected for processing (5)
  • src/lib/onboard.ts
  • src/lib/onboard/policy-preset-reconciliation.ts
  • src/lib/onboard/policy-resume-selection.test.ts
  • src/lib/onboard/policy-resume-selection.ts
  • src/lib/onboard/policy-selection.ts

📝 Walkthrough

Walkthrough

The onboarding flow now resolves tier default preset names during resume and passes them through stale-preset detection and unavailable-preset pruning. Built-in web-search presets matching tier defaults are preserved, with tests covering Balanced and Restricted tier behavior.

Changes

Tier-default preset preservation

Layer / File(s) Summary
Tier-aware stale preset reconciliation
src/lib/onboard/policy-preset-reconciliation.ts
Stale-preset predicates and unavailable-preset pruning accept tier default preset names and preserve matching built-in web-search presets.
Tier-aware resume selection
src/lib/onboard/policy-resume-selection.ts, src/lib/onboard.ts, src/lib/onboard/policy-resume-selection.test.ts
Resume selection receives the tiers dependency, resolves tier defaults, applies the exemption, and tests Balanced and Restricted behavior.
Resume reapplication pruning
src/lib/onboard/policy-selection.ts
Recorded tier defaults are passed into unavailable-preset pruning during reuse reapplication.

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

Sequence Diagram(s)

sequenceDiagram
  participant Onboard
  participant ResumeSelection
  participant Tiers
  participant PresetReconciliation
  Onboard->>ResumeSelection: provide policies and tiers
  ResumeSelection->>Tiers: resolve tier presets
  Tiers-->>ResumeSelection: return tier default names
  ResumeSelection->>PresetReconciliation: evaluate presets with tier defaults
  PresetReconciliation-->>ResumeSelection: preserve or prune presets
Loading

Suggested labels: bug-fix, area: policy

Suggested reviewers: cv, laitingsheng, ericksoa

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main onboard reuse fix for tier-default preset preservation.
Linked Issues check ✅ Passed The changes address the reported reuse-path bug by preserving tier-default presets like brave and covering the affected cases with tests.
Out of Scope Changes check ✅ Passed The code changes stay focused on onboarding preset reuse and pruning, with no obvious unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/6844-brave-tier-default-reuse

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

@github-code-quality

github-code-quality Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage remains at 96%, unchanged from the main branch.


Updated July 14, 2026 10:42 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / medium confidence
Next action: Review the warnings below.
Findings: 0 blockers · 1 warning · 0 suggestions
Status: Canonical ledger: 0 blocker(s), 1 warning(s), 0 suggestion(s).

Model lanes

  • GPT-5.6 Terra (primary): Completed · medium confidence · 0 blockers · 1 warning · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 3 warnings · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 2 more warnings, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: onboard-repair, onboard-resume, cloud-onboard

2 optional E2E recommendations
  • brave-search
  • ubuntu-repo-cloud-openclaw
1 warning · 0 suggestions

Warnings

Warnings do not block.

PRA-1 Warning — Cover tier-default preservation in the policy reapply path

  • Location: src/lib/onboard/policy-selection.ts:324
  • Category: tests
  • Problem: The change adds a second tier-default exemption in setupPoliciesWithSelection for selectedPresets/reapply, but the added tests exercise only preparePolicyPresetResumeSelection. Existing policy-selection-recorded-tier coverage exercises selectedPresets: null, so it does not verify that a recorded Balanced selection containing brave reaches syncPresetSelection without being pruned.
  • Impact: A future change to the reapply pruner can reintroduce the reported reuse behavior—removing Balanced brave egress during reconciliation—while the current resume-selector tests continue to pass.
  • Recommendation: Add a focused setupPoliciesWithSelection test with selectedPresets ['npm', 'brave'], tierName 'balanced', no web-search configuration, and a tiers stub that declares brave; assert the selection passed to syncPresetSelection remains ['npm', 'brave'].
  • Verification: Inspect policy-selection-recorded-tier.test.ts and policy-resume-selection.test.ts: neither invokes setupPoliciesWithSelection with non-null selectedPresets containing a Balanced tier-default brave preset.
  • Test coverage: Unit test setupPoliciesWithSelection reapply with selectedPresets ['npm', 'brave'], tierName 'balanced', and null web search, asserting syncPresetSelection receives ['npm', 'brave']; pair it with the existing Restricted resume-selector negative test.
  • Evidence: src/lib/onboard/policy-selection.ts:324-350 computes recordedTierDefaultPresetNames and supplies it only to pruneUnavailablePresets(chosen) in the selectedPresets reapply branch. src/lib/onboard/policy-resume-selection.test.ts adds tests only for preparePolicyPresetResumeSelection. src/lib/onboard/policy-selection-recorded-tier.test.ts invokes setupPoliciesWithSelection with selectedPresets: null.

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@yanyunl1991

Copy link
Copy Markdown
Contributor Author

Superseded by #6856 (same fix, commit re-signed for the DCO check). Closing this one.

@yanyunl1991
yanyunl1991 deleted the fix/6844-brave-tier-default-reuse branch July 14, 2026 10:50
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.

[DGX Station][Onboard] 'brave' Balanced-tier preset dropped on re-onboard reuse while other tier defaults persist

1 participant