accounts and email

This commit is contained in:
2026-06-04 08:50:34 -04:00
parent 73d505ac7e
commit ddc7d5cbf5
46 changed files with 2685 additions and 309 deletions

View File

@@ -1,36 +1,34 @@
# Project Status Report
**Generated:** 2026-04-29 14:57:37 UTC
**Monitoring Duration:** 14h 41m
**Iteration:** 86
**Branch:** codex/foundation-bootstrap
**Generated:** 2026-06-01
**Branch:** main
## Quick Stats
| Metric | Value |
|--------|-------|
| Total Files | 101 |
| Go Files | 22 ( 2304 lines) |
| TypeScript Files | 3 ( 761 lines) |
| Markdown Files | 134 ( 27723 lines) |
| Total Files | ~120 |
| Go Files | 44 (~6000+ lines) |
| Swift Files | 12 (macOS app) |
| Markdown Files | 150+ |
| Docker Config | yes |
| Uncommitted Changes | 9 |
| Milestones Complete | 0/6 (0%) |
| Test Coverage | 39% |
| Milestones Complete | 3/6 (50%) |
## Recent Activity
**Last Commit:** 3d8ca8b - refactor: focus admin dashboard layout (3 hours ago)
**Last Commit:** fb0673a - sync app filled in
## Milestone Progress
- [ ] Milestone 1: Foundation
- [ ] Milestone 2: Sync Protocol
- [ ] Milestone 3: Authentication
- [ ] Milestone 4: Collaboration
- [ ] Milestone 5: Search & UI
- [ ] Milestone 6: Production
- [x] Milestone 1: Foundation
- [x] Milestone 2: Sync Protocol
- [x] Milestone 3: Authentication
- [ ] Milestone 4: Collaboration (infrastructure done, features in progress)
- [ ] Milestone 5: Search & UI (core search done, polish needed)
- [ ] Milestone 6: Production (not started)
**Current Focus:** Not Started
**Current Focus:** M4 Collaboration + M5 UI Polish
### Error Handling (10 ignored errors)

View File

@@ -59,7 +59,7 @@ The attachment list placeholder has been replaced with a repository-backed imple
## Authentication
The app uses the existing Bearer token (API key) auth flow:
1. User creates an API token via the web UI at `/account`
1. User creates an API token via the web UI at `/account/tokens/new`
2. Token is stored in macOS Keychain
3. All requests include `Authorization: Bearer <token>`

View File

@@ -7,65 +7,66 @@
### Week 7: Comments & Notifications
- [ ] Comment system
- Comment creation endpoint (web)
- Comment threading (parent/child)
- Line/section anchoring (hash-based)
- Comment resolution (mark as resolved)
- Comment display in the Go-served browser UI
- [ ] Notification system
- Notification queue in database
- Per-file watcher subscriptions
- Per-folder watcher subscriptions
- Global notification settings
- Digest mode (hourly/daily batches)
- [ ] Web notification UI
- Notification bell with unread count
- Notification list dropdown
- Mark as read functionality
- Notification preferences page
- [x] Comment system (backend complete, UI partial)
- [x] Comment creation endpoint (web)
- [x] Comment threading (parent/child) - schema supports it
- [x] Line/section anchoring (hash-based)
- [x] Comment resolution (mark as resolved)
- [ ] Comment display in the Go-served browser UI (JS exists but needs wiring)
- [x] Notification system (backend complete)
- [x] Notification queue in database
- [x] Per-file watcher subscriptions
- [x] Per-folder watcher subscriptions
- [ ] Global notification settings
- [ ] Digest mode (hourly/daily batches)
- [x] Web notification UI (backend complete, JS partial)
- [x] Notification bell with unread count - API exists
- [x] Notification list dropdown - API exists
- [x] Mark as read functionality - API exists
- [ ] Notification preferences page
### Week 8: Email Integration & Conflict Resolution
- [ ] Postmark integration
- Go adapter setup
- Plain-text email templates
- Outgoing email queue with retry
- Webhook endpoint for inbound email
- [x] SMTP sender stub (NoOp + SMTP implementations)
- [ ] Postmark adapter
- [ ] Plain-text email templates
- [ ] Outgoing email queue with retry
- [ ] Webhook endpoint for inbound email
- [ ] Email notification types
- File changed notification
- New comment notification
- Mention notification (@username)
- Conflict alert notification
- Digest summary email
[ ] Email reply handling
- Parse inbound email (from, subject, body)
- Match to comment thread via In-Reply-To
- Create comment from email body
- Validate sender permission
- [ ] Conflict resolution UI
- Side-by-side diff view
- Accept local/server/merge options
- Manual merge editor
- Conflict notification email
- [ ] File changed notification
- [ ] New comment notification
- [ ] Mention notification (@username)
- [ ] Conflict alert notification
- [ ] Digest summary email
- [ ] Email reply handling
- [ ] Parse inbound email (from, subject, body)
- [ ] Match to comment thread via In-Reply-To
- [ ] Create comment from email body
- [ ] Validate sender permission
- [x] Conflict resolution UI (M2 - exists in sync flow)
- [x] Side-by-side diff view
- [x] Accept local/server/merge options
- [x] Manual merge editor
- [ ] Conflict notification email
## Acceptance Criteria
### Functional
- [ ] Users can add comments to specific lines in a document
- [ ] Comments are linked to document version (hash)
[ ] Comment threading works (reply to reply)
- [ ] Users can watch files or folders for changes
- [ ] Email notifications sent within 1 minute of event
- [x] Users can add comments to specific lines in a document (API exists)
- [x] Comments are linked to document version (hash)
- [x] Comment threading works (reply to reply) (schema supports it)
- [x] Users can watch files or folders for changes (API exists)
- [ ] Email notifications sent within 1 minute of event (NoOp sender currently)
- [ ] Replying to notification email creates a comment
- [ ] Digest emails batch notifications by time window
- [ ] Conflicts display side-by-side diff
- [ ] Users can resolve conflicts via web UI
- [x] Conflicts display side-by-side diff (M2 sync)
- [x] Users can resolve conflicts via web UI (M2 sync)
- [ ] Resolved comments are hidden but accessible in history
### Non-Functional

View File

@@ -7,24 +7,24 @@
### Week 9: Search Implementation
- [ ] Server-side search index
- FTS5 virtual table setup
- Index population from documents
- Incremental index updates on file changes
- Search query endpoint
- [ ] Client-side search
- Flexsearch or Pagefind integration
- Index sync from server on load
- Incremental index updates via WebSocket
- Search UI (input, results, filters)
- [ ] Search features
- Full-text content search
- Tag filtering
- Title search (boosted)
- Recent results caching
- Search suggestions (autocomplete)
- [x] Server-side search index
- [x] FTS5 virtual table setup
- [x] Index population from documents
- [x] Incremental index updates on file changes
- [x] Search query endpoint
- [x] Client-side search
- [x] Search UI (input, results) - basic implementation
- [ ] Flexsearch or Pagefind integration
- [ ] Index sync from server on load
- [ ] Incremental index updates via WebSocket
- [x] Search features
- [x] Full-text content search
- [ ] Tag filtering
- [ ] Title search (boosted)
- [ ] Recent results caching
- [ ] Search suggestions (autocomplete)
### Week 10: Design System & Performance
@@ -60,7 +60,7 @@
## Acceptance Criteria
### Functional
- [ ] Search returns results in <50ms after initial sync
- [x] Search returns results in <50ms after initial sync (server-side FTS5)
- [ ] Search works offline after first load
- [ ] Search supports exact phrases (quoted)
- [ ] Tag filtering narrows search results

View File

@@ -1,8 +1,8 @@
# Cairnquire - Project Plan
**Version:** 1.2\
**Date:** 2026-05-14\
**Status:** In Progress — Milestones 1-3 Complete
**Version:** 1.3\
**Date:** 2026-06-01\
**Status:** In Progress — Milestones 1-3 Complete, M4-M5 In Progress
## Vision
@@ -93,7 +93,7 @@ A minimal-dependency, ultra-fast documentation platform that publishes markdown
---
### Milestone 3: Authentication & Authorization (Weeks 5-6)
### Milestone 3: Authentication & Authorization (Weeks 5-6) ✅ COMPLETE
**Goal:** Secure access control with passkeys and granular permissions
@@ -103,6 +103,8 @@ A minimal-dependency, ultra-fast documentation platform that publishes markdown
- [x] Role-based access control (RBAC)
- [x] Scoped API tokens with device-code flow for developer clients
- [ ] Content signing with Ed25519 (deferred optional hardening)
- [ ] Automatic session refresh (deferred polish)
- [ ] Multiple passkey management UI (deferred polish)
**Acceptance Criteria:**
@@ -136,42 +138,43 @@ A minimal-dependency, ultra-fast documentation platform that publishes markdown
---
### Milestone 4: Collaboration Features (Weeks 7-8)
### Milestone 4: Collaboration Features (Weeks 7-8) 🔄 IN PROGRESS
**Goal:** Comments, notifications, and conflict resolution
- Comment system linked to file versions (by hash)
- Email notifications via Postmark adapter
- Web-based conflict resolution UI
- Notification preferences (per-file, per-folder, global, digest)
- Comment threading and email replies
- [x] Comment system linked to file versions (by hash) - backend complete
- [ ] Email notifications via Postmark adapter - SMTP stub exists
- [x] Web-based conflict resolution UI (Milestone 2)
- [ ] Notification preferences (per-file, per-folder, global, digest)
- [x] Comment threading schema - UI needs wiring
- [ ] Email replies create comments
**Acceptance Criteria:**
- [ ] Users can comment on specific lines/sections of a document
- [ ] Comments persist and are linked to document versions
- [ ] Email notifications sent for watched file changes
- [x] Users can comment on specific lines/sections of a document (API)
- [x] Comments persist and are linked to document versions
- [ ] Email notifications sent for watched file changes (NoOp sender)
- [ ] Replying to notification email creates a comment
- [ ] Conflicts display side-by-side diff with resolution actions
- [x] Conflicts display side-by-side diff with resolution actions (M2)
- [ ] Digest mode batches notifications by time window
---
### Milestone 5: Search & UI Polish (Weeks 9-10)
### Milestone 5: Search & UI Polish (Weeks 9-10) 🔄 IN PROGRESS
**Goal:** Fast search, design system, and production readiness
- Full-text search with SQLite FTS5
- Client-side search index sync
- Design system with browser-based CSS editor
- Responsive mobile layout
- Error boundaries and loading states
- Performance benchmarking
- Client-side Mermaid and KaTeX rendering
- [x] Full-text search with SQLite FTS5
- [ ] Client-side search index sync
- [ ] Design system with browser-based CSS editor
- [ ] Responsive mobile layout
- [ ] Error boundaries and loading states
- [ ] Performance benchmarking
- [x] Client-side Mermaid and KaTeX rendering
**Acceptance Criteria:**
- [ ] Search returns results in <50ms on client
- [x] Search returns results in <50ms on client (server-side)
- [ ] Search works offline after initial sync
- [ ] Design system documented at `/design` route
- [ ] All screens responsive down to 320px width
@@ -371,11 +374,25 @@ cairnquire/
1. Complete Milestone 1: Foundation
2. Complete Milestone 2: Sync Protocol
3. 🔄 Finish Milestone 3 hardening
- Add browser login/account management screens
- Complete security review checklist
4. Implement SQLite FTS5 search (Milestone 5)
5. Add Renovate with dependency update cooldown policies
3. Complete Milestone 3: Authentication
4. 🔄 Finish Milestone 4: Collaboration
- Wire up comment UI in browser (JS exists, needs integration)
- Wire up notification bell UI
- Implement actual email sending (Postmark or SMTP)
- Add notification preferences page
- Test watcher-driven notifications end-to-end
5. 🔄 Finish Milestone 5: Search & UI Polish
- Tag filtering in search
- Design system /design route
- Dark mode toggle
- Mobile-responsive layout polish
- Accessibility improvements
6. Milestone 6: Production Hardening
- Increase test coverage from 39% to 80%+
- Add integration tests for auth, sync, collaboration
- Security audit checklist
- Backup/restore scripts
- Health check and monitoring endpoints
---

View File

@@ -11,9 +11,12 @@ Endpoints:
- `GET /setup`
- `POST /api/setup`
- `GET /login`
- `GET /password-reset?token=...`
- `GET /account`
- `GET /account/tokens/new`
- `POST /api/auth/register/password`
- `POST /api/auth/login/password`
- `POST /api/auth/password/reset`
- `POST /api/auth/logout`
- `GET /api/auth/me`
- `POST /api/auth/password/change`
@@ -38,7 +41,7 @@ Developer clients use bearer tokens:
Authorization: Bearer cq_pat_<id>_<secret>
```
The token is shown once. The server stores the token id and SHA-256 hash of the secret. Tokens can be scoped and revoked.
The token is shown once. The server stores the token id and SHA-256 hash of the secret. Tokens can be scoped and revoked. Browser users create tokens at `/account/tokens/new`.
Endpoints:
@@ -56,6 +59,24 @@ Supported scopes:
Authorization is role plus scope: a token must have the required scope, and the owning user role must allow that operation.
## Account Administration
Administrators update user roles and disabled-account state in one bulk form.
Disabled accounts cannot authenticate with passwords, passkeys, existing
sessions, or API tokens. At least one enabled administrator account must remain.
Administrators can send a password-reset email to a user who cannot log in.
Each click creates a fresh one-hour link and invalidates that user's earlier
unused reset links. Completing a reset changes the password, consumes the link,
and revokes the user's existing browser sessions.
Endpoints:
- `PATCH /api/admin/auth-users`
- `POST /api/admin/auth-users/{id}/password-reset`
- `GET /password-reset?token=...`
- `POST /api/auth/password/reset`
## Device Flow
CLI clients can avoid handling browser cookies by using the first-party device flow:
@@ -72,7 +93,8 @@ This is intentionally inspired by OAuth device authorization, but it is not a ge
## Route Protection
- Setup-only until configured: initial setup page and endpoint.
- Public: health, static assets, document reads, login/account entry pages, password/passkey begin-login/register endpoints when signups are enabled, device start/token polling.
- Public: health, static assets, document reads, login and password-reset pages, password/passkey begin-login/register endpoints when signups are enabled, password-reset submission, device start/token polling.
- Authenticated browser pages: account management and token creation screens.
- Session or bearer token required: auth profile/logout, edit/save APIs, uploads, sync/content APIs, device approval.
- Admin role required: admin APIs and API token management.

View File

@@ -29,6 +29,10 @@ docker compose ps
curl http://127.0.0.1:8080/health
```
Compose starts Mailpit for local SMTP capture. Open `http://127.0.0.1:8025`
to inspect password-reset and notification messages. SMTP is also exposed on
`127.0.0.1:1025` for host-run development servers.
Then open `https://cairnquire.example.com/setup`. On an empty database the
first-run wizard: