Conversation
Introduce the first, profile-only step of the minimal-footprint build: - `[profile.tiny]` in Cargo.toml: opt-level="z", fat LTO, one codegen unit, no incremental, stripped symbols, and panic="abort", with the interactive hot-path crates pinned back to opt-level=3 so the TUI stays responsive. - `scripts/build_tiny.sh` wraps the build (`tiny` profile plus `JCODE_DEV_FEATURE_PROFILE=minimal`) and reports the resulting size. - `assets/config-templates/tiny.toml` turns off runtime work that is compiled in but unnecessary for basic coding: update checks, the memory subsystem and its sidecar, swarm, mermaid, decorative animations, sleep inhibition, desktop notifications, autoreview/autojudge, integration discovery, and the non-essential tools. - `docs/TINY_BUILD.md` documents the recipe, the `panic = "abort"` behavior tradeoff, what is deliberately left alone, and the measured result (136 MB -> 23.5 MB, -82%). - `scripts/dev_cargo.sh` treats `tiny` as non-incremental so the sccache decision matches the profile's `incremental = false`. No Rust code was restructured; subsystem removal is left to later steps. Measured: binary 136,489,952 B -> 24,613,488 B; __text 64,617,564 B -> 16,117,640 B; build ~16 min on a 10-core host under memory pressure.
|
| profile="${JCODE_TINY_PROFILE:-tiny}" | ||
| feature_profile="${JCODE_TINY_FEATURES:-minimal}" | ||
|
|
||
| bin="$repo_root/target/$profile/jcode" |
There was a problem hiding this comment.
The script constructs the executable path as target/$profile/jcode instead of using Cargo’s actual artifact location. With JCODE_TINY_PROFILE=dev, Cargo successfully creates target/debug/jcode, but the script checks target/dev/jcode and exits as if no binary was produced. When CARGO_TARGET_DIR is set, it can instead size and run a stale binary in the repository’s default target directory rather than the binary that was just built. This makes supported build configurations fail or report misleading footprint and version results.
Artifacts
- A disposable-package harness copied and executes the changed build script with a real local Cargo pass-through for tiny, dev, and custom-target configurations, ending with the reproduced behavior.
- The command-captured authored harness source shows exactly how the disposable Cargo package and three execution cases were created, ending with the executable test definition.
- The first captured execution shows default tiny succeeds, dev builds but the script misses Cargo's debug output, and custom target uses a divergent artifact path, ending with a successful harness exit.
- The repeated execution changes the custom-target binary version, proving the script reports the old default-target version despite Cargo creating the distinct custom-target binary, ending with a successful harness exit.
- The command-captured numbered source identifies the hard-coded artifact path at line 53 and its validation, sizing, and version use at lines 69 through 80, ending with successful command completion.
- The captured shell syntax check validates both the changed script and the focused harness, ending with exit code 0.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/build_tiny.sh
Line: 53
Comment:
**Use Cargo output path**
The script constructs the executable path as `target/$profile/jcode` instead of using Cargo’s actual artifact location. With `JCODE_TINY_PROFILE=dev`, Cargo successfully creates `target/debug/jcode`, but the script checks `target/dev/jcode` and exits as if no binary was produced. When `CARGO_TARGET_DIR` is set, it can instead size and run a stale binary in the repository’s default target directory rather than the binary that was just built. This makes supported build configurations fail or report misleading footprint and version results.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Closes #1272
What this changes
This is the first, profile-only step toward a minimal-footprint jcode. It adds no Rust code and restructures nothing.
Cargo.toml— a new[profile.tiny]:opt-level = "z",lto = "fat",codegen-units = 1,incremental = false,strip = "symbols",debug = 0,panic = "abort". The interactive hot-path crates (ratatuifamily,crossterm,unicode-*,jcode-tui-anim,jcode-fuzzy) are pinned back toopt-level = 3, matching the existing dev/selfdev/test pins, because atopt-level = "z"the render loop and fuzzy picker feel visibly laggy.scripts/build_tiny.sh— one command that builds with thetinyprofile plus the existingJCODE_DEV_FEATURE_PROFILE=minimal(i.e.--no-default-features) and reports the resulting size and version.assets/config-templates/tiny.toml— a reduced runtime config that disables the background and optional work that is compiled in but unnecessary for basic coding: update checks, the memory subsystem and its LLM sidecar, swarm, Mermaid, decorative animations, LaTeX/image rendering, sleep inhibition, desktop notifications, autoreview/autojudge, integration discovery, and the non-essential tools (tools.profile = "minimal").docs/TINY_BUILD.md— documents the recipe, the measured result, thepanic = "abort"behavior tradeoff, what is deliberately left alone, and the later steps. Linked fromdocs/README.md.scripts/dev_cargo.sh— treatstinyas non-incremental so the sccache decision matches the profile'sincremental = false.The
minimalfeature profile is not new; it already maps to--no-default-featuresand is the default forscripts/test_fast.sh, so the feature set built here is a known-compiling configuration.Measured
Apple Silicon (aarch64) macOS, Rust stable. The baseline is the existing
target/release/jcode, built with the default feature set and thereleaseprofile, so the numbers cover the feature-set reduction and the profile change together:release(default features)tiny+minimal__text(code)__eh_frame__gcc_except_tabThe
__eh_frame/__gcc_except_tabcollapse comes frompanic = "abort"plusstrip; the__textreduction fromopt-level = "z"+ fat LTO + dropping the embedding/AWS/PDF dependency stacks.Build time was about 16 minutes on a 10-core host.
scripts/dev_cargo.shthrottled it to a single rustc job because the host was under memory pressure, so an unloaded machine will be faster.Validation
scripts/build_tiny.shcompletes with exit code 0 and producestarget/tiny/jcode(23.5 MB,jcode v0.84.54-dev).target/tiny/jcode --versionand--helpwork.JCODE_HOMEcontaining it,jcode --no-update model listexits 0 and lists models.scripts/check_dependency_boundaries.pypasses.Note:
scripts/check_guardrails.sh --skip-slowreports 6 failing gates (fmt, warning budget, oversized-file/test ratchets, panic-prone and swallowed-error ratchets) on the base commit, all referencing Rust files this PR does not touch. This PR adds no Rust code, so it neither causes nor fixes those.Tradeoffs / review notes
panic = "abort"removes unwind tables but disables thecatch_unwindgraceful-degradation paths in the TUI draw loop, the Mermaid renderer, and PDF extraction. Session state is persisted server-side, so a client abort is recoverable, but reviewers who consider those paths load-bearing should ask for the line to be dropped — the profile still yields most of the win without it.tinyprofile deliberately does not touchinstall_release.sh, so it cannot accidentally become a release channel. The doc shows how to install it under a separate launcher name.#[cfg]-out subsystems such as memory/swarm. Those are the larger, separately reviewable follow-ups.