@@ -9,21 +9,31 @@ import (
99 "github.com/latebit-io/demarkus-library/internal/core/domain"
1010)
1111
12- // ReadingService is the inbound (driving) port — the use cases the reading room
13- // exposes to its primary adapters (the web adapter). Driving adapters depend on
14- // this interface, not on the concrete service.
12+ // The inbound (driving) port is split into four concerns — Reader, GraphService,
13+ // MapService, Editor — and composed as ReadingService, the full surface the web
14+ // adapter drives. The concrete *service.ReadingService satisfies all four; a
15+ // narrower consumer (a preview-only handler, the Phase 4 librarian needing only
16+ // reads) can depend on just the slice it uses rather than the whole 20-method
17+ // surface.
1518//
16- // Every method takes the request context (cancellation + the logged-in
17- // reader's bearer in broker mode, Phase 1b/ADR 0004) and a world: the library
18- // spans a universe of worlds, and a document's address is (world, path). A
19- // world is either a knowledge-system world name (resolved by the broker) or a
19+ // Every context-taking method takes the request context (cancellation + the
20+ // logged-in reader's bearer in broker mode, Phase 1b/ADR 0004) and a world: the
21+ // library spans a universe of worlds, and a document's address is (world, path).
22+ // A world is either a knowledge-system world name (resolved by the broker) or a
2023// demarkus host[:port] reached directly — the distributed knowledge graph is
2124// traversable across both.
22- type ReadingService interface {
25+
26+ // Reader is the read side: fetch and render documents, listings, editions, and
27+ // the catalog, plus the trail engine's cached variants.
28+ type Reader interface {
2329 // Read fetches and renders the document at (world, path).
2430 Read (ctx context.Context , world , path string ) (domain.Document , error )
2531 // Browse renders a directory listing (the stacks) at (world, path).
2632 Browse (ctx context.Context , world , path string ) (domain.Document , error )
33+ // Open reads (world, path), dispatching to Browse for a listing path and
34+ // Read for a document (domain.IsListingPath) — so callers address a
35+ // resource without re-deciding the listing-vs-document rule themselves.
36+ Open (ctx context.Context , world , path string ) (domain.Document , error )
2737 // History renders the edition history of the document at (world, path).
2838 History (ctx context.Context , world , path string ) (domain.Document , error )
2939 // Search renders the card catalog (LOOKUP) results for query under scope
@@ -36,22 +46,28 @@ type ReadingService interface {
3646 // the projection's escape to protocol (ADR 0005 decision 12).
3747 Raw (ctx context.Context , world , path string ) (domain.RawDocument , error )
3848
39- // ReadCached, BrowseCached, and TagCached are the trail engine's
40- // unfocused-pane reads (ADR 0005 decision 9): served from the
49+ // ReadCached, BrowseCached, OpenCached, and TagCached are the trail
50+ // engine's unfocused-pane reads (ADR 0005 decision 9): served from the
4151 // rendered-document cache, reading through on a miss. The focused pane
4252 // uses the live methods, which refresh the cache — so a trail click
4353 // costs exactly one world read. Without a cache wired they behave as
44- // their live counterparts.
54+ // their live counterparts. OpenCached dispatches by path shape like Open.
4555 ReadCached (ctx context.Context , world , path string ) (domain.Document , error )
4656 BrowseCached (ctx context.Context , world , path string ) (domain.Document , error )
57+ OpenCached (ctx context.Context , world , path string ) (domain.Document , error )
4758 TagCached (ctx context.Context , world , tag string ) (domain.Document , error )
59+ }
4860
61+ // GraphService is the render-time observed-links graph (R3; ADR 0005 §16): the
62+ // web adapter records resolved links, the core owns the edge store and answers
63+ // backlink / neighborhood queries.
64+ type GraphService interface {
4965 // RecordLinks records the in-universe document links observed in the
50- // rendered document at (world, path), replacing any prior observation
51- // (R3; ADR 0005 §16). The web adapter calls this after resolving links
52- // (rewriteLinks owns the URL scheme); the core owns the edge store. This
53- // is the render-time observed-links map that feeds Backlinks and
54- // Neighborhood — transport-symmetric, no broker graph store required.
66+ // rendered document at (world, path), replacing any prior observation. The
67+ // web adapter calls this after resolving links (rewriteLinks owns the URL
68+ // scheme); the core owns the edge store. This is the render-time
69+ // observed-links map that feeds Backlinks and Neighborhood —
70+ // transport-symmetric, no broker graph store required.
5571 RecordLinks (world , path string , targets []domain.Ref )
5672 // Backlinks returns the documents observed linking to (world, path) — the
5773 // margin's "referenced by" block and the graph pane's inbound edges.
@@ -62,25 +78,30 @@ type ReadingService interface {
6278 // document plus its observed outbound and inbound edges. Store-only (zero
6379 // world reads), so it works cold in both transports.
6480 Neighborhood (world , path string ) domain.Neighborhood
81+ }
6582
66- // Floor assembles the universe view's data (ADR 0005 decision 4):
67- // the authorized worlds and each world's top-importance catalog
68- // entries. Live rebuild; FloorCached serves the last build when the
69- // floor pane is unfocused (the same focused-live policy as documents).
83+ // MapService assembles the spatial views (ADR 0005 decision 4): the universe
84+ // floor and one-world map, each with a live build and a cached variant for
85+ // unfocused panes (the focused-live policy every pane follows).
86+ type MapService interface {
87+ // Floor assembles the universe view's data: the authorized worlds and each
88+ // world's top-importance catalog entries. Live rebuild; FloorCached serves
89+ // the last build when the floor pane is unfocused.
7090 Floor (ctx context.Context ) (domain.Floor , error )
7191 FloorCached (ctx context.Context ) (domain.Floor , error )
72-
73- // WorldMap assembles the world-view zoom (ADR 0005 decision 4 — the floor
74- // one zoom in): one world's catalog grouped into directory clusters with
75- // the intra-world edges among the rendered documents. Live rebuild;
76- // WorldMapCached serves the last build for an unfocused/parent pane (the
77- // focused-live policy every pane follows).
92+ // WorldMap assembles the world-view zoom (the floor one zoom in): one
93+ // world's catalog grouped into directory clusters with the intra-world
94+ // edges among the rendered documents. Live rebuild; WorldMapCached serves
95+ // the last build for an unfocused/parent pane.
7896 WorldMap (ctx context.Context , world string ) (domain.WorldMap , error )
7997 WorldMapCached (ctx context.Context , world string ) (domain.WorldMap , error )
98+ }
8099
81- // EditDraft fetches the source view for the cataloging desk's edit form
82- // (Phase 3): the document's raw markdown plus its current metadata and
83- // version, so the editor pre-fills exactly what the catalog holds.
100+ // Editor is the cataloging desk's write side (Phase 3).
101+ type Editor interface {
102+ // EditDraft fetches the source view for the edit form: the document's raw
103+ // markdown plus its current metadata and version, so the editor pre-fills
104+ // exactly what the catalog holds.
84105 EditDraft (ctx context.Context , world , path string ) (domain.EditDraft , error )
85106 // Preview renders edit-buffer markdown to sanitized HTML for the desk's
86107 // live preview — the same renderer the reader uses, so what you see is what
@@ -99,6 +120,16 @@ type ReadingService interface {
99120 Append (ctx context.Context , world , path , body string ) (domain.Document , error )
100121}
101122
123+ // ReadingService is the full inbound surface the web adapter drives — the four
124+ // concerns composed. Driving adapters depend on this (or a narrower slice), not
125+ // on the concrete service.
126+ type ReadingService interface {
127+ Reader
128+ GraphService
129+ MapService
130+ Editor
131+ }
132+
102133// WorldGateway is an outbound (driven) port — read from demarkus worlds. The
103134// adapter translates transport status into domain errors and returns markdown
104135// bodies for the core to render. Implementations: direct QUIC (world is a
0 commit comments