v1.3.0: Bedrock translator refactor, usage metrics, session restore fixes, and predefined rules

Major changes:

- **Bedrock translator architecture**: Extract orchestration logic from `impl.rs` into
  a dedicated `translator.rs` module. Rename `convert_request.rs` → `request_translator.rs`
  and `stream.rs` → `response_translator.rs` for clarity. Remove `tool_docs.rs` (inlined).
  Remove `fallback_to_warp` setting and server fallback path — Bedrock is now the sole backend.

- **Unknown tool handling**: The response translator now detects hallucinated/unknown tool
  calls from the model and synthesizes error tool_results so the conversation doesn't
  deadlock waiting for a result that will never come.

- **Usage display overhaul**: Replace credit-based usage display with detailed token metrics
  showing context window %, cache hit rate (read/write/miss), and estimated cost in dollars.
  Add `total_input_tokens`, `total_cache_read_tokens`, `total_cache_write_tokens`, and
  `cache_miss_tokens` accessors to `AIConversation`.

- **Predefined rules system**: Add `predefined_rules.rs` with 11 system-defined behavioral
  rules that are auto-seeded on first launch. Add "Add Predefined Rules" button to the
  Rules UI for re-adding them later. Track seeding state via `has_seeded_predefined_rules`
  setting.

- **Session restore improvements**: Rename database file from `warp.sqlite` to
  `galaxy.sqlite` with automatic migration from both same-directory and state_dir legacy
  paths. Improve CWD persistence by falling back to `session_startup_path` for agent-mode
  and fresh tabs. Add extensive session-save/restore logging.

- **Shell bootstrap rebrand**: Rename `WARP_INITIAL_WORKING_DIR` environment variable to
  `GALAXY_INITIAL_WORKING_DIR` across bash, zsh, and fish bootstrap scripts.

- **Model defaults**: Change default Bedrock model from Opus 4.7 to Opus 4.6.
  Add `context_window_for_model()` helper with model-aware context sizes.
  Remove `is_bedrock_model()` (no longer needed without server fallback).

- **User query persistence**: The response translator now emits a `UserQuery` proto message
  at stream start so the user's prompt persists across sessions for conversation titles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ryan Ward
2026-05-20 15:15:28 -05:00
co-authored by Claude Opus 4.6
parent ec99146ccc
commit eaa2ddc75e
38 changed files with 1687 additions and 1129 deletions
+2 -63
View File
@@ -82,8 +82,8 @@ fn test_cross_region_prefix_unknown_region() {
fn test_get_effective_models_empty_returns_defaults() {
let models = get_effective_models(&[]);
assert_eq!(models.len(), DEFAULT_BEDROCK_MODELS.len());
assert_eq!(models[0].model_id, "anthropic.claude-opus-4-7");
assert_eq!(models[0].display_name, "Claude Opus 4.7");
assert_eq!(models[0].model_id, "anthropic.claude-opus-4-6");
assert_eq!(models[0].display_name, "Claude Opus 4.6");
}
#[test]
@@ -98,69 +98,8 @@ fn test_get_effective_models_custom_overrides() {
assert_eq!(models[0].model_id, "custom.model-v1:0");
}
#[test]
fn test_is_bedrock_model_known_prefix() {
assert!(is_bedrock_model("anthropic.claude-sonnet-4-6", &[]));
assert!(is_bedrock_model("amazon.nova-pro-v1:0", &[]));
assert!(is_bedrock_model("meta.llama3-70b-instruct-v1:0", &[]));
assert!(is_bedrock_model("mistral.mistral-large-v1:0", &[]));
assert!(is_bedrock_model("deepseek.r1-v1:0", &[]));
}
#[test]
fn test_is_bedrock_model_cross_region_prefix() {
assert!(is_bedrock_model("us.anthropic.claude-sonnet-4-6", &[]));
assert!(is_bedrock_model("eu.anthropic.claude-sonnet-4-6", &[]));
assert!(is_bedrock_model("global.anthropic.claude-opus-4-7", &[]));
}
#[test]
fn test_is_bedrock_model_unknown() {
assert!(!is_bedrock_model("gpt-4o", &[]));
assert!(!is_bedrock_model("gemini-pro", &[]));
}
#[test]
fn test_is_bedrock_model_custom_config() {
let custom = vec![BedrockModelConfig {
model_id: "custom.my-model-v1:0".to_string(),
display_name: "Custom".to_string(),
vision_supported: false,
}];
assert!(is_bedrock_model("custom.my-model-v1:0", &custom));
}
#[test]
fn test_is_bedrock_model_arn() {
assert!(is_bedrock_model(
"arn:aws:bedrock:us-east-1:156729649053:application-inference-profile/fma5bsw4oxhy",
&[],
));
}
#[test]
fn test_cross_region_prefix_skips_arn() {
let arn = "arn:aws:bedrock:us-east-1:156729649053:application-inference-profile/fma5bsw4oxhy";
assert_eq!(apply_cross_region_prefix(arn, "us-east-1"), arn);
}
#[test]
fn test_is_bedrock_model_coding_agent_arn() {
assert!(is_bedrock_model(
"arn:aws:bedrock:us-east-1:156729649053:application-inference-profile/coding-agent-anthropic-claude-opus-4-6-lt2v72",
&[],
));
}
#[test]
fn test_is_bedrock_model_custom_config_with_arn() {
let custom = vec![BedrockModelConfig {
model_id: "arn:aws:bedrock:us-east-1:156729649053:application-inference-profile/coding-assistant-inference-profile".to_string(),
display_name: "Coding Assistant".to_string(),
vision_supported: true,
}];
assert!(is_bedrock_model(
"arn:aws:bedrock:us-east-1:156729649053:application-inference-profile/coding-assistant-inference-profile",
&custom,
));
}