Skip to content

fix(tests): use CARGO_BIN_EXE_kcode in cli_exit_status.rs - #152

Merged
KooshaPari merged 2 commits into
masterfrom
fix/cli-exit-status-kcode-bin
Nov 5, 2026
Merged

KooshaPari merged 2 commits into
masterfrom
fix/cli-exit-status-kcode-bin

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

User description

Closes #151

Summary

tests/cli_exit_status.rs on master does not compile after the
jcode -> kcode bin-target rename because it references
env!("CARGO_BIN_EXE_jcode"), which cargo does not define. This PR
fixes that by using the correct compile-time variable,
env!("CARGO_BIN_EXE_kcode"), and brings the rest of the file in line
with the fork's CLI reality (KCODE_HOME, kcode version banner).

Root cause

The root package has both a library target and a binary target:

[lib]
name = "jcode"
path = "src/lib.rs"

[[bin]]
name = "kcode"
path = "src/main.rs"

cargo sets CARGO_BIN_EXE_<NAME> per bin target name. Because the
binary is kcode and the library is jcode, CARGO_BIN_EXE_jcode does
not exist and env!("CARGO_BIN_EXE_jcode") is a compile-time error.
Every other integration test in the repo already uses the correct
spelling (tests/e2e/binary_integration.rs, tests/api_stdio_cli.rs,
tests/e2e/windows_lifecycle.rs).

The fork residue in the same file also affects two assertions:

  • JCODE_HOME -> KCODE_HOME (canonical fork env var; the only
    JCODE_HOME reference in src/ and crates/ is this broken test).
    See crates/jcode-storage/src/lib.rs::jcode_dir, which reads
    std::env::var("KCODE_HOME"), and crates/jcode-build-support/src/paths.rs,
    which reads KCODE_HOME.
  • .starts_with("jcode ") -> .starts_with("kcode ") because
    src/cli/args.rs:30 declares #[command(name = "kcode")], so the
    version banner starts with "kcode ".

Fix

--- a/tests/cli_exit_status.rs
+++ b/tests/cli_exit_status.rs
@@ -3,18 +3,18 @@ use std::process::{Command, Output};
 
 fn invoke(args: &[&str]) -> Output {
     let root = tempfile::tempdir().unwrap();
-    let output = Command::new(env!("CARGO_BIN_EXE_jcode"))
+    let output = Command::new(env!("CARGO_BIN_EXE_kcode"))
         .current_dir(root.path())
         .env_clear()
         .env("HOME", root.path())
-        .env("JCODE_HOME", root.path().join("jcode"))
+        .env("KCODE_HOME", root.path().join("kcode"))
         .env("JCODE_NO_TELEMETRY", "1")
         .env("NO_COLOR", "1")
         .args(args)
         .output()
         .expect("run jcode CLI");
     assert!(
-        !root.path().join("jcode").exists(),
+        !root.path().join("kcode").exists(),
         "parsing must exit before creating application state"
     );
     output
@@ -58,6 +58,6 @@ fn version_exits_successfully_on_stdout() {
     assert!(
         String::from_utf8(output.stdout)
             .unwrap()
-            .starts_with("jcode ")
+        .starts_with("kcode ")
     );
 }

Four line changes in one file. No other files touched. Scope held tight
to the bin-target rename and the three obvious fork-residue assertions.

Validation

  • cargo test --test cli_exit_status --no-run -> exit 0. The test
    binary compiles successfully (it did not compile on master).
  • cargo test --test cli_exit_status -> 2 passed, 2 FAILED on macOS.
    The two failures are caused by self_heal_macos_code_signature()
    (src/main.rs:156) running unconditionally on macOS and leaking
    xattr / codesign output into the spawned process's stderr, which
    breaks the output.stderr.is_empty() assertion in
    help_exits_successfully_on_stdout and version_exits_successfully_on_stdout.
    This is a separate fork-introduced macOS stderr leak unrelated to the
    bin-target rename and is intentionally left out of scope. Linux CI is
    unaffected.
  • cargo fmt --all -- --check -> 9 files in master have rustfmt drift,
    none of them tests/cli_exit_status.rs. Per the pre-existing
    investigation, those 9 files belong to PR fix(ci): clear repo-wide rustfmt drift + env! macro in cli_exit_status #129 / a follow-up fmt pass.

Relationship to PR #129

PR #129 (fix/repo-ci-pre-existing-drift) attempted the same fix in this
file by changing env!("CARGO_BIN_EXE_jcode") to
std::env::var("CARGO_BIN_EXE_jcode").expect("CARGO_BIN_EXE_jcode").
That conversion is incorrect at runtime: CARGO_BIN_EXE_* is a
compile-time cargo variable for integration test targets, never a
runtime environment variable. The std::env::var(...) form would fail at
runtime with "environment variable not found". This PR supersedes that
approach for tests/cli_exit_status.rs by using the correct variable
name (CARGO_BIN_EXE_kcode) and keeping it as a compile-time
env!().

Ledger trailers

tx-agent: jcode
tx-validated: test
tx-task: cli-exit-status-kcode-bin

CodeAnt-AI Description

Align CLI exit-status checks with kcode's environment and version output

What Changed

  • Exit-status tests use KCODE_HOME and check that invalid commands do not create kcode application state
  • The version check now expects the kcode banner

Impact

✅ CLI exit-status tests match kcode behavior
✅ Version output checks reflect the kcode name

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

…on test

The root package's binary target is named `kcode` (`[[bin]] name = "kcode"`,
path = src/main.rs); the library target is named `jcode` (`[lib] name = "jcode"`).
cargo sets CARGO_BIN_EXE_<NAME> per BIN TARGET NAME, so CARGO_BIN_EXE_jcode is not
defined at compile time. The fork's home env var is KCODE_HOME (see
crates/jcode-storage/src/lib.rs::jcode_dir), and the CLI's clap command name is
"kcode" (src/cli/args.rs:30 #[command(name = "kcode")]), so the version banner
starts with "kcode ". Align this test with the fork's reality.

PR #129 attempted the same fix using std::env::var("CARGO_BIN_EXE_jcode"), but
CARGO_BIN_EXE_* is a compile-time cargo variable, never present at runtime; that
form will fail at runtime with "environment variable not found". The correct
form is env!("CARGO_BIN_EXE_kcode").

tx-agent: jcode
tx-validated: test
tx-task: cli-exit-status-kcode-bin
tx-intent: unblock tests/cli_exit_status.rs compile on master after the kcode bin rename
Copilot AI balanced review requested due to automatic review settings October 19, 2026 22:34
@codeant-ai

codeant-ai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #66936 Incremental review completed 2991f8c Nov 03, 2026 · 07:22 07:23
✅  Reviewed your PR d639961 Oct 19, 2026 · 22:34 22:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codeant-ai

codeant-ai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ac038892-ee36-4755-aeee-143f2ca35d0e
Commits

Reviewing files that changed from the base of the PR and between ac34906 and 2991f8c.

Files selected for processing: 1
  • tests/cli_exit_status.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label Oct 19, 2026
@codeant-ai

codeant-ai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 2991f8c1db52

KooshaPari added a commit that referenced this pull request Oct 20, 2026
…PR stack

tx-agent: jcode
tx-validated: manual
tx-task: governance-2026-10-19
tx-scope: docs/sessions/2026-10-19-orchestration-governance
tx-intent: give the operator a no-force-push merge order for PRs #152/#127/#140/#148/#129/#132/#134/#150/#145
Comment thread tests/cli_exit_status.rs
.env("HOME", root.path())
.env("JCODE_HOME", root.path().join("jcode"))
.env("KCODE_HOME", root.path().join("kcode"))
.env("JCODE_NO_TELEMETRY", "1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Fork-residue env var not updated

Source code reads KCODE_NO_TELEMETRY (see crates/jcode-telemetry-core/src/lib.rs), and no source reads JCODE_NO_TELEMETRY. Leaving JCODE_NO_TELEMETRY here is inert and inconsistent with the rest of the fork.

Suggested change
.env("JCODE_NO_TELEMETRY", "1")
.env("KCODE_NO_TELEMETRY", "1")

@kilo-code-bot

kilo-code-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
tests/cli_exit_status.rs 11 Fork-residue env var JCODE_NO_TELEMETRY not updated to KCODE_NO_TELEMETRY
Files Reviewed (1 files)
  • tests/cli_exit_status.rs - 1 issue

Fix these issues in Kilo Cloud


Reviewed by free · Input: 63.6K · Output: 1.5K · Cached: 154.3K

@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@KooshaPari
KooshaPari merged commit 1e63f46 into master Nov 5, 2026
19 of 20 checks passed
@KooshaPari
KooshaPari deleted the fix/cli-exit-status-kcode-bin branch November 27, 2026 09:42
KooshaPari added a commit that referenced this pull request Nov 28, 2026
… plan (#375)

* docs(sessions): add cross-harness orchestration governance proposal

Proposes 4 enforcement mechanisms for the "Always Subagent — main context is management-only" operator directive (2026-10-11 21:08); records the 2026-10-19 manual cross-harness propagation of the rule to all 4 derivative AGENTS.md copies (codex, forge, kcode, helioslite); lists operator-approved next steps (none yet; each mechanism awaiting decision).

tx-agent: jcode
tx-validated: manual
tx-task: governance-2026-10-19
tx-scope: docs/sessions/2026-10-19-orchestration-governance
tx-intent: capture the cross-harness propagation decision + enforcement backlog in the repo

* docs(sessions): add fix-forward merge integration plan for the KCode PR stack

tx-agent: jcode
tx-validated: manual
tx-task: governance-2026-10-19
tx-scope: docs/sessions/2026-10-19-orchestration-governance
tx-intent: give the operator a no-force-push merge order for PRs #152/#127/#140/#148/#129/#132/#134/#150/#145

* docs(ci): rebuild the merge integration plan against master 2aea04d

tx-agent: jcode
tx-validated: manual
tx-task: 143
tx-scope: docs/sessions/2026-10-19-orchestration-governance
tx-intent: replace the stale 2026-10-19 PR stack plan with one built from current master ground truth

* docs(ci): rebuild the merge integration plan against master 2aea04d

tx-agent: jcode
tx-validated: manual
tx-task: 143
tx-scope: docs/sessions/2026-10-19-orchestration-governance
tx-intent: replace the stale 2026-10-19 PR stack plan with one built from current master ground truth

* docs(merge): refresh the merge plan with the recomputed stack and resolved conflicts

The recomputed residuals (recomputed against origin/master 2aea04d
via git merge-tree --write-tree) now cover 12 open PRs in the KCode
stack. The four PRs previously flagged as needing hand-resolved
conflicts (#140, #127, #157, #158) have already been merged against
origin/master by a parallel agent as real 2-parent merge commits at
d6e4cfa, b6508e6, 264c09a, and 47b42e2 respectively; merge-tree
reports zero conflict markers for all four. Two new PRs (#163 transport
pipe-stem, #164 CI timeout headroom) extend the stack to 12.

The CI Quality Guardrails clippy gate has a coverage gap that no
existing PR fixes: the command is 'cargo clippy --all-targets
--all-features -- -D warnings' with no --workspace, so exactly one
workspace member (jcode-sdk) is unreachable from the root package and
is never linted. In the green run id 39390720989 the cargo test -p
jcode-sdk parity step still emitted the 'never used' warning for the
Subscriber alias at crates/jcode-sdk/src/client.rs:330. The --workspace
change is NOT a no-op and may surface additional pre-existing
violations; this is recorded as an OPEN RISK, not a resolved fact.

The KCode self-hosted runner desk-kcode-1 wedged on 2026-10-21 in the
Build & Test (desk-linux) job of run 39530002307. Root cause: the
desk WSL2 instance is capped by .wslconfig at memory=16GB (not the
64GB the Windows host has), was competing with a 1h43m orphaned
cargo llvm-cov --workspace job, and the Build step in
.github/workflows/ci.yml has no per-step run_with_timeout.py wrapper.
Remediation (terminating the orphan) brought memory from 13.9/16 GB to
9.4/16 GB and recovered the runner.

Detailed conflict resolutions and the runner wedge root-cause analysis
moved to a new companion file 05a_MERGE_EVIDENCE.md so the plan itself
fits the 500-line cap.

tx-agent: jcode
tx-validated: manual
tx-scope: docs/sessions/2026-10-19-orchestration-governance/
tx-intent: Refresh the merge plan against recomputed 12-PR residuals + 4 applied conflict resolutions + clippy coverage gap + runner wedge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tests): cli_exit_status.rs reads CARGO_BIN_EXE_jcode but the bin target is kcode

2 participants