personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: preserve stream qualifier in remote ingest (tmux.observer collision)

stream_name(remote="fedora.tmux") calls _strip_hostname which strips
everything after the first dot, treating ".tmux" as a domain suffix.
Both the desktop observer ("fedora") and tmux observer ("fedora.tmux")
were landing in the same "fedora" stream.

Clients already send their canonical stream name in meta["stream"].
Use that value when present instead of re-deriving from the registration
name. Falls back to the old derivation if meta stream is absent/invalid.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+52 -2
+10 -2
apps/remote/routes.py
··· 422 422 day_dir = day_path(day) 423 423 day_dir.mkdir(parents=True, exist_ok=True) 424 424 425 - # Determine stream name from remote metadata 425 + # Determine stream name: trust client-provided stream in meta if valid, 426 + # otherwise derive from remote registration name. 427 + # Deriving from remote name via stream_name(remote=...) calls _strip_hostname, 428 + # which strips qualifiers like ".tmux" — so "fedora.tmux" becomes "fedora", 429 + # colliding both observers into one stream. 430 + client_stream = meta.get("stream", "").strip() 426 431 remote_name = remote.get("name", "unknown") 427 - stream = stream_name(remote=remote_name) 432 + if client_stream and re.match(r"^[a-z0-9][a-z0-9._-]*$", client_stream): 433 + stream = client_stream 434 + else: 435 + stream = stream_name(remote=remote_name) 428 436 429 437 # Find available segment key within the stream directory 430 438 stream_dir = day_dir / stream
+42
apps/remote/tests/test_routes.py
··· 1528 1528 ) 1529 1529 assert expected_file.exists() 1530 1530 assert expected_file.read_bytes() == valid_data 1531 + 1532 + 1533 + def test_ingest_stream_qualifier_preserved(remote_env): 1534 + """Regression: tmux observer must land in host.tmux, not host stream. 1535 + 1536 + When a client registers as "fedora.tmux" and uploads with 1537 + meta={"stream": "fedora.tmux"}, the server was calling 1538 + stream_name(remote="fedora.tmux") which strips the qualifier via 1539 + _strip_hostname, collapsing both desktop and tmux observers into 1540 + the same "fedora" stream. The fix: trust meta["stream"] when present. 1541 + """ 1542 + env = remote_env() 1543 + 1544 + # Register as the tmux observer would (name = stream name with qualifier) 1545 + resp = env.client.post( 1546 + "/app/remote/api/create", 1547 + json={"name": "fedora.tmux"}, 1548 + content_type="application/json", 1549 + ) 1550 + key = resp.get_json()["key"] 1551 + 1552 + test_data = b"tmux capture content" 1553 + meta = json.dumps({"host": "fedora", "platform": "linux", "stream": "fedora.tmux"}) 1554 + resp = env.client.post( 1555 + f"/app/remote/ingest/{key}", 1556 + data={ 1557 + "day": "20250103", 1558 + "segment": "120000_300", 1559 + "meta": meta, 1560 + "files": (io.BytesIO(test_data), "tmux.jsonl"), 1561 + }, 1562 + ) 1563 + assert resp.status_code == 200 1564 + assert resp.get_json()["status"] == "ok" 1565 + 1566 + # Must land under fedora.tmux/, NOT fedora/ 1567 + assert ( 1568 + env.journal / "20250103" / "fedora.tmux" / "120000_300" / "tmux.jsonl" 1569 + ).exists() 1570 + assert not ( 1571 + env.journal / "20250103" / "fedora" / "120000_300" / "tmux.jsonl" 1572 + ).exists()