GeezerVison is showing github.com — Merge pull request #980 from lidge-jun/codex/stack7-service-vision · lidge-jun/opencodex@7343f0b
File treeExpand file treeCollapse file tree Open diff view settings devlog/_plan/260804_stack7_service_vision
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: bin/ocx.mjs +55-13Lines changed: 55 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -134,20 +134,53 @@ function runNpmSelfUpdate() { | 134 | 134 | } | 135 | 135 |
| 136 | 136 | // Remember whether a background service manages the proxy BEFORE stopping — `ocx stop` | 137 | | - // unloads it permanently, so a successful update must reinstall it afterwards. | | 137 | + // unloads it, so a successful update must refresh and restart it afterwards. | 138 | 138 | const serviceStatePath = join(configDir(), "service-state.json"); | 139 | 139 | const serviceWasInstalled = existsSync(serviceStatePath); | 140 | 140 | const trayBeforeUpdate = planWindowsTrayUpdate( | 141 | 141 | process.platform === "win32" ? trayInstallState() : { installed: false, running: false }, | 142 | 142 | ); | 143 | | - /** Read the backend from service-state.json so the update reinstalls the same one. */ | 144 | | - function serviceReinstallArgs() { | | 143 | + /** | | 144 | + * Refresh the existing service without re-registering it. `service repair` discovers | | 145 | + * the installed backend itself and, on Windows scheduler installs, rewrites the wrapper | | 146 | + * assets and restarts the existing task without `schtasks /create` — the elevation a | | 147 | + * non-admin `ocx update` does not have. | | 148 | + */ | | 149 | + function serviceRefreshArgs() { | | 150 | + return [launcher, "service", "repair"]; | | 151 | + } | | 152 | + /** Register from scratch, preserving the recorded backend. Only for a genuinely absent service. */ | | 153 | + function serviceInstallArgs() { | 145 | 154 | try { | 146 | 155 | const state = JSON.parse(readFileSync(serviceStatePath, "utf8")); | 147 | 156 | if (state.backend === "native") return [launcher, "service", "install", "--native"]; | 148 | 157 | } catch { /* missing or corrupt — fall through to default */ } | 149 | 158 | return [launcher, "service", "install"]; | 150 | 159 | } | | 160 | + /** | | 161 | + * Structured "is a service actually registered?" answer. | | 162 | + * | | 163 | + * This file is plain Node ESM and cannot import `diagnoseService()` from the | | 164 | + * TypeScript runtime, so it asks the freshly-installed launcher — which runs that | | 165 | + * diagnostic under Bun — and reads `startup.serviceInstalled`. | | 166 | + * | | 167 | + * Returns `null` when the probe itself could not answer, which callers must treat as | | 168 | + * "unknown" rather than "absent": failing closed here means NOT re-registering. | | 169 | + */ | | 170 | + function readServiceInstalledFromStatus(launcherPath) { | | 171 | + try { | | 172 | + const st = spawnSync(process.execPath, [launcherPath, "status", "--json"], { | | 173 | + encoding: "utf8", | | 174 | + timeout: 20_000, | | 175 | + windowsHide: true, | | 176 | + }); | | 177 | + if (st.status !== 0 || typeof st.stdout !== "string" || !st.stdout.trim()) return null; | | 178 | + const installed = JSON.parse(st.stdout)?.startup?.serviceInstalled; | | 179 | + return typeof installed === "boolean" ? installed : null; | | 180 | + } catch { | | 181 | + return null; | | 182 | + } | | 183 | + } | 151 | 184 |
| 152 | 185 | // Capture listen target before stop clears runtime-port.json (mirrors GUI/CLI update worker). | 153 | 186 | // Do not treat a live runtime port of 10100 as "missing" — track whether the read succeeded. | @@ -241,15 +274,26 @@ function runNpmSelfUpdate() { | 241 | 274 | if (trayBeforeUpdate.restoreOnFailure) runTrayLifecycle(launcher, "start"); | 242 | 275 | } | 243 | 276 | } | 244 | | - // The stop above unloaded any managed service; reinstall via the freshly-installed | | 277 | + // The stop above unloaded any managed service; refresh via the freshly-installed | 245 | 278 | // launcher so the new files write the baked paths and the service restarts. | 246 | 279 | if (serviceWasInstalled) { | 247 | | - console.log("Reinstalling the background service with the updated files..."); | | 280 | + console.log("Refreshing the background service with the updated files..."); | 248 | 281 | const prevBake = process.env.OCX_BAKE_PORT; | 249 | 282 | process.env.OCX_BAKE_PORT = String(bakePort); | 250 | 283 | try { | 251 | | - const svcArgs = serviceReinstallArgs(); | 252 | | - const svc = spawnSync(process.execPath, svcArgs, { stdio: "inherit", windowsHide: true }); | | 284 | + let svc = spawnSync(process.execPath, serviceRefreshArgs(), { stdio: "inherit", windowsHide: true }); | | 285 | + // `serviceWasInstalled` is inferred from service-state.json alone, which can be | | 286 | + // STALE — present while the registration is gone. Repair refuses that case by | | 287 | + // design, and its thrown Error is indistinguishable from any other failure at | | 288 | + // this layer (plain Error, inherited stdio, generic exit status). So ask for | | 289 | + // structured state instead of parsing the failure: install only when the | | 290 | + // diagnostic says the service is genuinely absent. Installing after ANY repair | | 291 | + // failure would resurrect the elevation prompt this change exists to avoid, and | | 292 | + // could re-register a service the user just uninstalled. | | 293 | + if (svc.status !== 0 && readServiceInstalledFromStatus(launcher) === false) { | | 294 | + console.log("No registered service found — installing it instead."); | | 295 | + svc = spawnSync(process.execPath, serviceInstallArgs(), { stdio: "inherit", windowsHide: true }); | | 296 | + } | 253 | 297 | let needDirectStart = svc.status !== 0; | 254 | 298 | if (!needDirectStart) { | 255 | 299 | // Exit 0 can still leave stale/missing assets that never bring the proxy | @@ -274,17 +318,15 @@ function runNpmSelfUpdate() { | 274 | 318 | } | 275 | 319 | } | 276 | 320 | if (needDirectStart) { | 277 | | - // On Windows, schtasks /create requires elevation. The launcher inherits the | 278 | | - // user's (non-admin) token, so the service reinstall can fail with access | 279 | | - // denied — or exit 0 while leaving a non-viable manager. Fall back to a | 280 | | - // direct detached proxy start so the update never leaves the user without | 281 | | - // a running proxy. | | 321 | + // A repair needs no elevation, but it can still fail — or exit 0 while leaving | | 322 | + // a non-viable manager. Fall back to a direct detached proxy start so the | | 323 | + // update never leaves the user without a running proxy. | 282 | 324 | console.warn( | 283 | 325 | svc.status === 0 | 284 | 326 | ? "opencodex: service refresh left a non-viable manager — starting the proxy directly instead." | 285 | 327 | : "opencodex: service refresh failed — starting the proxy directly instead.", | 286 | 328 | ); | 287 | | - console.warn(" Run 'ocx service install' as administrator to refresh the background service."); | | 329 | + console.warn(" Run 'ocx service repair' to see why the background service could not restart."); | 288 | 330 | const env = { ...process.env }; | 289 | 331 | delete env.OCX_SERVICE; | 290 | 332 | const child = spawn(process.execPath, [launcher, "start", "--port", String(bakePort)], { | |
Collapse file Copy file name to clipboard +95Lines changed: 95 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# 000 — Scope: stack layer 7, the two real-but-off-theme contributor bugs | | 2 | + | | 3 | +## Objective | | 4 | + | | 5 | +Two overnight contributor pull requests describe real defects that the #951–#973 | | 6 | +stack does not touch. Both were left open at the end of the overnight triage | | 7 | +(`devlog/_plan/260804_overnight_triage/000_dispositions.md`) with "real, | | 8 | +independent, own review track" as the verdict. This unit turns that verdict into | | 9 | +a seventh stack layer, reconstructed here, and closes the source pull requests | | 10 | +as superseded. | | 11 | + | | 12 | +| Source PR | Author | Issue | Defect | | | 13 | +|---|---|---|---| | | 14 | +| #964 | @Yuxin-Qiao | #956 | NVIDIA NIM text-only models never activate the vision sidecar | | | 15 | +| #970 | @stephen-drew | — | `ocx update` re-registers the background service from a non-elevated updater | | | 16 | + | | 17 | +A third item was added after the roadmap cycle opened, at the user's request: | | 18 | +renaming `qwen3.8-max-preview` to the now-stable `qwen3.8-max` and replacing its | | 19 | +reseller-proxy price overlay with Alibaba's published $2/$6 rate (`040`). | | 20 | + | | 21 | +Layer 7 is the last layer. After it lands the stack merges bottom-up from #952 | | 22 | +and every issue a landed layer resolves gets closed with its merge commit named. | | 23 | + | | 24 | +## Baseline | | 25 | + | | 26 | +Measured 2026-08-04. `origin/dev` at `af3ddedb4` — layer 1 (#951) is **merged**, | | 27 | +so the chain is now six open layers, not six-of-six pending: | | 28 | + | | 29 | +| PR | Branch | Base | State | | | 30 | +|---|---|---|---| | | 31 | +| #951 | `codex/bug-stack-plan` | `dev` | **merged** `af3ddedb4` | | | 32 | +| #952 | `codex/908-long-context-pricing` | #951's branch | open | | | 33 | +| #953 | `codex/carry-contributor-bugfixes` | #952 | open | | | 34 | +| #954 | `codex/545-classifier-thinking-disabled` | #953 | open | | | 35 | +| #955 | `codex/915-cooldown-recovery-probe` | #954 | open | | | 36 | +| #973 | `codex/stack6-overnight-triage` | #955 | open | | | 37 | +| **new** | `codex/stack7-service-vision` | #973 | this unit | | | 38 | + | | 39 | +Titles currently read `stack N/6` and must be renumbered to `N/7`. | | 40 | + | | 41 | +## Why these two are reconstructed rather than carried | | 42 | + | | 43 | +The overnight unit carried six contributor fixes verbatim with `git cherry-pick -x` | | 44 | +because the code was right and only the base was wrong. These two are different: | | 45 | +each has a design defect that a straight cherry-pick would import. | | 46 | + | | 47 | +**#964** classifies NVIDIA NIM models with a hand-written ~64-entry allowlist, and | | 48 | +**six** entries are backwards: `thinkingmachines/inkling`, | | 49 | +`minimaxai/minimax-m3`, `moonshotai/kimi-k2.6`, `moonshotai/kimi-k2.5`, | | 50 | +`stepfun-ai/step-3.7-flash`, and `mistralai/mistral-medium-3.5-128b` are natively | | 51 | +image-capable per NVIDIA's own documentation. Listing them makes the proxy | | 52 | +substitute another model's text description for an image the model could have | | 53 | +read — silent quality loss, no error. Issue #956's own body carries two of the | | 54 | +same errors, so reporter and author shared the premise. | | 55 | + | | 56 | +A per-id audit of the whole list (`011`) found only 26 of ~64 entries verifiable | | 57 | +as text-only; 32 are absent from NVIDIA's current catalog and are dropped. | | 58 | + | | 59 | +Two attempts to replace the list *shape* were then falsified at the audit gate | | 60 | +(`001`, `002`), and the root cause is recorded in `002`: NIM is the first | | 61 | +provider here asked to classify over an unbounded model set, and it publishes no | | 62 | +modality metadata, so an unknown id carries no signal at all. The landed design | | 63 | +fixes the known ids and states the open-world gap as a limitation rather than | | 64 | +claiming a mechanism that does not work. | | 65 | + | | 66 | +**#970** switches the post-update service refresh from `install` to `repair`. | | 67 | +`repairService()` and `ocx service repair` **already exist** in this tree | | 68 | +(`src/service.ts:1755`, `src/service.ts:2526`), so the real change is a handful of | | 69 | +call sites and a pile of advice strings — not the 522-line diff the PR carries. | | 70 | +More importantly `repairService()` throws when the service is not installed, and | | 71 | +the update path runs *after* `ocx stop`. Whether that substitution is safe on all | | 72 | +three platforms is a correctness question the PR does not answer, and it is | | 73 | +answered in `020` before any code is written. | | 74 | + | | 75 | +## Non-goals | | 76 | + | | 77 | +- #961 is an enhancement (provider custom headers via PATCH), already labeled | | 78 | + `enhancement` by the triage bot and confirmed unchanged. No code, no relabel. | | 79 | +- #966 stays open with its two surviving falsifications; the author may push | | 80 | + corrections. | | 81 | +- #907 stays blocked on `lidge-jun/jawcode`; nothing in this unit touches it. | | 82 | +- No push to `dev`, `preview`, or `main`. Layer 7 is a `codex/` branch like the | | 83 | + rest of the stack. | | 84 | + | | 85 | +## Documents | | 86 | + | | 87 | +| Doc | Contents | | | 88 | +|---|---| | | 89 | +| `001_audit_response.md` | A-gate FAIL — five blockers, synthesis, and what changed | | | 90 | +| `002_audit_response_r2.md` | A-gate FAIL round 2 — root cause and the design that follows | | | 91 | +| `003_audit_response_r3.md` | A-gate FAIL round 3 — a sixth false positive changes the method | | | 92 | +| `010_nim_vision_classification.md` | #964 reconstruction — the classification design and its diff | | | 93 | +| `011_nim_id_audit.md` | per-id verification of #964's list: 26 ship, 6 reversed, 32 dropped | | | 94 | +| `020_service_repair_path.md` | #970 reconstruction — call-site inventory and the after-stop safety proof | | | 95 | +| `030_merge_and_close_sequence.md` | bottom-up merge order, retargeting, and issue closure evidence | |
Collapse file Copy file name to clipboard +114Lines changed: 114 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +# 001 — Audit response: five blockers, all accepted | | 2 | + | | 3 | +The A-gate reviewer returned **FAIL** on the first roadmap. Every blocker was | | 4 | +independently reproduced before being accepted; none was rebutted. This document | | 5 | +records the synthesis, per REVIEW-SYNTHESIS-01, before the plan was re-patched. | | 6 | + | | 7 | +## B1 [P0] — the inverted list does not default to sidecar-on | | 8 | + | | 9 | +**Claim:** `010`'s central justification is false. A complement taken over a | | 10 | +static `NVIDIA_NIM_CHAT_MODELS` leaves an unclassified id in *neither* list, so | | 11 | +`modelInList` returns false (`src/types.ts:204`), `planVisionSidecar` returns | | 12 | +`undefined` (`src/vision/index.ts:235`), and the catalog advertises no image | | 13 | +modality (`src/codex/catalog/provider-fetch.ts:176`). | | 14 | + | | 15 | +**Reproduced.** `.tmp/probe_complement.ts`, modelling the exact proposed shape: | | 16 | + | | 17 | +```console | | 18 | +deepseek-ai/deepseek-v4-flash sidecarWouldRun=true | | 19 | +moonshotai/kimi-k2.6 sidecarWouldRun=false | | 20 | +brandnew/model-nobody-classified sidecarWouldRun=false <-- #956 persists | | 21 | +``` | | 22 | + | | 23 | +**Accepted.** I inverted which list is maintained but kept the closed world. The | | 24 | +failure I claimed to have fixed survives verbatim for any id NVIDIA adds after | | 25 | +the snapshot. This is the same lesson as the three earlier allowlist failures in | | 26 | +this session, and I reproduced it while writing the document that cites them. | | 27 | + | | 28 | +**Root cause:** the classification field is membership-in-a-list, so any design | | 29 | +expressed purely as list contents inherits closed-world semantics. Escaping it | | 30 | +requires changing the *predicate*, not the lists. | | 31 | + | | 32 | +## B2 [P0] — verified vision models stay unusable from the Codex app | | 33 | + | | 34 | +**Claim:** removing a native-vision id from `noVisionModels` is not enough. | | 35 | +`applyProviderConfigHints` adds `image` to `inputModalities` only for | | 36 | +`noVisionModels` members (`provider-fetch.ts:176`), and NIM `/v1/models` carries | | 37 | +no modality metadata. So kimi-k2.6 et al. end up advertised text-only and the | | 38 | +Codex app blocks attachments before their native path can run. | | 39 | + | | 40 | +**Accepted.** `010` explicitly asserted the catalog "does not fabricate" image | | 41 | +capability for these ids and treated that as correct. It is a second bug, not a | | 42 | +neutral outcome: #964 makes them lossy, my first design makes them blocked. | | 43 | + | | 44 | +**Fix:** verified native-vision ids need explicit | | 45 | +`modelInputModalities[id] = ["text","image"]`, asserted against the emitted | | 46 | +catalog payload rather than against `undefined`. | | 47 | + | | 48 | +## B3 [P0] — the Windows GUI updater never reaches the refresh command | | 49 | + | | 50 | +**Claim:** `src/update/job.ts:775-790` sets `skipServiceInstall = true` | | 51 | +unconditionally when `process.platform === "win32" && OCX_SERVICE === "1"`. | | 52 | +Changing the argv cannot affect a command that is never spawned. | | 53 | + | | 54 | +**Verified in source.** The skip's own comment states the reason: "`schtasks | | 55 | +/create` will UAC-fail and can race the subsequent direct start." | | 56 | + | | 57 | +**Accepted, and it strengthens the change.** That skip is a workaround for | | 58 | +exactly the defect #970 reports. `repair` does not call `/create` | | 59 | +(`src/service.ts:1775-1785`), so the justification for skipping evaporates — | | 60 | +the skip must be narrowed to the install argv rather than left in place. Without | | 61 | +this, the dashboard-triggered Windows update, the most common GUI path, keeps | | 62 | +the bug while the CLI path gets fixed. | | 63 | + | | 64 | +## B4 [P1] — the stale-marker fallback has no discriminator | | 65 | + | | 66 | +**Claim:** `repairService()` throws plain `Error` for unsupported, conflict, | | 67 | +ownership, auth, absent-registration, asset-write, start, and health failures | | 68 | +alike (`src/service.ts:1755-1770`). `bin/ocx.mjs` spawns with inherited stdio and | | 69 | +sees only an exit status (`bin/ocx.mjs:251`), so "not installed" is | | 70 | +indistinguishable from any other failure. | | 71 | + | | 72 | +**Accepted.** My proposed "repair, fall back to install on not-installed" was | | 73 | +unimplementable as written. Broadening it to "install after any repair failure" | | 74 | +would reintroduce the UAC path and could re-register a service the user had | | 75 | +deliberately uninstalled concurrently. | | 76 | + | | 77 | +**Fix:** do not infer from the failure at all. Re-run a structured diagnostic | | 78 | +(`diagnoseService()`) after a failed repair and install only when it reports the | | 79 | +service genuinely absent while the managed-service marker still expresses intent. | | 80 | +State beats error-message parsing. | | 81 | + | | 82 | +## B5 [P1] — retargeting produces no fresh CI evidence | | 83 | + | | 84 | +**Claim:** `.github/workflows/ci.yml` uses default `pull_request` activity types | | 85 | +(`opened`/`synchronize`/`reopened`). A base edit emits `edited`, which is not | | 86 | +among them. So after retargeting a stacked child to `dev`, `gh pr checks` can | | 87 | +show green checks bound to the same head sha that were never run against the new | | 88 | +merge base. Material because `dev` is well ahead of the stacked heads. | | 89 | + | | 90 | +**Accepted.** `030` said "re-read CI on the exact head sha", which I framed as | | 91 | +the rigorous option. It is necessary but not sufficient: sha identity does not | | 92 | +imply base identity. | | 93 | + | | 94 | +**Fix:** after retargeting, merge current `dev` into the child to force a | | 95 | +`synchronize` event, and require a run whose base matches the retargeted PR | | 96 | +before merging. | | 97 | + | | 98 | +## Sequencing change this forces | | 99 | + | | 100 | +`030` closed #964 and #970 when stack 7 *opens*, mirroring the earlier carried | | 101 | +PRs. Those were closed with replacement code already on a branch. Here the | | 102 | +replacement does not exist yet and its design just failed audit, so closing now | | 103 | +would remove the contributor's live path while ours is unproven. | | 104 | + | | 105 | +**Changed:** both close only after stack 7 is open **and** green. This | | 106 | +contradicts the sequencing written in the first draft of `030`; the earlier text | | 107 | +was wrong and is corrected there. | | 108 | + | | 109 | +## What survived | | 110 | + | | 111 | +`020`'s after-stop safety proof — that `ocx stop` never deregisters on any of the | | 112 | +three platforms — was independently re-derived and holds | | 113 | +(`src/service.ts:2204-2225`, with `uninstall`/`remove` as separate paths at | | 114 | +`:2610`). It remains the foundation of the #970 reconstruction. |
|