Commit Graph

24 Commits

Author SHA1 Message Date
Motoko
ae2409ef46 fix: API token project ownership check
- API tokens now verify project belongs to token owner before access
- Researcher tokens only access research/general docs in owner's projects
- Developer tokens only access development/general docs in owner's projects
- Viewer tokens have read-only access to all doc types in owner's projects
- Add test for cross-user project access prevention
2026-03-31 01:56:26 +00:00
Motoko
204badb964 feat: Add role-based API tokens for Claudia Docs
- Add api_tokens table with role-based access (researcher, developer, viewer)
- Add POST /auth/token/generate endpoint for creating tokens
- Add GET /auth/tokens endpoint for listing user's tokens
- Add DELETE /auth/tokens/{token_id} endpoint for revoking tokens
- Add agent_type field to documents (research, development, general)
- Implement role-based access control for documents:
  - researcher: access to research and general documents
  - developer: access to development and general documents
  - viewer: read-only access
- Update document model and schemas with agent_type field
- Add comprehensive tests for API token functionality
- All existing tests pass (73 total)
2026-03-31 01:46:51 +00:00
Motoko
5beac2d673 docs: Add environment variables configuration to README 2026-03-31 01:05:04 +00:00
Motoko
d15c823da2 feat: disable user registration via DISABLE_REGISTRATION env var
- Add DISABLE_REGISTRATION setting (default False) in app/config.py
- Return 403 when registration is disabled in POST /auth/register
- Add test_register_disabled test
2026-03-31 00:39:28 +00:00
Motoko
02292523ff feat: add PATCH /projects/{id} for partial updates
- Added PATCH endpoint for projects (supports name and/or description)
- Added test_patch_project test case
- Verify folder_id already supported in POST /api/v1/projects/{project_id}/documents
2026-03-31 00:16:27 +00:00
Motoko
d3a2194c86 migration: add Phase 3 columns (outgoing_links, backlinks_count) 2026-03-31 00:04:59 +00:00
Motoko
07f9ac91fc Phase 3: Graph view, backlinks, quick switcher, export
- Add outgoing_links (JSON) and backlinks_count to Document model
- POST /documents/{id}/detect-links — detect [[uuid]] patterns in content
- GET /documents/{id}/backlinks — documents referencing this doc
- GET /documents/{id}/outgoing-links — documents this doc references
- GET /documents/{id}/links — combined incoming + outgoing
- GET /projects/{id}/graph — full project relationship graph
- GET /search/quick — fuzzy search (Quick Switcher Cmd+K)
- GET /projects/{id}/documents/search — project-scoped search
- GET /documents/{id}/export — markdown|json export
- GET /projects/{id}/export — json|zip export
- 27 new tests
2026-03-30 23:46:45 +00:00
Motoko
202e70b4a8 Add migration script to convert markdown content to TipTap JSON
- Script migrates documents where content (markdown) exists but tiptap_content is NULL
- Idempotent: only processes documents needing migration
- Reports count of processed documents and any errors
- Includes post-migration validation
2026-03-30 23:28:01 +00:00
Motoko
71e5e3570f fix migration: remove notnull validation that fails with DEFAULT NULL
SQLite PRAGMA table_info returns notnull=1 for columns with DEFAULT,
even when they are nullable. Now only checks column existence.
2026-03-30 23:24:12 +00:00
Motoko
38e1237fbc feat: add Phase 2 migration script for documents table
Adds columns: reasoning_type, confidence, reasoning_steps, model_source, tiptap_content

- Skips columns if they already exist (idempotent)
- Includes post-migration validation
- Documents SQLite-compatible rollback procedure
2026-03-30 23:19:34 +00:00
Motoko
bbbe42358d Phase 2: Add reasoning and TipTap content endpoints
- Extend Document model with reasoning_type, confidence, reasoning_steps, model_source, tiptap_content fields
- Add new endpoints:
  - GET /documents/{id}/reasoning - Get reasoning metadata
  - PATCH /documents/{id}/reasoning - Update reasoning metadata
  - GET /documents/{id}/reasoning-panel - Get reasoning panel data for UI
  - POST /documents/{id}/reasoning-steps - Add reasoning step
  - DELETE /documents/{id}/reasoning-steps/{step} - Delete reasoning step
  - GET /documents/{id}/content?format=tiptap|markdown - Get content in TipTap or Markdown
  - PUT /documents/{id}/content - Update content (supports both TipTap JSON and Markdown)
- Add TipTap to Markdown conversion
- Update database schema with new columns
- Add comprehensive tests for all new endpoints
- All 37 tests passing
2026-03-30 23:11:44 +00:00
Motoko
0645b9c59c Add data/ to .gitignore, remove from tracking 2026-03-30 19:52:33 +00:00
Motoko
695ea482d5 Add detailed logging for admin credentials from env vars 2026-03-30 19:48:13 +00:00
Motoko
4d72239649 Fix: Use DocumentBriefResponse in DocumentListResponse to avoid validation error 2026-03-30 18:52:18 +00:00
Motoko
2884ba2e55 Fix: Make INITIAL_ADMIN_USERNAME and INITIAL_ADMIN_PASSWORD required env vars with validation 2026-03-30 17:47:49 +00:00
Motoko
957f9bee2a Fix: Restore admin auto-creation with defaults admin/admin123 2026-03-30 17:07:16 +00:00
Motoko
287bd17e04 Fix: Disable auto admin creation by default 2026-03-30 16:52:24 +00:00
Motoko
c2b673fdd3 Fix: Check for any existing user, not just admin role 2026-03-30 16:45:13 +00:00
Motoko
6c7617f1b5 Fix: Create initial admin user from environment variables on startup 2026-03-30 16:38:43 +00:00
Motoko
caea6c58d9 Fix: Use absolute path /app/data for SQLite in Docker 2026-03-30 15:49:22 +00:00
Motoko
c97f02ef46 Fix database path resolution for Docker 2026-03-30 15:48:02 +00:00
Motoko
d838e69907 Add Dockerfile for backend 2026-03-30 15:33:32 +00:00
Motoko
7f3e8a8f53 Phase 1 MVP - Complete implementation
- Auth: register, login, JWT with refresh tokens, blocklist
- Projects/Folders/Documents CRUD with soft deletes
- Tags CRUD and assignment
- FTS5 search with highlights and tag filtering
- ADR-001, ADR-002, ADR-003 compliant
- Security fixes applied (JWT_SECRET_KEY, exception handler, cookie secure)
- 25 tests passing
2026-03-30 15:17:27 +00:00
33f19e02f8 Initial commit 2026-03-30 13:46:59 +00:00