Skip to content

fix(platform-integrations): make bob custom-mode merge robust#263

Merged
illeatmyhat merged 1 commit into
mainfrom
fix/bob-mode-merge-sentinel
Jun 1, 2026
Merged

fix(platform-integrations): make bob custom-mode merge robust#263
illeatmyhat merged 1 commit into
mainfrom
fix/bob-mode-merge-sentinel

Conversation

@illeatmyhat
Copy link
Copy Markdown
Collaborator

@illeatmyhat illeatmyhat commented Jun 1, 2026

Follow-up to #258. Running the released installer (install --platform bob --mode lite --dir "$HOME") reported ✓ Merged custom mode 'evolve-lite' but did not actually add the mode to ~/.bob/settings/custom_modes.yaml.

Root cause — two combined faults in merge_yaml_custom_mode

  1. Sentinel substring false-match. Detection used if start in existing. The install-evolve-lite marketplace mode documents the literal # >>>evolve:evolve-lite<<< inside its customInstructions. That substring made the merge think a block already existed → it took the replace branch → found no matching end sentinel → no-op'd, while still printing ✓. Detection is now a line-anchored start..end regex, so a sentinel literal quoted inside another mode is ignored.

  2. Indentation mismatch. The inserted block hardcoded 2-space list indentation. A target written with 0-indent sequence items (yaml.safe_dump / marketplace tooling) became a 0-indent/2-indent mix = invalid YAML. The block now matches the indentation already used under customModes:.

remove_yaml_custom_mode is likewise line-anchored.

Test

Adds test_install_merges_mode_despite_sentinel_literal_in_another_mode, reproducing the exact failure (0-indent target whose text contains the sentinel literal) and asserting the mode merges, indentation stays consistent, and the pre-existing mode is preserved. Full suite: 213 passed.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved YAML custom mode installation to correctly preserve indentation patterns
    • Enhanced sentinel detection to prevent accidental matches in quoted content, ensuring reliable custom mode merging during installation

The Bob custom_modes.yaml merge had two faults that combined to silently drop
the evolve-lite mode while still reporting success:

- Sentinel detection used a substring check (`if start in existing`). The
  install-evolve-lite marketplace mode documents the literal
  `# >>>evolve:evolve-lite<<<` in its customInstructions, so the merge thought a
  block already existed, took the replace branch, found no matching end
  sentinel, and no-op'd. Detection is now a line-anchored start..end regex.

- The inserted block hardcoded 2-space list indentation. A target written with
  0-indent sequence items (yaml.safe_dump / marketplace tooling) ended up with
  mixed indentation = invalid YAML. The block now matches the indentation
  already used under customModes:.

remove_yaml_custom_mode is likewise line-anchored. Adds a regression test
reproducing the exact failure (0-indent target + sentinel literal in another mode).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a0fea6b-535d-4bda-a49d-ee074b28af3c

📥 Commits

Reviewing files that changed from the base of the PR and between cbcf6b1 and c5f13cf.

📒 Files selected for processing (2)
  • platform-integrations/install.sh
  • tests/platform_integrations/test_idempotency.py

📝 Walkthrough

Walkthrough

The platform installer now detects existing list-item indentation in custom modes and uses line-anchored regex matching for sentinel blocks to prevent false positives when sentinel text appears inside quoted content. A regression test validates these improvements.

Changes

Sentinel block robustness improvements

Layer / File(s) Summary
Merge custom mode with indentation detection and line-anchored sentinel logic
platform-integrations/install.sh
merge_yaml_custom_mode detects the indentation pattern of existing - list items under customModes: and uses matched indentation when inserting the sentinel block. Sentinel detection switches from substring replacement to line-anchored regex that requires markers at line start, preventing matches inside quoted content. Replaces existing block if found; appends otherwise.
Remove custom mode with line-anchored sentinel logic
platform-integrations/install.sh
remove_yaml_custom_mode updates sentinel-removal regex to require line-anchored start/end markers with optional trailing newline, ensuring only real sentinel blocks are removed rather than incidental occurrences in custom instruction text.
Regression test for quoted sentinel boundary cases
tests/platform_integrations/test_idempotency.py
New test constructs a custom_modes.yaml with a quoted # >>>evolve:evolve-lite<<< literal, runs Bob install in lite mode, and asserts the real evolve-lite sentinel block is properly merged, YAML indentation is consistent, and both modes appear in the result.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • vinodmut
  • gaodan-fang
  • visahak

Poem

🐰 With regex anchors standing tall and true,
No quoted sentinels slip on through!
Indents aligned like rows of hay,
Our YAML blocks now merge the right way.

🚥 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 accurately describes the main change: fixing the custom-mode merge logic in bob platform-integrations to be more robust by handling line-anchored sentinels and matching indentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/bob-mode-merge-sentinel

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 and usage tips.

@illeatmyhat illeatmyhat merged commit aa93ad3 into main Jun 1, 2026
16 checks passed
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.

1 participant