Skip to content

Commit 2684008

Browse files
honor2030senamakel
andauthored
test: guard RPC alias catalog freshness (tinyhumansai#1705)
Co-authored-by: honor2030 <19909783+honor2030@users.noreply.github.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
1 parent 8f60c18 commit 2684008

4 files changed

Lines changed: 260 additions & 136 deletions

File tree

scripts/shortcuts/review/fix.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ else
6363
conflict_block=""
6464
fi
6565

66-
prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
67-
-v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" \
68-
-v conflict="$conflict_block" '
66+
prompt=$(REVIEW_CONFLICT_BLOCK="$conflict_block" \
67+
awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
68+
-v head_repo="$REVIEW_HEAD_REPO" -v head_branch="$REVIEW_HEAD_BRANCH" '
69+
BEGIN { conflict = ENVIRON["REVIEW_CONFLICT_BLOCK"] }
6970
{
7071
gsub(/__PR__/, pr);
7172
gsub(/__REPO__/, repo);

scripts/shortcuts/review/review.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ else
5656
conflict_block=""
5757
fi
5858

59-
prompt=$(awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" \
60-
-v conflict="$conflict_block" '
59+
prompt=$(REVIEW_CONFLICT_BLOCK="$conflict_block" \
60+
awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" '
61+
BEGIN { conflict = ENVIRON["REVIEW_CONFLICT_BLOCK"] }
6162
{ gsub(/__PR__/, pr); gsub(/__REPO__/, repo); gsub(/__CONFLICT_BLOCK__/, conflict); print }
6263
' "$template")
6364

src/core/dispatch.rs

Lines changed: 0 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ pub async fn dispatch(
3131
method: &str,
3232
params: serde_json::Value,
3333
) -> Result<serde_json::Value, String> {
34-
let method = if let Some(canonical) = normalize_legacy_method(method) {
35-
log::debug!(
36-
"[rpc] legacy method '{}' rewritten to '{}'",
37-
method,
38-
canonical
39-
);
40-
canonical
41-
} else {
42-
method
43-
};
44-
4534
log::trace!(
4635
"[rpc:dispatch] enter method={} params={}",
4736
method,
@@ -97,44 +86,6 @@ pub async fn dispatch(
9786
Err(format!("unknown method: {method}"))
9887
}
9988

100-
/// Normalizes legacy un-namespaced method names to their canonical equivalents.
101-
///
102-
/// This provides defense-in-depth against stale or unbalanced callers that may
103-
/// still be using old method names.
104-
///
105-
/// Source of truth: `app/src/services/rpcMethods.ts` (`LEGACY_METHOD_ALIASES`)
106-
fn normalize_legacy_method(method: &str) -> Option<&'static str> {
107-
match method {
108-
"openhuman.get_analytics_settings" => Some("openhuman.config_get_analytics_settings"),
109-
"openhuman.get_composio_trigger_settings" => {
110-
Some("openhuman.config_get_composio_trigger_settings")
111-
}
112-
"openhuman.get_config" => Some("openhuman.config_get"),
113-
"openhuman.get_runtime_flags" => Some("openhuman.config_get_runtime_flags"),
114-
"openhuman.ping" => Some("core.ping"),
115-
"openhuman.set_browser_allow_all" => Some("openhuman.config_set_browser_allow_all"),
116-
"openhuman.update_analytics_settings" => Some("openhuman.config_update_analytics_settings"),
117-
"openhuman.update_browser_settings" => Some("openhuman.config_update_browser_settings"),
118-
"openhuman.update_composio_trigger_settings" => {
119-
Some("openhuman.config_update_composio_trigger_settings")
120-
}
121-
"openhuman.update_local_ai_settings" => Some("openhuman.config_update_local_ai_settings"),
122-
"openhuman.update_memory_settings" => Some("openhuman.config_update_memory_settings"),
123-
"openhuman.update_model_settings" => Some("openhuman.config_update_model_settings"),
124-
"openhuman.update_runtime_settings" => Some("openhuman.config_update_runtime_settings"),
125-
"openhuman.update_screen_intelligence_settings" => {
126-
Some("openhuman.config_update_screen_intelligence_settings")
127-
}
128-
"openhuman.workspace_onboarding_flag_exists" => {
129-
Some("openhuman.config_workspace_onboarding_flag_exists")
130-
}
131-
"openhuman.workspace_onboarding_flag_set" => {
132-
Some("openhuman.config_workspace_onboarding_flag_set")
133-
}
134-
_ => None,
135-
}
136-
}
137-
13889
/// Handles internal core-level RPC methods.
13990
///
14091
/// These methods provide basic information about the server and its version.
@@ -298,87 +249,6 @@ mod tests {
298249
assert!(result.logs.is_empty());
299250
}
300251

301-
#[test]
302-
fn test_normalize_legacy_method_all_aliases() {
303-
let cases = vec![
304-
(
305-
"openhuman.get_analytics_settings",
306-
"openhuman.config_get_analytics_settings",
307-
),
308-
(
309-
"openhuman.get_composio_trigger_settings",
310-
"openhuman.config_get_composio_trigger_settings",
311-
),
312-
("openhuman.get_config", "openhuman.config_get"),
313-
(
314-
"openhuman.get_runtime_flags",
315-
"openhuman.config_get_runtime_flags",
316-
),
317-
("openhuman.ping", "core.ping"),
318-
(
319-
"openhuman.set_browser_allow_all",
320-
"openhuman.config_set_browser_allow_all",
321-
),
322-
(
323-
"openhuman.update_analytics_settings",
324-
"openhuman.config_update_analytics_settings",
325-
),
326-
(
327-
"openhuman.update_browser_settings",
328-
"openhuman.config_update_browser_settings",
329-
),
330-
(
331-
"openhuman.update_composio_trigger_settings",
332-
"openhuman.config_update_composio_trigger_settings",
333-
),
334-
(
335-
"openhuman.update_local_ai_settings",
336-
"openhuman.config_update_local_ai_settings",
337-
),
338-
(
339-
"openhuman.update_memory_settings",
340-
"openhuman.config_update_memory_settings",
341-
),
342-
(
343-
"openhuman.update_model_settings",
344-
"openhuman.config_update_model_settings",
345-
),
346-
(
347-
"openhuman.update_runtime_settings",
348-
"openhuman.config_update_runtime_settings",
349-
),
350-
(
351-
"openhuman.update_screen_intelligence_settings",
352-
"openhuman.config_update_screen_intelligence_settings",
353-
),
354-
(
355-
"openhuman.workspace_onboarding_flag_exists",
356-
"openhuman.config_workspace_onboarding_flag_exists",
357-
),
358-
(
359-
"openhuman.workspace_onboarding_flag_set",
360-
"openhuman.config_workspace_onboarding_flag_set",
361-
),
362-
];
363-
364-
for (legacy, canonical) in cases {
365-
assert_eq!(
366-
normalize_legacy_method(legacy),
367-
Some(canonical),
368-
"Legacy method {} should normalize to {}",
369-
legacy,
370-
canonical
371-
);
372-
}
373-
}
374-
375-
#[test]
376-
fn test_normalize_legacy_method_none_for_unknown_or_canonical() {
377-
assert!(normalize_legacy_method("core.ping").is_none());
378-
assert!(normalize_legacy_method("openhuman.config_get").is_none());
379-
assert!(normalize_legacy_method("unknown.method").is_none());
380-
}
381-
382252
#[tokio::test]
383253
async fn dispatch_legacy_ping_rewrites_and_succeeds() {
384254
let out = dispatch(test_state(), "openhuman.ping", json!({}))

0 commit comments

Comments
 (0)