Commit Graph

19 Commits

Author SHA1 Message Date
saravanakumardb1
573483c20e feat(backend): Phase C.3 Zapier-compatible polling endpoint + event-types discovery 2026-04-18 18:09:56 -07:00
saravanakumardb1
79ac0bb1d6 feat(backend): Phase C.1-C.2 wire domain events from timer + routine repositories to webhook dispatch 2026-04-18 18:09:04 -07:00
saravanakumardb1
e021e96c80 feat(backend): Phase B.1 day planner engine + routes + 11 tests 2026-04-18 18:03:55 -07:00
saravanakumardb1
0240d3c807 feat(backend): TODO-008 wire telemetry trackEvent() into agent-actions + context-message routes 2026-04-18 18:01:19 -07:00
saravanakumardb1
0e7c1aeb15 feat(backend): state-change event detection + clone template on start
- PUT /timers/🆔 detect state→fired and state→completed transitions,
  emit timer.fired / timer.completed domain events
- PUT /routines/🆔 detect status→completed transition,
  emit routine.completed domain event
- POST /routines/:id/start (TODO-004): when isTemplate=true, clone the
  template into a new RoutineDoc instead of mutating in-place. Original
  template stays reusable. Non-templates still update in place.

All 6 ChronoMind event types are now fully wired end-to-end.
2026-04-13 17:00:05 -07:00
saravanakumardb1
0129f5623c fix(backend): emit routine.started and household.created domain events
Event bus defines 6 event types but only timer.created was wired.
Wire the two straightforward create/start events:
- routine.started: emitted from POST /routines/:id/start
- household.created: emitted from POST /households
2026-04-13 15:52:49 -07:00
saravanakumardb1
d74c80a711 fix(cleanup): TODO-010 — replace hardcoded PRODUCT_ID with import from product-config 2026-04-13 14:56:57 -07:00
saravanakumardb1
c1972ef0d0 feat(backend): emit timer.created event from POST /timers route
Wire getEventBus().emit() into the timer creation handler so webhook
subscribers and future listeners receive typed domain events.
2026-04-13 11:50:39 -07:00
saravanakumardb1
9897d2cd09 docs(todos): standardize all TODOs with running numbers and delegatable instructions
Replace ad-hoc AGENTIC-N comments with standardized TODO-NNN format across
the entire codebase. Each TODO has:
  - Running number (TODO-001 through TODO-011)
  - Priority level (high/medium/low)
  - Phase reference (0, A.1, A.4, B, cleanup)
  - Clear step-by-step instructions an AI agent can follow

TODO index:
  TODO-001: Kill switch maintenance banner (providers.tsx)
  TODO-002: Feedback button in settings page
  TODO-003: Accessibility focus trap for modals
  TODO-004: Clone routine template instead of mutating in-place
  TODO-005: Wire real LLM enrichment for context messages
  TODO-006: Centralize backend URL configuration
  TODO-007: MCP tool integration tests (common-plat)
  TODO-008: Wire trackEvent() calls into routes + components
  TODO-009: Unit tests for AI context generation
  TODO-010: Import PRODUCT_ID from product-config (5 route files)
  TODO-011: Wire error boundary to telemetry

Added consolidated TODO Index table at top of AGENTIC_AI_ROADMAP.md
for agent scanning. 219 backend tests pass, no code changes.
2026-04-01 01:05:25 -07:00
saravanakumardb1
ea5adcc6ca fix(backend): harden Phase A endpoints — Zod validation, feature flag gate, state filtering
3 bugs fixed in recent Phase A code:

1. POST /api/context-message: Add Zod schema validation, feature flag gate
   (ai_context_messages.enabled), and safe body parsing. Previously had no
   validation and unsafe 'as' cast that could null-ptr on missing body.

2. GET /api/timers/availability: Filter out dismissed/completed/fired timers.
   Previously included inactive timers in occupied intervals, causing the
   endpoint to report less free time than actually available.

3. agent-actions/routes.ts: Import PRODUCT_ID from product-config.ts instead
   of hardcoding 'chronomind' string. Ensures consistency if product identity
   changes.

Also: Add EXTRACTION_SERVICE_URL + PLATFORM_SERVICE_URL to .env.example.

All 219 backend tests pass. No breaking changes.
2026-03-31 23:56:35 -07:00
saravanakumardb1
29a48025eb feat(agent-actions): Phase A.2 — agent action audit trail module + tests
Add agent-actions module for AI/MCP operation audit trail:

- types.ts: 3 enums (ACTOR_TYPES, ACTION_STATES, ACTION_TYPES), AgentActionDoc,
  CreateAgentActionSchema, AgentActionQuerySchema, BatchApproveSchema
- repository.ts: CRUD + batchApproveByActor using @bytelyst/datastore
- routes.ts: 5 endpoints (list, create, approve, reject, batch-approve)
  All gated behind isFeatureEnabled('agent_inbox.enabled')
- Registered cm_agent_actions container in cosmos-init.ts
- Registered agentActionRoutes in server.ts

Tests (37 new, 219 total):
- 22 agent-actions schema tests (constants, create, query, batch-approve)
- 15 timer schema tests (RescheduleTimerSchema, AvailabilityQuerySchema)

All 219 backend tests pass. No breaking changes.
2026-03-31 23:38:03 -07:00
saravanakumardb1
686f5fb33e feat(mcp): Phase A.1 — reschedule, availability, and start-routine endpoints
Add 3 new backend REST endpoints for MCP tool support:

- POST /timers/:id/reschedule — shift timer by delta seconds or set new target time
- GET /timers/availability — find free time slots in a window (interval merge algorithm)
- POST /routines/:id/start — transition routine from ready/template → active

All endpoints gated behind isFeatureEnabled('mcp.enabled') flag (default false).
Zod schemas: RescheduleTimerSchema (XOR validation), AvailabilityQuerySchema, FreeSlot type.

All 182 backend tests pass. No breaking changes to existing APIs.
2026-03-31 23:31:04 -07:00
saravanakumardb1
253a9db0ea feat(backend): encrypt sensitive fields across all modules
- timers: description
- routines: description, steps[].notes
- shared-timers: description
- webhooks: secret, description
- Add @bytelyst/field-encrypt dep + chronomind-mek config
- field-encrypt singleton (getEncryptor lazy pattern)
- Encrypt on create/update/batchUpsert, decrypt on read/list/since
- Backward-compatible via isEncryptedField guard
- 182/182 tests passing, typecheck clean
2026-03-21 12:11:39 -07:00
saravanakumardb1
b4a6c62e15 refactor(backend): remove errors.ts re-export, import @bytelyst/errors directly 2026-03-20 07:19:29 -07:00
saravanakumardb1
909daf8853 fix(diagnostics): getAuthToken throws when no token (type-safe), void .start(), unsyncedCount replaces conflictCount 2026-03-05 11:18:27 -08:00
saravanakumardb1
4a3ac76ff7 feat(mcp): add GET /timers/sync-status endpoint (chronomind.syncStatus MCP tool) 2026-03-05 11:04:44 -08:00
saravanakumardb1
4cb5d3e627 fix(backend): replace $contains with post-filter for webhook events array query
$contains generates CONTAINS() SQL in Cosmos (string match), not
ARRAY_CONTAINS() needed for string[] fields. Use findMany + in-memory
post-filter for correct behavior across both providers.
2026-03-02 01:49:18 -08:00
saravanakumardb1
03d4b7def9 refactor(backend): migrate ChronoMind repositories to @bytelyst/datastore 2026-03-02 01:45:16 -08:00
saravanakumardb1
f10b83c122 feat(backend): scaffold product-specific Fastify backend (port 4011)
Add backend/ directory with Fastify 5 + TypeScript ESM service:
- Modules: timers, routines, households, shared-timers, webhooks (migrated from platform-service)
- Cosmos containers: timers, routines, households, shared_timers, webhook_subscriptions, webhook_events
- JWT verification via jose (matches platform-service issuer)
- Shared @bytelyst/* packages via file: refs
- 171 Vitest tests passing

Update AGENTS.md: update backend integration section with product backend details
2026-03-01 20:39:08 -08:00