fix(commons): lowercase branch-name normalization across all resolution sites — S304 F52. trade/artifact/profile/welcome/search ops all uppercased vs identity's lowercase (diverged af350fe0), so ownership guards never matched and gifts were invisible. DB sweep confirmed clean (bug blocked bad writes). Live gift+trade round-trip green, 449 tests, seedgo 31/31. DPLAN-0250 Track A, dispatched to @commons
This commit is contained in:
@@ -75,8 +75,8 @@ def _validate_metadata(metadata_str: str) -> Optional[dict]:
|
||||
|
||||
|
||||
def _resolve_branch_name(mention: str) -> Optional[str]:
|
||||
"""Resolve a @mention to a branch name."""
|
||||
name = mention.lstrip("@").upper()
|
||||
"""Resolve a @mention to a branch name (lowercase-normalized)."""
|
||||
name = mention.lstrip("@").lower()
|
||||
|
||||
if not os.path.exists(BRANCH_REGISTRY_PATH):
|
||||
return None
|
||||
@@ -85,7 +85,7 @@ def _resolve_branch_name(mention: str) -> Optional[str]:
|
||||
with open(BRANCH_REGISTRY_PATH, encoding="utf-8") as f:
|
||||
registry = json.load(f)
|
||||
for branch in registry.get("branches", []):
|
||||
if branch.get("name") == name:
|
||||
if branch.get("name", "").lower() == name:
|
||||
return name
|
||||
return None
|
||||
except Exception:
|
||||
|
||||
@@ -54,8 +54,8 @@ RARITY_COLORS = {
|
||||
|
||||
|
||||
def _resolve_branch_name(mention: str) -> Optional[str]:
|
||||
"""Resolve a @mention to a branch name."""
|
||||
name = mention.lstrip("@").upper()
|
||||
"""Resolve a @mention to a branch name (lowercase-normalized)."""
|
||||
name = mention.lstrip("@").lower()
|
||||
|
||||
if not os.path.exists(BRANCH_REGISTRY_PATH):
|
||||
return None
|
||||
@@ -64,7 +64,7 @@ def _resolve_branch_name(mention: str) -> Optional[str]:
|
||||
with open(BRANCH_REGISTRY_PATH, encoding="utf-8") as f:
|
||||
registry = json.load(f)
|
||||
for branch in registry.get("branches", []):
|
||||
if branch.get("name") == name:
|
||||
if branch.get("name", "").lower() == name:
|
||||
return name
|
||||
return None
|
||||
except Exception:
|
||||
|
||||
@@ -58,7 +58,7 @@ def show_profile(args: List[str]) -> dict:
|
||||
|
||||
# Determine which branch to show
|
||||
if args:
|
||||
target_branch = args[0].upper()
|
||||
target_branch = args[0].lower()
|
||||
else:
|
||||
caller = get_caller_branch()
|
||||
if not caller:
|
||||
|
||||
@@ -62,7 +62,7 @@ def _parse_search_args(args: List[str]) -> dict:
|
||||
result["room"] = remaining[i + 1].lower()
|
||||
i += 2
|
||||
elif flag == "--author" and i + 1 < len(remaining):
|
||||
result["author"] = remaining[i + 1].upper()
|
||||
result["author"] = remaining[i + 1].lower()
|
||||
i += 2
|
||||
elif flag == "--type" and i + 1 < len(remaining):
|
||||
search_type = remaining[i + 1].lower()
|
||||
|
||||
@@ -55,7 +55,7 @@ def run_welcome(args: List[str]) -> dict:
|
||||
conn = get_db()
|
||||
|
||||
if filtered_args:
|
||||
branch_name = filtered_args[0].upper()
|
||||
branch_name = filtered_args[0].lower()
|
||||
if dry_run:
|
||||
already = has_been_welcomed(conn, branch_name)
|
||||
close_db(conn)
|
||||
@@ -114,7 +114,7 @@ def _welcome_specific(conn, branch_name: str) -> dict:
|
||||
Returns:
|
||||
Dict with success and welcome result
|
||||
"""
|
||||
agent = conn.execute("SELECT branch_name FROM agents WHERE branch_name = ?", (branch_name,)).fetchone()
|
||||
agent = conn.execute("SELECT branch_name FROM agents WHERE LOWER(branch_name) = ?", (branch_name,)).fetchone()
|
||||
|
||||
if not agent:
|
||||
return {"success": False, "error": f"Branch '{branch_name}' not found in The Commons."}
|
||||
|
||||
@@ -993,7 +993,7 @@ def test_run_welcome_dry_run_specific_branch(
|
||||
"""run_welcome <branch> --dry-run reports whether the branch would be welcomed."""
|
||||
from aipass.commons.apps.handlers.welcome.welcome_ops import run_welcome
|
||||
|
||||
_seed_agent(initialized_db, "GAMMA")
|
||||
_seed_agent(initialized_db, "gamma")
|
||||
|
||||
mock_get_db.return_value = initialized_db
|
||||
mock_close.side_effect = lambda c: None
|
||||
@@ -1001,7 +1001,7 @@ def test_run_welcome_dry_run_specific_branch(
|
||||
result = run_welcome(["gamma", "--dry-run"])
|
||||
assert result["success"] is True
|
||||
assert result["dry_run"] is True
|
||||
assert result["branch"] == "GAMMA"
|
||||
assert result["branch"] == "gamma"
|
||||
assert result["would_welcome"] is True
|
||||
|
||||
|
||||
@@ -1076,7 +1076,7 @@ def test_run_welcome_specific_branch_success(
|
||||
"""run_welcome <branch> creates a welcome post for that branch."""
|
||||
from aipass.commons.apps.handlers.welcome.welcome_ops import run_welcome
|
||||
|
||||
_seed_agent(initialized_db, "EPSILON")
|
||||
_seed_agent(initialized_db, "epsilon")
|
||||
|
||||
mock_get_db.return_value = initialized_db
|
||||
mock_close.side_effect = lambda c: None
|
||||
@@ -1085,7 +1085,7 @@ def test_run_welcome_specific_branch_success(
|
||||
assert result["success"] is True
|
||||
assert result["action"] == "specific"
|
||||
assert result["already_welcomed"] is False
|
||||
assert result["branch"] == "EPSILON"
|
||||
assert result["branch"] == "epsilon"
|
||||
assert result["post_id"] is not None
|
||||
|
||||
|
||||
|
||||
@@ -58,10 +58,10 @@ def test_parse_search_args_room_flag():
|
||||
|
||||
|
||||
def test_parse_search_args_author_flag():
|
||||
"""The --author flag should set the author filter and uppercase it."""
|
||||
"""The --author flag should set the author filter and lowercase it."""
|
||||
result = _parse_search_args(["test", "--author", "drone"])
|
||||
assert result["query"] == "test"
|
||||
assert result["author"] == "DRONE"
|
||||
assert result["author"] == "drone"
|
||||
|
||||
|
||||
def test_parse_search_args_type_flag_valid():
|
||||
@@ -94,7 +94,7 @@ def test_parse_search_args_all_flags():
|
||||
)
|
||||
assert result["query"] == "registry"
|
||||
assert result["room"] == "dev"
|
||||
assert result["author"] == "FLOW"
|
||||
assert result["author"] == "flow"
|
||||
assert result["search_type"] == "posts"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user