feat(adapter): Phase 6 Slice C scaffold — ItemWriter interface + Server.Writes + MBrianWriter stub
Mechanism-independent groundwork for the write-path migration. Mirrors the slice-B ItemReader pattern: - store/adapter.go: ItemWriter interface extracted from *Store's write surface (Create/Update/Reparent/AddParent/SetPublic/SetPinned/ SoftDelete/SoftDeleteCascade + AddLink/AddLinkDated/DeleteLink), with a compile-time witness that *Store satisfies it. - store/mbrian_writer.go: MBrianWriter stub — an HTTP client (NOT a pgx writer) against mBrian's scoped /api/projax/* write API per head's mechanism call (option c). Bodies return errNotImplementedSliceC until the HTTP impl + final spec land. Holds a pool for write-path read-backs. - web/server.go: Server.Writes field (twin of Items), defaulted to the concrete *Store in web.New. main.go will flip Items+Writes atomically — the slice-B half-flip (reads mBrian, writes projax.items) was the bug. No behaviour change: both Items and Writes still resolve to *Store.
This commit is contained in:
@@ -80,8 +80,15 @@ type Server struct {
|
||||
// aggregator depends on. Phase 6 Slice B introduces it: today the
|
||||
// concrete *Store satisfies the ItemReader interface (legacy path);
|
||||
// after the mBrian backend rollout PROJAX_BACKEND=mbrian wires
|
||||
// *store.MBrianReader here. Writes still flow through Store.
|
||||
// *store.MBrianReader here.
|
||||
Items store.ItemReader
|
||||
// Writes is the write-path adapter every UI write handler, the
|
||||
// /admin/bulk apply path, and the MCP write tools depend on. Phase 6
|
||||
// Slice C introduces it as the twin of Items: today the concrete
|
||||
// *Store satisfies ItemWriter (legacy path); PROJAX_BACKEND=mbrian
|
||||
// wires *store.MBrianWriter here. main.go flips Items + Writes
|
||||
// together — never one without the other (the slice-B half-flip bug).
|
||||
Writes store.ItemWriter
|
||||
pages map[string]*template.Template
|
||||
Logger *slog.Logger
|
||||
Auth *AuthConfig // nil → no auth (local dev / tests)
|
||||
@@ -374,9 +381,11 @@ func New(s *store.Store, logger *slog.Logger) (*Server, error) {
|
||||
|
||||
return &Server{
|
||||
Store: s,
|
||||
// Default Items satisfier is *Store itself. main.go can override
|
||||
// post-construction (e.g. PROJAX_BACKEND=mbrian → MBrianReader).
|
||||
// Default Items + Writes satisfier is *Store itself. main.go can
|
||||
// override both post-construction, atomically (PROJAX_BACKEND=mbrian
|
||||
// → MBrianReader + MBrianWriter).
|
||||
Items: s,
|
||||
Writes: s,
|
||||
pages: pages,
|
||||
Logger: logger,
|
||||
dashboard: cache.NewTTL[*dashboardPayload](dashboardCacheTTL),
|
||||
|
||||
Reference in New Issue
Block a user