Commit Graph
110 Commits
Author SHA1 Message Date
dasemuandClaude Opus 5.5 e43452f5af feat(graph): graph view with network, local, synapse, cluster and namespace modes
- synapse-ffi: graph_data() returns the whole page-level graph (links, tags,
  property refs, block refs/embeds per page, unlinked mentions, decayed
  synapses) as parallel arrays with degree, backlinks, Louvain clusters and
  primary tags; cached by op seq, synapse state and hour.
- synapse-ffi: ForceLayout, a Barnes-Hut force layout stepped from Dart on a
  Rust worker thread (pin/unpin for dragging, reheat).
- app: Graph view with a mode selector (Network, Local, Synapses, Clusters,
  Namespaces, Timeline), filters (title, tag, date range, min links,
  orphans, journals, mentions), pan/zoom, node drag, hover highlighting,
  activation pulse, cluster hulls, radial namespace/tag tree, and a local
  graph panel on every page. Edges render as one vertex mesh, nodes in
  colour/size batches, culled to the viewport.
- Tests: Rust extraction/mentions/cache/clusters/layout; widget tests for
  mode switching, filters and layout restarts; a real-app integration
  smoke test with frame timings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:39:07 +02:00
dasemuandClaude Opus 5.5 dba9ba3eaa perf(core): cached statements, no per-op savepoints inside transactions
Single operations skip their own savepoint when an enclosing transaction
exists, SQL goes through the prepared-statement cache, and the page cache
and temp store stay in memory. 208k-block import: 65 s -> 19 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:06:20 +02:00
dasemuandClaude Opus 5.5 d536192603 fix(import): handle real-world Logseq graphs
- empty bullets no longer panic the outline parser
- weekday names with non-ASCII letters (miércoles) no longer panic the date parser
- journal refs are recognised in the configured title format and in Logseq's
  default one, so graphs whose format changed keep their date links

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:06:20 +02:00
dasemu 6a4a76670b Merge branch 'refs/heads/claude/import-96e10a' into feat/integration 2026-10-21 14:48:30 +02:00
dasemuandClaude Sonnet 5.5 5fdc4bb48a fix(import): never clobber native content on re-import
Track imported pages/blocks, stable fallback ids, per-document savepoints,
rename-safe page lookup, append on first import into existing pages.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 14:48:03 +02:00
dasemu cd03301abf Merge branch 'refs/heads/claude/sync-server-edc467' into feat/integration
# Conflicts:
#	docs/sync.md
2026-10-21 14:44:03 +02:00
dasemu a85316d470 Merge branch 'refs/heads/claude/history-785c80' into feat/integration 2026-10-21 14:43:53 +02:00
dasemu cc96aff183 Merge branch 'refs/heads/claude/app-13aee9' into feat/integration 2026-10-21 14:43:53 +02:00
dasemu e1022b9d6f Merge branch 'refs/heads/claude/search-f73aec' into feat/integration 2026-10-21 14:43:53 +02:00
dasemuandClaude Sonnet 5.5 9ce35f90ff fix(sync): robust blob handling, op validation and quarantine
- upload_blob resumes until the server confirms the blob (202/409 are not success)
- missing local blob skips its PutAsset instead of blocking all later ops
- failed blob downloads are counted and retried, not fatal to the cycle
- server validates pushed ops (hash, hlc, clock skew) and returns per-op rejections
- pulled ops that can never apply are quarantined; storage errors stay fatal
- SYNAPSE_MAX_CLOCK_SKEW_MINUTES; document Arc<Mutex<Graph>> handle for the FFI

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 14:38:58 +02:00
dasemuandClaude Sonnet 5.5 2b52144311 fix(history): make restore_page and restore_graph atomic
Both run inside Graph::transaction so a failure halfway rolls every change
back. Adds a fault-injection hook and a regression test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 14:38:46 +02:00
dasemuandClaude Opus 5.5 268e152efc fix(ffi): atomic compound outline edits, validated anchors, shared graph
- indent, outdent and merge run in one Graph::transaction, so a failure
  part-way no longer duplicates merged text or strands siblings.
- Placements check that the anchor block exists and is on the target page.
- SynapseGraph holds Arc<Mutex<Graph>> and exposes shared() (not bridged)
  for the sync client.
- docs: rustup's cargo must come first in PATH; sync wording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:38:36 +02:00
dasemuandClaude Opus 5.5 f9137c9896 fix(core): harden merge rules and validation found in review
- page_tree shows orphans and parent cycles (from concurrent moves) as roots;
  descendants CTE and move_block ancestor walk are cycle-safe
- title conflicts compare titles only (not aliases), journals keep their title,
  and loser suffixes use the random id tail so they cannot collide
- aliases get an HLC and tombstones (last-writer-wins)
- remote page deletes cascade to blocks; LastChildOf validates the parent
- reject empty and date-shaped titles on create/rename; ensure_page redirects
  dates to journals; rename rewrites refs inside block properties
- single-row writes run inside savepoints; invalid remote asset hashes are
  ignored and never reach blob paths; HLC counter cannot overflow its width
- busy_timeout for multi-connection use; schema v2 migration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:33:22 +02:00
dasemuandClaude Sonnet 5.5 2931d063f3 fix(search): use nestable SAVEPOINT in store_embeddings
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 14:20:36 +02:00
dasemuandClaude Opus 5.5 3266ddda3a chore(hooks): run stop checks with the rustup toolchain
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:14:44 +02:00
dasemuandClaude Opus 5.5 30d58a0166 feat(core): nestable transactions, put_page and journals_before
Importer runs its write phase in one transaction (replaces the
synchronous=OFF workaround); the FFI journals feed uses journals_before
instead of walking back one day per query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:04:26 +02:00
dasemu 537d70bb55 Merge branch 'refs/heads/claude/sync-server-edc467' into feat/integration
# Conflicts:
#	CLAUDE.md
#	Cargo.lock
2026-10-21 14:02:01 +02:00
dasemu 6a794000d1 docs: index all crate docs 2026-10-21 14:01:48 +02:00
dasemu 5f719f5541 Merge branch 'refs/heads/claude/app-13aee9' into feat/integration
# Conflicts:
#	Cargo.lock
2026-10-21 14:00:08 +02:00
dasemu 9649a76b3c Merge branch 'refs/heads/claude/caldav-1d8050' into feat/integration
# Conflicts:
#	Cargo.lock
2026-10-21 14:00:03 +02:00
dasemu 56d3edf0ce Merge branch 'refs/heads/claude/history-785c80' into feat/integration
# Conflicts:
#	Cargo.lock
2026-10-21 14:00:02 +02:00
dasemu c315d184ea Merge branch 'refs/heads/claude/ai-c15c7e' into feat/integration
# Conflicts:
#	Cargo.lock
2026-10-21 13:59:58 +02:00
dasemu b02ec34371 Merge branch 'refs/heads/claude/search-f73aec' into feat/integration
# Conflicts:
#	Cargo.lock
2026-10-21 13:59:55 +02:00
dasemu f02798d5fb Merge branch 'refs/heads/claude/import-96e10a' into feat/integration 2026-10-21 13:59:46 +02:00
dasemuandClaude Sonnet 5.5 4aa3c01a7f feat(sync): op-log sync protocol, client and axum server
Adds synapse-sync (protocol types, Remote transport and read API, SyncClient with
background loop, SSE realtime, resumable blobs) and synapse-server (multi-graph,
bearer auth, blob streaming, read API, authenticated update endpoint), with e2e
tests, docs/sync.md, docs/server.md, systemd unit and update script.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 04:25:00 +02:00
dasemuandClaude Opus 5.5 5e25db3e24 fix(app): read views after queued writes, reload on write failure
- Page and journal views read through the write queue after the previous
  view's pending saves, so they never load stale text.
- A failed write reloads the current view and shows a message instead of
  leaving blocks on temporary ids; inserts also trigger reconciliation.
- Completion replaces the query range, not up to the caret, and closes
  when the caret moves away.
- Renaming a page reloads it so rewritten links are not overwritten.
- Dropping below an expanded parent lands as its first child, where the
  indicator is drawn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 04:08:36 +02:00
dasemuandClaude Opus 5.5 fce7526fcf docs: app build/run guide, analyze via dart on non-ASCII paths
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:59:42 +02:00
dasemuandClaude Opus 5.5 df42d4010f feat(app): Flutter outliner with journals, page view and timeline
Logseq-like outliner (render/edit Markdown per block, Enter/Tab/Shift-Tab,
backspace merge, arrow navigation, drag to reorder, collapse, [[ # ((
autocomplete, TODO/DONE), journals feed with prev/next links, page view with
linked references and related panel, virtualised CustomPainter timeline,
Ctrl+K quick switcher, sidebar with recents, light/dark theme with bundled
Inter, Noto Serif and Source Code Pro. Edits are optimistic and serialised
to the core through one write queue. Cargokit builds synapse-ffi; its build
tool is patched to use the library name (synapse_ffi) of hyphenated crates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:59:42 +02:00
dasemuandClaude Opus 5.5 c3d6636606 chore(ffi): add demo graph seed example
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:59:42 +02:00
dasemuandClaude Opus 5.5 8c11d049fb fix(ffi): keep merged children in place and rename PageView to PageData
Merging a first child into its parent now gives its children the merged
block's slot instead of appending them after the parent's other children.
PageView clashed with Flutter's PageView widget in Dart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:52:59 +02:00
dasemuandClaude Sonnet 5.5 6697924bf5 feat(ai): provider-agnostic AI crate (Anthropic, OpenAI, Gemini, compatible)
Streaming chat, embeddings (Embedder impl), key stores, retries/cancellation,
and graph features: ask_graph, summarize_journal, suggest_links_and_tags,
extract_tasks, consolidate_week.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 03:41:21 +02:00
dasemuandClaude Sonnet 5.5 e1e64ca2de feat(search): full-text, vector, hybrid search and auto-link suggestions
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 03:39:20 +02:00
dasemuandClaude Sonnet 5.5 a2a6cd8cfb feat(import): Logseq graph importer
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 03:38:22 +02:00
dasemuandClaude Sonnet 5.5 b5e0d0f325 feat(caldav): CalDAV client, VEVENT/VTODO mapping and two-way sync
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 03:37:48 +02:00
dasemuandClaude Sonnet 5.5 3ab03777ea feat(history): git-based snapshots, page history and restore
Deterministic Logseq-compatible Markdown export committed to a bare gix
repository, incremental snapshots driven by the op log, snapshot policy,
page history/diff, restore through the Graph API and pure-Rust HTTP push.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 03:36:59 +02:00
dasemuandClaude Opus 5.5 305428eaea feat(ffi): flutter_rust_bridge API over synapse-core
Opaque SynapseGraph handle (graph behind a mutex) with coarse-grained calls:
journals feed, page views, outline editing (insert, update, move, indent,
outdent, merge, delete), backlinks, aliases, rename, timeline, related,
record_visit, assets and a title/block search stopgap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:36:32 +02:00
dasemuandClaude Opus 5.5 fbcfcf678f feat(core): workspace and synapse-core foundation
Domain model, SQLite graph store, link parser, journals chained in time,
page origin/activity anchors, weighted synapses with spreading activation,
content-addressed blob store and HLC op log with LWW remote apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:24:22 +02:00
dasemuandClaude Opus 5.5 7f5c7738e5 chore: bootstrap Claude setup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 03:16:48 +02:00
dasemu 21b9acfa4a Merge pull request 'chore: bootstrap Claude setup' (#1) from chore/bootstrap into main
Reviewed-on: #1
2026-10-18 18:50:28 +00:00
dasemuandClaude Sonnet 5 f4366407d8 chore: bootstrap Claude setup
Add root CLAUDE.md, LESSONS.md, .env.example, .claude/settings.json
hooks (PostToolUse lint, Stop lint+test via bb dev:lint-and-test), and
a .gitea/workflows/ci.yml lint+test workflow. No development branch
exists here, so CI targets main; version.yml automation is skipped
since this repo already has its own tag-driven release/version flow
(scripts/bump-version.sh, build.yml on v* tags).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-18 15:04:51 +02:00
dasemu b339cbb3b7 Rename product to Synapse; add Gitea CI, VPS deploy templates, RPM build fixes
Rebrands user-facing product identity from Logseq to Synapse (package
metadata, Electron appId/protocol scheme, Android/iOS display names, HTML
titles, and the English UI dictionary), authored by Darío Sevilla
<dario@dariosevilla.es>. Internal Clojure namespaces, :logseq.class/*
and :logseq.property/* DB schema idents, and deps.edn's upstream git
dependency coordinates are intentionally left untouched -- those are
either persisted data in existing graphs or point at real upstream repos,
and renaming them has no user-visible benefit.

Also:
- .gitea/workflows/build.yml: Linux (AppImage/deb/rpm), Windows (nsis),
  and Android (debug APK) build jobs.
- deploy/: systemd unit + Caddyfile templates for a self-hosted VPS
  (daemon on loopback, Caddy reverse-proxies /v1/*, /mcp, /healthz and
  serves the static web client with TLS).
- gulpfile.js / prepare-desktop-runtime-js.mjs: LOGSEQ_SKIP_CLI_BUNDLE
  skips the cli/ OCaml package (no toolchain in this environment) instead
  of failing the build; LOGSEQ_ELECTRON_BUILDER_ARGS lets CI override the
  packaged Linux targets independently of the local default.
- resources/electron-builder.yml: drop the extraResources entry for a
  SKILL.md that doesn't exist in this fork, and the author.email fix
  needed for the rpm/deb targets' Packager/Maintainer metadata.
2026-08-27 12:03:03 +02:00
dasemu d8996bd5e1 Fase B8+B9: stateful code kernel and live notes bound to external URLs
B8 - executable code blocks with a real kernel:
- worker/handler/kernel.cljs: one persistent SCI interpreter session per
  page, reused across block evaluations so defs/state survive between runs.
  Deliberately scoped to the same privileges the existing client-side
  single-shot evaluator already had (no shell/fs access, no call-api).
- Run button + result display wired into block.cljs's code-block UI.
- New :logseq.property.code/result and /executed-at properties (65.38).

B9 - live notes: pages tagged #LiveNote that fetch external content on a
refresh schedule and render it via the render-resource pipeline:
- worker/handler/live_notes.cljs: per-block credential storage, scheduled
  refresh (Node-only), thread-apis for manual refresh and auth.
- worker/handler/render_resource/live_note.cljs: reads back fetched content,
  watching [:entity block-uuid] for reactive invalidation.
- New :logseq.class/LiveNote + :logseq.property.livenote/* properties (65.39).

Bugs found and fixed along the way while actually exercising page creation
through page-handler/create! for the first time in a test (previously only
pure-fn tests existed for CalDAV/Event/Contact):
- logseq-property-namespaces (property.cljs) was missing the citation/event/
  contact/caldav/livenote namespaces, causing auto-create-ontology to treat
  already-built-in properties as new user idents.
- outliner/page.cljs's build-page-tx always added the generic #Page tag even
  when the caller tagged with a built-in class that extends #Page, which
  malli-schema rejects as conflicting; it also lost the property type when
  building ref-typed property values for new pages, breaking non-:default
  types like :number.
- entity-util/page? never recognized Event/Contact/LiveNote as pages (only
  Journal/Whiteboard/Tag/Property/Page had dedicated recognition), so pages
  tagged with those classes alone weren't treated as pages anywhere in the
  app; added built-in-page-child? alongside the existing per-class checks.
- caldav.cljs's upsert-page! passed a bare keyword as a tag where an entity
  was required, and two error logs passed raw error objects to glogi that
  triggered runaway recursion in this test environment; both fixed.
2026-08-26 22:41:23 +02:00
dasemu 0158430489 Fase B7: CalDAV/CardDAV sync with Nextcloud, and a Calendar view type
- New built-in classes Event and Contact (schema 65.37), plus a
  Calendar View view type alongside table/list/gallery, backed by a new
  fixed month-grid calendar-view component in components/views.cljs
  reusing the existing scheduled/deadline properties.
- New worker/handler/caldav.cljs: a deliberately-scoped CalDAV
  (VEVENT/VTODO) + CardDAV (VCARD) client against a single Nextcloud
  calendar/addressbook collection, with its own minimal iCalendar/vCard
  encoder-decoder and namespace-agnostic multistatus XML extraction
  (no external ical/rrule/xml dependency exists in this project).
- RRULE <-> :logseq.property.repeat/* translation covers only the
  `plus` (advance-from-scheduled) repeat mode with a bare FREQ(;INTERVAL)
  rule -- dotted-plus/double-plus and anything with BYDAY/COUNT/UNTIL
  are left untranslated on purpose rather than mistranslated.
- Credentials live in the platform keychain (save-secret-text!), never
  in the graph. Sync runs Node-only, every 15 minutes per open repo,
  started/stopped alongside the repo's lifecycle in db_core.cljs.
  Conflicts are last-write-wins via ETag: a 412 on push is skipped and
  retried after the next pull refreshes the stored ETag.
2026-08-26 21:11:00 +02:00
dasemu dadeca7165 Fase B6: temporal relevance decay and vector-based "similar pages"
- combine-results now applies a bounded (never below 0.5x) exponential
  decay based on :block/updated-at, so more recently touched blocks/pages
  rank slightly higher for otherwise-equal matches.
- New search/similar-blocks reuses the existing zvec index: fetch a
  block's own already-indexed embedding (new :fetch capability on
  open-vector-index, via zvec's fetchSync) and re-query the index with
  it instead of embedding a fresh query string.
- Exposed as a :similar-pages render-resource (worker/handler/render-resource/similar.cljs),
  consistent with how linked/unlinked references are already wired, plus
  a raw :thread-api/search-similar-blocks for non-UI callers.
- New "Similar pages" section on the page view, above the existing
  linked/unlinked references.
2026-08-26 20:21:28 +02:00
dasemu d59aec181e Fase B5: temporal/linear graph view mode
Adds a third :temporal view mode alongside :tags-and-objects and
:all-pages. The backend reuses build-all-pages-graph's node/link shape
unchanged (every node already carries :block/created-at); only the
client-side pixi layout differs, arranging nodes along a fixed
chronological timeline (oldest first, staggered across a few lanes)
instead of running the force simulation, following the existing
grid-layout fixed-position precedent.
2026-08-26 19:03:21 +02:00
dasemu b67f7e9f78 Fase B3+B4: built-in Project/Area tags and Citation class
B3: registers :logseq.class/Project and :logseq.class/Area as
built-in page-like classes (the TODO in class.cljs already asked for
this), so users can tag pages/journals with them out of the box.
Fixed a markdown-mirror test whose "Custom Tag" fixture used to be
titled "Project" and collided with the new built-in class.

B4: adds :logseq.class/Citation plus /target and /context properties,
following the :logseq.class/Comments pattern. Since target is a
:node-typed ref, citation blocks automatically show up in the
existing block/citation reference graph without any changes there.
2026-08-26 19:03:14 +02:00
dasemu fcf41c7b41 Fase B2: give Contents root semantics alongside Library
Adds a shared common-config/contents-page-name constant and
ldb/contents?/get-contents-page, mirroring the existing Library
helpers. Contents already qualifies as an internal page, so the
existing namespace-title split mechanism (e.g. "Contents/Proyectos")
already parents pages under it via :block/parent, coexisting with
Library rather than replacing it as the default root.
2026-08-26 19:02:49 +02:00
dasemu c50511a7b5 Fase B1: chain journal pages with previous/next graph links
Adds :logseq.property.journal/previous and /next (built-in, hidden,
single-cardinality node refs) and maintains them in
logseq.outliner.page/create whenever a new journal page is created.
Filling a gap between two already-linked journals re-links both
neighbors around the new page instead of just appending. A migration
backfills the chain across all existing journal pages ordered by day.
2026-08-26 19:02:44 +02:00
dasemuandClaude Sonnet 5 db7f1fac7d Fase 9 (2/N): daemon-hosted MCP server, retire electron/mcp_server.cljs
Completes Fase 9's "consolidar MCP" half: the daemon now serves its own
MCP endpoint at /mcp, exposing every semantic-routes operation as an MCP
tool against the daemon's authoritative graph, and the old Electron-local
MCP server is retired since it's now redundant.

New: src/main/frontend/worker/mcp_server.cljs
The CF-Worker's own MCP endpoint (deps/db-sync/worker/entry.mjs) generates
its tools from the OpenAPI document via @cloudflare/codemode's
openApiMcpServer, a package that only exists inside Cloudflare Workers,
plus a pile of ChatGPT-App-specific tooling (asset image resources,
upload_asset, Cognito protected-resource metadata) this daemon has no use
for -- none of that ports to Node. So this registers one tool per
operation by hand instead, using @modelcontextprotocol/sdk directly, the
same pattern electron/mcp_server.cljs already used for its own 6 tools
(registerTool with an explicit title/description/inputSchema/handler) --
just generated from semantic-routes' operation table and operation-docs
(now public) instead of writing 35 one-off registrations by hand, so the
MCP tool surface can't drift from the HTTP routes or the OpenAPI document.
Each tool's Zod input shape is assembled from path params (auto-derived
from the route's :param segments) plus a per-operation-id map of the
extra query/body fields; a handful of shared fragments (pagination,
time filters, the recursive block-tree shape, property-value/task-status
selectors) cover the repetition across list/create/update operations.

Each tool's handler makes a loopback HTTP call to this same daemon's own
/v1/semantic/* route, forwarding the /mcp request's own Authorization
header -- reusing the already-tested HTTP-layer logic (repo-error
validation, lock-owner assertion, response shaping) instead of a second
request path directly against the thread-api. Session/transport plumbing
(handle-post/get/delete-request, the transports-by-session-id map) is
adapted from electron/mcp_server.cljs's Fastify-based version: that one
gets req/res already unwrapped-to-Node-primitives via `.raw` with the
body pre-parsed by Fastify; this one is called straight from the daemon's
own raw http.createServer callback, so req/res already are what
StreamableHTTPServerTransport wants, and the body needs parsing here
instead. No separate auth check either -- the daemon's existing
bearer-token check on every route (request-authorized? in
db_worker_node.cljs) already gates /mcp before this is reached.

Wires POST/GET/DELETE /mcp into db_worker_node.cljs's make-server cond
chain, alongside the existing /v1/semantic/* branch.

Dependencies: adds @modelcontextprotocol/sdk and zod (zod/v3 -- the SDK
doesn't work with zod 4's default export, same constraint
electron/mcp_server.cljs already worked around) to the root package.json;
previously only resources/package.json (Electron's own bundle) had them.

Retired: electron/mcp_server.cljs and its wiring (electron/server.cljs's
initialize-mcp-routes, its 3 POST/GET/DELETE /mcp route registrations,
the :mcp-enabled? config field; components/server.cljs's "copy MCP URL"
popup link; components/settings.cljs's entire AI settings tab, which had
nothing in it besides the MCP-server toggle). Electron already talks to
the daemon (Fase 3) rather than driving itself locally, so a second,
separately-configured MCP surface bolted onto Electron's own local
automation API server (which otherwise stays -- /api is a distinct,
still-used concern) was redundant with the daemon's new one. Removed the
4 associated i18n keys (server/mcp-url-copied, settings/ai,
settings.ai/enable-mcp-server[-desc]) from all ~26 locale dicts.

New: src/test/frontend/worker/mcp_server_test.cljs
Connects a real @modelcontextprotocol/sdk client over HTTP to a live
daemon's /mcp endpoint: lists all registered tools, round-trips
createPage/getPage and a recursive captureToToday block tree, and checks
a tool call against a nonexistent page surfaces as MCP error content
rather than throwing. 4 tests, 11 assertions.

Verification: all 5 shadow-cljs targets compile with 0 warnings. Full
`bb dev:test` run: the only failures are the same 7 pre-existing,
sandboxed-network-related persist_db_test.cljs failures already
documented in the Fase 8 and Fase 9 (1/N) commits -- identical test names,
identical ECONNREFUSED/Invalid URL errors. Every other shard, including
all three daemon-HTTP worker test files sharing one test.js process
(db_worker_node_test.cljs, semantic_test.cljs, mcp_server_test.cljs),
passes clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-26 17:07:27 +02:00
dasemuandClaude Sonnet 5 196de21731 Fase 9 (1/N): re-host the semantic API onto the daemon
Ports the 38-operation semantic API from deps/db-sync's Cloudflare Worker
handler (handler/semantic.cljs + routes/semantic.cljs) onto the daemon's
own authoritative conn, per the plan's Fase 9. deps/db-sync itself is
untouched -- this only adds the daemon-side equivalent.

New:
- worker/semantic_routes.cljs: route table + OpenAPI 3.1.0 document
  generator, adapted from the CF-Worker's routes/semantic.cljs. Drops the
  :graph-id URL segment and listGraphs operation entirely -- the daemon is
  bound to a single repo per process (see db_worker_node.cljs's
  bound-repo), unlike the CF-Worker's per-graph Durable Objects, so every
  request implicitly targets the daemon's own bound repo. Security scheme
  is a bearer token (the daemon's actual session auth) instead of OAuth2.
- worker/handler/semantic.cljs: the 38 operations themselves, ported from
  the CF-Worker's handler/semantic.cljs. Adaptations from the original:
  * ensure-conn! (lazy SQLite conn open) -> worker.state/get-datascript-conn
    (the daemon already holds the authoritative conn for its bound repo).
  * broadcast-change! calls dropped entirely -- any transact! against the
    conn is already picked up by the listener worker.db-listener installs,
    which broadcasts to every connected client, so nothing here needs to
    push manually.
  * HTTP body reads (p/let + body-clj) dropped -- bodies arrive already
    JSON-parsed from the HTTP layer, and every operation is synchronous
    (DataScript itself is synchronous), so none of this needs promises.
  * http/bad-request, http/not-found, js/Response error helpers -> ex-info
    with :status/:code, matching every other thread-api in this codebase.
  * R2 asset storage -> platform/asset-write-bytes! (local filesystem),
    using the <uuid>.<type> naming convention components/block/asset.cljs
    already establishes. R2 signed URLs -> server-relative
    /v1/assets/:repo/:name paths (already served, with ETag caching, by
    the existing Fase 5 asset routes) since bearer-token auth already
    gates those with the same ?token= fallback semantic GET routes need.
  Registered as a single :thread-api/semantic-request thread-api
  dispatched by handler keyword, mirroring how the CF-Worker original
  dispatched via one big `case` in `handle`.
- db_worker_node.cljs: wires a /v1/semantic/* branch (JSON body parsed
  for most operations; raw bytes read directly for assets-create,
  mirroring the existing /v1/assets/:repo/:name PUT route) plus
  /v1/semantic/openapi.json. Unlike /v1/invoke -- an internal RPC
  transport whose transit-encoded results Logseq's own clients already
  know how to decode -- /v1/semantic/* is the public HTTP API documented
  by the OpenAPI doc and meant for arbitrary HTTP/MCP clients, so results
  are decoded server-side into plain JSON, the same way the existing
  /v1/assets/:repo/:name GET route already does for the other route with
  external HTTP consumers.
- src/test/frontend/worker/semantic_test.cljs: exercises pages,
  blocks/properties, capture, tags/tasks, search, the OpenAPI document,
  401-without-auth, and 404-on-unknown-route against a live daemon over
  real HTTP. 7 tests, 31 assertions.

Verification: all 5 shadow-cljs targets compile with 0 warnings. Full
`bb dev:test` run has zero regressions -- the only failures are the same
7 pre-existing, sandboxed-network-related persist_db_test.cljs failures
(ECONNREFUSED / Invalid URL) already documented as environmental in the
Fase 8 commit.

Found and fixed in-session: semantic_test.cljs originally set its own
LOGSEQ_DAEMON_USERNAME/PASSWORD env vars at namespace load time, colliding
with db_worker_node_test.cljs doing the same (both get bundled into the
same test.js process) -- whichever namespace loaded last won the race and
locked the other file's daemons out of their own bootstrapped credential,
cascading into ~150 unrelated failures. Fixed by reusing the same literal
credential constants instead of introducing a second one.

Known follow-up, not yet done: the plan's "consolidar MCP" half of Fase 9
-- an MCP JSON-RPC endpoint on the daemon (the CF-Worker's equivalent,
deps/db-sync/worker/entry.mjs, leans on @cloudflare/codemode's
openApiMcpServer plus ChatGPT-app-specific tooling that doesn't port to
Node) and the decision on electron/mcp_server.cljs's fate are still open.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-26 16:34:14 +02:00