- Expand app.py _seed_corpus() to ingest main docs/ folder (CAPABILITY_CONTRACT, GLOSSARY, M01-M13, X01-X04, OVERVIEW, ARCHITECTURE, roadmap, etc.)
- Content-addressed deduplication via BLAKE3 (automatic no-op on re-ingest)
- Integrated with Ask tab RAG query + routing traces
- Enhanced bus capability.py with trust levels and request context
- Improved RAG service ingestion flow with doc_cid tracking
- Updated UI ask.py and mesh.py tabs for better query visualization
- Settings tab shows active corpus and document count
- Updated tasks.md with completion status
feat(agent): wire real ReAct tool-calling loop into Ask tab (M21)
GitHub Actions
833bc64
Turns the stubbed ToolExecutor into a working multi-step agent:
- Fix ToolExecutor.execute() bus dispatch: it built a RouteRequest and called
bus.call(req), but the HearthNet CapabilityBus API is positional
bus.call(name, version, body). The tool path was therefore never reachable.
Now dispatches correctly and surfaces bus errors instead of fabricating.
- Add ToolExecutor.run_react_loop(): a model-agnostic ReAct loop mirroring the
proven browser agent format (action: {json} -> Observation:), so it works on
tiny local models with no native function-calling. Returns {final, steps}
with a Thought -> Tool -> Observation trace.
- Add default_tool_set(bus): binds read-only tools to REAL existing caps
(rag.query, rag.list_corpora, trans.text, market.list, moe.route,
tool.plant_identify). No side-effecting tools, no mock handlers.
- Ask tab: add 'Agent mode' toggle + Agent Steps panel showing each tool call
and observation over the live bus.
- tests/test_phase1_agent.py: 5 n…
test: add P2/P3 user story coverage (78 new tests)
fix(bus): fail over to remote provider when local errors + stamp _routed_via
GitHub Actions
aea0c36
ASK/RAG now route over the mesh when this node cannot serve a capability
locally (e.g. LLM _UnavailableBackend). handle_call retries the best remote
provider on a local application error, and every caller-facing result is
stamped with _routed_via so the UI routing trace shows the true serving node
(local vs peer). Inbound remote calls (local_only) never fail over or stamp.
fix(chat): wire ChatService with bus in app.py so cross-node sends deliver
GitHub Actions
fa5b4a9
The HF Space / UI entry point constructed ChatService without a bus=
reference, so _deliver_remote short-circuited to 'queued' before ever
attempting remote delivery. Pass bus=node.bus (matching node.py wiring)
so local->peer chat is delivered over the bus transport.
Verified live: local browser UI -> HF Space now reports 'delivered' and
the message lands in the Space chat log.
Add regression tests covering manual ChatService wiring + the no-bus
failure mode. Tidy stray blank lines in relay_client.
fix(relay): register hub node directly via /manifest, even when absent from roster
GitHub Actions
caa7fae
The live HF Space's roster can omit its own current node id (a stale entry from
a previous deployment may linger instead). Relying on hub_node_id appearing in
the roster was insufficient: chat to the hub fell back to the relay mailbox path
and degraded to 'queued' across event loops.
RelayClient now fetches GET /manifest on join to learn the hub's authoritative
node id + capabilities, and registers every capability with a direct http/https
endpoint pointing at the relay base URL. CompositeTransport then serves the hub
via /bus/v1/call, which works regardless of roster state or the caller's event
loop. Verified live against the HF Space: cross-loop chat.send now returns
'delivered' and the message lands in the Space's chat log.
Adds test_hub_registered_directly_even_when_absent_from_roster.
fix(relay): route hub node via direct HTTP to fix cross-event-loop chat delivery
GitHub Actions
6cbb125
The Gradio UI runs async handlers on different event loops across invocations.
The relay poll loop (started during join on loop A) resolves correlation
futures, but Chat handlers run on loop B -- a loop-bound future created in loop
B is never resolved by the poll loop in loop A, so cross-node chat delivery
degraded to 'queued' instead of 'delivered'.
The relay hub's own in-process node (the HF Space) is always directly reachable
over HTTP at the relay base URL. The hub now advertises its node id via
'hub_node_id' in the join response; RelayClient gives that peer a direct
http/https endpoint so CompositeTransport serves it via /bus/v1/call, bypassing
the poll loop entirely. This works regardless of the caller's event loop. Other
(NAT-bound) peers continue to use the relay mailbox path.
Adds tests: test_join_exposes_hub_node_id and
test_hub_peer_routed_via_direct_http_across_loops.
fix: resolve cross-node chat [echo] bug
GitHub Actions
cbad453
Root causes:
1. Gradio race condition: peer_dropdown.change updates peer_id textbox
async, but clicking Send before update completes sends to empty recipient
which falls back to self → 'direct' → [echo].
Fix: pass both peer_dropdown and peer_id as inputs to send_msg;
use peer_box when non-empty, else peer_drop (no async dependency).
2. Node ID prefix collision: local app.py used hf-space-* prefix same as
HF Space nodes. _apply_roster skips own ID, so the live Space node
(hf-space-f28143c5) was silently skipped and only stale dead nodes
appeared in the dropdown.
Fix: use SPACE_HOST env var (set only on HF) to discriminate; local
nodes now get local-* prefix (local-f28143c5), so Space nodes appear
as genuine remote peers.
Also added:
- tests/test_chat_cross_node.py: 4 integration tests for cross-node
chat delivery, history, self-send, and unknown-node cases (all pass)
Add all-to-all internet mesh over relay hub (P1-P3) + user-story screenshot proof
GitHub Actions
8f53c4c
Quality improvements: Unicode chars, Token class, imports, type hints, formatting
GitHub Actions
3f78ea8
- Ruff formatting applied to all 158 files
- Fixed Unicode character ambiguities (RUF001)
- Removed duplicate methods in _EchoBackend class
- Updated Token dataclass with proper type hints
- Fixed unused imports and parameter shadowing
- Improved optional import handling
- 47% reduction in ruff lint violations (51 → 27)
- All tests passing, no regressions
feat: real node-to-node HTTP peering (local <-> HF Space)
GitHub Actions
8231854
Wires the previously-scaffolded mesh end-to-end so a local node can peer
with the public HF Space and route real llm.chat/rag.query/moe.* calls.
- HttpBusTransport: bus.transport.call() now forwards to remote peers via
POST /bus/v1/call (in-process delivery still used for same-process nodes)
- DiscoveryService: adds discovery.peer.add (fetch /manifest + register
remote caps) and discovery.peers capabilities
- node.py: default to HttpBusTransport; register DiscoveryService on every node
- app.py: mount /bus/v1/call, /bus/v1/capabilities, /manifest, /health into
the Gradio FastAPI app so the HF Space bus is reachable on its public port
- test_http_peer_routing.py: two real uvicorn nodes peer and route over HTTP
fix: webagent at /webagent/ via lifespan mount; ticker shows real HN+BBC news
GitHub Actions
694ac0a
Popup fix:
- Serve webagent via FastAPI StaticFiles at /webagent/ (not file= which HF proxy blocks)
- Inject mount via ASGI lifespan patched into demo.launch so it runs regardless
of whether HF Space or __main__ calls launch()
- iframe src changed from file=<abs_path> to /webagent/index.html
Ticker fix:
- Remove static placeholder items; track populated at runtime via JS
- Fetch real Hacker News top stories (hacker-news.firebaseio.com JSON API)
- Fetch BBC World RSS via allorigins CORS proxy
- Static placeholder shown until APIs respond; doubled for seamless loop
feat: easter egg CSS injected via js_on_load (no gr.Blocks css= deprecation)
GitHub Actions
6b2d40b
- Remove _EGG_CSS constant; CSS now injected into document.head inside _EGG_JS
- Idempotent guard: checks for #hn-egg-styles before inserting <style>
- gr.Blocks no longer receives css= (fixes Gradio 6 deprecation warning)
- gr.HTML uses html_template + js_on_load only (no css_template needed)
- Ticker (e key) and agent modal (a key) verified working via Playwright
- Esc closes both; elements reside in document.body for correct fixed positioning
- allowed_paths added to demo.launch() for webagent iframe file= src
fix: complete easter egg rewrite using Gradio 6 js= API
GitHub Actions
5347513
Root cause: Gradio's position:fixed was trapped inside stacking context.
Scripts in head= were blocked by CSP. CSS in gr.HTML() was blocked too.
Solution:
1. Use gr.Blocks(js=...) — Gradio 6 native JS injection, runs on page load,
NOT blocked by CSP because Gradio bundles it with its own scripts
2. Create ticker + modal in JS, append directly to document.body —
escapes ALL Gradio containers/stacking contexts
3. CSS via gr.Blocks(css=...) — Gradio injects this as proper stylesheet
Also: re-applied Python 3.10 UTC fixes (reverted again by formatter)
fix: CSS via gr.Blocks(css=) + serve webagent as static files
GitHub Actions
f620ad7
Problem 1 - Ticker was empty (CSP blocked inline <style> in gr.HTML()):
- Moved CSS out of gr.HTML() into gr.Blocks(css=...) parameter
- Gradio injects this as a proper stylesheet, bypassing CSP
- Doubled ticker items for seamless infinite scroll loop
Problem 2 - Agent modal showed blank (iframe pointed to localhost:8099):
- Mounted webagent/ directory as FastAPI static files at /webagent/
- Changed iframe src from http://127.0.0.1:8099/index.html -> /webagent/index.html
- Now works on both local and HF Space (same origin)
Keyboard shortcuts:
e = toggle news ticker at top of page
a = open/close browser agent popup modal
test: add comprehensive easter egg tests
GitHub Actions
cbff2cf
Added tests to verify easter egg ticker is properly implemented:
- Script injected via Blocks head parameter (executes in browser)
- HTML/CSS in gr.HTML() component (no script tags)
- Event listener checks for 'e' key (both lowercase and uppercase)
- Guards against INPUT/TEXTAREA to prevent triggering while typing
- Retry logic for DOM element initialization
- Ticker toggles .active class for animation
Also fixed: removed extra triple-quote causing syntax error in app.py
test: add Python 3.10 compatibility check
GitHub Actions
d5d0b5e
Prevents regression of UTC import issue that breaks on Python 3.10
(used by HF Spaces). The test scans all hearthnet/*.py files and
verifies no code uses 'from datetime import UTC'.
Instead, all files must use:
from datetime import timezone
UTC = timezone.utc
This test runs on every commit to catch any future regressions.
fix(tests,identity): order-independent event loop + Windows key permissions
GitHub Actions
6a14ec5
conftest autouse fixture provisions a fresh current event loop per test (Python 3.13 asyncio.run resets the current loop to None, causing order-dependent failures). Four test_coverage_boost concurrency tests now build gather() inside an async wrapper. keys.py POSIX 0o600 check is gated behind os.name==posix; stat.S_IMODE returns 0o666 on NTFS (not an error), so the guard wrongly rejected valid keys on Windows. POSIX enforcement unchanged.
P1 gossip: _HttpxSyncClient adapter fixes _gossip_loop (wrong HttpClient args + missing httpx .get/.post). P2/P3: install_extended_services registers Embedding(bge-small)/Rerank/Ocr/Translation/Stt/Tts/Image* with graceful unavailable. P4: EvidenceService + CivilDefenseService bus adapters (research=True). P6: app.py uses real RagService+FederatedRagService with seeded corpus, multi-backend LlmService (HF + opt-in Nemotron/Modal/MiniCPM), opens EventLog and injects into Marketplace/Chat. Adds sentence-transformers, httpx, pytest-asyncio. No mocks; optional deps degrade honestly.
fix(llm): single multi-model llm.chat so sponsor backends are reachable
GitHub Actions
90a59b3
Registry keys local caps by (node,name,version); registering one llm.chat per backend overwrote earlier ones, so HF (registered last) hid Nemotron/Modal/MiniCPM even with NVIDIA_API_KEY set. Now LlmService registers one llm.chat/llm.complete advertising the full model catalogue in params.models and dispatches each call to the owning backend via _resolve_backend. _model_matches and registry _remote_params_compatible honour the catalogue for cross-node routing.
fix: test_m06 RouteRequest API + events import; test_specialized_nodes regex
settings.py: the markdown f-string contained {node_id or 'hf-space-...'} but
node_id was not a local variable in build_settings_tab() scope — replaced with
a literal HF Space invite URL string.
tests/test_ui_coverage.py: added TestTabBuildRegression (6 tests) that:
- Calls build_settings_tab / build_ask_tab / build_chat_tab /
build_getting_started_tab with bus=None (mimics HF Space startup)
- Scans settings.py source for bare {node_id} f-string references
- Builds the full 8-tab UI with a MagicMock bus (full startup simulation)
These tests will catch any future build-time NameError before deployment.
fix: asyncio.get_running_loop() across backends; expand mesh/capability/model UI docs
GitHub Actions
8ee8138
asyncio fix (Invalid file descriptor: -1 on Python 3.10):
Replace asyncio.get_event_loop() with get_running_loop() in all async
methods across 13 files (24 occurrences). get_event_loop() can silently
create a new loop when called outside a running loop, which gets orphaned
and triggers ValueError in __del__ on GC. get_running_loop() raises
RuntimeError immediately if no loop is running — failing fast is correct.
Settings tab - 'Join This Mesh' section rewritten with:
- Option A (same LAN / mDNS): exact commands, timing, verify step
- Option B (invite QR): redeem command, HF Space invite URL example
- Option C (relay): config.toml snippet
- Connecting 3+ meshes: multi-community bridge pattern with code
Getting Started tab - new sections:
- 'Calling a Capability on Any Node': bus.call() Python + CLI examples
for llm.chat / rag.query / chat.send / market.list / registry.all()
- 'Getting Model Weights from a Peer Node': model.list / model.pull /
model.status…
fix: ZeroGPU CUDA init, corpus scan sync, extended user story tests
GitHub Actions
45540b0
- hf_local.py: detect SPACE_HOST env and force device=-1 (CPU) to avoid
ZeroGPU torch._C._cuda_init crash outside @spaces.GPU
- ask.py: split _get_corpora into sync (build-time registry scan, no
event loop needed) and async (bus.call rag.list_corpora on refresh)
Fixes: ERR_ABORTED on initial page load + dropdown showing only (none)
- test_e2e_user_stories.py: add TestUS11ApiCoverage (6 API tests for
corpus refresh, LLM error surface, RAG trace, chat delivery status,
broadcast send, invite host) and TestUS12MeshConnection (mesh join
methods documented in Settings, mutual peer discovery)
fix: PyNaCl in requirements, file tab download+auto-refresh, impl status table
GitHub Actions
dfa947a
requirements.txt:
- Add pynacl>=1.5.0 (needed for Ed25519 signing, invite QR generation,
X3DH/Double Ratchet, token issuance — was missing from HF Space deps)
hearthnet/ui/tabs/files.py:
- Fix wrong key: 'blobs' -> 'files' (file.list returns output.files)
- Add type='filepath' to gr.File for Gradio 6 API correctness
- Auto-refresh blob list after successful upload (now outputs to [upload_result, blobs_out])
- Add Download section: CID input + download button -> gr.File output
Uses file.get capability, decodes base64, writes temp file for Gradio to serve
- Show helpful 'No files yet' message when list is empty
hearthnet/ui/tabs/settings.py:
- Expand impl status table: M26-M31 each get their own row with description
- Add X08 tensor transport + X09 conformance suite rows
- Update M12 description to show all 9 commands
- Update M07/M08 descriptions to reflect current state
- Add footer note explaining 🔬 experimental flag meaning
fix: Python 3.10 compatibility for HF Space (Python 3.10 env)
GitHub Actions
38391a8
datetime.UTC was added in Python 3.11. HF Space runs Python 3.10.
Replace all 11 occurrences with timezone.utc:
- hearthnet/services/chat/service.py
- hearthnet/identity/manifest.py
- hearthnet/events/log.py
- hearthnet/events/snapshot.py
- hearthnet/transport/server.py
- hearthnet/transport/client.py
- hearthnet/transport/tls.py (datetime.datetime.now(datetime.UTC))
- hearthnet/ui/onboarding.py
- hearthnet/services/marketplace/post.py
- hearthnet/services/marketplace/service.py
- hearthnet/services/marketplace/views.py
tomllib is stdlib >= 3.11. Remove bare top-level import from config.py;
the try/except fallback (tomllib -> tomli -> None) already present is now
the only import path.
Fix 6 test failures in test_complexity.py + test_performance.py:
- Embedding error check: look at 'message' field, not error code
- Marketplace: 'posts' key not 'listings' in market.list output
- EventLog: 'community.member.joined' is a valid EventType (not 'community.e…
types.py: add all Phase 3 type aliases per IMPLEMENTATION_REFERENCE_p3.md §4
- ShardID, ExpertID, ExpertKind, ClaimID, SourceID, EvidenceLevel
- RoundID, LoraBeaconID, LoraDeviceID, AlertID, AlertSeverity, AckStatus
- ProtocolVersion dataclass with __str__
constants.py: add all Phase 3 numeric constants per impl_ref_p3.md §5
- M26 distributed inference (8 constants)
- M27 MoE routing (7 constants)
- M28 fedlearn (9 constants)
- M29 LoRa beacons (6 constants)
- M30 evidence graph (3 constants)
- M31 civil defense (5 constants)
- X08 tensor transport (5 constants)
- X09 conformance suite (2 constants)
ARCHITECTURE.md: new top-level architecture reference
- Full module map (Phase 1+2+3 + cross-cutting)
- Composition root pattern (HearthNode)
- Capability bus data flow diagram
- Discovery + emergency mode flows
- MoE expert routing flow
- M26 distributed inference / BitTorrent-style model sharing flow
- File tree with annotations
- Config reference (…
feat: X01/X02/X06/X09/M02/M22 wiring + conformance suite + mobile PWA + 22 new tests
GitHub Actions
9505822
HearthNode.start() / stop() (node.py):
- 15-step startup: EventLog (X02), mDNS+UDP discovery (M02), Detector.start(),
HttpServer (X01), gossip sync loop, WebSocket pubsub wiring (X06)
- Detector.run() -> Detector.start() fix; EventLog.close() in stop()
- Removed duplicate HearthNode class that was shadowing start()/stop()
ProtocolService (hearthnet/services/protocol/service.py):
- protocol.version.list@1.0 — returns contract_versions, impl info, started flag
- protocol.conformance.report@1.0 — runs X09 check suite in-process
- Registered in install_demo_services() and install_services()
ConformanceRunner (hearthnet/conformance/):
- runner.py — 21 checks across suite 1.0/2.0/3.0, fast mode skips
unregistered capabilities, structured ConformanceReport.as_dict()
- Checks: protocol, embed, rag, file, market, llm, chat, moe, model, plant tool,
ocr/trans/rerank (Phase 2), moe.register/model.status (Phase 3)
Mobile PWA (hearthnet/ui/mobile/):
- static.py — PWA_MANIFEST, SERVICE_WORKE…
feat: Phase 3 wired + plant tool + MoE bus + model distribution always-on
GitHub Actions
c91b229
MoeService (M27):
- hearthnet/services/moe/service.py — wraps MoeRouter as bus service
- Capabilities: moe.route, moe.register, moe.list, moe.handoff
- Registered in both install_demo_services() and install_services()
PlantIdentificationService (M21 tool):
- hearthnet/services/tools/plant.py — tool.plant_identify on the bus
- Priority: local vision.describe + llm.complete > HF Inference API > unavailable
- PLANT_TOOL_DEFINITION for ToolExecutor (LLM mid-gen tool call)
- HEARTHNET_HF_TOKEN env var enables HF Inference API (opt-in)
ModelDistributionService (M26):
- Always registered — auto-creates BlobStore in ~/.hearthnet/blobs if no store given
- install_demo_services() uses tmpdir BlobStore for test isolation
- No longer requires blob_store=... to be passed explicitly
node.py:
- install_demo_services() now registers MoeService, PlantIdentificationService,
ModelDistributionService (tmpdir store — no disk writes persist)
- install_services() now registers MoeService, PlantIdentific…
fix: 0 test failures; FileService; real RagService; emergency probe; chat return
GitHub Actions
4aaae80
TESTS:
- conftest.py: nest_asyncio.apply() fixes Python 3.13 + pytest-asyncio 0.26
event-loop isolation — was causing 32 cross-test failures; now 102 passed 0 failed
- pyproject.toml: asyncio_mode=strict + asyncio_default_fixture_loop_scope=function
SERVICES (no mocks, no fakes in production):
- hearthnet/services/__init__.py: import real RagService not demo.RagService
- hearthnet/services/files/: new FileService providing file.put/file.get/file.list/
file.delete via bus (BLAKE3 CID, in-memory or disk store)
- node.py: register FileService in both install_demo_services and install_services
- marketplace: add market.delete capability (alias for expire)
UI BUGS FIXED:
- ui/tabs/chat.py: add missing return in except block (was returning None on error)
- ui/tabs/emergency.py: wire Run Connectivity Probe button with sync probe +
show results; was defined but never connected
- ui/tabs/settings.py: gen_invite gracefully handles missing nacl/community manifest
APP.PY (HF Space):
- Reg…
fix: @spaces.GPU wrapper for ZeroGPU; 18 real component tests
GitHub Actions
6db565a
- app.py: when HF_SPACES=True, patch HfLocalBackend.chat to route
through a @spaces.GPU decorated _gpu_pipeline_call wrapper.
Without this, ZeroGPU raises 'No @spaces.GPU function detected'.
- tests/test_components_real.py: 18 new tests that verify the actual
output of RAG retrieval, LLM routing, Chat delivery, Bus routing
and marketplace — not just 'something appeared in the page'.
Also includes TestHfSpacesCompatibility that would have caught
this exact @spaces.GPU regression before deployment.
Test results: 18/18 pass (new), pre-existing failures unchanged.
tests/test_e2e_user_stories.py — 30 passing Playwright tests across 10 user stories:
US-01 Ask tab: LLM responds, routing trace appears (3 tests)
US-02 Ask + RAG corpus: context-aware query (1 test)
US-03 Chat: send direct message, delivery confirmed (2 tests)
US-04 Mesh tab: live SVG topology, capability matrix (3 tests)
US-05 Settings: node identity, peer list, QR join, specialized-node howto (5 tests)
US-06 Marketplace: post an offer, list shows it (2 tests)
US-07 Files: blob store tab (1 test)
US-08 Emergency: connectivity mode tab (1 test)
US-09 Bob node: independent UI, LLM, sees Alice in mesh (4 tests)
US-10 All 7 tabs: present + renders without traceback (8 tests)
docs/screenshots/stories/ — 31 screenshots saved by tests, one per story step:
US01: alice home, ask empty, LLM response, routing trace
US02: ask with RAG corpus
US03: chat tab, sent message with delivery confirmation
US04: mesh tab initial, live topology SVG, capability matrix
US05: nod…
feat: mesh graph tab, routing trace, QR invite, remove all fakes, specialized-node tests
GitHub Actions
7573216
- hearthnet/ui/tabs/mesh.py: NEW — live SVG topology from bus.registry.all_remote()
- hearthnet/ui/tabs/ask.py: routing trace panel shows which node answered each request
- hearthnet/ui/tabs/settings.py: QR code join, specialized-node howto, full help text
- hearthnet/ui/tabs/chat.py: proper help text, delivery status explained
- hearthnet/ui/tabs/marketplace.py: remove Demo Post fake (show empty or error)
- hearthnet/ui/app.py: add Mesh tab (7 tabs total)
- hearthnet/bus/registry.py: fix remote params_compatible — corpus/model routing now
works correctly across peer nodes (was always True, now checks descriptor params)
- app.py: replace hardcoded NODES/marketplace items with reference topology + note
- tests/test_specialized_nodes.py: 15 new tests covering OCR-only, medical RAG,
thin client, combined node, 4-node routing matrix, failover, local-first routing
- requirements.txt: add qrcode[svg] for scannable invite QR codes
- docs/screenshots/: updated — mesh graph (Alice+Bob), cha…
feat: BitTorrent-style model weight distribution; no fake LLM in production
GitHub Actions
d4978df
ModelDistributionService (hearthnet/services/llm/model_distribution.py):
- model.advertise@1.0 — announces which GGUF/Ollama model files a node holds
- model.list@1.0 — list models available on any peer node
- model.chunk_read@1.0 — serve one CID-addressed chunk of a model file
- model.pull@1.0 — download a model from a peer via chunked blob transfer
- model.status@1.0 — check progress of in-flight pull job
- Auto-scans ~/.ollama/models manifests and models_dir/*.gguf on start()
- CID-addressed (BLAKE3 content hash) — same model from two sources = same CID
- Pull job runs as asyncio background task; progress tracked in PullJob dataclass
- After successful pull, model is registered locally and the node starts
advertising it to further peers (seeder effect)
LlmService cleanup:
- _EchoBackend labeled FOR TESTS ONLY — never used in production paths
- New _UnavailableBackend: returns clear error instead of silent echo when no
real backend is configured ('configure Ollama /…