Repository navigation
feat(codex): opt-in profile + launcher (no dead-proxy lock-out), doctor, onboarding, shared insights - #440
feat(codex): opt-in profile + launcher (no dead-proxy lock-out), doctor, onboarding, shared insights#440OsherElhadad wants to merge 4 commits into
Conversation
…lt provider; doctor, onboarding, shared insights A stopped proxy used to block Codex from starting because setup rewrote the default model_provider. Setup now writes only a context-guru profile file and a launcher that restarts the proxy or falls back to plain codex. Adds a SessionStart advisory hook, doctor and onboarding skills, and replaces the 128-line insights stub with the Claude plugin's insights engine (verbatim copy guarded by a drift test). Signed-off-by: Osher-Elhadad <[email protected]>
|
Reviewer: approved. python3 -m unittest test_codex_plugin test_insights: 41 OK; CI all pass; config.toml is only touched by the legacy-migration path (profile file is marker-checked before unlink); launcher falls back to plain codex; insights_core.py is byte-identical to context-guru-plugin/scripts/insights.py. Heads-up (non-blocking): the verbatim copy means the upcoming feat/plugin-insights redesign of insights.py will fail the drift test until insights_core.py is refreshed with the cp command in the test; the Python tests are not run in CI, so nothing will flag it automatically. Also consider trimming 'IBM gateway' and the model name from the PR body. |
OsherElhadad
left a comment
There was a problem hiding this comment.
Review: REQUEST CHANGES at b6f35b4. (Posted as a comment: GitHub does not let the author account request changes.)
Verified:
- On the PR head, the Codex plugin suite passes (41 tests) and CI is green. The commit is by Osher-Elhadad and signed off, with no AI attribution.
- No lock-out.
launch()runscodex --profile context-guruonly when the proxy is routed andrevive()succeeds; otherwise it warns and execs plaincodex. With that condition forced true, test_launch_falls_back_to_plain_codex_when_proxy_cannot_start fails. config.tomlis untouched; the profile and proxy config are written 0600 through a temp file andos.replace.
Blocking: after merging current main, test_core_is_a_verbatim_copy_of_the_claude_insights fails. Main has since changed context-guru-plugin/scripts/insights.py (637204a and 7836726, the cache_aware_summarizer presets), so codex-marketplace/.../scripts/insights_core.py is stale. Merge main into the branch and copy insights.py over insights_core.py again. The suite should then pass on the merged tree.
…hts.py Signed-off-by: Osher-Elhadad <[email protected]>
OsherElhadad
left a comment
There was a problem hiding this comment.
Re-check: APPROVE at 168867a. Main is merged in (075450f), and codex-marketplace/.../insights_core.py is again byte-identical to context-guru-plugin/scripts/insights.py, so the verbatim-copy test passes. CI is green (build-test, purego, trivy, DCO). 168867a is signed off. The merge commit 075450f has no sign-off, so squash-merge with an explicit subject and body. This approval covers 168867a.
Signed-off-by: Osher-Elhadad <[email protected]> # Conflicts: # codex-marketplace/plugins/context-guru/hooks.json # codex-marketplace/plugins/context-guru/scripts/codex_plugin.py # codex-marketplace/plugins/context-guru/scripts/test_codex_plugin.py
OsherElhadad
left a comment
There was a problem hiding this comment.
Re-review: APPROVE at 1df1aa6 (main merged; last approved 168867a).
- Conflicts.
git show --remerge-diff 1df1aa6dshows three, in the Codex plugin:- hooks.json. It parses as valid JSON. It keeps this PR's advisory
session-start-hook(SessionStart, no matcher) alongside main's signal hooks: SessionStart withcompact|resume|clear(async) and SessionEnd. - codex_plugin.py. It has the union of both command sets: setup, status, ensure, serve, signal, update, uninstall, configure, doctor, launch and session-start-hook.
signal_hookstill POSTs withContent-Type: application/json, as #520/#524 require. - The merged hook test. It asserts both halves: the first SessionStart hook is the advisory one, and every other hook is exactly
codex_plugin.py" signal. That keeps main's guarantee that the proxy lifecycle never depends on a sandboxed hook, with this PR's advisory hook as the single named exception.
- hooks.json. It parses as valid JSON. It keeps this PR's advisory
- Copy and tests.
insights_core.pyis still byte-identical to the Claude plugin'sinsights.py, on this head and on a local merge with today's main. On that merge, the Codex unittests pass (42), andgo vetand the plugin's Codex/Insights/Signal tests pass. CI is green, and the merge commit is signed off.
Non-blocking:
- The advisory hook's command leaves
${PLUGIN_ROOT}unquoted, while the signal hooks quote it, so a plugin root with a space breaks only the advisory hook. - The advisory hook can call
revive()from inside Codex's hook sandbox. That is harmless, since it is best effort and only prints a message.
This approval covers 1df1aa6.
…ad proxy cannot lock Codex out Setup no longer rewrites the default model_provider. It writes a Codex profile file and a launcher, context-guru-codex. The launcher checks the proxy, restarts the owned service, and runs codex --profile context-guru. If the proxy cannot start, it warns and runs plain codex. A legacy install is migrated back on the next setup. Adds a doctor command and skill, an advisory SessionStart hook and an onboarding skill. Strips a trailing /v1 from the provider base_url so the proxy upstream does not become /v1/v1/responses. Based on #440 by Osher Elhadad, without its insights copy. Refs #440 Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
…ests and a data-dependence row - The SessionStart hook never fails and no longer checks or restarts the proxy. A sandboxed hook may not reach loopback, so a failed check proved nothing. - Setup refuses to overwrite a profile file that is not managed (config_conflict). - The launcher refuses a user --profile, and names a missing profile apart from a dead proxy. - Uninstall removes the launcher. The doctor legacy fix points to context-guru-reset --yes. - Quote PLUGIN_ROOT in the hook. Fix the setup skill's file name. - Add tests for doctor, the hook, the profile guard and the launcher. - Add the docs/data-dependence row for the Codex plugin. Refs #440 Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
… and the conflict path - One write_record helper writes install.json atomically at 0600. All 7 write sites use it. - The README says the hook warns only when the launcher did not start the session. - A profile conflict prints the profile path, not the proxy.yaml path. Refs #440 Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
feat(codex): opt-in profile and launcher, doctor, onboarding, so a dead proxy cannot lock Codex out Setup no longer rewrites the default model_provider. It writes a Codex profile file and a launcher, context-guru-codex. The launcher checks the proxy, restarts the owned service, and runs codex --profile context-guru. If the proxy cannot start, it warns and runs plain codex. A legacy install is migrated back on the next setup. Adds a doctor command and skill, an advisory SessionStart hook and an onboarding skill. Strips a trailing /v1 from the provider base_url so the proxy upstream does not become /v1/v1/responses. Based on #440 by Osher Elhadad, without its insights copy. Refs #440 fix(codex): fail-open hook, refuse an unmanaged profile, add doctor tests and a data-dependence row - The SessionStart hook never fails and no longer checks or restarts the proxy. A sandboxed hook may not reach loopback, so a failed check proved nothing. - Setup refuses to overwrite a profile file that is not managed (config_conflict). - The launcher refuses a user --profile, and names a missing profile apart from a dead proxy. - Uninstall removes the launcher. The doctor legacy fix points to context-guru-reset --yes. - Quote PLUGIN_ROOT in the hook. Fix the setup skill's file name. - Add tests for doctor, the hook, the profile guard and the launcher. - Add the docs/data-dependence row for the Codex plugin. Refs #440 fix(codex): write install.json at mode 0600, fix the README hook text and the conflict path - One write_record helper writes install.json atomically at 0600. All 7 write sites use it. - The README says the hook warns only when the launcher did not start the session. - A profile conflict prints the profile path, not the proxy.yaml path. Refs #440 Behavior change (plain codex is no longer routed after setup; routing moves to the context-guru-codex launcher and an opt-in profile) approved by the owner in the integrator session: "1509 ok". Credential: the profile file and install.json hold the provider key at 0600 until #1512 moves it out; the owner accepted this. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Part of #436 (Workstream C). Tested against the real Codex CLI 0.162.1 (npm
@openai/codex), modelazure/gpt-5.5through the IBM gateway's Responses endpoint, proxy built from this branch on port 4125, isolated CODEX_HOME.Problems and changes
model_provider. Now setup writes only$CODEX_HOME/context-guru.config.toml(Codex >= 0.134 profile file;[profiles.x]in config.toml is rejected by 0.162) and a launchercontext-guru-codexthat health-checks the proxy, restarts its user service, runscodex --profile context-guru, and if the proxy cannot be brought up warns and runs plaincodex.config.tomlis never modified (byte-identical across setup and uninstall). A legacy install is migrated back on the next setup. A SessionStart hook cannot fix this (it runs after provider selection) so it is advisory only.insights_core.pyis a verbatim copy ofcontext-guru-plugin/scripts/insights.py(the Codex marketplace is a sparse checkout, so it cannot import across directories); a test fails on drift.insights.pysupplies the Codex port/options and rewrites fix commands to$context-guru-*.onboardingSkill,$context-guru-doctorskill andcodex_plugin.py doctor.base_urlending in/v1was passed as the proxy upstream, giving/v1/v1/responses-> 404 through the proxy. Now stripped.Before (origin/main plugin, same gateway config)
After
Also verified live: plugin installed through
codex plugin marketplace add+codex plugin add; Codex loaded the skill from the plugin cache and ran$context-guru-doctor; the SessionStart hook executes (with--dangerously-bypass-hook-trust; otherwise it waits for/hooksreview);insights.py allagainst the proxy after real routed traffic (125 lines, 5 requests, window/decl/keep-alive/component sections) vs the stub's 14 lines; uninstall removes the profile and stops the proxy (no process on 4125 afterwards).Not verified
systemMessagerendering in the TUI;codex execdoes not print it.Tests
cd codex-marketplace/plugins/context-guru/scripts && python3 -m unittest test_codex_plugin test_insights-> 41 tests OK (new: launcher routes / falls back, hook advisory, legacy migration, onboarding/doctor wiring, insights drift + Codex wording with a stub server).