Skip to content

test(bob-plugin): fold the shell-change checks into the #968 test - #1015

Merged
amiddavid merged 3 commits into
mainfrom
fix/bob-shell-change-rollback
Nov 11, 2026
Merged

amiddavid merged 3 commits into
mainfrom
fix/bob-shell-change-rollback

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

No behavior change. This PR changes one test. The code it tests is already on main.

Summary

This PR makes the test for a failed re-run after a change of login shell stricter. It adds 3 checks to the existing test from #968.

What we found

What changed

test_bob_plugin.py, in test_a_failed_shell_change_keeps_the_old_rc_block:

  1. The user has their own ~/.zshrc before the zsh re-run.
  2. New checks:
    • the output has rolled_back=true;
    • the output does not have old_rc_block=removed;
    • the user's .zshrc is byte-identical after the rollback.

How it was tested

  • The test passes on this branch.
  • It fails on the old order: with the cleanup moved to before bob_hooks.install, it fails on old_rc_block=removed.
  • go test -count=1 ./bob-plugin/: OK.

Data dependence

None.

🤖 Generated with Claude Code

setup removes our block from the old startup file only after the last
step that can fail (on main since #968). Nothing tested that order. A
re-run under a new shell that fails later must leave the old file
routing Bob; with the cleanup mid-setup, the rollback left Bob routed
nowhere while it said rolled_back=true. The test fails on that order.

Found in the round-3 review of #973.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 f513107f43ba blocking

Verdict: blocking

The new test is correct and passes by reading. But a test on main already pins the same order. The PR's main reason ("No test covered the order") is wrong.

Findings

  1. bob-plugin/context-guru/scripts/test_bob_plugin.py:648 — the new test duplicates test_a_failed_shell_change_keeps_the_old_rc_block (line 603), which is already on main
    • What fails: the PR adds a second test for one concept, and its description says that no test covered the order. That claim is false, so the stated reason for the PR does not hold.
    • Proof:
      • The base (407d9d1a) has test_a_failed_shell_change_keeps_the_old_rc_block at line 603. It came in with #968 (10329879).
      • That test does the same steps: setup under bash, then setup under SHELL=/bin/zsh with PLUGIN.bob_hooks.install patched to raise OSError.
      • It asserts code == 1, result=setup_failed, and ROUTE.is_routed(self.rc). The last assertion is the one that catches the old mid-setup cleanup. If _remove_old_rc_block ran before bob_hooks.install (bob_plugin.py:654), .bash_profile would lose its block and line 616 would fail.
      • So the PR's "It fails on the old order" check proves nothing new: the old test fails on the old order too.
      • The new test adds only three checks: rolled_back=true, no old_rc_block=removed, and a pre-existing .zshrc that stays byte-identical. The .zshrc case is a small real addition (it covers rc_created=False for the new file, so the rollback must remove the block and keep the user's content).
    • Fix: add the three new assertions and the pre-existing .zshrc to the test at line 603, and delete the new test. Correct the PR body: say the order was already pinned, and that this PR makes that test stricter. Or close the PR if the extra checks are not worth a change.

Non-blocking

  • The old test at line 603 patches bob_route.probe. Setup never reaches the probe there, because bob_hooks.install fails first. The new test correctly leaves the patch out. If you merge the tests, you can drop that patch.
  • The merge commit f513107f brings no change to the PR diff. Only test_bob_plugin.py changes (+19 lines).

What I checked

  • The full diff 407d9d1a..f513107f (one file, 19 added lines), and both commits.
  • _setup_changes in bob_plugin.py:602-672: _remove_old_rc_block runs last, after write_record(record) at line 663, inside the try. A failure in bob_hooks.install goes to undo.run() before the cleanup runs.
  • Undo.run / _undo: the undo steps are config, service, rc, hooks. service rewrites the old plist and waits until it is healthy (the FakeProxy is still running). hooks is a no-op because had["hooks"] is true. rc calls bob_route.remove(.zshrc, created=False). So rolled_back=true holds.
  • bob_route.install / remove: install appends block(port), and remove takes out the same bytes, so .zshrc goes back to alias ll='ls -l'\n byte for byte.
  • rc_candidates: under zsh the target is ~/.zshrc. The test needs no macOS home and runs on the Linux CI runner.
  • bobplugin_test.go runs the Python suite through go test ./bob-plugin/, so CI picks up the new test.
  • The PR has no behavior change and no data dependence. That is correct: the PR changes only a test.
  • I did not run the tests (live tests are not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 f513107f43ba approve

Verdict: approve

Findings

None.

Non-blocking

  • The PR says "No test covered the order". That is not correct. main already has
    test_a_failed_shell_change_keeps_the_old_rc_block (bob-plugin/context-guru/scripts/test_bob_plugin.py:603 on base,
    added in #968). It runs the same scenario: bash setup, a zsh re-run, bob_hooks.install fails, and it asserts
    ROUTE.is_routed(self.rc). That assertion also fails if the cleanup moves back to mid-setup.
  • The new test adds 3 real checks that the old test does not have:
    1. the user's own .zshrc exists before the re-run and is byte-identical after the rollback;
    2. rolled_back=true is in the output;
    3. old_rc_block=removed is not in the output.
  • Proposal: correct the PR text ("an existing test covers the route; this one adds the user's .zshrc
    and the rollback report"). Or fold the 3 new checks into the existing test, so one scenario has one test.
    Either is fine.

What I checked

  • The full diff: one file, 19 added lines, test_bob_plugin.py:648-665. The merge commit f513107f brings in only main.
  • _setup_changes in bob_plugin.py:602-696: _remove_old_rc_block runs after the final write_record, as the PR says.
    The except block calls undo.run() and prints rolled_back.
  • The trace of the new test:
    • The .zshrc exists before the re-run. So rc_created is False, and had["rc"] is False.
    • bob_route.install appends our block to the .zshrc. Then bob_hooks.install raises OSError.
    • Undo._undo("rc") calls bob_route.remove(.zshrc, created=False). That removes only our block, so the bytes
      match the start again (bob_route.py:232-269).
    • The undo of "service" puts the old plist back. wait_healthy reaches the FakeProxy, so ok is True and the
      output has rolled_back=true. The exit code is 1.
    • ~/.bash_profile is not touched, so is_routed(self.rc) is True.
  • The test does not patch bob_route.probe. That is correct: the failure comes before the probe, and the first
    setup runs under bash like other tests in the suite.
  • The Go test bob-plugin/bobplugin_test.go runs this suite through python3 -m unittest, so CI picks the test up.
  • Data dependence: none. Behavior change: none (test only).
  • I did not run the tests. Live tests are not approved for this review.

The test from #968 already pins the order: setup removes the old block only
after the last step that can fail. The new test ran the same steps.

Move its 3 extra checks into the #968 test and delete the new test:
- the rollback reports rolled_back=true;
- setup does not report old_rc_block=removed;
- the user's own .zshrc is byte-identical after the rollback.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

Reply to round 1 (reviewer 1 and reviewer 2).

Reviewer 2, finding 1 (the new test duplicates the #968 test): fixed in 2f02885.

  • I deleted the new test.
  • I moved its 3 checks into test_a_failed_shell_change_keeps_the_old_rc_block: rolled_back=true, no old_rc_block=removed, and the user's own .zshrc stays byte-identical.
  • With the cleanup moved to before bob_hooks.install, the stricter test fails on old_rc_block=removed. go test -count=1 ./bob-plugin/ passes.

Reviewer 1, non-blocking (the PR text is wrong): fixed. The PR title and body now say that #968 already pins the order, and that this PR makes that test stricter.

Reviewer 2, non-blocking (the bob_route.probe patch is not needed): not changed. That patch was in the #968 test before this PR. Removing it is not part of this change.

@vz-ibm vz-ibm changed the title test(bob-plugin): a failed re-run after a shell change keeps Bob routed test(bob-plugin): fold the shell-change checks into the #968 test Nov 10, 2026

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (claude, user of @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 2f028859e39e approve

Verdict: approve

My round-1 finding is fixed. The PR now changes one test, and it adds 6 lines. I found nothing new.

Findings

None.

Status of earlier findings

  • Reviewer 2, finding 1 (the new test duplicates the #968 test): fixed in 2f028859.
    • The new test is deleted. grep finds no test_a_failed_rerun_after_a_shell_change in bob-plugin/.
    • test_a_failed_shell_change_keeps_the_old_rc_block (test_bob_plugin.py:603) now has the 3 extra checks: rolled_back=true, no old_rc_block=removed, and a byte-identical .zshrc.
    • The test writes .zshrc after the bash setup and before the zsh re-run. So rc_created is False for .zshrc, and the rollback must keep the user's content. My round-1 trace still holds: bob_route.remove(.zshrc, created=False) takes out only our block.
    • The PR body is corrected. It now says that #968 already pins the order, and that this PR makes that test stricter.
  • Reviewer 1, non-blocking (the PR text is wrong): fixed. The title and body are correct now.
  • Reviewer 2, non-blocking (the bob_route.probe patch is not needed): not changed, by the author's choice. The reason is right: the patch was in the #968 test before this PR, and removing it is out of scope. It does no harm.

Non-blocking

  • None.

What I checked

  • Last review: round 1, f513107f43ba3503186234fb82074ead6b47f39d, 2026-11-10T12:46:37Z
  • New commits read: 1 — 2f028859 test(bob-plugin): fold the shell-change checks into the #968 test
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-1 review (12:46:40Z, approve, one non-blocking point on the PR text). I checked that the PR text is now corrected.
    • The author's reply comment (12:56:36Z). I checked each of its 3 points against the commit and the PR body (see "Status of earlier findings").
    • Commit 2f028859. I read the full diff and the whole changed test (test_bob_plugin.py:603-622).
  • The net diff 407d9d1a..2f028859: one file, test_bob_plugin.py, 6 added lines, all in one test. No code changes.
  • The commit has a DCO sign-off and an Assisted-By: line.
  • Behavior change: none. Data dependence: none. Both are correct for a test-only PR.
  • I did not run the tests (live tests are not approved).

@vz-ibm vz-ibm left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (claude, user of @vz-ibm) Claude Code 2.1.316 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 2f028859e39e approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 2, finding 1 (the new test duplicates the #968 test): fixed. 2f028859 deletes the new test.
    It moves its 3 checks into test_a_failed_shell_change_keeps_the_old_rc_block (test_bob_plugin.py:603-622).
    The file now has no test_a_failed_rerun_after_a_shell_change... (grep count 0).
  • Reviewer 1, non-blocking (the PR text is wrong): fixed. The PR body now says that #968 already pins the order,
    and that this PR makes that test stricter.
  • Reviewer 2, non-blocking (the bob_route.probe patch is not needed): not changed, by the author's choice.
    The reason is correct: the patch was there before this PR and does no harm. I accept it.

Non-blocking

  • None.

What I checked

  • Last review: round 1, f513107f43ba3503186234fb82074ead6b47f39d, 2026-11-10T12:46:40Z
  • New commits read: 1 — 2f028859 test(bob-plugin): fold the shell-change checks into the #968 test
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Commit 2f028859: I read the full diff and the whole changed test. See below.
    • Author's comment at 2026-11-10T12:56:36Z (reply to round 1): I checked each of its 3 points. See "Earlier findings".
    • The changed PR body: I read it in full. It is now correct.
  • The full diff 407d9d1a..HEAD is now 6 added lines in one test. No product code changes.
  • The trace of the stricter test:
    • The user's .zshrc exists before the zsh re-run. So rc_created is False, and bob_route.check(.zshrc) passes.
    • bob_route.install appends our block. Then bob_hooks.install raises OSError("disk full").
    • The undo of "rc" calls bob_route.remove(.zshrc, created=False). It removes only our block, so the file is
      alias ll='ls -l'\n again, byte for byte.
    • The undo of "service" puts the old plist back. The FakeProxy still answers, so the output has rolled_back=true.
    • _remove_old_rc_block does not run, so the output has no old_rc_block= line, and ~/.bash_profile still routes Bob.
  • On the old order (cleanup before bob_hooks.install), _remove_old_rc_block prints old_rc_block=removed and
    removes the bash block. So 2 assertions fail, as the author says.
  • Data dependence: none. Behavior change: none (test only).
  • I did not run the tests. Live tests are not approved for this review.

@amiddavid
amiddavid merged commit a067848 into main Nov 11, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants