Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Whitestone
6ebf54d457 fix: closes #731
Some checks failed
CI / test (pull_request) Failing after 8s
CI / validate (pull_request) Failing after 13s
Review Approval Gate / verify-review (pull_request) Failing after 3s
2026-04-12 12:39:23 -04:00
3 changed files with 15 additions and 23 deletions

View File

@@ -98,15 +98,6 @@ optional_rooms:
purpose: Catch-all for artefacts not yet assigned to a named room
wizards: ["*"]
- key: sovereign
label: Sovereign
purpose: Artifacts of Alexander Whitestone's requests, directives, and conversation history
wizards: ["*"]
conventions:
naming: "YYYY-MM-DD_HHMMSS_<topic>.md"
index: "INDEX.md"
description: "Each artifact is a dated record of a request from Alexander and the wizard's response. The running INDEX.md provides a chronological catalog."
# Tunnel routing table
# Defines which room pairs are connected across wizard wings.
# A tunnel lets `recall <query> --fleet` search both wings at once.
@@ -121,5 +112,3 @@ tunnels:
description: Fleet-wide issue and PR knowledge
- rooms: [experiments, experiments]
description: Cross-wizard spike and prototype results
- rooms: [sovereign, sovereign]
description: Alexander's requests and responses shared across all wizards

View File

@@ -66,7 +66,12 @@ class NostrIdentity:
if privkey_hex:
self.privkey = int(privkey_hex, 16)
else:
self.privkey = int.from_bytes(os.urandom(32), 'big') % N
# Rejection sampling: avoid modulo bias from % N
while True:
candidate = int.from_bytes(os.urandom(32), 'big')
if 0 < candidate < N:
self.privkey = candidate
break
self.pubkey = get_pubkey(self.privkey)
def sign_event(self, event):

View File

@@ -50,23 +50,21 @@ async def broadcast_handler(websocket: websockets.WebSocketServerProtocol):
# Broadcast to all OTHER clients
if not clients:
continue
disconnected = set()
# Create broadcast tasks for efficiency
tasks = []
# Track (client, task) pairs so failed clients are identified directly
send_jobs = []
for client in clients:
if client != websocket and client.open:
tasks.append(asyncio.create_task(client.send(message)))
if tasks:
results = await asyncio.gather(*tasks, return_exceptions=True)
for i, result in enumerate(results):
send_jobs.append((client, asyncio.create_task(client.send(message))))
if send_jobs:
results = await asyncio.gather(*[job[1] for job in send_jobs], return_exceptions=True)
for (target_client, _), result in zip(send_jobs, results):
if isinstance(result, Exception):
# Find the client that failed
target_client = [c for c in clients if c != websocket][i]
logger.error(f"Failed to send to a client {target_client.remote_address}: {result}")
disconnected.add(target_client)
if disconnected:
clients.difference_update(disconnected)