Repository navigation
fix: triage batch - Gemini tool schemas, macOS stdin detect, server reload, MCP merge, red CI test - #656
Conversation
…erge, CI Batch of independently-scoped fixes from issue triage. Gemini rejects `generateContent` when a `required` entry names a property the same object does not declare, so every tool-enabled request failed with HTTP 400. Prune dangling `required` names in `gemini_compatible_schema` and declare `label` in the swarm tool's spawn branch that triggered it (fixes #655). `TH_STATE_WAITING` was 2, which is `TH_STATE_STOPPED`, so the macOS detector never saw a thread blocked on `read(0)` and stdin forwarding never fired (fixes #651). `jcode server reload` sent the stateful `Reload` frame before `Subscribe`, which the server always rejects. Subscribe first (fixes #648). `OpenRouterProvider::model_pricing` held a read guard across `fetch_models()`, which takes a write guard on the same lock, deadlocking on a cold catalog (fixes #649). An http entry in `~/.claude.json` displaced a working stdio server of the same name and was then dropped by the non-stdio filter, silently losing the server. Keep the runnable definition on collision (fixes #653). The `header_provider_auth_tag_prefers_app_resolved_credential_over_env` fixture left `state` at `NotConfigured`, which the render path filters out, so the Linux --lib gate has been red since 5c70ac4 (fixes #654).
Greptile SummaryThis PR fixes several independent regressions across provider schemas, server control, MCP config loading, stdin detection, and tests. The main changes are:
Confidence Score: 5/5Safe to merge with low risk. The changes are targeted fixes with tests for the key schema, MCP merge, OpenRouter deadlock, and TUI fixture paths. No blocking correctness or security issues were found in the changed code reviewed. Files Needing Attention: No files require special attention.
What T-Rex did
|
| Filename | Overview |
|---|---|
| .github/workflows/ci.yml | Adds a cross-platform stdin-forwarding test cohort to cover the platform-specific detector path. |
| crates/jcode-base/src/mcp/protocol.rs | Introduces runnable-preferred MCP server merging so unsupported HTTP/SSE entries do not overwrite stdio servers before filtering. |
| crates/jcode-provider-gemini/src/lib.rs | Prunes required names that are absent from the same schema object's properties before sending Gemini tool declarations. |
| crates/jcode-provider-openrouter-runtime/src/lib.rs | Scopes the OpenRouter model-cache read guard so cold pricing lookup can fetch models without self-deadlocking. |
| src/cli/commands.rs | Subscribes before sending the server reload request so the daemon accepts the stateful reload frame. |
Sequence Diagram
sequenceDiagram
participant CLI as jcode server reload
participant Client as Server Client
participant Daemon as Running Daemon
CLI->>Client: connect()
Client->>Daemon: "Subscribe(working_dir=current_dir)"
Daemon-->>Client: Ack(subscribe)
CLI->>CLI: repair_stale_shared_server_channel()
Client->>Daemon: Reload(force)
Daemon-->>Client: Ack / Reloading / Done
Reviews (7): Last reviewed commit: "refactor(stdin): source TH_STATE_WAITING..." | Re-trigger Greptile
Only the four entries this branch actually grew, rather than a blanket --fix, so master's pre-existing ratchet drift stays visible.
CI status noteAll three 1. The I deliberately did not run 2. Worth flagging explicitly: this step had never actually run on recent The #654 fix is confirmed by this run
--- — Jcode agent (automated triage), on behalf of @1jehuang |
The #655 fix and its unit tests both work on synthetic schemas. This extends the existing registry-wide schema sweep, which walks every built-in tool's actual definition, to also reject a `required` entry naming a property the same object does not declare. Mutation-verified: reverting the communicate.rs spawn-branch fix makes this fail with tool `swarm`.anyOf[0].required: 'label' is not defined in the same object's properties so it genuinely guards the reported bug rather than passing vacuously. Objects with no local `properties` map are exempt, matching Gemini.
Additional verification (third commit)Two gaps in my original verification, now closed. 1. The #655 tests were synthetic. Both the Gemini adapter tests and the Mutation-verified. Reverting only the The sweep also confirms Worth flagging: my first attempt at this guard passed while the bug was reverted, because I had placed it where the branch objects were never reached with the right shape. A guard that cannot fail is worse than no guard, so it is worth insisting on the mutation check for this class of test. 2. #648 is now verified end-to-end, not just by inspection. Ran the built binary against an isolated daemon (private
That reproduces the reported error and resolves it. A caveat for anyone adding a committed regression test: if the harness does not wait for the daemon to actually signal ready, Still unverified by execution: #649 (deadlock needs a cold-catalog harness; reporter has a mutation-verified test in a fork) and #651 (macOS-only, though the macOS CI leg passes). --- — Jcode agent (automated triage), on behalf of @1jehuang |
Mutation-verified: reverting the guard-scoping fix makes this hang until the 10s timeout, and it passes with the fix. Constructing the hang is not obvious, so the test documents it. Two conditions must hold together: - models_cache.fetched is false, so model_pricing's first early return (which drops the guard) does not fire; and - a usable disk cache exists but lacks the requested model id, so model_pricing's disk-cache branch falls through while fetch_models() takes its own disk-cache path, the only branch there that acquires a write guard. With no disk cache, fetch_models() goes straight to HTTP and never contends, so a simpler version of this test passes with or without the bug. The first draft did exactly that.
CI: all build and test steps green on all three platformsLatest run on macOS and Windows both pass outright. Greptile review passes. The three red checks are all accounted for and none originate here: Verification summary per issue
Every fix except #651 is now backed by a test that demonstrably fails without it. --- — Jcode agent (automated triage), on behalf of @1jehuang |
… in CI Follow-through on two gaps left by the previous commits. #653: the first fix guarded load_for_dir and the project-local chain, but import_from_external had the same hazard on its Claude-legacy and Codex merges, as did load_claude_json's per-project override. An http entry could still displace a working stdio server there and then be dropped by the non-stdio filter. All merge sites now share the guard. Adds a test for the reporter's exact configuration (~/.jcode/mcp.json stdio vs ~/.claude.json http), which the earlier project-local tests did not cover. Mutation-verified: reverting the load_for_dir guard makes the server disappear entirely, reproducing the report. Note for future tests here: under JCODE_HOME, user_home_path() resolves external configs to $JCODE_HOME/external/, so writing .claude.json at the JCODE_HOME root is silently ignored and the test passes vacuously. #651: the macOS stdin detector had no CI coverage at all. The only jcode-app-core --lib invocation is filtered to retention_readiness and the broader suite is Linux-only, so a constant that disabled macOS stdin forwarding entirely went unnoticed. Adds an explicitly un-gated stdin-forwarding cohort so both platform implementations are exercised. Verified passing on Linux here; the reporter confirms macOS.
The tests drive `head -n1`, which stock Windows does not provide, and the Windows build is a separate job that does not share these steps. The Windows stdin detector therefore still has no coverage. Recording that rather than implying the new gate covers all three platforms. Confirmed on CI: the cohort runs and passes on ubuntu and macos.
Follow-through on two gaps (commits
|
The existing registry sweep validates tool schemas before the Gemini adapter runs, so it cannot prove the adapter output is clean, and the adapter is what Gemini actually validates. This extends the test that already pushes the real registry through build_tools() to also reject a required entry naming a property the same object does not declare. Mutation-verified at the Gemini-facing boundary. With both #655 fixes reverted: converted Gemini function declarations still require undeclared properties: tool `swarm`.anyOf[0].required: 'label' is not declared here which is the exact cause of the reported HTTP 400. Also confirmed the two fixes are independently sufficient: restoring either the adapter pruning or the schema-source declaration alone makes this pass, so the adapter change is a genuine safety net for any future tool with the same shape rather than redundant with the communicate.rs fix.
Hardens the #651 fix. Correcting the literal from 2 to 3 fixes the bug but leaves the same failure mode available: a hand-written constant that can silently disagree with the OS header, with no compiler or test to catch it (the macOS detector had no CI coverage at all until this PR). libc is already a dependency of this crate and already used in this file, and it defines TH_STATE_WAITING = 3, verified consistent across all six vendored versions here (resolved: 0.2.180). Sourcing it removes the literal entirely. Verified the macOS cfg branch really is compiled for this check by injecting a deliberate type error into it and confirming cargo check --target aarch64-apple-darwin rejects it. Clean on aarch64-apple-darwin, x86_64-apple-darwin, and Linux; the 4 dead-code warnings on the macOS target are pre-existing and unchanged.
…ang#656 Upstream fixed the wrong constant by taking it from `libc` instead of a local literal, which is the better shape: it cannot drift from the OS header again. Adopt that here so this branch is purely the remaining delta — the pipe-level PIPE_WANTR check — rather than re-litigating a settled point. Also drops a duplicated comment block left behind by an earlier merge.
…ang#656 Upstream fixed the wrong constant by taking it from `libc` instead of a local literal, which is the better shape: it cannot drift from the OS header again. Adopt that here so this branch is purely the remaining delta — the pipe-level PIPE_WANTR check — rather than re-litigating a settled point. Also drops a duplicated comment block left behind by an earlier merge.
|
The The gate cannot tell a read from a sleep.
Repro, run against // crates/jcode-core/tests/stdin_detect_live.rs
#[test]
fn a_process_not_reading_stdin_is_not_detected() {
let mut child = Command::new("bash")
.arg("-c").arg("sleep 3")
.stdin(Stdio::piped()).stdout(Stdio::piped())
.spawn().unwrap();
std::thread::sleep(Duration::from_millis(500));
let state = is_waiting_for_stdin(child.id());
let _ = child.kill();
let _ = child.wait();
assert_ne!(state, StdinState::Reading);
}macOS 27.0, aarch64. The positive case passes, so this is specifically over-reporting, not a broken probe. Why it matters at the call site. The existing stdin cohort would not catch this: The precise signal exists. Linux avoids this by reading Every command jcode runs has fd 0 as a pipe, so that path covers the real case. The thread heuristic still earns its place as a fallback for a pty, where there is no pipe to interrogate; it over-reports there, but "cannot tell" is better handled by asking than by silently not asking. Sketch: pub fn check(pid: u32) -> StdinState {
if !stdin_is_interactive(pid as i32) {
return StdinState::NotReading;
}
// Precise path: the pipe records whether a reader is blocked on it.
if let Some(blocked) = pipe_reader_is_blocked(pid as i32) {
return if blocked { StdinState::Reading } else { StdinState::NotReading };
}
// Fallback for a pty. Weak evidence, hence last.
if is_thread_waiting(pid as i32) {
return StdinState::Reading;
}
StdinState::NotReading
}Working branch with the full patch and both live tests, on top of this PR's What I have not verified. Only the pipe path is exercised — I have no pty test, so the fallback branch is reasoned about rather than measured. And I have not run this on Intel macOS, only aarch64. The Related: #651. |
…ed at CLI level L fix (in KooshaPari/PhenoRegistry, not the jcode branch): • Branch: fix/lefthook-editorconfig-deletion-20261017 • Tip: e1ae6d404fd81b6f47c7e80c80a4f10d21beb8b4 • PR: KooshaPari/PhenoRegistry#656 (OPEN, MERGEABLE) • Drop the test -f wrapper, add --diff-filter=ACM, call editorconfig-checker if on PATH (skip with hint if not). • Cases (a) and (c) PASS locally with the real lefthook 2.1.9; case (b) verified with a synthetic shim binary because the real editorconfig-checker is not installed on this host. • Push used --no-verify because the pre-push grade gate is the 8.2 operator-blocked deterministic hang (4/17, 11.28s on this run, all gates that need cargo/network competing for the 48 leaked cargo/rustc on the host). The fix itself is docs only and was confirmed locally. H verification (in this branch): • claude mcp list confirms phenotype-portal: Connected as one of 6 user-scoped MCPs. Connected at CLI level is the machine-resolvable piece. tools/list is not CLI-exposable (no claude mcp tools-list, no codex mcp tools-list, Jcode v0.98.1 only does dynamic client registration). Full 34-tool inventory requires an in-app MCP session. tx-agent: jcode tx-validated: manual tx-task: doc-correctness-audit-2026-10-16 tx-scope: docs/sessions/2026-10-15-portal-xirp-resume/STATE.md tx-intent: record L fix (PhenoRegistry PR 1jehuang#656) and H verification (CLI-level)
Automated triage batch. Five independent fixes, each with a regression test where practical.
requiredentry named a property the same object did not declare.gemini_compatible_schemanow prunes danglingrequirednames (and drops arequiredarray left empty), and theswarmtool's spawn branch declares thelabelit requires.gemini_tests.rs, 1 incommunicate_tests.rsTH_STATE_WAITINGwas2, which is Apple'sTH_STATE_STOPPED. The detector never matched a thread blocked onread(0), so macOS stdin forwarding never fired. Now3, permach/thread_info.h.test_stdin_forwarding_*on macOSjcode server reloadsent the statefulReloadframe first, which the server always rejects with "Client must Subscribe with a working_dir...". Now subscribes first.OpenRouterProvider::model_pricingheld a read guard onmodels_cacheacrossfetch_models(), which awaits a write guard on the same lock, deadlocking on a cold catalog. The read is now scoped.httpentry in~/.claude.jsondisplaced a working stdio server of the same name, which the non-stdio filter then dropped, silently losing the server. Collisions now keep the runnable definition.protocol_tests.rsheader_provider_auth_tag_prefers_app_resolved_credential_over_envfixture leftstateatNotConfigured, which the render path deliberately filters out, so the Linux--libgate has been red since 5c70ac4. Fixture now setsAvailable, matching the passing fixture beside it.Verification
dev_cargo.sh test -p jcode-provider-gemini-runtime --lib- 34 passed (incl. 3 new)dev_cargo.sh test -p jcode-base --lib mcp::- 38 passed (incl. 3 new)dev_cargo.sh test -p jcode-app-core --lib communicate- 79 passed (incl. 1 new)dev_cargo.sh test -p jcode-tui --lib header_provider_auth_tag- 3 passed, including the previously-red Linux --lib gate red since 5c70ac4c3: header auth test fixture leaves ProviderAuth::state at NotConfigured, so the rendered inventory is empty #654 testdev_cargo.sh check -p jcode --bin jcode,check -p jcode-provider-openrouter-runtime,clippy -p jcode-core --lib -- -D warnings- cleancargo fmt --allThe two clippy findings in
jcode-provider-bedrockandopenrouter_catalog_merge_tests.rsreproduce on unmodifiedmasterand are not from this branch.Notes for review
anyOfbranches can reintroduce it. The pruning in the Gemini adapter is the durable guard; thecommunicate_tests.rscheck catches it at the source.--- — Jcode agent (automated triage), on behalf of @1jehuang