2026-06-09 15:04:37 +01:00
# Loki Architecture
## Objective
Expose local Chrome tab state as provider-owned, typed service state for
2026-06-09 16:12:31 +01:00
CultMesh/Eve consumers while keeping Chrome installation easy for the operator.
2026-06-09 15:04:37 +01:00
## Current Mechanism
2026-06-09 16:12:31 +01:00
The Chrome extension observes tab metadata with explicit Chrome permissions and
2026-06-13 19:46:10 +01:00
posts reports to Loki's localhost ingest endpoint. On explicit operator command
from the popup, it can capture the active tab's visible page text, headings,
links, and visible form controls for Codex-assisted navigation. On command, it
also uses `chrome.debugger` to attach to debuggable tabs, probe Chrome Debugger
Protocol domains, and detach. Chrome can also expose DevTools metadata on
2026-06-09 17:04:38 +01:00
`127.0.0.1:{port}` when started with `--remote-debugging-port` . Loki normalizes
these sources into one snapshot and writes typed witness documents from that
state.
2026-06-09 15:04:37 +01:00
```mermaid
flowchart LR
2026-06-09 16:12:31 +01:00
Extension["Chrome extension"] --> Ingest["extension ingest"]
2026-06-13 19:46:10 +01:00
Snapshot["active page snapshot"] --> Ingest
2026-06-09 17:04:38 +01:00
Debugger["chrome.debugger sweep"] --> Ingest
2026-06-09 16:12:31 +01:00
Chrome["Chrome CDP endpoint"] --> Observe["observe CDP"]
Config["Loki config"] --> Ingest
Config --> Observe
Ingest --> Combine["combined snapshot"]
Observe --> Combine
Combine --> Snapshot["chrome_snapshot.cc"]
2026-06-09 17:04:38 +01:00
Combine --> Debug["chrome_debug_probe.cc"]
2026-06-09 15:04:37 +01:00
Snapshot --> Provider["provider_advertisement.cc"]
Snapshot --> Surface["eve_surface.cc"]
```
## Invariants
- CDP reachability is observed state, not assumed capability.
2026-06-09 16:12:31 +01:00
- Extension reachability is observed state, not assumed capability.
2026-06-09 17:04:38 +01:00
- Debug sweeps are explicit observations, not continuous hidden attachment.
2026-06-13 19:46:10 +01:00
- Page snapshots are explicit active-tab observations, not continuous page
surveillance.
2026-06-09 15:04:37 +01:00
- Chrome owns page reality; Loki owns only the observation snapshot.
- `.cc` witnesses are the durable local state surface.
- Eve/CultUI output is derived from the same snapshot as the witness.
- No renderer or dashboard can override the daemon's observation state.
## Intended Change Path
1. Add CultCacheTS-backed binary `.cc` persistence behind the current writer.
2. Add CultNet/CultMesh publication of the same documents.
3. Add command handling only through `gamecult.eve.command.v1` .
2026-06-13 19:46:10 +01:00
4. Add operator-approved screenshot capture.
2026-06-09 15:04:37 +01:00
## Command Boundary
2026-06-13 19:46:10 +01:00
Loki currently advertises no executable tab commands. Page snapshot capture is
extension-owned and popup-triggered: the operator clicks once, the extension
captures the active tab, posts the typed observation, and detaches. A future
daemon-originated command path still needs an explicit command document, audit
log, origin, target tab id, and denial path before it should act.