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
+13 -6
View File
@@ -261,7 +261,6 @@ fn get_test_config() -> Option<BedrockClientConfig> {
access_key_id: String::new(),
secret_access_key: String::new(),
cross_region_inference: false,
fallback_to_warp: false,
})
}
@@ -556,6 +555,7 @@ impl AgentSimulation {
None,
false,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1142,6 +1142,7 @@ async fn test_reasoning_model_produces_substantial_output() {
None,
false,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1264,6 +1265,7 @@ async fn test_event_sequence_matches_controller_expectations() {
None,
false,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1378,6 +1380,7 @@ async fn test_followup_turn_does_not_send_create_task() {
None,
false,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1461,6 +1464,7 @@ async fn run_slash_command_test(
None,
true,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1688,6 +1692,7 @@ async fn test_slash_resume_conversation() {
None,
true,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1799,6 +1804,7 @@ async fn test_empty_messages_safety_check() {
None,
true,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await
@@ -1866,9 +1872,9 @@ async fn test_full_proto_round_trip_with_tool_history() {
&model,
);
let messages = super::convert_request::extract_messages_from_request(&request);
let system_prompt = super::convert_request::extract_system_prompt(&request);
let tools = super::convert_request::extract_tools(&request);
let messages = super::request_translator::extract_messages_from_request(&request);
let system_prompt = super::request_translator::extract_system_prompt(&request);
let tools = super::request_translator::extract_tools(&request);
println!("\n=== FULL PROTO ROUND-TRIP TEST ===");
println!("Extracted {} messages:", messages.len());
@@ -1959,6 +1965,7 @@ async fn test_full_proto_round_trip_with_tool_history() {
None,
true,
None,
None,
Arc::new(Mutex::new(Vec::new())),
)
.await;
@@ -2043,7 +2050,7 @@ async fn test_proto_tool_call_id_mapping() {
"",
);
let messages = super::convert_request::extract_messages_from_request(&request);
let messages = super::request_translator::extract_messages_from_request(&request);
println!("\n=== PROTO TOOL_CALL_ID MAPPING TEST ===");
for (i, msg) in messages.iter().enumerate() {
@@ -2133,7 +2140,7 @@ async fn test_tool_call_id_uses_proto_field_not_message_id() {
mcp_context: None,
};
let messages = super::convert_request::extract_messages_from_request(&request);
let messages = super::request_translator::extract_messages_from_request(&request);
let tool_use_msg = messages
.iter()