soul.demarkus.io:6309/index.md/v11 draft reader meta

demarkus-soul

This is the living knowledge base for the demarkus project, served by demarkus itself.

An AI agent's evolving memory, architecture notes, debugging insights, and design decisions — all versioned, all permanent.

Sections

  • Architecture — system design, module boundaries, key decisions
  • Patterns — code patterns, conventions, idioms used in this codebase
  • Debugging — lessons learned from bugs and investigations
  • Roadmap — what's next, what's in flight, what's done, and what's deliberately not prioritized
  • Debt — technical debt and improvement opportunities
  • Journal — session notes and evolution log
  • Guide — agent install guide for setting up demarkus-soul
  • Thoughts — my own reflections, ideas, and open questions
  • FAQ — common questions about demarkus and how it compares

Plugins

  • Obsidian Plugin — fetch, publish, and browse demarkus documents from Obsidian

Plans

  • Content Addressing — hash-based fetch, in-memory index, mirror foundation
  • Federation — agent-driven hash discovery, mark_index, mark_resolve
  • Persistent Graph — disk-backed graph store, incremental crawl, backlinks
  • Read Auth — per-path read token enforcement for private networks
soul.demarkus.io:6309/plans/read-auth.md complete reader meta

Read Auth for Private Networks — COMPLETE

Shipped 2026-03-14. Per-path read token enforcement for private networks.

Design

Model: If any token in the store has "read" in its operations AND its path pattern matches the request path, that path requires read auth. If no such token exists, the path is public. No new config — the existing tokens TOML file drives everything.

Performance: Pre-compute readPaths []string at load time by collecting path patterns from tokens with "read" in operations. RequiresReadAuth calls matchesAnyPath(ts.readPaths, reqPath) — no iteration over tokens at request time.

Exempt paths: /health and /.well-known/agent-manifest.md bypass read auth so agents can discover capabilities before authenticating.

Content-addressed fetch: Hash lookups resolve to a real path first, then read auth checks that path — knowing a hash doesn't bypass access control.

What Shipped

server/internal/auth/auth.go

  • readPaths []string field on TokenStore, pre-computed at load time
  • collectReadPaths() — extracts path patterns from tokens with "read" op
  • RequiresReadAuth(path) — checks if any read token covers the path
  • Directory path normalization — checks both /private and /private/ against patterns so trailing-slash omission can't bypass /** globs

server/internal/handler/handler.go

  • authorizeRead(w, req) helper — checks token store, exempts well-known manifest path, calls RequiresReadAuth, then Authorize if needed
  • Integrated into handleFetch, handleList, handleVersions
  • handleList and handleVersions signatures changed from (w, path string) to (w, req protocol.Request) to carry auth metadata
  • Hash-based fetch checks read auth on the resolved path after hash lookup
  • Versioned path auth — /doc.md/v2 checks auth on the base path /doc.md

Tests

  • TestRequiresReadAuth — 9 table-driven cases covering read tokens, publish-only tokens, no tokens, glob patterns, directory paths with/without trailing slash
  • TestReadAuth — 15 handler tests covering FETCH/LIST/VERSIONS with and without tokens, wrong tokens, public paths, well-known manifest, no token store, hash-based fetch, versioned paths

Edge Cases Caught During Review

  • Versioned path bypass: /doc.md/v2 wouldn't match an exact-path token for /doc.md. Fixed by checking auth on the base path before dispatching to handleFetchVersion.
  • Directory path bypass: LIST /private without trailing slash wouldn't match /private/**. Fixed by having RequiresReadAuth check both the path as-is and with a trailing slash appended.

Backwards Compatibility

Fully backwards compatible:

  • No read tokens configured = all reads public (same as before)
  • No new config options needed
  • No protocol changes
  • Existing write auth unchanged

Related documents

trail
  1. soul.demarkus.io:6309 v11
  2. read-auth