Skip to content

fix(pi): wait for a cold first start; name the right settings.json - #1344

Merged
amiddavid merged 5 commits into
mainfrom
fix/pi-cold-start-and-warning-path
Nov 24, 2026
Merged

amiddavid merged 5 commits into
mainfrom
fix/pi-cold-start-and-warning-path

Conversation

@vz-ibm

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

Copy link
Copy Markdown
Collaborator

Behavior change (the owner approved the time limit in the session; confirm on this PR): Pi users whose proxy starts slowly.

  • Old: setup and update gave up after 5 s when the proxy did not answer.
  • New: setup and update wait up to 20 s (a deadline, not a count of tries). A proxy that answers at once adds no wait.
  • No change: the session-start restart and configure keep 5 s, so they stay inside the extension's 60 s limit. The first request still waits at most 10 s (fix(pi): hold routed requests while the start check restarts the proxy #1215).
  • One small change for restart and configure: a proxy that accepts the connection but does not answer /healthz made the old wait last up to about 55 s (50 checks of 1 s). Now the wait stops at 5 s. A proxy that answers within 5 s sees no change.
  • A first setup that still fails removes the service it started, so nothing runs with no record. A re-run keeps the earlier install's service.
  • No setting turns it off. To undo it, set COLD_START_SECONDS back to 5 in pi_plugin.py.

Data dependence: none. No row in docs/data-dependence.md changes.

Summary

Two small Pi fixes, found while I checked the QA guide and v0.7.6/v0.7.7.

#1288: the first setup can fail on a cold start

  • In one test, 2 of 3 fresh setups failed with health_check_failed. The proxy started a few seconds after setup's 5 s check, and the service stayed running with no install record.
  • wait_healthy() stops at a deadline: 20 s for setup and update, 5 s for restart and configure. On a failed first setup, stop_service() removes the half service.

#1289: the two-copies warning names the wrong file

  • It always said ~/.pi/agent/settings.json. With PI_CODING_AGENT_DIR set, it now names $PI_CODING_AGENT_DIR/settings.json.

How it was tested

  • Python: new fake-clock tests: a cold start waits up to 20 s; the wait stops at its deadline even when each check is slow; a proxy that answers at once adds no wait; restart and configure stay inside 60 s; which paths wait 20 s; a failed first setup removes its service, a failed re-run keeps it. 156 tests pass.
  • Node: settingsPath() names the right settings.json, with and without PI_CODING_AGENT_DIR. 54 tests pass.
  • Node: 1 new test (the warning names $PI_CODING_AGENT_DIR/settings.json). 53 tests pass.
  • go test -count=1 ./pi-package/, make lint.

Fixes #1288
Fixes #1289

Assisted-By: Claude (Anthropic AI) [email protected]

#1288: the first setup after a download could fail with
health_check_failed. The proxy started a few seconds after setup's
5 s check (2 of 3 fresh setups in one test), and the service stayed
running with no record.
- wait_healthy checks every 0.1 s for up to 20 s. A proxy that
  answers at once adds no wait.
- A first setup that still fails removes the service it started. A
  re-run keeps the service of the earlier install.

#1289: the two-copies warning always named ~/.pi/agent/settings.json.
It now names $PI_CODING_AGENT_DIR/settings.json when that is set.

Behavior change (#1288): Pi users whose proxy starts slowly. Old:
setup (and the session-start restart, and configure and update)
gave up after 5 s. New: up to 20 s. The first request still waits
at most 10 s (#1215). No setting turns it off.

Data dependence: none.

Fixes #1288
Fixes #1289

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 1 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 6ff96beb3fd3 blocking

Verdict: blocking

Findings

  1. pi-package/scripts/pi_plugin.py:149 — the 20 s wait breaks the 60 s time budget of restart and configure
    • What fails: a restart or a configure that waits for the restart lock can now run past the extension's 60 s limit (RESTART_TIMEOUT_MS, extensions/context-guru.ts:104, used at lines 478 and 627). Pi then kills the Python command. The person sees "the restart did not finish within 60 seconds and was stopped", or a configure with no facts, instead of the real result (busy, down, or configured).
    • Proof (worst case, restart, line 1088-1109):
      • Lock wait: up to LOCK_WAIT_SECONDS = 40 s (line 138).
      • healthy(port, timeout=START_CHECK_SECONDS): up to 5 s (line 1105).
      • restart_service() on a fast kickstart: about 0 s.
      • wait_healthy(port): old 5 s, new 20 s (line 1109).
      • Total: old about 50 s, inside 60 s. New about 65 s, past 60 s.
    • Proof (configure, line 1142-1175): lock wait 40 s + start_service (wait_launchd_gone up to 5 s, then wait_healthy 20 s) = about 65 s, past the 60 s limit of line 627.
    • The comment at lines 134-137 states the rule this breaks: "A caller that waits 40 s reports busy and still finishes inside the extension's 60 s limit." The PR makes the contended case more likely too: setup holds the lock across start_service (line 975), and that now holds it for up to 20 s more.
    • It is worse when /healthz accepts the connection but does not answer (for example, a listener that is open before the server serves). Each healthy() call then takes its 1 s timeout (line 141). 200 tries x (1 s + 0.1 s) = about 220 s, not "about 20 s" as the docstring says. The old limit was about 55 s in the same case.
    • Fix: make wait_healthy stop at a deadline (time.monotonic() + 20), not after a count of tries, so a slow healthy() cannot stretch it. Then make the budget fit again: for example, lower LOCK_WAIT_SECONDS to about 30 s, or give the restart and configure paths a deadline that ends before 60 s. Update the comment at lines 134-137. Add a test that pins the sum (lock wait + start check + health wait) below RESTART_TIMEOUT_MS / 1000, next to test_a_restart_that_waits_too_long_for_the_lock_reports_busy (test_pi_plugin.py:695), which only checks LOCK_WAIT_SECONDS < 60.

Non-blocking

  • test_pi_plugin.py:274 counts calls to healthy, not time. With finding 1 fixed by a deadline, the test can mock time.monotonic and check that the loop stops at 20 s even when each healthy() call is slow.
  • The first half of the same test (answers at try 150) does not check that the loop stopped at once on the first True. A call count would pin "a proxy that answers adds no wait".
  • Pre-existing, not from this PR: a re-run of setup that moves to a new port (choose_port, line 190) rewrites the plist or unit with the new port in start_service. When that start fails, the record keeps the old port, but the service now runs on the new one. "A re-run keeps the earlier install's service" is then only partly true. Consider a follow-up issue.
  • PI_CODING_AGENT_DIR is used as is, with no ~ expansion, in both pi_plugin.py:75 and the new warning. That is consistent. I did not check whether Pi itself expands ~ in that value.

What I checked

  • Read CLAUDE.md rules that apply (fail open, behavior change, data dependence, tests wait on a condition).
  • Read the full diff of the one commit (4 files, +62/-4) and the commit message.
  • Read the code around each change: healthy, wait_healthy, start_service, restart_service, stop_service, wait_launchd_gone, launchd_bootstrap, setup, restart, configure, restart_lock, choose_port, and the extension's time limits (START_CHECK_TIMEOUT_MS, FIRST_REQUEST_WAIT_MS, RESTART_TIMEOUT_MS, checkAtStart).
  • First-setup cleanup: record is read again under the lock (line 964), so record.get("port") reflects only a successful earlier install. stop_service returns not_owned and does nothing for a foreign unit or plist, so the cleanup cannot remove a service context-guru did not write. In the existing test test_no_route_is_written_when_the_proxy_does_not_come_up, the real stop_service now runs, but the sandbox HOME has no unit or plist, so it returns gone and runs no command.
  • The new TS test saves and restores PI_CODING_AGENT_DIR and the LOADED global in finally. The extension path matches agent_dir() in pi_plugin.py:75.
  • The PR body names the behavior change at the top, with who, old, new, and "no setting turns it off". It asks the owner to confirm on the PR. That confirmation must be on the PR before merge.
  • Data dependence: none. No component or proxy feature changes; the PR touches only the Pi package host scripts. No row is needed.
  • The new tests mock time.sleep and use no real waits. No binary or LFS file is added.
  • I did not run the tests. Live tests were 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 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 6ff96beb3fd3 blocking

Verdict: blocking

Findings

  1. pi-package/scripts/pi_plugin.py:149 — wait_healthy counts tries, not time, so "about 20 s" can be about 220 s, and configure goes past its 60 s limit
    • What fails: a proxy that accepts the TCP connection but does not answer /healthz within 1 s (a stuck or very busy process). Each healthy() call then waits its full timeout=1 (line 141), plus the 0.1 s sleep. 200 tries take about 220 s, not 20 s. Before this PR, 50 tries took about 55 s.
    • Proof:
      • configure runs with RESTART_TIMEOUT_MS = 60_000 (context-guru.ts:104, :627). It waits up to LOCK_WAIT_SECONDS = 40 for the lock, then calls start_service → wait_healthy (pi_plugin.py:1176). With a normal "not up yet" proxy (connection refused, fast tries): 40 + 20 s + the launchctl time is more than 60 s. With a stuck listener: about 220 s, even with no lock wait. Before: 40 + 5 s, or 55 s, both inside 60 s. pi.exec then kills configure, and the person gets no facts, only a killed command. restart_pending stays set, so the next configure retries. The harm is a wrong message, not lost state.
      • The comment at pi_plugin.py:134-138 says a 40 s lock wait "still finishes inside the extension's 60 s limit". With the new wait, this is no longer true, and the PR does not update the comment.
      • setup has a 300 s limit (context-guru.ts:578), so 220 s alone does not kill it. restart was already at about 5 + 55 = 60 s in the stuck case before this PR, so that part is not new.
      • The new test (test_pi_plugin.py:274) mocks healthy to return at once, so it checks the count of calls, not the time.
    • Fix: bound the loop by a monotonic deadline, for example deadline = time.monotonic() + 20 and healthy(port, timeout=min(1, remaining)). Test it with a fake clock. Then make the budget fit: lower LOCK_WAIT_SECONDS (for example to 35 s) or raise RESTART_TIMEOUT_MS, and update the comment at lines 134-138 with the new numbers.

Non-blocking

  • Behavior change needs the human's yes on the PR. The PR body says the owner approved the time limit "in the session; confirm on this PR". CLAUDE.md requires a human developer's yes, and an agent's report of it does not count. The yes must be on the PR before merge.
  • pi_plugin.py:956-959: the drop_download docstring says "After a failed start the binary stays, because the service names it." On a failed first setup, the service is now removed, so this reason is gone. The binary still stays. The next setup downloads again (#1157 logic at line 851), so no harm. Update the comment.
  • A failed first setup also leaves the proxy config that write_proxy_config wrote (line 970). The next setup overwrites it (it is ours), so no harm. Mention it only if you want "nothing is left" to be exact.
  • context-guru.ts:421: the long inline ternary is hard to read. A small settingsPath() helper would also let the unset case have its own test. The existing test at tests/context-guru.test.ts:477 only matches /settings\.json/, so the ~/.pi/agent/settings.json default has no exact test.

What I checked

  • Read the full diff (4 files, +62/-4) and the commit message.
  • Read the code around each change: healthy, wait_healthy, start_service, restart_service, stop_service, restart_lock, LOCK_WAIT_SECONDS, setup, restart, configure, and all wait_healthy callers.
  • Checked the record logic. record is read again under the lock (line 967). A record with no port means no successful setup, because setup writes the record only after the start works. A re-run keeps the old service. The new tests cover both branches.
  • Checked that stop_service returns not_owned and removes nothing when a foreign unit or plist exists. start_service returns False for that case too, so the new branch does not remove a file we do not own.
  • Checked the TS change. Pi and pi_plugin.py:agent_dir() both use PI_CODING_AGENT_DIR, with an empty value treated as unset. The two now agree. The new test restores the environment variable and LOADED.
  • Checked the existing tests that reach health_check_failed (line 271). On the first-setup path, they now call the real stop_service, which finds no unit or plist in the sandbox and returns gone. No real service command runs.
  • Data dependence: no component or feature data changes. No row file is needed.
  • Fail open: the change is in the Pi installer, not in the request path.
  • I did not run any tests. Live tests are not approved.

Round-1 review of #1344:
- wait_healthy now stops at a deadline, so a slow health check cannot
  stretch the wait past its limit.
- Only setup and update (a cold first start) wait up to 20 s.
  Restart and configure keep 5 s, inside the extension's 60 s limit.
- A failed first setup removes the service it started.
- settingsPath() names the settings.json that Pi uses, with tests.

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

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to round 1 (fixed in 3d43428)

Finding 1 of both reviewers (the 20 s wait and the 60 s limit): fixed.

  • wait_healthy now stops at a deadline (time.monotonic()), not after a count of tries. Each check uses min(1, remaining), so a slow /healthz cannot stretch the wait.
  • Only a cold start waits up to 20 s: setup and update (COLD_START_SECONDS). They have the 300 s limit.
  • restart and configure keep 5 s (WARM_START_SECONDS), as before this PR.
  • New test test_restart_and_configure_stay_inside_the_extensions_60_second_limit: it checks LOCK_WAIT_SECONDS + START_CHECK_SECONDS + 5 + WARM_START_SECONDS < 60.
  • New fake-clock tests: test_a_cold_start_waits_up_to_20_seconds, test_the_wait_stops_at_its_deadline_even_when_each_check_is_slow, test_a_proxy_that_answers_at_once_adds_no_wait (it checks 1 call).
  • test_setup_and_update_wait_for_a_cold_start_configure_does_not pins which path gets which wait.

Non-blocking:

  • drop_download docstring: updated. The binary stays so that the next setup can use it.
  • settingsPath() helper: added, with an exact test for both cases (~/.pi/agent/settings.json, and $PI_CODING_AGENT_DIR/settings.json).
  • The proxy config left after a failed first setup: no change. The next setup overwrites it.
  • The re-setup on a new port: not from this PR. Filed as pi: a failed re-setup on a new port leaves the service on that port #1347.
  • ~ in PI_CODING_AGENT_DIR: no change. Both places use the value as it is, the same as Pi.
  • The human's yes: the behavior change is now smaller (only setup and update). The yes will come from the owner on this PR.

Checks: Python 156 tests OK, Node 54 pass, go test ./pi-package/ ok, make lint clean.

@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.325 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 3d434284a952 approve

Verdict: approve

Findings

None.

Status of round-1 findings

  • Reviewer 1, finding 1 (the 20 s wait breaks the 60 s limit): fixed.
    • wait_healthy (pi_plugin.py:156) now stops at a time.monotonic() deadline. Each check gets min(1, remaining), so a slow /healthz cannot stretch the wait.
    • Only setup (line 986) and update (line 1266) pass cold_start=True and wait 20 s. Both run under the extension's 300 s limit.
    • restart (line 1120, default) and configure (start_service default) wait 5 s. Worst case: 40 + 5 + 5 + 5 = 55 s, inside 60 s.
    • test_restart_and_configure_stay_inside_the_extensions_60_second_limit pins that sum.
  • Reviewer 2, finding 1 (same defect): fixed, for the same reasons. The deadline also fixes the "about 220 s" case.
  • My non-blocking points: the fake-clock tests now check time, not a count. test_a_proxy_that_answers_at_once_adds_no_wait checks 1 call and 0 s. The re-setup port issue is filed as #1347. The ~ point needs no change.
  • Reviewer 2's non-blocking points: the drop_download docstring is updated. settingsPath() is added with an exact test for both cases. The left-over proxy config is accepted as harmless; I agree, because the next setup overwrites a config it owns.

Non-blocking

  • A small narrowing on the warm path, not named in the PR body. Before this PR, the warm wait was 50 tries. When /healthz accepted the connection but answered slowly, it could last up to about 55 s. Now it stops at 5 s. The PR body says restart and configure have "no change". For a refused connection that is true. For a slow answer, they now give up sooner. I think the risk is low: a warm proxy answers /healthz at once when it serves. Add one line to the behavior-change block so the owner's yes covers it.
  • The owner's yes for the behavior change is still not on the PR. CLAUDE.md requires it before merge.
  • CI was still pending when I read it (analyze, build-test, purego, record, trivy).
  • The comment at pi_plugin.py:134-137 still says "A caller that waits 40 s ... finishes inside the extension's 60 s limit". That is true again. The new comment at lines 149-151 explains why.

What I checked

  • Last review: round 1, 6ff96be, 2026-11-24T10:35:51Z
  • New commits read: 1 (3d434284 fix(pi): stop the start wait at a deadline; 20 s only for setup/update)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-1 review (10:36:08Z): read it. Its finding 1 is the same as mine, and the new commit fixes it. I checked each of its non-blocking points above.
    • The author's comment "Replies to round 1" (10:49:35Z): I checked each reply against the code. All of them match the diff.
    • Commit 3d434284: read the full diff (4 files, +98/-28).
  • Read the code around each change: wait_healthy, start_service, restart, configure, update, setup, LOCK_WAIT_SECONDS, START_CHECK_SECONDS.
  • wait_healthy reads WARM_START_SECONDS at call time, so the Restart test class patch to 0.05 s works. With sleep mocked and the real clock, the loop spins for 0.05 s only.
  • Other tests that run the real start_service (test_pi_plugin.py:1450) mock healthy to True, so they return on the first check and do not spin.
  • The new test test_setup_and_update_wait_for_a_cold_start_configure_does_not checks the cold_start value for setup and configure. contextlib is imported (line 8). update is not in that test, but line 1266 passes cold_start=True directly.
  • The fake start helpers in tests take the new cold_start argument, so they still match the real signature.
  • The updated PR body names the behavior change at the top, with who, old, new, and how to undo it.
  • Data dependence: none. The change is in the Pi installer only. Fail open is not affected; the change is not in the request path.
  • I did not run the tests. Live tests were 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 2 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 3d434284a952 approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 2, finding 1 (try count, not time; the 60 s limit): fixed.
    • wait_healthy (pi_plugin.py:156-167) now stops at a time.monotonic() deadline. Each check gets min(1, remaining). The sleep is cut to the time that is left.
    • Only setup (line 986) and update (line 1266) pass cold_start=True and wait 20 s. Their limits in the extension are 300 s.
    • restart (line 1120, default) and configure (line 1175, no flag) wait 5 s. Worst case for restart: 40 s lock + 5 s start check + 5 s = 50 s. For configure: 40 s lock + up to 5 s wait_launchd_gone + 5 s = 50 s, plus the launchctl time. Both are inside 60 s again.
    • The new fake-clock tests check the deadline with slow checks, the 15 s success, and one call for a proxy that answers at once.
  • Reviewer 1, finding 1 (the same 60 s budget): fixed. I checked this with the same trace as above. The new test test_restart_and_configure_stay_inside_the_extensions_60_second_limit pins the sum at 55 s, below 60 s.
  • My non-blocking points: the drop_download docstring is updated. settingsPath() is added, with an exact test for both cases. The author kept the leftover proxy config on purpose, and I accept that reason: the next setup overwrites it.
  • Reviewer 1's non-blocking points: the author filed the port-move case as #1347, and it is not from this PR. The author kept ~ in PI_CODING_AGENT_DIR unexpanded, the same as agent_dir(), and I accept that reason.

Non-blocking

  • The human's yes is still not on the PR. The PR body still says "confirm on this PR". The merge must wait for the owner's yes.
  • The PR body says "No change" for restart and configure, but one case changes. If the proxy accepts the connection but does not answer, the old loop ran 50 checks of up to 1 s each, about 55 s. The new deadline stops it at about 5 s. A proxy that is up within 5 s is not affected. Add one line to the behavior-change block.
  • The test name says "update", but the test does not check update. test_setup_and_update_wait_for_a_cold_start_configure_does_not (test_pi_plugin.py:317) checks only setup and configure. A cold_start=True check on the update --install call would pin line 1266.
  • The Restart tests now depend on the real clock. Restart.setUp (test_pi_plugin.py:498-502) sets WARM_START_SECONDS to 0.05 s on the real clock. test_launchd_kickstarts_our_label needs its third healthy() answer inside those 50 ms. A CI pause of more than 50 ms makes it report down. That is rare, but it is a time-based wait, which CLAUDE.md asks tests to avoid. A fake time.monotonic only inside wait_healthy (for example a clock argument) would remove the risk and leave the lock tests on the real clock.
  • The deadline is soft by up to about 1 s. urlopen's timeout applies to each socket operation (connect, then read), so one check can take more than min(1, remaining). The budget still fits (55 s + about 1 s < 60 s). No change is needed.

What I checked

  • Last review: round 1, 6ff96be, 2026-11-24T10:36:08Z
  • New commits read: 1 (3d434284 fix(pi): stop the start wait at a deadline; 20 s only for setup/update)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Commit 3d434284: I read the whole diff (4 files, +98/-28) and the code around it: wait_healthy, start_service, restart, configure, update, setup, LOCK_WAIT_SECONDS, and the Restart, Controller and ConfigByName test helpers.
    • The author's comment of 2026-11-24T10:49:35Z (replies to round 1): I checked each reply against the code. See "Earlier findings".
    • Reviewer 1's round-1 review (10:35:51Z, read for the first time in this round): I checked its finding and its non-blocking points. See "Earlier findings".
    • The updated PR body: it names the smaller behavior change and says how to undo it. The owner's yes is still not on the PR.
  • All 4 test stubs of start_service now take cold_start=False, so the new keyword does not break them.
  • wait_healthy reads WARM_START_SECONDS when it is called, not when it is defined, so the patch in Restart.setUp takes effect.
  • Data dependence: none. The PR touches only the Pi package host scripts.
  • I did not run the tests. Live tests are not approved.

Round-2 review of #1344:
- wait_healthy takes an optional clock and sleep. The Restart tests use
  them, so no test depends on a 50 ms real-clock window.
- The update test now checks that update --install is a cold start.

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

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Replies to round 2 (fixed in 5ba774b)

  • The slow-answer case for restart and configure (both reviewers): added to the behavior-change block in the PR body. The old wait could last about 55 s; now it stops at 5 s.
  • The test name says "update" (reviewer 2): fixed. test_update_re_renders_with_the_new_binary_before_the_start now checks that update --install is a cold start. I checked that it fails when update uses the 5 s wait.
  • The Restart tests used a 50 ms real-clock window (reviewer 2): fixed. wait_healthy takes an optional clock and sleep. The Restart tests run that wait on a fake clock. The lock tests keep the real clock.
  • The deadline is soft by up to about 1 s (reviewer 2): no change, as you said. The sum is 55 s + about 1 s, below 60 s.
  • The human's yes: still needed on this PR before merge.

Checks: Python 156 tests OK, Node 54 pass, go test ./pi-package/ ok, make lint clean.

@amiddavid

Copy link
Copy Markdown
Collaborator

The integrator merged main into this branch at the owner's request. New head: 225729555.

@vz-ibm, reviewers: please re-check the delta.

Conflicts: none. The merge was clean. The delta is main's new commits only; this PR's own diff is unchanged.

Tests (macOS)

  • python3 -m unittest discover -s pi-package/scripts -p 'test_*.py': 218 pass
  • python3 -m unittest pi-package/release/test_release.py: 12 pass
  • go test ./pi-package/...: pass

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 @amiddavid) Claude Code 2.1.331 offload-review skill, @amiddavid's session fresh 2 of 2 3 of 3 225729555865 approve

Verdict: approve

Findings

None.

Earlier findings

  • Reviewer 1 and reviewer 2, round 1, finding 1 (the 60 s budget): fixed in 3d434284. Round 2 of both reviewers confirmed it. The new commits do not change it.
  • Reviewer 2, round 2, non-blocking (the Restart tests on a 50 ms real-clock window): fixed in 5ba774bf. wait_healthy (pi_plugin.py:156) takes an optional clock and sleep. Restart.setUp (test_pi_plugin.py:498-509) wraps wait_healthy with a fake clock that each sleep moves forward. The lock tests keep the real clock. The wrapper signature (port, seconds=None) matches both callers: pi_plugin.py:705 (positional seconds) and pi_plugin.py:1121 (no seconds).
  • Reviewer 2, round 2, non-blocking (the test name says "update" but does not check it): fixed. test_update_re_renders_with_the_new_binary_before_the_start now records cold_start and asserts it is true. The fake start takes cold_start=False, so the check fails if update drops the flag.
  • Both reviewers, round 2 (the slow-answer case for restart and configure not named): fixed. The PR body now has a line for it.
  • Reviewer 2, round 2 (the deadline is soft by about 1 s): no change, as I said. Accepted.

Non-blocking

  • Behavior-change yes. The PR body still says "confirm on this PR". No human yes is on the PR yet. This is a Pi PR, so the owner rule of 2026-11-20 (Pi behavior changes are FYI to the owner, the PR author's yes is enough) may apply. The integrator must record which rule covers it in the squash message.
  • CI is still pending at this head (analyze, build-test, purego, record, trivy). Only DCO has passed.
  • The PR body has two Node lines under "How it was tested": "54 tests pass" and "53 tests pass". The second line is stale. The test counts also predate the merge (the merge comment says 218 Python tests now).

What I checked

  • Last review: round 2, 3d43428, 2026-11-24T10:51:58Z
  • New commits read: 2 on the PR side, plus the main commits that the merge brings in.
    • 5ba774bf test(pi): run the restart wait on a fake clock; pin update's cold start. Full diff read (2 files, +20/-10).
    • 22572955 Merge remote-tracking branch 'origin/main' into integrator/pi-1344.
    • Main commits in the merge (reviewed in their own PRs; I read their log and stat and checked overlap with this PR): 7f657d1b (#1335), 2c8d8b89 (#1330), 71d18d6e (#1326), 8f67d0c7 (#1336), 46e94e57 (#1271), 290898d3 (#1333), 2ee6dbc9 (#1328), 807d2178 (#1327), c3096caa (#1315), 28383ae2 (#1332), 8e3e6746 (#1325), 98c9a740 (#1339), d6cc5286 (#1322).
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three files).
  • New items since my last review:
    • Author comment "Replies to round 2" (10:55:27Z): I checked each reply against 5ba774bf. All match. See "Earlier findings".
    • Reviewer 1's round-2 review (10:51:44Z, read for the first time): its non-blocking points (the slow-answer line, the human's yes, CI pending) are handled or still open as listed above.
    • Integrator comment (12:46:17Z, "please re-check the delta"): I checked it. See the merge checks below.
  • Merge checks:
    • git show --remerge-diff 22572955 is empty, so the merge resolved no conflict by hand.
    • The PR diff against the old base (de4e2f92..5ba774bf) and against the new base (7f657d1b..HEAD) are the same, except for line numbers and index lines. 4 files, +155/-17.
    • Overlap: #1335 changed pi-package/extensions/context-guru.ts (the compaction mark, session_shutdown). The PR's settingsPath() (line 30) and its use (line 439) sit apart from it and still read the same.
    • Overlap: #1326 and #1330 changed install_pi.py. It calls pi_plugin.agent_dir(), which reads PI_CODING_AGENT_DIR the same way as settingsPath(). It does not call wait_healthy or the start constants.
  • Data dependence: none. The PR touches only the Pi package host scripts. Fail open is not affected: the change is not in the request path.
  • I did not run the tests. Live tests are not approved.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 @amiddavid) Claude Code 2.1.331 offload-review skill, @amiddavid's session fresh 1 of 2 3 of 3 225729555865 approve

Verdict: approve

Findings

None.

Status of earlier findings

  • Reviewer 1, finding 1 (round 1, the 60 s budget): fixed in 3d434284. Still fixed at this head. restart (pi_plugin.py:1121) and configure use the 5 s warm wait. Only start_service(cold_start=True) (pi_plugin.py:705) gets 20 s.
  • Reviewer 2, finding 1 (round 1, try count, not time): fixed, for the same reason.
  • Round-2 non-blocking points (both reviewers):
    • The slow-answer case for restart and configure: the author says the PR body names it now. I accept that.
    • The test name says "update": fixed. test_update_re_renders_with_the_new_binary_before_the_start now asserts seen["cold_start"] for update --install.
    • The 50 ms real-clock window in the Restart tests: fixed. See "What I checked".
    • The soft deadline of about 1 s: no change, as reviewer 2 proposed. The sum stays below 60 s.

Non-blocking

  • The owner's yes for the behavior change is still not on the PR. The only human comment (12:46:17Z) is about the merge of main. CLAUDE.md asks for a human developer's yes before merge. The integrator must check this.

What I checked

  • Last review: round 2, 3d43428, 2026-11-24T10:51:44Z
  • New commits read: 2
    • 5ba774bf test(pi): run the restart wait on a fake clock; pin update's cold start
    • 22572955 Merge remote-tracking branch 'origin/main' into integrator/pi-1344
  • Read in full: 4 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-2 review (10:51:58Z): read it. Its non-blocking points are handled, as listed above.
    • The author's comment "Replies to round 2" (10:55:27Z): I checked each reply against 5ba774bf. All of them match the diff.
    • The comment by amiddavid (12:46:17Z), "merged main, please re-check the delta": I checked the merge. See below.
  • 5ba774bf, wait_healthy (pi_plugin.py:156-168): the new clock and sleep arguments default to time.monotonic and time.sleep. The only production callers (lines 705 and 1121) do not pass them, so production behavior is the same as at 3d434284.
  • 5ba774bf, Restart.setUp: it patches pi_plugin.wait_healthy with a wrapper that runs the real function on a fake clock. sleep moves the clock. start_service and restart look up wait_healthy as a module global at call time, so they get the wrapper. The wrapper's (port, seconds=None) matches both call forms. With healthy always False, the loop ends after about 50 fake sleeps of 0.1 s. No test now depends on the real clock in this wait. The lock tests keep the real time.monotonic.
  • Merge 22572955: git merge-tree --write-tree 5ba774bf 7f657d1b gives tree de2293c2. That is the same as the HEAD tree. So the merge is clean and has no hand edits.
  • git diff 7f657d1b..HEAD --stat: the PR's own diff is still only 4 files (context-guru.ts, pi_plugin.py, test_pi_plugin.py, context-guru.test.ts).
  • Main's Pi changes since the merge base (de4e2f92..7f657d1b) do not touch pi_plugin.py. In context-guru.ts they add the compaction mark, in another part of the file than settingsPath(). In install_pi.py they add check_folders, which uses pi_plugin.agent_dir(). That reads PI_CODING_AGENT_DIR the same way as settingsPath() (an empty value means unset). No conflict in behavior.
  • Data dependence: none. The PR changes only the Pi package host scripts. Fail open is not affected; the change is not in the request path. No binary or LFS file.
  • I did not run the tests. Live tests were not approved.

@vz-ibm

vz-ibm commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Behavior change approved (owner): setup and update wait up to 20 s for the proxy to start (was 5 s). Restart and configure keep 5 s. Posted by my assistant at my request. — Vitaly

#1342 merged to main. Its tests and this PR's tests both changed the same
places.

Conflicts and resolution:
- pi-package/tests/context-guru.test.ts, import list: keep both
  settingsPath (this PR) and recoverStaleRoute (#1342).
- pi-package/tests/context-guru.test.ts, tests: keep this PR's two-copies
  warning and settingsPath tests, then #1342's recoverStaleRoute tests.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

The integrator merged main into this branch again at the owner's request, after #1342 merged. New head: f1c50eca.

@vz-ibm, reviewers: please re-check the delta.

Conflict: pi-package/tests/context-guru.test.ts, in the import list and in the tests. Both sides added code.
Resolution: kept both. This PR's settingsPath tests and #1342's recoverStaleRoute tests are in the file. No change to real code.

Tests (macOS)

  • Pi script tests: 225 pass
  • Release tests: 12 pass
  • go test ./pi-package/...: pass (it runs the Pi TypeScript tests)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 @amiddavid) Claude Code 2.1.331 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 4 f1c50ecac549 approve

Verdict: approve

Findings

None.

Earlier findings

  • Round 1, finding 1 of both reviewers (the 60 s budget): fixed in 3d434284. Still fixed at this head. The new merge does not touch pi_plugin.py.
  • Round 2 non-blocking points (both reviewers): fixed in 5ba774bf, as my round-3 review says. No change since.
  • My round-3 non-blocking points:
    • Behavior-change yes: now on the PR. Comment by vz-ibm at 14:07:59Z: "Behavior change approved ... setup and update wait up to 20 s ... Restart and configure keep 5 s." Vitaly is the PR author, and Pi behavior changes are FYI to the owner (owner rule of 2026-11-20). The comment says an assistant posted it at Vitaly's request. The integrator can record it in the squash message.
    • CI pending: not checked again at this head. The integrator checks CI at hand-off.
    • The two Node test counts in the PR body: not fixed. It is a text nit only.

Non-blocking

  • The PR body still lists "54 tests pass" and "53 tests pass" for Node, and Python counts from before the two merges. The merge comment gives the current counts (225 Pi script tests). Update the body before the squash, or leave the counts out of the squash message.

What I checked

  • Last review: round 3, 2257295, 2026-11-24T12:50:46Z
  • New commits read: 8. One is on the PR side; seven are main commits that the merge brings in.
    • f1c50eca Merge origin/main into fix/pi-cold-start-and-warning-path. Read in full, with git show --remerge-diff.
    • Main commits (reviewed in their own PRs; I read their messages and stats and checked overlap with this PR): f4ee9f87 fix(pi): a Pi window open during an uninstall no longer fails (#1342), d847e7c8 fix(apply): report a head-TTL relabel as a change (#1356), f5a77414 refactor(campaign): move the adapt recommendation choice (#1334), e31ed42f refactor(accrec): move the accountant glue (#1337), 9f7475ce refactor(compactionpoint) (#1320), 52876118 refactor(keepalive): move wait windows, signal and manual ping rules (#1338), 2257295 is my last reviewed head.
  • Read in full: 6 reviews, 5 comments, 0 inline comments (from the three files).
  • New items since my last review:
    • Reviewer 1's round-3 review (12:50:49Z): approve. Its one open point (the owner's yes) is now answered by the 14:07:59Z comment.
    • Comment by vz-ibm (14:07:59Z), the behavior-change yes: checked. It names the same change as the PR body.
    • Comment by amiddavid (14:27:58Z), "merged main again, please re-check the delta": checked. See below.
  • Merge f1c50eca checks:
    • The remerge-diff shows one conflict only, in pi-package/tests/context-guru.test.ts. The resolution keeps both sides: the import list has settingsPath and recoverStaleRoute. The file has this PR's two tests (the two-copies warning, settingsPath), then #1342's staleWorld helper and recoverStaleRoute tests. The braces close correctly (}); after the settingsPath test, line 577).
    • The PR diff against the new base (f4ee9f87..HEAD) is the same 4 files, +155/-17, as against the old base. A line-by-line compare shows only the changed import context and the hunk position. No real-code change from the merge.
    • #1342 also changed pi-package/extensions/context-guru.ts (stale-route recovery). The PR's settingsPath() (line 30) and its use in the two-copies warning (line 470) are apart from that code. LOADED handling (lines 463, 476, 619) is unchanged.
    • The new tests/recover.test.ts (#1342) also uses LOADED and deletes it after each test (line 55). This PR's two-copies test also deletes LOADED and restores PI_CODING_AGENT_DIR in finally. The two do not leak state into each other.
  • Data dependence: none. The PR changes only the Pi package host scripts. Fail open is not affected: the change is not in the request path. No binary or LFS file.
  • I did not run the tests. Live tests are not approved.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 @amiddavid) Claude Code 2.1.331 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 4 f1c50ecac549 approve

Verdict: approve

Findings

None.

Status of earlier findings

  • Reviewer 1 and reviewer 2, round 1, finding 1 (the 60 s budget): fixed in 3d434284. The new merge does not touch pi_plugin.py on the PR side. wait_healthy (pi_plugin.py:156), the cold start (line 705) and the warm restart (line 1121) are the same as at 22572955.
  • Round-2 non-blocking points: fixed in 5ba774bf, as rounds 3 of both reviewers said. No change since.
  • My round-3 point (the owner's yes is not on the PR): fixed. The comment of 14:07:59Z records it: "Behavior change approved (owner): setup and update wait up to 20 s ... Restart and configure keep 5 s."
  • Reviewer 2, round 3 (CI pending, a stale Node test count in the PR body): not code findings. The integrator checks CI at the final head.

Non-blocking

  • The yes of 14:07:59Z names the 20 s cold start. It does not name the smaller change on the warm path (a slow /healthz answer now stops at 5 s, not about 55 s). The PR body names it in the behavior-change block, so I read the yes as covering the whole block. The integrator can confirm this with the owner if needed.

What I checked

  • Last review: round 3, 2257295, 2026-11-24T12:50:49Z
  • New commits read: 1 (f1c50eca Merge origin/main into fix/pi-cold-start-and-warning-path). It brings in main's f4ee9f87 (#1342), reviewed in its own PR. I read its message and its Pi diff to check the overlap.
  • Read in full: 6 reviews, 5 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-3 review (12:50:46Z): read it. Its points are listed above.
    • Comment by vz-ibm (14:07:59Z), the owner's yes for the behavior change: checked. It matches the change in the PR. See "Non-blocking".
    • Comment by amiddavid (14:27:58Z), "merged main again, please re-check the delta": checked. See the merge checks below.
  • Merge checks for f1c50eca:
    • git show --remerge-diff f1c50eca shows one conflict, in pi-package/tests/context-guru.test.ts. The resolution keeps both sides. The import list has settingsPath (this PR) and recoverStaleRoute (#1342). The tests have this PR's two-copies warning and settingsPath tests, then #1342's staleWorld and recoverStaleRoute tests. The resolution adds the closing }); and a blank line between them, so each test is complete. No other change.
    • git diff --stat f4ee9f87..HEAD: the PR's own diff is still 4 files, +155/-17.
    • I compared the changed lines of 7f657d1b..22572955 and f4ee9f87..HEAD. The only difference is the import line, which now also has recoverStaleRoute. The PR's diff is the same.
    • #1342 changed context-guru.ts. The second-copy branch of contextGuru (lines 464-475) still returns before any of #1342's new handlers. So the two-copies warning test still sees only the warning. settingsPath() (line 30) is used once, at line 470.
    • #1342 changed install_pi.py (asks about open Pi windows). It does not call wait_healthy, start_service or the start constants.
  • Data dependence: none. The PR touches only the Pi package host scripts. Fail open is not affected: the change is not in the request path. No binary or LFS file.
  • I did not run the tests. Live tests were not approved.

@amiddavid
amiddavid merged commit 49f3531 into main Nov 24, 2026
2 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 24, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator

Integrator: the 4 Pi PRs are merged: #1326, #1342, #1330 and #1344 (49f3531).

@vz-ibm, they ship in v0.7.8. The owner chose a direct v0.7.8 with no beta. It is cut after a few more PRs from other sessions merge. As with v0.7.7, please run your full installer check from the live release, releases/latest, when it is out. I will post here when it is published.

amiddavid added a commit that referenced this pull request Nov 24, 2026
chore(plugins): bump the plugin versions for v0.7.8

- Pi package: 0.1.6 -> 0.1.7 (#1326, #1330, #1335, #1342, #1344).
- OpenCode plugin: pinned proxy version v0.7.7 -> v0.7.8.
- Unchanged: Claude Code plugin 0.7.8 (test files only changed since
  v0.7.7), Codex 0.2.14, Bob 0.1.3.


Release owner (David Amid, 2026-11-24, integrator session): cut v0.7.8 now. Version bumps are under the owner standing approval.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator

Integrator: v0.7.8 is released and is latest: https://github.com/rossoctl/context-guru/releases/tag/v0.7.8

@vz-ibm, it holds the 4 Pi PRs: #1326, #1330, #1342 and #1344. The release has install-pi.sh, context-guru-pi-v0.7.8.tar.gz and its SHA-256 list. Please run your full installer check from the live release (releases/latest, no CG_PI_RELEASE_URL needed) and post the proof here. A fix, if one is needed, goes into v0.7.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

2 participants