Skip to content

fix(plugin): self-heal the Ping header on SessionStart - #691

Merged
OsherElhadad merged 3 commits into
mainfrom
fix/ping-header-selfheal
Oct 25, 2026
Merged

OsherElhadad merged 3 commits into
mainfrom
fix/ping-header-selfheal

Conversation

@OsherElhadad

@OsherElhadad OsherElhadad commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #685

Data dependence change (needs confirmation)

  • The header x-context-guru-ping: 1 makes the server hold the latest request body and key for the Ping button. It holds them 5 minutes after the last request on a 5-minute cache, and up to 59 minutes on a 1-hour cache. This is the row "Keep-alive pings" in docs/data-dependence.md.
  • With keep-alive off, this PR moves one group of installs from "nothing held" to "held for the button": installs that predate --no-ping-header (v0.5.4). They get the header at their next session start.
  • The hook proves the install is older first. It prints the full consent words and how to opt out.
  • Any other install with no record is not changed. It gets one note: "Ping is off for this install. Run /context-guru:install to turn it on."
  • The person in the "Decided by" column of that row must confirm this before merge.

Summary

  • An install that predates --no-ping-header gets the Ping header at the next SessionStart, with the consent words.
  • The Ping toast now tells the truth about what to do.
  • /context-guru:doctor checks the header.

What we found

  • Manual Ping needs the header x-context-guru-ping: 1 on the request.
  • Only install.sh wrote that header.
  • An install made before the header existed never had it.
  • A restart did not add it. The toast said "restart Claude Code", so the user was stuck.

What changed

  • Self-heal. start-proxy.sh calls settings.py ensure-ping-header at SessionStart.
    • It acts only on a settings file that holds our routing record (installed_base_url) and an install-scope row older than 2026-10-22 13:58:53 UTC (when --no-ping-header shipped).
    • It adds the one header line and records it. Uninstall removes exactly that line.
    • It prints: "Ping enabled for this install; it works from your next session".
  • Opt-out. add --no-ping-header records ping_header_opt_out: true and removes our recorded line. SessionStart does not heal that install.
    • An install that cannot be proven older gets a one-time note and no write.
    • A line the user removed by hand is not added again.
  • Safe. It never touches a file that is not ours. It never changes the user's own headers or their own ping line. It writes atomically.
  • Message. not opted in now reads: "Ping isn't enabled for this install yet; it turns on in your next session (or run /context-guru:install)".
  • Doctor. New check: "Ping header is set". It shows how to fix a missing header.
  • The Codex copy of cg.py is updated to match.

How it was tested

  • 17 Go tests in ping_selfheal_test.go (old install healed with consent words, unprovable install gets a note and no write, a v0.5.4 opt-out stays off, a hand-removed line stays removed, --no-ping-header removes our line in every branch, doctor check, and the cases below):
    • an old install is healed by the real start-proxy.sh
    • a second run changes nothing
    • a --no-ping-header install is not healed
    • the user's other headers stay
    • the user's own ping line stays
    • files that are not ours stay untouched
    • uninstall removes exactly our line
    • --check writes nothing
  • claude plugin test .: 33 pass, 0 fail.
  • go test ./context-guru-plugin/...: 4 tests fail, TestCGGoldens, TestSaveMoreWidthASCIIAndColour, TestCostlySettingsGoldens and TestSaveMoreDefaultIncludesTheSettingsCard. They fail the same way on a clean origin/main. Everything else passes.
  • Real run: the real hook against a sandbox HOME, with an old-shaped settings.json.

Before:

"env": { "ANTHROPIC_BASE_URL": "http://127.0.0.1:8931/anthropic", "ANTHROPIC_AUTH_TOKEN": "REDACTED", "ANTHROPIC_CUSTOM_HEADERS": "x-mine: 1" },
"$context-guru": { "installed_base_url": "http://127.0.0.1:8931/anthropic" }

After one SessionStart:

"env": { "...": "...", "ANTHROPIC_CUSTOM_HEADERS": "x-mine: 1\nx-context-guru-ping: 1" },
"$context-guru": { "installed_base_url": "...", "installed_ping_header": "x-context-guru-ping: 1" }

A second run printed no note and changed nothing.

Technical notes

🤖 Generated with Claude Code

An install made before the x-context-guru-ping header existed never
got it, and a restart could not add it. The Ping button then failed
with "restart Claude Code".

- settings.py: new ensure-ping-header command. It adds the header to
  the settings file that holds our routing, and records it so
  uninstall removes it.
- settings.py add: record ping_header_opt_out for --no-ping-header.
  SessionStart does not heal an opted-out install.
- start-proxy.sh: call ensure-ping-header and print one note.
- hooks/model.ts: say the true action for "not opted in".
- doctor: report whether the ping header is set.

Closes #685

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>

@OsherElhadad OsherElhadad 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 @OsherElhadad) Claude Code 2.1.310 offload-review skill, @OsherElhadad's session fresh 2 of 2 1 of 2 542df902d352 blocking

Verdict: blocking

Findings

  1. context-guru-plugin/scripts/settings.py:3063 — the heal turns Ping on for users who opted out on v0.5.4, without consent

    • What fails: --no-ping-header shipped in 328064e (#667, tag v0.5.4). An install made with it on v0.5.4 has our installed_base_url, no ping line, no installed_ping_header and no ping_header_opt_out (that key is new in this PR). ping_header_state returns missing for it, and the next SessionStart writes x-context-guru-ping: 1. The user's explicit opt-out is reversed.
    • Also: install.sh prints the consent text ping_note= (what the server keeps in memory, for how long, how to opt out) every time it writes the header (install.sh:1243-1247). The heal prints only "Ping enabled for this install; it works from your next session". So users who never saw the consent now have their latest request body and key held in memory (docs/data-dependence.md:215, "Without the header nothing is held").
    • Data dependence: the PR body says "Data dependence: none". This is not correct. For each healed install the change turns on holding the body and key for the button. CLAUDE.md asks to say this at the top of the PR, update docs/data-dependence.md, and get the "Decided by" person to confirm.
    • Proof: trace ensure-ping-header on {"env":{"ANTHROPIC_BASE_URL":U},"$context-guru":{"installed_base_url":U}}. This is the exact output of a v0.5.4 add --no-ping-header (the v0.5.4 cmd_add writes no opt-out key). ping_header_state → missing → add_ping_header → save → healed. Nothing tells a v0.5.4 opt-out apart from a pre-#667 install.
    • Fix: at least print the full consent text (the same words as ping_note=) with the opt-out command when the hook heals. Better: heal only installs that are older than #667, if some marker shows that. Otherwise, state the trade-off in the PR and in docs/data-dependence.md, and get it confirmed.
  2. context-guru-plugin/scripts/settings.py:2906-2918 — the documented opt-out does not remove a healed header

    • What fails: the consent text says "To opt out, re-run the install with --no-ping-header". After a heal, the file has the ping line and installed_ping_header. A re-run with --no-ping-header goes to the completed branch. That branch calls record_ping_choice(meta, False) and sets ping_header_opt_out: true, but it never removes the line. Result: the header still goes out, the record says "opted out", and doctor hides the check (opted-out is not in ("present", "missing"), cg.py:678). The user believes they opted out, but the server still holds the body and key.
    • Proof: cmd_add with ping_on=False: the unchanged test fails on the new clause (no opt-out record yet), so the code goes to if current == args.url:. That branch has if ping_on and add_ping_header(...) and no removal. remove_ping_header is called only from cmd_remove. The same holds in the repointed and fresh branches. Before this PR the gap was rare; the heal now puts the line into every older install, so the gap matters.
    • Fix: when ping_on is false and meta[installed_ping_header] == PING_HEADER, call remove_ping_header(env, meta) in all three write branches. Add a test: heal, then add --no-ping-header, then assert no ping line and ping_header_opt_out: true.

Non-blocking

  • start-proxy.sh:332 starts python3 at every routed SessionStart. Section (0b) above it first uses a grep so it does not start python3 in the common case. A grep -qs '"installed_ping_header"\|"ping_header_opt_out"' pre-check here would keep the hook cheap after the first heal.
  • settings.py:3088-3092: env merges per key across scopes. If our routing is in the user file but the project settings.json sets its own ANTHROPIC_CUSTOM_HEADERS, the healed user-scope line is hidden. Doctor then says present, but the session does not send it. This is rare; a note in doctor's text could help.
  • settings.py:2899: a plain add --no-ping-header re-run on an older opted-out file now takes the completed branch with added_keys="". It also makes a new backup, and the note "filled in the keys that were missing" is misleading.

What I checked

  • The full diff of 542df90 (8 files) and the commit message.
  • cmd_add in full (all four branches), add_ping_header, remove_ping_header, with_ping_header, cmd_remove meta cleanup.
  • start-proxy.sh order: the (0b) status-line repoint, the port gate and the routing gate before (1a); note goes to stdout; the fail-open || ph_out_="".
  • cmd_ensure_ping_header: the file list, the realpath de-dup, the state rule, --check, exit 0 on all paths.
  • install.sh R_NOPING and ping_note consent; the #667 history (328064e, tag v0.5.4).
  • docs/data-dependence.md rows for Keep-alive and 5-min-ping.
  • The doctor check in both cg.py copies (they are the same); the model.ts text and its test.
  • All 8 new Go tests and the plugin_test.go fixture change. Go is not run (not approved).

@OsherElhadad OsherElhadad 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 @OsherElhadad) Claude Code 2.1.310 offload-review skill, @OsherElhadad's session fresh 1 of 2 1 of 2 542df902d352 blocking

Verdict: blocking

Findings

  1. context-guru-plugin/scripts/settings.py:3073 — the heal turns on Ping for users who already opted out with --no-ping-header

    • What fails: a user installs with --no-ping-header on v0.5.4 (#667) or any build up to this PR. That add wrote no record of the choice. The file looks the same as an install from before the header. The next SessionStart returns missing and adds x-context-guru-ping: 1. From then on the proxy holds that user's last body and key, against their explicit choice.
    • Proof: before this PR, cmd_add with --no-ping-header only skipped add_ping_header. It wrote only installed_base_url into $context-guru. ping_header_state (settings.py:3063-3077) sees installed_base_url == routed URL, no ping_header_opt_out, no ping line, and returns "missing". cmd_ensure_ping_header then calls add_ping_header and save. The PR body says it on purpose: "An install with no record of either choice counts as heal." The test TestSessionStartDoesNotHealAnInstallMadeWithNoPingHeader creates the opt-out with the NEW add, so it does not cover an opt-out made by the released code.
    • Fix: do not write the header for an install with no record. Show a note at SessionStart instead ("Ping is not enabled for this install; run /context-guru:install to turn it on"). Or add only when a record proves the install predates #667 (for example, an install-scope row older than the #667 release). Add a test with a file written by the v0.5.4 add --no-ping-header.
  2. context-guru-plugin/scripts/start-proxy.sh:336 — the heal holds body and key with no consent note, and the PR states no data-dependence change

    • What fails: the header makes the server keep the user's latest request body and key in memory (docs/data-dependence.md:215). install.sh says this every time it writes the header, and says how to opt out (install.sh:1243-1247, ping_note). The heal writes the same header but prints only "Ping enabled for this install; it works from your next session". The user is not told what is kept, for how long, or how to turn it off.
    • Proof: start-proxy.sh:336 is the only output of the heal. CLAUDE.md "Metadata first" requires the PR to say what a feature keeps and to get the "Decided by" person to confirm a change. The PR says "Data dependence: none", but for every old install the change moves keep-alive-off sessions from "nothing held" to "body and key held".
    • Fix: put the ping_note words (what is kept, how long, how to opt out) in the SessionStart note. State the change at the top of the PR and get the data-dependence owner to confirm. Finding 1's "note, do not write" fix also removes this problem.
  3. context-guru-plugin/scripts/settings.py:3073 — a user who removes the ping line by hand gets it back every session

    • What fails: after a heal, the user deletes x-context-guru-ping: 1 from ANTHROPIC_CUSTOM_HEADERS to stop the server keeping their data. The next SessionStart sees no ping line and no opt-out, returns missing, and adds the line again. The user cannot turn it off by editing settings, which is the obvious way.
    • Proof: ping_header_state does not read installed_ping_header. After a heal, meta holds installed_ping_header: "x-context-guru-ping: 1". If that record is present and the line is gone, the user removed our line. The function still returns "missing".
    • Fix: in ping_header_state, return opted-out (or a new removed state) when meta[PING_HEADER_META] == PING_HEADER and no ping line is present. Add a test: heal, delete the line, run SessionStart, and expect no change.
  4. context-guru-plugin/scripts/settings.py:2915 — re-running the install with --no-ping-header records the opt-out but keeps our header

    • What fails: install.sh tells the user "To opt out, re-run the install with --no-ping-header" (install.sh:1246). With this PR, that re-run on a file with our recorded line goes to the completed branch. record_ping_choice(meta, False) writes ping_header_opt_out: true, but x-context-guru-ping: 1 and installed_ping_header stay. The proxy still holds body and key. ping_header_state now returns opted-out, so doctor hides the check, and the file says the opposite of what it does.
    • Proof: settings.py:2898-2900. With ping_on=False and the header present, the new and (ping_on or ... PING_OPT_OUT_META ...) clause is False, so the code falls to line 2905 and later. Nothing in that branch calls remove_ping_header. The bug in the opt-out path existed before, but this PR writes the header for many more users, and this re-run is the only opt-out it gives them.
    • Fix: in record_ping_choice, when ping_on is False, call remove_ping_header(env, meta) and pop PING_HEADER_META. Pass env in. Add a test: heal, re-run add --no-ping-header, and expect our line gone and the user's other headers kept.
  5. context-guru-plugin/scripts/cg.py:1235 — /context-guru:ping still says "restart Claude Code after the plugin update"

    • What fails: the PR fixes the wrong advice only in the mod toast (hooks/model.ts:123). cg.py ping prints Can't ping: restart Claude Code after the plugin update. for the same not opted in reason. That is the exact message #685 says leaves the user stuck. The Codex copy (codex-marketplace/.../cg.py:1235) has the same text. The comment above PING_REASONS says "The mod's toast says the same", which is now false.
    • Proof: grep -n "not opted in" context-guru-plugin/scripts/cg.py gives line 1235 with the old text. ping_test.go:224 and :239 still assert the old text, so the tests lock the wrong advice in.
    • Fix: change PING_REASONS["not opted in"] in both cg.py copies to the new words, and update ping_test.go:224 and :239.

Non-blocking

  • ping_header_state returns present for a user line x-context-guru-ping: 0. Doctor then shows "ok: Ping header is set" when Ping is off. Check the value, or say "set by you" in the doctor line.
  • The Codex copy of cg.py calls settings.py, but codex-marketplace/plugins/context-guru/scripts/ has no settings.py. _ping_header_state always returns unknown there, so the doctor check never shows. That is harmless, but it is dead code in the Codex plugin.
  • No test covers the new doctor check (present → ok, missing → warn, other states → no line).
  • cmd_ensure_ping_header heals every matching file, but it reports only the last state it sees. When two scopes are both missing, the note and file= name only one of them. This is fine for the note, but file= can mislead a caller.

What I checked

  • I read the full diff of 542df90 (8 files) and the commit message.
  • I read the code around each change: with_ping_header, add_ping_header, remove_ping_header, all six exits of cmd_add, cmd_remove's meta cleanup, save, user_scope_files, _read_install_scopes.
  • I read the start-proxy.sh flow before step (1a): the FORCE gate, the routed-port gate, note(). I checked that the heal call fails open: || ph_out_="", stderr is dropped, and the command always exits 0.
  • I read install.sh's --no-ping-header handling and ping_note consent text, and #667 (328064e) to find what an older --no-ping-header install wrote.
  • I read docs/data-dependence.md rows for Ping and keep-alive.
  • I read the new tests and the helpers they use (settingsInDir, sandboxEnv, headersOf), and the changed TestAnAlreadyRoutedProjectStillGetsAHatch fixture.
  • I read ping_test.go for the not opted in text.
  • I did not run tests. Live tests are not approved, and Go is not installed.

Review round 1 on #691.

- Heal only an install that provably predates --no-ping-header: its
  install-scope row is older than 2026-10-22 13:58:53 UTC. Print the
  consent words when it writes.
- Any other install with no record gets one note and no write.
- A line the user removed by hand (installed_ping_header present, line
  absent) is not added again.
- `add --no-ping-header` removes our recorded line in every write
  branch and records the opt-out.
- A user ping line that is not 1 is not "present".
- start-proxy.sh uses a grep before it starts python3.
- cg.py ping and its Codex copy use the new "not opted in" words.
- docs/data-dependence.md names the heal.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Round 1 is fixed in e645bf1. One reply per finding.

Reviewer 2

  1. Fixed. The heal writes only when the install-scope row for the file is older than the release of --no-ping-header (2026-10-22 13:58:53 UTC). Any other install with no record gets one note, no write. The heal prints the full consent words. The data-dependence change is now at the top of the PR body and in docs/data-dependence.md. The "Decided by" person must confirm.
  2. Fixed. add --no-ping-header removes our recorded line in all write branches. It records the opt-out and clears installed_ping_header. Tests: TestOptingOutAfterAHealRemovesOurLineOnly, TestOptingOutRemovesOurLineWhenTheInstallMoves.
  • Non-blocking, python3 start: fixed. A grep runs first. python3 starts only when a file has our routing record and no ping record.
  • Non-blocking, per-key env merge hides the healed line: not fixed. The case is rare. Doctor reads the file, not the live session. Open to a follow-up.
  • Non-blocking, misleading completed note on a plain opt-out re-run: partly fixed. The re-run now lists the header in added_keys when it removes the line. A no-op opt-out re-run is unchanged.

Reviewer 1

  1. Fixed, same change as R2 feat: Go context-engineering proxy/library (tree-sitter, TOON, Starlark extractor, config, metrics, real integrations) #1. Test: TestSessionStartKeepsAV054OptOutOff uses the v0.5.4 file shape. TestSessionStartDoesNotWriteWhenTheInstallCannotBeProvenOlder covers "no row" and "newer row" and the one-time note.
  2. Fixed. The heal prints the ping_note words. The PR body states the change at the top.
  3. Fixed. State removed (record present, line absent) is never healed. Test: TestSessionStartDoesNotReAddALineTheUserRemoved.
  4. Fixed. See R2 feat(engine): unify compaction under one Compactor abstraction; add summarizer + truncation; comprehensive stats #2.
  5. Fixed. PING_REASONS['not opted in'] has the new words in both cg.py copies. ping_test.go is updated.
  • Non-blocking, x-context-guru-ping: 0 counted as present: fixed. State user-off. Doctor warns.
  • Non-blocking, Codex copy has no settings.py: not fixed. The check shows nothing there, which is the safe result.
  • Non-blocking, doctor test: added (TestDoctorShowsThePingHeaderLine, TestDoctorPingCheck).
  • Non-blocking, only the last state is reported: partly fixed. The strongest state wins (a healed or missing file beats a present one).

@OsherElhadad OsherElhadad 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 @OsherElhadad) Claude Code 2.1.310 offload-review skill, @OsherElhadad's session resumed 2 of 2 2 of 2 e645bf159242 blocking

Verdict: blocking

Earlier findings

  • R2 #1 (heal reverses a v0.5.4 opt-out): fixed, with one gap. The heal now needs an install-scope row older than 2026-10-22 13:58:53 UTC (= 16:58:53 +0300 of 328064e, correct). It prints the full consent words. The PR body states the data-dependence change at the top. docs/data-dependence.md row "Keep-alive pings" is updated. The gap is new finding 1 below.
  • R2 #2 (opt-out does not remove a healed line): fixed. record_ping_choice now calls remove_ping_header and pops installed_ping_header in all three write branches. It removes only the line we recorded, so a user's own ping line stays. The unchanged clause now needs ping_header_opt_out and no installed_ping_header, so a re-run after an opt-out is a no-op. Tests TestOptingOutAfterAHealRemovesOurLineOnly and TestOptingOutRemovesOurLineWhenTheInstallMoves cover the completed and repointed branches.
  • R1 #1, #2: fixed (same change as R2 #1). TestSessionStartKeepsAV054OptOutOff uses the v0.5.4 file shape.
  • R1 #3 (a line the user removed comes back): fixed. New state removed. It is never healed. The start-proxy.sh grep also skips a file with installed_ping_header.
  • R1 #4: fixed (same as R2 #2).
  • R1 #5 (cg.py ping text): fixed in both cg.py copies. ping_test.go:224 and :239 now assert the new words.
  • Non-blocking items: I accept the author's replies. The per-key merge note stays open for a follow-up, and that is fine.

Findings

  1. context-guru-plugin/scripts/settings.py:3079-3091 — predates_ping_flag uses the FIRST row that names the file, not the newest. An old legacy row can still turn on Ping for a v0.5.4 opt-out.
    • What fails: install-scope.json can hold two rows for the same machine-wide file. The code says so: _machine_wide_record (settings.py:1667-1669) says "a file holding two such rows is a legacy row plus its migrated self". A user-scope record_install_scope "migrates nothing and drops nothing" (settings.py:1163-1168). So it writes a new row under user_scope_key() and leaves the legacy row under the project key. Example:
      1. Before user_scope_key() (f45697d, 2026-09-25), the user runs a machine-wide install from project P. The row goes under P, scope=user, file=~/.claude/settings.json, recorded_at in September.
      2. On v0.5.4 the user re-runs it with --no-ping-header. The v0.5.4 add writes no opt-out key. record_install_scope writes a new row under user_scope_key(), stamped after the cutoff. The P row stays, with its old stamp, and it comes first in the file.
      3. At SessionStart, predates_ping_flag loops _read_install_scopes().values() in file order. It finds the P row first and returns when < cutoff → True. The heal writes the header, and the user's opt-out is reversed.
    • Proof: settings.py:3083-3089 has return when < cutoff inside the loop, on the first match. Nothing compares it to later rows. cmd_port copies a legacy row to user_key with dict(mw_rec) (settings.py:2245-2249), so it keeps the OLD recorded_at. That is a second way to have an old stamp on a file that was installed again later. The tests write only one row (recordInstall), so they do not cover this.
    • Fix: look at every row whose file matches. Heal only when the NEWEST recorded_at is before the cutoff (or: all matching rows are tz-aware and before the cutoff). Add a test with two rows for the same file: one before the cutoff, one after. Expect no write and the one-time note.

Non-blocking

  • The data-dependence change still needs the confirmation from the "Decided by" person of the "Keep-alive pings" row before merge (CLAUDE.md). I see no such comment on the PR yet.
  • start-proxy.sh:336-345: the grep gate checks only the three fixed files. An install in a custom file (found by cmd_ensure_ping_header through the install-scope rows) does not start python3 unless one of the three files also passes the gate. That is the safe direction: no heal, no note.
  • PING_FLAG_SHIPPED is the author date of the squash commit. Anyone who installed from the #667 feature branch before that time looks "older". This is very rare, so I do not block on it.

What I checked

  • Last review: round 1, 542df90, 2026-10-25T10:04:31Z
  • New commits read: 1 (e645bf1 fix(plugin): ask before turning Ping on; opt-out removes the header)
  • 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 (10:05:55Z); I read all 5 findings and 4 non-blocking points, and I checked each fix above. The author's reply comment (10:16:30Z); I checked each reply against the code. The new commit e645bf1; I read the full diff of 7 files.
  • The full diff 542df90..e645bf1: settings.py, start-proxy.sh, both cg.py copies, ping_test.go, ping_selfheal_test.go, docs/data-dependence.md. I also read the PR body (new "Data dependence change" section).
  • Around the changes: record_install_scope (all of it), resolve_install_scope migration, _is_machine_wide_row, _machine_wide_record, the cmd_port write, remove_ping_header, all cmd_add branches with the new record_ping_choice(env, meta, ping_on).
  • ping_header_state states and the rank order in cmd_ensure_ping_header. The one-time note file (ping-header-note.json, mode 0600, fail-open). The consent text matches install.sh ping_note.
  • start-proxy.sh (1a): the grep gate, the note= parse, and fail-open (|| ph_out_="", stderr dropped, exit 0).
  • The 9 new and 7 changed Go tests. I did not run them: live tests are not approved, and Go is not installed.

@OsherElhadad OsherElhadad 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 @OsherElhadad) Claude Code 2.1.310 offload-review skill, @OsherElhadad's session resumed 1 of 2 2 of 2 e645bf159242 blocking

Verdict: blocking

Status of round-1 findings

  • R1 #1 (heal overrides a v0.5.4 opt-out): fixed for project installs. For a machine-wide install, a gap is left open. See new finding 1.
  • R1 #2 (no consent words, wrong data-dependence statement): fixed. PING_CONSENT has the ping_note words. The PR body states the change at the top. docs/data-dependence.md:215 names the heal. The "Decided by" person still has to confirm. That is a process step for the author, not a code defect.
  • R1 #3 (a removed line comes back): fixed. The removed state is never healed. The start-proxy.sh grep also skips a file that has installed_ping_header.
  • R1 #4 (a --no-ping-header re-run keeps our line): fixed. record_ping_choice calls remove_ping_header in all three write branches, and the unchanged gate now needs PING_HEADER_META to be absent.
  • R1 #5 (old words in cg.py): fixed in both copies, and ping_test.go is updated.
  • R2 #1: fixed, the same as R1 #1 and #2, with the same gap as new finding 1.
  • R2 #2: fixed, the same as R1 #4.
  • Non-blocking, my round 1: user-off is fixed. The doctor tests are added. I accept the Codex "shows nothing" reply. I accept the "strongest state wins" reply.
  • Non-blocking, R2's round 1: I accept the per-key env merge reply, because doctor reads files, not the live session.

Findings

  1. context-guru-plugin/scripts/settings.py:3082-3088 — predates_ping_flag trusts the first row that names the file, not the newest. A machine-wide v0.5.4 opt-out can still be healed.
    • What fails: a user made a machine-wide install before 2026-09-25 (f45697d, user_scope_key). That install filed its row under a project key, with scope=user, file=~/.claude/settings.json, and an old recorded_at. On v0.5.4 the user re-ran the machine-wide install with --no-ping-header. record_install_scope then wrote a new row under user_scope_key() with a stamp after the cutoff. The user-scope branch "migrates nothing and drops nothing" (settings.py:1163-1168), so the legacy row stays. port alloc also only copies a legacy row to user_key; it does not delete the old row (settings.py:2245-2250). The install-scope file now has two rows for one file: the legacy row first, because a new key is added at the end of the dict, and the new row second. predates_ping_flag returns on the first match, the old stamp, so the result is True. The next SessionStart writes the header, and the server holds the body and key for a user who opted out.
    • Proof: settings.py:3082-3088 loops _read_install_scopes().values() and does return when < cutoff on the first row whose file matches. _machine_wide_record's docstring (settings.py:1660-1670) says that this two-row shape ("a legacy row plus its migrated self") is a real, expected state. No test covers two rows for one file. recordInstall writes exactly one row.
    • Fix: use the newest recorded_at across all rows that match the file (max(...)), and heal only when that newest stamp is before the cutoff. A row without a parseable stamp should mean "do not heal". Add a test with two rows for one file: an old legacy row first and a new row second. Expect no write.

Non-blocking

  • start-proxy.sh:335-344: for an install that cannot be proved older, the file never gets a ping record. So the grep gate passes on every SessionStart, and python3 starts every session, only to find that the note was already seen. You could write a small marker into $context-guru (for example ping_header_note_shown), or add the seen file to the grep gate.
  • start-proxy.sh:335-337 greps only the three standard files. cmd_ensure_ping_header also reads the file of the install-scope rows (a custom --file install). For such an install, the shell gate never starts python3, so it is never healed or noted. This is safe, because it writes nothing, but the docs say "at its next session start".
  • TestDoctorShowsThePingHeaderLine: runCGCode sets CLAUDE_PROJECT_DIR to a temp dir, then appends CLAUDE_PROJECT_DIR=e.proj. The later value wins under Go's exec, so the test is correct. The test does not pin CLAUDE_CONFIG_DIR for the user file, but runCGCode already gives it a temp dir. OK.

What I checked

  • Last review: round 1, 542df90, 2026-10-25T10:05:55Z
  • New commits read: 1 (e645bf1 fix(plugin): ask before turning Ping on; opt-out removes the header)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review: the author's comment at 2026-10-25T10:16:30Z, with one reply per finding from both reviewers. I checked each reply against the code (see "Status of round-1 findings"). There are no new comments from other people.
  • I read the full diff 542df90..e645bf1 (7 files): settings.py, start-proxy.sh, both cg.py copies, ping_selfheal_test.go, ping_test.go, docs/data-dependence.md.
  • I read the code around each change: all write branches of cmd_add with the new record_ping_choice, remove_ping_header, ping_header_state, cmd_ensure_ping_header (the file list, the rank, the note), predates_ping_flag, ping_note_seen and mark_ping_note_seen.
  • I checked that every cmd_add exit (unchanged, completed, repointed, added) calls record_install_scope, so it updates recorded_at. That is true at HEAD and in v0.5.4. So for a project install, the stamp proof holds.
  • I read record_install_scope (settings.py:1114-1237), _is_machine_wide_row, _machine_wide_record, and the port alloc legacy-row move, to see when two rows can name one file.
  • I checked the cutoff: 2026-10-22 16:58:53 +0300 is 13:58:53 UTC, which matches 328064e.
  • I checked that the start-proxy.sh block fails open: || ph_out_="", stderr is dropped, and an empty note prints nothing.
  • I read the new tests and the helpers runCGCode and sandboxEnv.
  • I read the updated PR body (the data-dependence section at the top).
  • I did not run tests. Live tests are not approved, and Go is not installed.

Review round 2 on #691.

- predates_ping_flag looks at every row that names the file. It
  allows the heal only when all of them have a tz-aware recorded_at
  before the release of --no-ping-header. One newer or unreadable row
  means no write and one note.
- start-proxy.sh skips python3 once the note was shown for the file.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
@OsherElhadad

Copy link
Copy Markdown
Collaborator Author

Round 2 is fixed in the new commit.

Reviewer 2, finding 1, and Reviewer 1, finding 1 (same bug): fixed.

  • predates_ping_flag now reads every install-scope row that names the file.
  • It allows the heal only when all of them have a timezone-aware recorded_at before the cutoff.
  • One newer row, one unreadable row, or one date without a timezone means no write. The user gets the one-time note.
  • Tests: TestSessionStartDoesNotHealWhenAnyRowForTheFileIsNewOrUnreadable (old then new, new then old, old then garbage, old then naive) and TestSessionStartHealsWhenEveryRowIsOld.

Non-blocking

  • Reviewer 1, python3 starts every session after the note: fixed. The shell gate now also checks the seen-file, so python3 does not start again. I used the seen-file, not a $context-guru marker, so uninstall stays clean.
  • Custom-file installs are not seen by the shell gate: not changed. The result is safe (no write). The docs wording applies to the three standard files.
  • Release date of the flag from the squash commit: not changed. The case is rare.
  • Confirmation by the "Decided by" person: still open. It is a process step before merge.

@OsherElhadad
OsherElhadad merged commit 86c118b into main Oct 25, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Oct 25, 2026
amiddavid added a commit that referenced this pull request Oct 25, 2026
Main added #691 and #692. The only conflict was docs/data-dependence.md:
#691 added three sentences to the end of the "Keep-alive pings" row, and
this branch edits the "Body stash" row next to it. Main's keep-alive row
is kept as it is, and so is this branch's Body stash row.

Also, in the same commit, two small round-2 fixes:
- Delete spendHeld, which has no caller since the claim replaced it.
- Say that sweep_not_registered is counted at the request, not at a ping.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
OsherElhadad pushed a commit that referenced this pull request Oct 25, 2026
…0.2.5)

Both plugins changed in this release, so installed plugins must update.

- Claude Code plugin: 0.6.0 was set in #694. No change here.
- Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py
  and one skill changed in #512, #681, #683, #691, #694 and #698.

Assisted-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
amiddavid pushed a commit that referenced this pull request Oct 26, 2026
…0.2.5) (#701)

chore(plugin): bump the plugins for v0.6.0 (Claude Code 0.6.0, Codex 0.2.5)

Both plugins changed in this release, so installed plugins must update.

- Claude Code plugin: 0.6.0 was set in #694. No change here.
- Codex plugin: 0.2.4 to 0.2.5. The vendored cg.py and costly.py
  and one skill changed in #512, #681, #683, #691, #694 and #698.

Assisted-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Osher Elhadad <[email protected]>
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.

Ping says "restart Claude Code" but a restart never adds the x-context-guru-ping header

1 participant