Commit Graph

60 Commits

Author SHA1 Message Date
saravanakumardb1
1258d49488 feat(backend): emit task.created + workspace.created events; add share revocation regression test
Sprint B — closes audit items B6 (event-bus completeness) and B3
(public-share revocation regression).

Event bus:
- note-tasks/repository.ts createNoteTask now emits task.created with
  taskId, noteId, workspaceId, userId, title
- workspaces/repository.ts createWorkspace now emits workspace.created
  with workspaceId, userId, name

The event-bus already declared these event types (event-bus.ts) and
webhook subscribers can target them, but they were never emitted —
making the contract dead. Emissions follow the same .catch(() => {})
pattern used by note.created/updated/deleted in notes/repository.ts so
a subscriber failure cannot break the create flow.

Regression tests:
- note-tasks/repository.test.ts and workspaces/repository.test.ts
  exercise the emission paths end-to-end through the in-memory
  datastore.
- note-shares/repository.integration.test.ts adds a 5-test integration
  suite for the public-share revocation path: token resolves before
  revocation; token returns null after deleteShare (hard delete);
  expired token returns null; cross-product token rejected;
  listSharesForNote does not include revoked shares.

Verified:
- pnpm --filter @notelett/backend run test: 380/380 (was 373, +7 new)
- pnpm run verify end-to-end green
2026-05-22 23:23:08 -07:00
9bded74567 fix(lint): clear production lint blockers 2026-05-05 14:04:49 -07:00
efcc5fa044 feat(data): add seed bootstrap strategy 2026-05-05 13:45:43 -07:00
e71febe51a fix(sharing): harden note share revocation flows 2026-05-05 12:25:16 -07:00
09f30c003e feat(notes): harden import export readiness 2026-05-05 12:15:11 -07:00
3aa385774e test(backend): verify scheduler webhook lifecycle 2026-05-05 11:37:28 -07:00
205c44bc3f test(backend): document cosmos query scope 2026-05-05 11:17:27 -07:00
ff33a057ab test(backend): cover structured error mapping 2026-05-05 11:15:02 -07:00
c31f51ddbd fix(backend): propagate outbound request ids 2026-05-05 11:06:02 -07:00
7016fc1ad5 refactor(backend): route startup logs through logger 2026-05-05 11:00:38 -07:00
6b37b728aa fix(security): encrypt sensitive note metadata 2026-05-05 10:12:40 -07:00
ee4a8ab2ea fix(security): add backend abuse rate limits 2026-05-05 10:05:33 -07:00
saravanakumardb1
7d7e445135 feat(prompts): inject palace wake-up context into Smart Actions
Enrich the system prompt with L0/L1/L2 workspace context from the
palace when running Smart Actions. Best-effort — failures never block
prompt execution. Gives LLM access to decisions, preferences, and
semantically relevant memories from the workspace.
2026-04-13 12:33:34 -07:00
saravanakumardb1
06590b9175 feat(palace): extract KG triples from entities + refresh L1 cache on note save
After storing memories, generate subject-predicate-object triples from
entity pairs found in extracted memories. Also trigger L1 critical facts
cache regeneration so wake-up context stays fresh.
2026-04-13 12:33:16 -07:00
saravanakumardb1
190d23280f feat(backend): add domain event bus and wire note CRUD events
- New lib/event-bus.ts: lightweight typed pub/sub with error isolation
  via Promise.allSettled. Supports note.created, note.updated,
  note.deleted, task.created, workspace.created events.
- notes/repository.ts: emit events on create, update, and delete.
- .env.example: add TELEMETRY_ENABLED, FEATURE_FLAGS_ENABLED,
  FIELD_ENCRYPT_ENABLED, PALACE_ENABLED, PALACE_EXTRACTION_ENABLED.
2026-04-13 10:00:12 -07:00
saravanakumardb1
1bf9896ea9 fix(palace): pass stripped plainText to extractor instead of raw HTML 2026-04-10 01:42:00 -07:00
saravanakumardb1
97662d1dc0 fix(palace): deleteMemory now decrements wing/room memoryCount 2026-04-10 01:40:34 -07:00
saravanakumardb1
be2f4ff0ad feat(palace): REST API routes with search, CRUD, KG, wake-up, maintenance (N5) 2026-04-10 01:35:20 -07:00
saravanakumardb1
31bdb0ada9 feat(palace): knowledge graph triple CRUD with temporal queries, contradiction detection (N3) 2026-04-10 01:30:02 -07:00
saravanakumardb1
a5dbeac77e feat(palace): wake-up context builder with L0/L1/L2 layers, L1 cache regeneration (N2) 2026-04-10 01:27:13 -07:00
saravanakumardb1
0af5f875bb feat(palace): auto-save hooks — extract memories on note create/update (N4) 2026-04-10 01:25:00 -07:00
saravanakumardb1
632b5df1ac feat(palace): add 30 tests with cross-user isolation, fix extractor regex fallback 2026-04-10 01:19:35 -07:00
saravanakumardb1
13020bc72f feat(palace): add LLM memory extractor with regex fallback 2026-04-10 01:16:55 -07:00
saravanakumardb1
44d8867aa5 feat(palace): add user-isolated repository with CRUD, search, dedup, prune, encryption 2026-04-10 01:15:41 -07:00
saravanakumardb1
38006af1a3 feat(palace): add @bytelyst/palace dep, palace types, 6 cosmos containers, config vars 2026-04-10 01:14:00 -07:00
saravanakumardb1
b7bdfd97bc fix(test): resolve all TS lint errors in note-collaborators routes test — properly typed mock fns 2026-04-06 20:56:20 -07:00
saravanakumardb1
338e80fc33 fix(intake): support comma-separated status filter in GET /intake/jobs — fixes mobile polling contract mismatch 2026-04-06 20:48:26 -07:00
saravanakumardb1
599d68e116 feat(sharing): add collaborative shares, export-text, deep-link helper — note-collaborators module (11 new tests) 2026-04-06 20:31:31 -07:00
saravanakumardb1
0e16714da1 feat(intake): add URL intake pipeline — classifier, extractors, rules engine, routes, 6 new prompt templates (27 total), 26 new tests 2026-04-06 20:28:36 -07:00
saravanakumardb1
6f262a5218 fix: register missing note_shares+note_versions containers, add multi-note input type 2026-04-06 20:20:12 -07:00
saravanakumardb1
96015be313 fix: add /userId partition key to scheduler schedule+webhook collections 2026-04-06 16:29:24 -07:00
saravanakumardb1
6095f1d985 feat(smart-actions): add prompt-result screen, capture sub-routes, Cmd+Shift+A shortcut, telemetry events (G16-G19) 2026-04-06 13:43:47 -07:00
saravanakumardb1
2a7cfbb73e test(backend): add runner, reading-time, copilot-transform, note-hooks tests (G6-G9) 2026-04-06 13:29:33 -07:00
saravanakumardb1
093da76eee feat(smart-actions): add run-stream SSE, history endpoint, weekly-digest template, web client functions (G1-G5) 2026-04-06 13:27:02 -07:00
saravanakumardb1
e9f389a8b7 feat(backend): add 11 telemetry events for Smart Actions 2026-04-06 11:13:50 -07:00
saravanakumardb1
1b4b5af995 feat(backend): register 8 Smart Actions feature flags with route gating 2026-04-06 11:11:25 -07:00
saravanakumardb1
c71b01681f fix(backend): harden LLM error handling — retry, timeout, missing key guards 2026-04-06 11:09:08 -07:00
saravanakumardb1
b8bc096adb test(smart-actions): add scheduler, webhook, copilot integration tests 2026-04-06 11:05:42 -07:00
saravanakumardb1
f2c3258b53 fix(backend): review fixes — persist requiresApproval, shutdown hook, productId check, GET by ID
- repository.ts: persist requiresApproval field in createPromptTemplate (was silently dropped)
- server.ts: register onClose hook to call stopSchedulerLoop() on graceful shutdown
- scheduler.ts: add productId check in webhook trigger note lookup
- scheduler.ts: add GET /prompt-schedules/:id and GET /prompt-webhooks/:id endpoints
2026-04-06 10:45:03 -07:00
saravanakumardb1
3260b7ea0a feat(smart-actions): F1-F4 inline editor AI, F15-F19 mobile capture modes, F25-F27 scheduler/webhooks/approval
F1-F4: Inline editor AI
- Backend: expand CopilotAction with fix-rewrite, change-tone, continue, explain
- Backend: add tone parameter to copilot route for change-tone action
- Web: copilot-client adds CopilotTone type and tone parameter
- Web: NoteEditor toolbar gains AI row with Fix & Rewrite, Change Tone dropdown,
  Continue Writing (appends at cursor), Explain (inline popover)

F15-F19: Mobile capture enhancements
- Backend: POST /note-prompts/url-extract endpoint (fetch, strip HTML, LLM summarize)
- Mobile API: extractFromUrl() and copilotTransform() client functions
- Mobile: capture tab rewritten with 6 capture modes grid (text, photo, voice,
  URL, scan, paste) — URL extract + clipboard paste fully wired, camera/voice/scan
  surface native permission prompts (require expo-av/expo-image-picker)
- expo-clipboard added as dependency

F25-F27: Scheduled actions, webhook triggers, approval-gated actions
- New scheduler.ts module with PromptScheduleDoc + PromptWebhookDoc types
- Schedule CRUD: GET/POST/PATCH/DELETE /prompt-schedules
- Webhook CRUD: GET/POST/PATCH/DELETE /prompt-webhooks
- POST /prompt-webhooks/:id/trigger — execute template against note
- Scheduler loop (60s tick) with cron next-run calculation
- Diagnostics endpoint: GET /prompt-schedules/diagnostics
- Cosmos containers: note_prompt_schedules, note_prompt_webhooks
- PromptTemplateDoc gains requiresApproval field (F27)
- Runner produces approvalState: proposed|applied based on template flag
- Create/Update schemas accept requiresApproval boolean
2026-04-06 10:25:34 -07:00
saravanakumardb1
fe3b0f9b3e feat(backend): add note intelligence — embeddings, auto-summarize, duplicates, suggest-links, knowledge gaps
Phase 2 of Smart Actions Roadmap:

- Create lib/embeddings.ts: embedText(), cosineSimilarity(), stripHtmlForEmbedding()
- Add embedding + summaryArtifactId fields to NoteDoc
- Create lib/note-hooks.ts: runPostSaveHooks() for background AI enrichment
  - backgroundEmbed: compute and store note embedding vectors
  - backgroundAutoSummarize: generate summary artifact for notes > 300 words
  - Both gated behind feature flags (notelett_auto_embed_enabled, notelett_auto_summarize_enabled)
- Add intelligence endpoints to note-prompts routes:
  - POST /api/notes/:id/suggest-tags (F5) — LLM-generated tag suggestions
  - POST /api/notes/:id/check-duplicates (F8) — cosine similarity duplicate detection
  - POST /api/notes/:id/suggest-links (F9) — related note suggestions
  - POST /api/workspaces/:wsId/knowledge-gaps (F12) — workspace gap analysis
  - POST /api/notes/compare (F14) — multi-note comparison
  - POST /api/notes/merge (F13) — multi-note merge
- Add 4 feature flags for intelligence features
- 9 new tests in embeddings.test.ts (cosine similarity, HTML stripping, embedText)
2026-04-06 08:10:26 -07:00
saravanakumardb1
9e3a7206b9 feat(backend): add note-prompts module with Smart Actions LLM integration
- Add @bytelyst/llm dependency (file: ref) + llm.ts singleton wrapper
- Add LLM env vars to config (LLM_PROVIDER, LLM_DEFAULT_MODEL, LLM_VISION_MODEL, LLM_EMBEDDING_MODEL)
- Create note-prompts module: types, repository, runner, routes, seed (20 built-in templates)
- Built-in templates: 8 transform, 3 extract, 3 generate, 2 analyze, 2 vision, 2 export
- Prompt runner supports text, image, and text+image inputs via @bytelyst/llm vision
- Upgrade copilot-transform.ts to use @bytelyst/llm directly (with local heuristic fallback)
- Add reading-time endpoint (GET /api/notes/:id/reading-time)
- Extend agent-action types with smart_action and auto_enrich
- Add note_prompts Cosmos container to cosmos-init
- Register notePromptRoutes in server.ts
- 15 new tests (CRUD, run, slug resolution, seed validation, reading-time)
2026-04-06 08:01:42 -07:00
7ee2151f17 feat(phase3): wire notelett trail import route 2026-04-04 00:33:38 -07:00
9ecc7c6bf5 fix(notes): preserve phase1 transcript event lineage 2026-04-03 17:40:59 -07:00
6ffc2f8755 feat(notes): import phase1 transcript artifacts 2026-04-03 16:36:54 -07:00
8d8540e320 fix(note-shares): treat expired shares as not found
findShareByToken now returns null when expiresAt is in the past, aligning the public share API with stored metadata.

Add unit tests for expiry, future expiry, missing expiry, and no match.

Made-with: Cursor
2026-03-31 13:05:30 -07:00
5e3e374d3a fix(notes): export route order and lexical snippet ellipsis
Register GET /notes/export before GET /notes/:id so the path is not captured as an id.

Compute search snippets from stripped plain text so the trailing ellipsis matches visible length, not raw HTML length.

Made-with: Cursor
2026-03-31 13:05:29 -07:00
a697752d15 feat: implement WEB_AI_FAST_ROADMAP (web + backend + docs)
Phase 1: Command palette (⌘K), editor autosave with quiet auto-saves, dashboard
saved views from API + quick links + onboarding seed CTA, explicit task scan panel.

Phase 2: Context pack formatter with YAML frontmatter, copy on note + workspace .md export.

Phase 3: ADR for hybrid search without embeddings; POST /notes/search (lexical +
ranked hybrid); search UI mode toggle.

Phase 4: POST copilot + suggest-title; in-editor copilot actions; /chat retrieval
answers with citations (backend chat.rag_enabled).

Phase 5: Settings MCP snippet, offline queue note, API token deferral; DEEP_LINKS.md.

Phase 6: Note shares + public GET; share page; POST onboarding-seed.

Phase 7: note_versions on PATCH; version panel; create-note templates; PWA manifest.

Flags: search.hybrid_enabled, copilot.enabled, chat.rag_enabled, onboarding.seed_enabled.
Made-with: Cursor
2026-03-31 13:00:36 -07:00
saravanakumardb1
6acd1a70d4 fix(backend): fix trackEvent call signature and route registration tests
- auth.ts: type requireWriter param as { headers: { authorization?: string } } instead of unknown
- notes/routes.ts: fix 3 trackEvent calls from object form to positional args (event, userId, properties)
- workspaces/routes.ts: fix 1 trackEvent call from object form to positional args
- 5 route registration tests: add missing delete mock to app object for Phase 2 DELETE endpoints
2026-03-31 01:00:32 -07:00
8d84bcb841 feat: add DELETE endpoints, role enforcement, telemetry and feature flags
Phase 2 of the execution roadmap:
- Add DELETE endpoints for notes (soft-delete), workspaces, tasks, artifacts, relationships
- Add requireWriter() role enforcement on all write routes (POST/PATCH/DELETE)
- Activate trackEvent() telemetry on note.created, note.updated, note.archived, workspace.created
- Gate notes search behind isFeatureEnabled('notes.enabled')
- Update all test mocks to include role and new auth exports

Made-with: Cursor
2026-03-29 20:47:12 -07:00