Compare commits

..

12 Commits

Author SHA1 Message Date
Alexander Whitestone
f791cca049 fix: disable ChromaDB telemetry in all client paths (closes #1427)
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 9s
CI / test (pull_request) Failing after 51s
CI / validate (pull_request) Failing after 51s
2026-04-21 23:31:11 -04:00
324cdb0d26 Merge PR #1684
Some checks failed
Deploy Nexus / deploy (push) Failing after 7s
Staging Verification Gate / verify-staging (push) Failing after 13s
Merge PR #1684: portal hot-reload
2026-04-22 03:15:13 +00:00
b4473267e0 Merge PR #1685
Some checks failed
Deploy Nexus / deploy (push) Failing after 5s
Staging Verification Gate / verify-staging (push) Failing after 6s
Merge PR #1685: test collection errors
2026-04-22 03:15:07 +00:00
ed733d4eea Merge PR #1686
Some checks failed
Deploy Nexus / deploy (push) Failing after 3s
Staging Verification Gate / verify-staging (push) Has been cancelled
Merge PR #1686: A11Y text contrast
2026-04-22 03:15:03 +00:00
7c9f4310d0 Merge branch 'main' into fix/1536-hot-reload
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 8s
CI / test (pull_request) Failing after 1m8s
CI / validate (pull_request) Failing after 1m7s
2026-04-22 01:12:04 +00:00
2016a7e076 Merge branch 'main' into fix/1509-tests
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 10s
CI / test (pull_request) Failing after 1m9s
CI / validate (pull_request) Failing after 1m14s
2026-04-22 01:11:58 +00:00
b6ee9ba01b Merge branch 'main' into mimo/code/issue-702
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 10s
CI / test (pull_request) Failing after 1m10s
CI / validate (pull_request) Failing after 1m13s
2026-04-22 01:11:53 +00:00
15b9a4398c Merge branch 'main' into fix/1536-hot-reload
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 8s
CI / test (pull_request) Failing after 1m7s
CI / validate (pull_request) Failing after 1m11s
2026-04-22 01:05:01 +00:00
3f7277d920 Merge branch 'main' into fix/1509-tests
Some checks failed
Review Approval Gate / verify-review (pull_request) Failing after 12s
CI / test (pull_request) Failing after 1m10s
CI / validate (pull_request) Failing after 1m12s
2026-04-22 01:04:55 +00:00
cb944be172 Merge branch 'main' into mimo/code/issue-702
Some checks failed
CI / test (pull_request) Failing after 1m10s
Review Approval Gate / verify-review (pull_request) Failing after 12s
CI / validate (pull_request) Failing after 1m8s
2026-04-22 01:04:50 +00:00
Alexander Whitestone
ec2ed3c62f fix: test collection errors in bannerlord and evennia tests (closes #1509)
Some checks failed
CI / test (pull_request) Failing after 1m22s
CI / validate (pull_request) Failing after 1m3s
Review Approval Gate / verify-review (pull_request) Failing after 4s
- nexus/bannerlord_harness.py: fixed bare import to absolute
- nexus/evennia_ws_bridge.py: added clean_lines, normalize_event,
  parse_room_output functions that tests expected

Test results:
- test_bannerlord_harness.py: 39 tests collected
- test_evennia_ws_bridge.py: 5 tests collected
2026-04-21 08:08:49 -04:00
Alexander Whitestone
11175e72c0 feat: portal hot-reload from portals.json without server restart (closes #1536)
Some checks failed
CI / test (pull_request) Failing after 1m20s
CI / validate (pull_request) Failing after 1m24s
Review Approval Gate / verify-review (pull_request) Failing after 9s
2026-04-21 08:01:56 -04:00
11 changed files with 159 additions and 422 deletions

3
app.js
View File

@@ -734,6 +734,9 @@ async function init() {
const response = await fetch('./portals.json');
const portalData = await response.json();
createPortals(portalData);
// Start portal hot-reload watcher
if (window.PortalHotReload) PortalHotReload.start(5000);
} catch (e) {
console.error('Failed to load portals.json:', e);
addChatMessage('error', 'Portal registry offline. Check logs.');

View File

@@ -397,6 +397,7 @@
<script src="./boot.js"></script>
<script src="./avatar-customization.js"></script>
<script src="./lod-system.js"></script>
<script src="./portal-hot-reload.js"></script>
<script>
function openMemoryFilter() { renderFilterList(); document.getElementById('memory-filter').style.display = 'flex'; }
function closeMemoryFilter() { document.getElementById('memory-filter').style.display = 'none'; }

View File

@@ -1,317 +0,0 @@
// ═══════════════════════════════════════════════════════════════
// SPATIAL SEARCH — Find nearest user/object by name
// ═══════════════════════════════════════════════════════════════
//
// Search for users/objects by name with distance and direction.
// Provides autocomplete, pathfinding arrow, and keyboard shortcuts.
//
// Usage:
// const search = new SpatialSearch({ maxDistance: 1000 });
// search.registerEntity('id', { name, type, position });
// const results = search.searchEntities('query');
// ═══════════════════════════════════════════════════════════════
class SpatialSearch {
constructor(options = {}) {
this.maxDistance = options.maxDistance || 1000;
this.onResultSelect = options.onResultSelect || null;
this.entities = new Map();
this.selectedIndex = -1;
this.results = [];
this.isOpen = false;
this._initUI();
this._bindKeys();
}
// ─── Entity Management ─────────────────────────────────
registerEntity(id, { name, type = 'object', position }) {
this.entities.set(id, {
id,
name: name.toLowerCase(),
displayName: name,
type,
position: { ...position }
});
}
unregisterEntity(id) {
this.entities.delete(id);
}
updateEntityPosition(id, position) {
const entity = this.entities.get(id);
if (entity) {
entity.position = { ...position };
}
}
// ─── Search ────────────────────────────────────────────
searchEntities(query, cameraPosition = null) {
if (!query || query.length < 1) {
this.results = [];
this._renderResults();
return [];
}
const q = query.toLowerCase();
const results = [];
for (const [id, entity] of this.entities) {
if (!entity.name.includes(q)) continue;
let distance = 0;
let direction = '';
if (cameraPosition) {
distance = this._calculateDistance(cameraPosition, entity.position);
if (distance > this.maxDistance) continue;
direction = this._calculateDirection(cameraPosition, entity.position);
}
results.push({
id,
name: entity.displayName,
type: entity.type,
distance: Math.round(distance * 10) / 10,
direction,
position: entity.position
});
}
// Sort by distance
results.sort((a, b) => a.distance - b.distance);
this.results = results.slice(0, 10); // Limit to 10 results
this.selectedIndex = this.results.length > 0 ? 0 : -1;
this._renderResults();
return this.results;
}
selectResult(index) {
if (index < 0 || index >= this.results.length) return;
this.selectedIndex = index;
this._renderResults();
const result = this.results[index];
if (result && this.onResultSelect) {
this.onResultSelect(result);
}
this.close();
}
// ─── Distance & Direction ──────────────────────────────
_calculateDistance(from, to) {
const dx = to.x - from.x;
const dy = to.y - from.y;
const dz = to.z - from.z;
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
_calculateDirection(from, to) {
const dx = to.x - from.x;
const dz = to.z - from.z;
const angle = Math.atan2(dx, dz) * (180 / Math.PI);
// Convert to compass direction
if (angle >= -22.5 && angle < 22.5) return 'N';
if (angle >= 22.5 && angle < 67.5) return 'NE';
if (angle >= 67.5 && angle < 112.5) return 'E';
if (angle >= 112.5 && angle < 157.5) return 'SE';
if (angle >= 157.5 || angle < -157.5) return 'S';
if (angle >= -157.5 && angle < -112.5) return 'SW';
if (angle >= -112.5 && angle < -67.5) return 'W';
if (angle >= -67.5 && angle < -22.5) return 'NW';
return 'N';
}
// ─── UI ────────────────────────────────────────────────
_initUI() {
// Search container
this.container = document.createElement('div');
this.container.id = 'spatial-search';
this.container.className = 'spatial-search';
this.container.style.display = 'none';
// Input
this.input = document.createElement('input');
this.input.type = 'text';
this.input.className = 'spatial-search-input';
this.input.placeholder = 'Search by name... (Ctrl+F)';
this.input.addEventListener('input', () => this._onInput());
this.input.addEventListener('keydown', (e) => this._onKeyDown(e));
// Results dropdown
this.dropdown = document.createElement('div');
this.dropdown.className = 'spatial-search-dropdown';
// Path arrow
this.arrow = document.createElement('div');
this.arrow.className = 'spatial-search-arrow';
this.arrow.style.display = 'none';
this.arrow.innerHTML = '<span class="arrow-icon">➤</span><span class="arrow-info"></span>';
this.container.appendChild(this.input);
this.container.appendChild(this.dropdown);
document.body.appendChild(this.container);
document.body.appendChild(this.arrow);
}
_bindKeys() {
document.addEventListener('keydown', (e) => {
// Ctrl+F or Cmd+F to toggle
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
e.preventDefault();
this.toggle();
return;
}
// Escape to close
if (e.key === 'Escape' && this.isOpen) {
e.preventDefault();
this.close();
return;
}
});
}
_onInput() {
const query = this.input.value;
// Get camera position if available
const cameraPos = window.camera ? {
x: window.camera.position.x,
y: window.camera.position.y,
z: window.camera.position.z
} : null;
this.searchEntities(query, cameraPos);
}
_onKeyDown(e) {
if (!this.isOpen || this.results.length === 0) return;
switch (e.key) {
case 'ArrowDown':
e.preventDefault();
this.selectedIndex = Math.min(this.selectedIndex + 1, this.results.length - 1);
this._renderResults();
break;
case 'ArrowUp':
e.preventDefault();
this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
this._renderResults();
break;
case 'Enter':
e.preventDefault();
if (this.selectedIndex >= 0) {
this.selectResult(this.selectedIndex);
}
break;
}
}
_renderResults() {
this.dropdown.innerHTML = '';
if (this.results.length === 0) {
if (this.input.value) {
this.dropdown.innerHTML = '<div class="spatial-search-empty">No results found</div>';
}
return;
}
this.results.forEach((result, index) => {
const item = document.createElement('div');
item.className = `spatial-search-item ${index === this.selectedIndex ? 'selected' : ''}`;
item.innerHTML = `
<span class="item-name">${this._escapeHtml(result.name)}</span>
<span class="item-type">${result.type}</span>
<span class="item-distance">${result.distance}m ${result.direction}</span>
`;
item.addEventListener('click', () => this.selectResult(index));
this.dropdown.appendChild(item);
});
}
_updateArrow(result) {
if (!result) {
this.arrow.style.display = 'none';
return;
}
this.arrow.style.display = 'flex';
const info = this.arrow.querySelector('.arrow-info');
if (info) {
info.textContent = `${result.name}${result.distance}m ${result.direction}`;
}
// Rotate arrow based on direction
const rotations = {
'N': 0, 'NE': 45, 'E': 90, 'SE': 135,
'S': 180, 'SW': 225, 'W': 270, 'NW': 315
};
const arrowIcon = this.arrow.querySelector('.arrow-icon');
if (arrowIcon) {
arrowIcon.style.transform = `rotate(${rotations[result.direction] || 0}deg)`;
}
}
_escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
return div.innerHTML;
}
// ─── Public API ────────────────────────────────────────
open() {
this.isOpen = true;
this.container.style.display = 'flex';
this.input.focus();
this.input.value = '';
this.results = [];
this._renderResults();
}
close() {
this.isOpen = false;
this.container.style.display = 'none';
this.input.blur();
this.selectedIndex = -1;
this._updateArrow(null);
}
toggle() {
if (this.isOpen) {
this.close();
} else {
this.open();
}
}
getStatus() {
return {
entityCount: this.entities.size,
isOpen: this.isOpen,
resultCount: this.results.length,
selectedIndex: this.selectedIndex
};
}
}
// Export for module systems
if (typeof module !== 'undefined' && module.exports) {
module.exports = SpatialSearch;
}
// Make available globally
if (typeof window !== 'undefined') {
window.SpatialSearch = SpatialSearch;
}

View File

@@ -29,7 +29,7 @@ from typing import Any, Callable, Optional
import websockets
from bannerlord_trace import BannerlordTraceLogger
from nexus.bannerlord_trace import BannerlordTraceLogger
# ═══════════════════════════════════════════════════════════════════════════
# CONFIGURATION

View File

@@ -304,6 +304,43 @@ async def inject_event(event_type: str, ws_url: str, **kwargs):
sys.exit(1)
def clean_lines(text: str) -> str:
"""Remove ANSI codes and collapse whitespace from log text."""
import re
text = strip_ansi(text)
text = re.sub(r'\s+', ' ', text).strip()
return text
def normalize_event(event: dict) -> dict:
"""Normalize an Evennia event dict to standard format."""
return {
"type": event.get("type", "unknown"),
"actor": event.get("actor", event.get("name", "")),
"room": event.get("room", event.get("location", "")),
"message": event.get("message", event.get("text", "")),
"timestamp": event.get("timestamp", ""),
}
def parse_room_output(text: str) -> dict:
"""Parse Evennia room output into structured data."""
import re
lines = text.strip().split("\n")
result = {"name": "", "description": "", "exits": [], "objects": []}
if lines:
result["name"] = strip_ansi(lines[0]).strip()
if len(lines) > 1:
result["description"] = strip_ansi(lines[1]).strip()
for line in lines[2:]:
line = strip_ansi(line).strip()
if line.startswith("Exits:"):
result["exits"] = [e.strip() for e in line[6:].split(",") if e.strip()]
elif line.startswith("You see:"):
result["objects"] = [o.strip() for o in line[8:].split(",") if o.strip()]
return result
def main():
parser = argparse.ArgumentParser(description="Evennia -> Nexus WebSocket Bridge")
sub = parser.add_subparsers(dest="mode")

View File

@@ -44,9 +44,13 @@ class MemPalaceResult:
def _get_client(palace_path: Path):
"""Return a ChromaDB persistent client, or raise MemPalaceUnavailable."""
"""Return a ChromaDB persistent client, or raise MemPalaceUnavailable.
Telemetry is disabled for sovereignty — no data leaks to Chroma Inc.
"""
try:
import chromadb # type: ignore
from chromadb.config import Settings
except ImportError as exc:
raise MemPalaceUnavailable(
"ChromaDB is not installed. "
@@ -59,7 +63,10 @@ def _get_client(palace_path: Path):
"Run 'mempalace mine' to initialise the palace."
)
return chromadb.PersistentClient(path=str(palace_path))
return chromadb.PersistentClient(
path=str(palace_path),
settings=Settings(anonymized_telemetry=False),
)
def search_memories(

105
portal-hot-reload.js Normal file
View File

@@ -0,0 +1,105 @@
/**
* Portal Hot-Reload for The Nexus
*
* Watches portals.json for changes and hot-reloads portal list
* without server restart. Existing connections unaffected.
*
* Usage:
* PortalHotReload.start(intervalMs);
* PortalHotReload.stop();
* PortalHotReload.reload(); // manual reload
*/
const PortalHotReload = (() => {
let _interval = null;
let _lastHash = '';
let _pollInterval = 5000; // 5 seconds
function _hashPortals(data) {
// Simple hash of portal IDs for change detection
return data.map(p => p.id || p.name).sort().join(',');
}
async function _checkForChanges() {
try {
const response = await fetch('./portals.json?t=' + Date.now());
if (!response.ok) return;
const data = await response.json();
const hash = _hashPortals(data);
if (hash !== _lastHash) {
console.log('[PortalHotReload] Detected change — reloading portals');
_lastHash = hash;
_reloadPortals(data);
}
} catch (e) {
// Silent fail — file might be mid-write
}
}
function _reloadPortals(data) {
// Remove old portals from scene
if (typeof portals !== 'undefined' && Array.isArray(portals)) {
portals.forEach(p => {
if (p.group && typeof scene !== 'undefined' && scene) {
scene.remove(p.group);
}
});
portals.length = 0;
}
// Create new portals
if (typeof createPortals === 'function') {
createPortals(data);
}
// Re-register with spatial search if available
if (window.SpatialSearch && typeof portals !== 'undefined') {
portals.forEach(p => {
if (p.config && p.config.name && p.group) {
SpatialSearch.register('portal', p, p.config.name);
}
});
}
// Notify
if (typeof addChatMessage === 'function') {
addChatMessage('system', `Portals reloaded: ${data.length} portals active`);
}
console.log(`[PortalHotReload] Reloaded ${data.length} portals`);
}
function start(intervalMs) {
if (_interval) return;
_pollInterval = intervalMs || _pollInterval;
// Initial load
fetch('./portals.json').then(r => r.json()).then(data => {
_lastHash = _hashPortals(data);
}).catch(() => {});
_interval = setInterval(_checkForChanges, _pollInterval);
console.log(`[PortalHotReload] Watching portals.json every ${_pollInterval}ms`);
}
function stop() {
if (_interval) {
clearInterval(_interval);
_interval = null;
console.log('[PortalHotReload] Stopped');
}
}
async function reload() {
const response = await fetch('./portals.json?t=' + Date.now());
const data = await response.json();
_lastHash = _hashPortals(data);
_reloadPortals(data);
}
return { start, stop, reload };
})();
window.PortalHotReload = PortalHotReload;

View File

@@ -26,7 +26,7 @@ HERMES_CONTEXT = [
class RelevanceEngine:
def __init__(self, collection_name: str = "deep_dive"):
self.client = chromadb.PersistentClient(path="./chroma_db")
self.client = chromadb.PersistentClient(path="./chroma_db", settings=chromadb.config.Settings(anonymized_telemetry=False))
self.embedding_fn = embedding_functions.SentenceTransformerEmbeddingFunction(
model_name="all-MiniLM-L6-v2"
)

View File

@@ -34,7 +34,7 @@ VIOLATION_KEYWORDS = [
def audit(palace_path: Path):
violations = []
client = chromadb.PersistentClient(path=str(palace_path))
client = chromadb.PersistentClient(path=str(palace_path), settings=chromadb.config.Settings(anonymized_telemetry=False))
try:
col = client.get_collection("mempalace_drawers")
except Exception as e:

View File

@@ -18,7 +18,7 @@ DOCS_PER_ROOM = 5
def main():
client = chromadb.PersistentClient(path=PALACE_PATH)
client = chromadb.PersistentClient(path=PALACE_PATH, settings=chromadb.config.Settings(anonymized_telemetry=False))
col = client.get_collection("mempalace_drawers")
# Discover rooms in this wing

View File

@@ -1,99 +0,0 @@
// Test suite for SpatialSearch module
// Run: node --test tests/test_spatial_search.js
const { describe, it, beforeEach } = require('node:test');
const assert = require('node:assert');
// Mock DOM for Node.js environment
global.document = {
createElement: (tag) => ({
className: '',
style: {},
innerHTML: '',
textContent: '',
addEventListener: () => {},
appendChild: () => {},
querySelector: () => ({ style: {}, textContent: '' })
}),
body: { appendChild: () => {} },
addEventListener: () => {}
};
global.window = { camera: null };
// Load module
const SpatialSearch = require('../js/spatial-search.js');
describe('SpatialSearch', () => {
let search;
beforeEach(() => {
search = new SpatialSearch({ maxDistance: 1000 });
});
it('loads correctly', () => {
assert.ok(SpatialSearch);
});
it('can be instantiated', () => {
assert.ok(search instanceof SpatialSearch);
});
it('can register entities', () => {
search.registerEntity('user1', {
name: 'Alice',
type: 'user',
position: { x: 10, y: 0, z: 5 }
});
const status = search.getStatus();
assert.strictEqual(status.entityCount, 1);
});
it('can unregister entities', () => {
search.registerEntity('user1', { name: 'Alice', type: 'user', position: { x: 0, y: 0, z: 0 } });
search.unregisterEntity('user1');
assert.strictEqual(search.getStatus().entityCount, 0);
});
it('can update entity position', () => {
search.registerEntity('user1', { name: 'Alice', type: 'user', position: { x: 0, y: 0, z: 0 } });
search.updateEntityPosition('user1', { x: 10, y: 0, z: 10 });
// Verify by searching with camera position
const results = search.searchEntities('alice', { x: 0, y: 0, z: 0 });
assert.strictEqual(results.length, 1);
assert.ok(results[0].distance > 0);
});
it('calculates distance correctly', () => {
const from = { x: 0, y: 0, z: 0 };
const to = { x: 3, y: 0, z: 4 };
const distance = search._calculateDistance(from, to);
assert.strictEqual(distance, 5); // 3-4-5 triangle
});
it('calculates direction correctly', () => {
const from = { x: 0, y: 0, z: 0 };
assert.strictEqual(search._calculateDirection(from, { x: 0, y: 0, z: 10 }), 'N');
assert.strictEqual(search._calculateDirection(from, { x: 10, y: 0, z: 0 }), 'E');
assert.strictEqual(search._calculateDirection(from, { x: 0, y: 0, z: -10 }), 'S');
assert.strictEqual(search._calculateDirection(from, { x: -10, y: 0, z: 0 }), 'W');
});
it('searches entities correctly', () => {
search.registerEntity('1', { name: 'Alice', type: 'user', position: { x: 5, y: 0, z: 0 } });
search.registerEntity('2', { name: 'Bob', type: 'user', position: { x: 10, y: 0, z: 0 } });
search.registerEntity('3', { name: 'Alice Shop', type: 'object', position: { x: 20, y: 0, z: 0 } });
const results = search.searchEntities('ali', { x: 0, y: 0, z: 0 });
assert.strictEqual(results.length, 2);
assert.strictEqual(results[0].name, 'Alice'); // Closer
assert.strictEqual(results[1].name, 'Alice Shop');
});
it('gets status', () => {
search.registerEntity('1', { name: 'Test', type: 'object', position: { x: 0, y: 0, z: 0 } });
const status = search.getStatus();
assert.strictEqual(status.entityCount, 1);
assert.strictEqual(status.isOpen, false);
assert.strictEqual(status.resultCount, 0);
});
});