Skip to content

fix: unbreak dev branch compilation after upstream/main merge#1

Open
Sigmachan wants to merge 1 commit into
itwizardo:devfrom
Sigmachan:fix/dev-branch-compilation
Open

fix: unbreak dev branch compilation after upstream/main merge#1
Sigmachan wants to merge 1 commit into
itwizardo:devfrom
Sigmachan:fix/dev-branch-compilation

Conversation

@Sigmachan

@Sigmachan Sigmachan commented Jun 12, 2026

Copy link
Copy Markdown

What

The dev HEAD (the Merge remote-tracking branch 'upstream/main' into dev commit) does not compile — cargo build --release fails before producing the hackcode binary. This PR restores a green build and test suite without changing intended behavior: every change either re-binds a symbol the merge left dangling, restores a subsystem the merge dropped, or repairs a syntactic/arity mismatch.

Fixes

Build blockers (cargo build --release):

  • runtime/session_control.rsSessionStore::from_cwd referenced canonical_cwd, which was never bound. Canonicalize cwd the same way from_data_dir does.
  • api/providers/mod.rsmodel_family_identity_for_kind did not cover ProviderKind::Ollama (non-exhaustive match). Mapped to Generic, alongside the other OpenAI-compatible providers.
  • rusty-claude-cli/main.rs — unbalanced delimiters: the final else block in main()'s error reporting was never closed.
  • rusty-claude-cli/main.rs — restored the model-provenance types the merge dropped (ModelProvenance, ModelSource) used by the status command (#148).
  • rusty-claude-cli/main.rs — restored stale_base_state_for / stale_base_json_value (#148) as thin wrappers over the existing runtime::{resolve_expected_base, check_base_commit}.
  • rusty-claude-cli/main.rsCliAction::HelpTopic is now a struct variant { topic, output_format }, matching its parser construction site and print_help_topic's two-argument signature.
  • rusty-claude-cli/main.rs — populate the lifecycle field when collecting managed sessions, via the existing classify_session_lifecycle_for (restores the saved only · dirty worktree · abandoned? signal).

Test build blocker (cargo test):

  • rusty-claude-cli/tests/*.rsenv!("CARGO_BIN_EXE_claw")CARGO_BIN_EXE_hackcode after the binary was renamed to hackcode (Cargo derives the env var from the [[bin]] name).

Verification

  • cargo build --release — clean.
  • cargo test -p rusty-claude-cli191 passing.
  • Seven failures remain and are pre-existing / out of scope for this PR (they are not compilation issues and are unrelated to these changes): incomplete clawhackcode strings in help/banner text (init_help_mentions_direct_subcommand, help_mentions_jsonl_resume_examples, startup_banner_mentions_workflow_completions), an MCP-config error-capture gap (status_degrades_gracefully_on_malformed_mcp_config_143), a boot-preflight contract test, an init artifacts test, and a spinner-timing test (render::spinner_advances_frames). Happy to fold fixes for any of these into a follow-up if useful.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed session directory collision for symlinked workspace paths by canonicalizing paths before computation.
  • New Features

    • Added model provenance tracking to display model source (config, flag, environment, or default).
    • Enhanced CLI help command with formatted output support.
    • Improved Ollama provider classification alongside OpenAI and xAI providers.
  • Chores

    • Updated CLI test suite to reference updated binary targets.

The `dev` HEAD (merge of upstream/main) did not compile. This restores a
green build and test suite without changing intended behavior.

- session_control: bind `canonical_cwd` in `SessionStore::from_cwd`
  (referenced but never defined after the merge)
- api/providers: cover `ProviderKind::Ollama` in `model_family_identity_for_kind`
  (Generic, matching the other OpenAI-compatible providers)
- cli/main: close the unbalanced `else` block in `main()` error reporting
- cli/main: restore the model-provenance subsystem the merge dropped
  (`ModelProvenance`, `ModelSource`; used by `status`)
- cli/main: restore `stale_base_state_for` / `stale_base_json_value`
  (thin wrappers over the existing runtime `check_base_commit`)
- cli/main: make `CliAction::HelpTopic` a struct variant carrying
  `output_format`, matching the parser and `print_help_topic` arity
- cli/main: populate the `lifecycle` field when listing managed sessions
  via the existing `classify_session_lifecycle_for`
- tests: `CARGO_BIN_EXE_claw` -> `CARGO_BIN_EXE_hackcode` after the binary rename

Build: `cargo build --release` clean. Tests: 191 passing. Seven pre-existing
failures remain (incomplete claw->hackcode help/banner strings, an mcp config
error-capture gap, and a spinner-timing test) — all unrelated to compilation.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR makes targeted improvements across the API provider routing, runtime session management, CLI command routing, and status reporting. It fixes provider model-family classification, canonicalizes session paths, extends help-topic routing with output formats, optimizes session listing via lifecycle caching, introduces model-provenance types and stale-base JSON serialization, and updates all test harnesses to validate against the hackcode binary.

Changes

Core CLI, API, and Runtime Improvements

Layer / File(s) Summary
Provider model-family routing for Ollama
rust/crates/api/src/providers/mod.rs
model_family_identity_for_kind now explicitly maps ProviderKind::Ollama to Generic model-family identity instead of falling through to the Anthropic default.
Session store path canonicalization
rust/crates/runtime/src/session_control.rs
SessionStore::from_cwd canonicalizes the provided working directory before fingerprinting and computing session namespace, ensuring symlink-equivalent paths map to the same session directory.
Help topic routing with output format support
rust/crates/rusty-claude-cli/src/main.rs
CliAction::HelpTopic enum extends to carry CliOutputFormat alongside topic; dispatcher is updated to pass both parameters through to print_help_topic, and control-flow formatting in error handling is adjusted.
Session lifecycle classification caching
rust/crates/rusty-claude-cli/src/main.rs
collect_sessions_from_dir now computes workspace lifecycle classification once per directory scan and reuses it for all managed session entries, eliminating redundant per-session recomputation.
Model provenance types and stale-base JSON serialization
rust/crates/rusty-claude-cli/src/main.rs
Introduces ModelSource (flag/env/config/default) and ModelProvenance (model, optional raw input, source) types; adds stale_base_state_for and stale_base_json_value helpers to produce stable JSON with fresh boolean and status token.
Test harness updates to hackcode binary
rust/crates/rusty-claude-cli/tests/*.rs
All CLI test helpers across cli_flags_and_config_defaults, compact_output, compact_repl_panic, mock_parity_harness, output_format_contract, and resume_slash_commands are updated to spawn the hackcode compiled binary instead of claw.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through provider routes so bright,
Sessions now walk the canonical path right,
Help topics wear new output format flair,
Lifecycle caching floats through the air,
Model provenance blooms in JSON's care!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: fixing compilation issues after an upstream/main merge. It clearly describes the primary objective across multiple build and test fixes throughout the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
rust/crates/api/src/providers/mod.rs (1)

566-581: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add test coverage for Ollama mapping.

The test verifies provider-to-identity mapping for Anthropic, OpenAi, and Xai but omits Ollama. Adding coverage for the Ollama case will prevent regression and document the intended Generic mapping.

✅ Proposed test extension
     #[test]
     fn maps_provider_kind_to_model_family_identity() {
-        // given: each supported provider kind
+        // given: all supported provider kinds
         let anthropic = ProviderKind::Anthropic;
         let openai = ProviderKind::OpenAi;
         let xai = ProviderKind::Xai;
+        let ollama = ProviderKind::Ollama;
 
-        // when: converting provider kinds to prompt model family identities
+        // when: converting provider kinds to model family identities
         let anthropic_identity = model_family_identity_for_kind(anthropic);
         let openai_identity = model_family_identity_for_kind(openai);
         let xai_identity = model_family_identity_for_kind(xai);
+        let ollama_identity = model_family_identity_for_kind(ollama);
 
         // then: Anthropic stays Claude and OpenAI-compatible providers are generic
         assert_eq!(anthropic_identity, runtime::ModelFamilyIdentity::Claude);
         assert_eq!(openai_identity, runtime::ModelFamilyIdentity::Generic);
         assert_eq!(xai_identity, runtime::ModelFamilyIdentity::Generic);
+        assert_eq!(ollama_identity, runtime::ModelFamilyIdentity::Generic);
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/crates/api/src/providers/mod.rs` around lines 566 - 581, Extend the
maps_provider_kind_to_model_family_identity test to include the Ollama provider:
create let ollama = ProviderKind::Ollama, call
model_family_identity_for_kind(ollama), and add an assertion that the result
equals runtime::ModelFamilyIdentity::Generic; modify the existing test block
(maps_provider_kind_to_model_family_identity) to include these lines so Ollama
mapping coverage is present alongside Anthropic/OpenAi/Xai.
rust/crates/rusty-claude-cli/src/main.rs (1)

6417-6424: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix model provenance resolution/source attribution in status output.

ModelProvenance::from_env_or_config_or_default never emits ModelSource::Config, and on env hits it keeps resolved as the caller-provided fallback model. This can emit inconsistent status payloads (model_source: "env" with a non-env model).

Suggested patch
 impl ModelProvenance {
     /// Probe the model-selection env vars; attribute to env when one is set,
     /// otherwise treat the resolved model as a built-in default.
     fn from_env_or_config_or_default(model: &str) -> Self {
         for key in ["HACKCODE_MODEL", "CLAW_MODEL", "ANTHROPIC_MODEL"] {
             if let Ok(value) = std::env::var(key) {
                 let trimmed = value.trim();
                 if !trimmed.is_empty() {
                     return Self {
-                        resolved: model.to_string(),
+                        resolved: resolve_model_alias_with_config(trimmed),
                         raw: Some(trimmed.to_string()),
                         source: ModelSource::Env,
                     };
                 }
             }
         }
+        if let Some(config_model) = config_model_for_current_dir() {
+            let trimmed = config_model.trim();
+            if !trimmed.is_empty() {
+                return Self {
+                    resolved: resolve_model_alias_with_config(trimmed),
+                    raw: Some(trimmed.to_string()),
+                    source: ModelSource::Config,
+                };
+            }
+        }
         Self {
-            resolved: model.to_string(),
+            resolved: resolve_model_alias_with_config(model),
             raw: None,
             source: ModelSource::Default,
         }
     }
 }

Also applies to: 6481-6500

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rust/crates/rusty-claude-cli/src/main.rs` around lines 6417 - 6424, The
status output misattributes model provenance because
ModelProvenance::from_env_or_config_or_default never sets ModelSource::Config
and, on env hits, leaves resolved as the fallback; replace the blind call with
logic that (a) checks for a flag (model_flag_raw) first (keep current branch),
(b) otherwise explicitly attempts to resolve the model from config and env in
order and sets ModelProvenance { resolved: <actual found value>, raw: None,
source: ModelSource::Config|ModelSource::Env } (or ModelSource::Default if
neither found). Update or add a helper (e.g.,
ModelProvenance::resolve_from_config_or_env_or_default) and use it where the old
call appears (the provenance variable here and the similar block around the
6481–6500 region) so resolved and source are consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@rust/crates/api/src/providers/mod.rs`:
- Around line 566-581: Extend the maps_provider_kind_to_model_family_identity
test to include the Ollama provider: create let ollama = ProviderKind::Ollama,
call model_family_identity_for_kind(ollama), and add an assertion that the
result equals runtime::ModelFamilyIdentity::Generic; modify the existing test
block (maps_provider_kind_to_model_family_identity) to include these lines so
Ollama mapping coverage is present alongside Anthropic/OpenAi/Xai.

In `@rust/crates/rusty-claude-cli/src/main.rs`:
- Around line 6417-6424: The status output misattributes model provenance
because ModelProvenance::from_env_or_config_or_default never sets
ModelSource::Config and, on env hits, leaves resolved as the fallback; replace
the blind call with logic that (a) checks for a flag (model_flag_raw) first
(keep current branch), (b) otherwise explicitly attempts to resolve the model
from config and env in order and sets ModelProvenance { resolved: <actual found
value>, raw: None, source: ModelSource::Config|ModelSource::Env } (or
ModelSource::Default if neither found). Update or add a helper (e.g.,
ModelProvenance::resolve_from_config_or_env_or_default) and use it where the old
call appears (the provenance variable here and the similar block around the
6481–6500 region) so resolved and source are consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8ab3b56a-5872-4ec4-9ee1-070949f49757

📥 Commits

Reviewing files that changed from the base of the PR and between 59506f2 and 6627fb5.

📒 Files selected for processing (9)
  • rust/crates/api/src/providers/mod.rs
  • rust/crates/runtime/src/session_control.rs
  • rust/crates/rusty-claude-cli/src/main.rs
  • rust/crates/rusty-claude-cli/tests/cli_flags_and_config_defaults.rs
  • rust/crates/rusty-claude-cli/tests/compact_output.rs
  • rust/crates/rusty-claude-cli/tests/compact_repl_panic.rs
  • rust/crates/rusty-claude-cli/tests/mock_parity_harness.rs
  • rust/crates/rusty-claude-cli/tests/output_format_contract.rs
  • rust/crates/rusty-claude-cli/tests/resume_slash_commands.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant