remdb 0.3.14__py3-none-any.whl → 0.3.133__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. rem/agentic/README.md +76 -0
  2. rem/agentic/__init__.py +15 -0
  3. rem/agentic/agents/__init__.py +16 -2
  4. rem/agentic/agents/sse_simulator.py +502 -0
  5. rem/agentic/context.py +51 -27
  6. rem/agentic/llm_provider_models.py +301 -0
  7. rem/agentic/mcp/tool_wrapper.py +112 -17
  8. rem/agentic/otel/setup.py +93 -4
  9. rem/agentic/providers/phoenix.py +302 -109
  10. rem/agentic/providers/pydantic_ai.py +215 -26
  11. rem/agentic/schema.py +361 -21
  12. rem/agentic/tools/rem_tools.py +3 -3
  13. rem/api/README.md +215 -1
  14. rem/api/deps.py +255 -0
  15. rem/api/main.py +132 -40
  16. rem/api/mcp_router/resources.py +1 -1
  17. rem/api/mcp_router/server.py +26 -5
  18. rem/api/mcp_router/tools.py +465 -7
  19. rem/api/routers/admin.py +494 -0
  20. rem/api/routers/auth.py +70 -0
  21. rem/api/routers/chat/completions.py +402 -20
  22. rem/api/routers/chat/models.py +88 -10
  23. rem/api/routers/chat/otel_utils.py +33 -0
  24. rem/api/routers/chat/sse_events.py +542 -0
  25. rem/api/routers/chat/streaming.py +642 -45
  26. rem/api/routers/dev.py +81 -0
  27. rem/api/routers/feedback.py +268 -0
  28. rem/api/routers/messages.py +473 -0
  29. rem/api/routers/models.py +78 -0
  30. rem/api/routers/query.py +360 -0
  31. rem/api/routers/shared_sessions.py +406 -0
  32. rem/auth/middleware.py +126 -27
  33. rem/cli/commands/README.md +237 -64
  34. rem/cli/commands/cluster.py +1808 -0
  35. rem/cli/commands/configure.py +1 -3
  36. rem/cli/commands/db.py +386 -143
  37. rem/cli/commands/experiments.py +418 -27
  38. rem/cli/commands/process.py +14 -8
  39. rem/cli/commands/schema.py +97 -50
  40. rem/cli/main.py +27 -6
  41. rem/config.py +10 -3
  42. rem/models/core/core_model.py +7 -1
  43. rem/models/core/experiment.py +54 -0
  44. rem/models/core/rem_query.py +5 -2
  45. rem/models/entities/__init__.py +21 -0
  46. rem/models/entities/domain_resource.py +38 -0
  47. rem/models/entities/feedback.py +123 -0
  48. rem/models/entities/message.py +30 -1
  49. rem/models/entities/session.py +83 -0
  50. rem/models/entities/shared_session.py +180 -0
  51. rem/registry.py +10 -4
  52. rem/schemas/agents/rem.yaml +7 -3
  53. rem/services/content/service.py +92 -20
  54. rem/services/embeddings/api.py +4 -4
  55. rem/services/embeddings/worker.py +16 -16
  56. rem/services/phoenix/client.py +154 -14
  57. rem/services/postgres/README.md +159 -15
  58. rem/services/postgres/__init__.py +2 -1
  59. rem/services/postgres/diff_service.py +531 -0
  60. rem/services/postgres/pydantic_to_sqlalchemy.py +427 -129
  61. rem/services/postgres/repository.py +132 -0
  62. rem/services/postgres/schema_generator.py +205 -4
  63. rem/services/postgres/service.py +6 -6
  64. rem/services/rem/parser.py +44 -9
  65. rem/services/rem/service.py +36 -2
  66. rem/services/session/compression.py +24 -1
  67. rem/services/session/reload.py +1 -1
  68. rem/settings.py +324 -23
  69. rem/sql/background_indexes.sql +21 -16
  70. rem/sql/migrations/001_install.sql +387 -54
  71. rem/sql/migrations/002_install_models.sql +2320 -393
  72. rem/sql/migrations/003_optional_extensions.sql +326 -0
  73. rem/sql/migrations/004_cache_system.sql +548 -0
  74. rem/utils/__init__.py +18 -0
  75. rem/utils/date_utils.py +2 -2
  76. rem/utils/model_helpers.py +156 -1
  77. rem/utils/schema_loader.py +220 -22
  78. rem/utils/sql_paths.py +146 -0
  79. rem/utils/sql_types.py +3 -1
  80. rem/workers/__init__.py +3 -1
  81. rem/workers/db_listener.py +579 -0
  82. rem/workers/unlogged_maintainer.py +463 -0
  83. {remdb-0.3.14.dist-info → remdb-0.3.133.dist-info}/METADATA +335 -226
  84. {remdb-0.3.14.dist-info → remdb-0.3.133.dist-info}/RECORD +86 -66
  85. {remdb-0.3.14.dist-info → remdb-0.3.133.dist-info}/WHEEL +1 -1
  86. rem/sql/002_install_models.sql +0 -1068
  87. rem/sql/install_models.sql +0 -1051
  88. rem/sql/migrations/003_seed_default_user.sql +0 -48
  89. {remdb-0.3.14.dist-info → remdb-0.3.133.dist-info}/entry_points.txt +0 -0
rem/settings.py CHANGED
@@ -15,7 +15,7 @@ Example .env file:
15
15
  API__LOG_LEVEL=info
16
16
 
17
17
  # LLM
18
- LLM__DEFAULT_MODEL=anthropic:claude-sonnet-4-5-20250929
18
+ LLM__DEFAULT_MODEL=openai:gpt-4.1
19
19
  LLM__DEFAULT_TEMPERATURE=0.5
20
20
  LLM__MAX_RETRIES=10
21
21
  LLM__OPENAI_API_KEY=sk-...
@@ -33,14 +33,15 @@ Example .env file:
33
33
  AUTH__OIDC_CLIENT_ID=your-client-id
34
34
  AUTH__SESSION_SECRET=your-secret-key
35
35
 
36
- # OpenTelemetry (disabled by default)
36
+ # OpenTelemetry (disabled by default - enable via env var when collector available)
37
+ # Standard OTLP collector ports: 4317 (gRPC), 4318 (HTTP)
37
38
  OTEL__ENABLED=false
38
39
  OTEL__SERVICE_NAME=rem-api
39
- OTEL__COLLECTOR_ENDPOINT=http://localhost:4318
40
- OTEL__PROTOCOL=http
40
+ OTEL__COLLECTOR_ENDPOINT=http://localhost:4317
41
+ OTEL__PROTOCOL=grpc
41
42
 
42
- # Arize Phoenix (disabled by default)
43
- PHOENIX__ENABLED=false
43
+ # Arize Phoenix (enabled by default - can be disabled via env var)
44
+ PHOENIX__ENABLED=true
44
45
  PHOENIX__COLLECTOR_ENDPOINT=http://localhost:6006/v1/traces
45
46
  PHOENIX__PROJECT_NAME=rem
46
47
 
@@ -58,7 +59,7 @@ Example .env file:
58
59
 
59
60
  import os
60
61
  import hashlib
61
- from pydantic import Field, field_validator, FieldValidationInfo
62
+ from pydantic import Field, field_validator, ValidationInfo
62
63
  from pydantic_settings import BaseSettings, SettingsConfigDict
63
64
  from loguru import logger
64
65
 
@@ -74,7 +75,7 @@ class LLMSettings(BaseSettings):
74
75
  LLM__EVALUATOR_MODEL or EVALUATOR_MODEL - Model for LLM-as-judge evaluation
75
76
  LLM__OPENAI_API_KEY or OPENAI_API_KEY - OpenAI API key
76
77
  LLM__ANTHROPIC_API_KEY or ANTHROPIC_API_KEY - Anthropic API key
77
- LLM__EMBEDDING_PROVIDER or EMBEDDING_PROVIDER - Default embedding provider (openai, cohere, jina, etc.)
78
+ LLM__EMBEDDING_PROVIDER or EMBEDDING_PROVIDER - Default embedding provider (openai)
78
79
  LLM__EMBEDDING_MODEL or EMBEDDING_MODEL - Default embedding model name
79
80
  """
80
81
 
@@ -86,7 +87,7 @@ class LLMSettings(BaseSettings):
86
87
  )
87
88
 
88
89
  default_model: str = Field(
89
- default="anthropic:claude-sonnet-4-5-20250929",
90
+ default="openai:gpt-4.1",
90
91
  description="Default LLM model (format: provider:model-id)",
91
92
  )
92
93
 
@@ -129,7 +130,7 @@ class LLMSettings(BaseSettings):
129
130
 
130
131
  embedding_provider: str = Field(
131
132
  default="openai",
132
- description="Default embedding provider (openai, cohere, jina, etc.)",
133
+ description="Default embedding provider (currently only openai supported)",
133
134
  )
134
135
 
135
136
  embedding_model: str = Field(
@@ -241,6 +242,11 @@ class OTELSettings(BaseSettings):
241
242
  description="Export timeout in milliseconds",
242
243
  )
243
244
 
245
+ insecure: bool = Field(
246
+ default=True,
247
+ description="Use insecure (non-TLS) gRPC connection (default: True for local dev)",
248
+ )
249
+
244
250
 
245
251
  class PhoenixSettings(BaseSettings):
246
252
  """
@@ -267,8 +273,8 @@ class PhoenixSettings(BaseSettings):
267
273
  )
268
274
 
269
275
  enabled: bool = Field(
270
- default=False,
271
- description="Enable Phoenix integration (disabled by default for local dev)",
276
+ default=True,
277
+ description="Enable Phoenix integration (enabled by default)",
272
278
  )
273
279
 
274
280
  base_url: str = Field(
@@ -361,10 +367,16 @@ class AuthSettings(BaseSettings):
361
367
  - Custom OIDC provider
362
368
 
363
369
  Environment variables:
364
- AUTH__ENABLED - Enable authentication (default: false)
370
+ AUTH__ENABLED - Enable authentication (default: true)
371
+ AUTH__ALLOW_ANONYMOUS - Allow rate-limited anonymous access (default: true)
365
372
  AUTH__SESSION_SECRET - Secret for session cookie signing
366
373
  AUTH__GOOGLE__* - Google OAuth settings
367
374
  AUTH__MICROSOFT__* - Microsoft OAuth settings
375
+
376
+ Access modes:
377
+ - enabled=true, allow_anonymous=true: Auth available, anonymous gets rate-limited access
378
+ - enabled=true, allow_anonymous=false: Auth required for all requests
379
+ - enabled=false: No auth, all requests treated as default user (dev mode)
368
380
  """
369
381
 
370
382
  model_config = SettingsConfigDict(
@@ -375,8 +387,26 @@ class AuthSettings(BaseSettings):
375
387
  )
376
388
 
377
389
  enabled: bool = Field(
378
- default=False,
379
- description="Enable authentication (disabled by default for testing)",
390
+ default=True,
391
+ description="Enable authentication (OAuth endpoints and middleware)",
392
+ )
393
+
394
+ allow_anonymous: bool = Field(
395
+ default=True,
396
+ description=(
397
+ "Allow anonymous (unauthenticated) access with rate limits. "
398
+ "When true, requests without auth get ANONYMOUS tier rate limits. "
399
+ "When false, all requests require authentication."
400
+ ),
401
+ )
402
+
403
+ mcp_requires_auth: bool = Field(
404
+ default=True,
405
+ description=(
406
+ "Require authentication for MCP endpoints. "
407
+ "MCP is a protected service and should always require login in production. "
408
+ "Set to false only for local development/testing."
409
+ ),
380
410
  )
381
411
 
382
412
  session_secret: str = Field(
@@ -390,7 +420,7 @@ class AuthSettings(BaseSettings):
390
420
 
391
421
  @field_validator("session_secret", mode="before")
392
422
  @classmethod
393
- def generate_dev_secret(cls, v: str | None, info: FieldValidationInfo) -> str:
423
+ def generate_dev_secret(cls, v: str | None, info: ValidationInfo) -> str:
394
424
  # Only generate if not already set and not in production
395
425
  if not v and info.data.get("environment") != "production":
396
426
  # Deterministic secret for development
@@ -662,6 +692,91 @@ class S3Settings(BaseSettings):
662
692
  )
663
693
 
664
694
 
695
+ class DataLakeSettings(BaseSettings):
696
+ """
697
+ Data lake settings for experiment and dataset storage.
698
+
699
+ Data Lake Convention:
700
+ The data lake provides a standardized structure for storing datasets,
701
+ experiments, and calibration data in S3. Users bring their own bucket
702
+ and the version is pinned by default to v0 in the path.
703
+
704
+ S3 Path Structure:
705
+ s3://{bucket}/{version}/datasets/
706
+ ├── raw/ # Raw source data + transformers
707
+ │ └── {dataset_name}/ # e.g., cns_drugs, codes, care
708
+ ├── tables/ # Database table data (JSONL)
709
+ │ ├── resources/ # → resources table
710
+ │ │ ├── drugs/{category}/ # Psychotropic drugs
711
+ │ │ ├── care/stages/ # Treatment stages
712
+ │ │ └── crisis/ # Crisis resources
713
+ │ └── codes/ # → codes table
714
+ │ ├── icd10/{category}/ # ICD-10 codes
715
+ │ └── cpt/ # CPT codes
716
+ └── calibration/ # Agent calibration
717
+ ├── experiments/ # Experiment configs + results
718
+ │ └── {agent}/{task}/ # e.g., siggy/risk-assessment
719
+ └── datasets/ # Shared evaluation datasets
720
+
721
+ Experiment Storage:
722
+ - Local: experiments/{agent}/{task}/experiment.yaml
723
+ - S3: s3://{bucket}/{version}/datasets/calibration/experiments/{agent}/{task}/
724
+
725
+ Environment variables:
726
+ DATA_LAKE__BUCKET_NAME - S3 bucket for data lake (required)
727
+ DATA_LAKE__VERSION - Path version prefix (default: v0)
728
+ DATA_LAKE__DATASETS_PREFIX - Datasets directory (default: datasets)
729
+ DATA_LAKE__EXPERIMENTS_PREFIX - Experiments subdirectory (default: experiments)
730
+ """
731
+
732
+ model_config = SettingsConfigDict(
733
+ env_prefix="DATA_LAKE__",
734
+ env_file=".env",
735
+ env_file_encoding="utf-8",
736
+ extra="ignore",
737
+ )
738
+
739
+ bucket_name: str | None = Field(
740
+ default=None,
741
+ description="S3 bucket for data lake storage (user-provided)",
742
+ )
743
+
744
+ version: str = Field(
745
+ default="v0",
746
+ description="API version for data lake paths",
747
+ )
748
+
749
+ datasets_prefix: str = Field(
750
+ default="datasets",
751
+ description="Root directory for datasets in the bucket",
752
+ )
753
+
754
+ experiments_prefix: str = Field(
755
+ default="experiments",
756
+ description="Subdirectory within calibration for experiments",
757
+ )
758
+
759
+ def get_base_uri(self) -> str | None:
760
+ """Get the base S3 URI for the data lake."""
761
+ if not self.bucket_name:
762
+ return None
763
+ return f"s3://{self.bucket_name}/{self.version}/{self.datasets_prefix}"
764
+
765
+ def get_experiment_uri(self, agent: str, task: str = "general") -> str | None:
766
+ """Get the S3 URI for an experiment."""
767
+ base = self.get_base_uri()
768
+ if not base:
769
+ return None
770
+ return f"{base}/calibration/{self.experiments_prefix}/{agent}/{task}"
771
+
772
+ def get_tables_uri(self, table: str = "resources") -> str | None:
773
+ """Get the S3 URI for a table directory."""
774
+ base = self.get_base_uri()
775
+ if not base:
776
+ return None
777
+ return f"{base}/tables/{table}"
778
+
779
+
665
780
  class ChunkingSettings(BaseSettings):
666
781
  """
667
782
  Document chunking settings for semantic text splitting.
@@ -980,6 +1095,75 @@ class APISettings(BaseSettings):
980
1095
  )
981
1096
 
982
1097
 
1098
+ class ModelsSettings(BaseSettings):
1099
+ """
1100
+ Custom model registration settings for downstream applications.
1101
+
1102
+ Allows downstream apps to specify Python modules containing custom models
1103
+ that should be imported (and thus registered) before schema generation.
1104
+
1105
+ This enables `rem db schema generate` to discover models registered with
1106
+ `@rem.register_model` in downstream applications.
1107
+
1108
+ Environment variables:
1109
+ MODELS__IMPORT_MODULES - Semicolon-separated list of Python modules to import
1110
+ Example: "models;myapp.entities;myapp.custom_models"
1111
+
1112
+ Example:
1113
+ # In downstream app's .env
1114
+ MODELS__IMPORT_MODULES=models
1115
+
1116
+ # In downstream app's models/__init__.py
1117
+ import rem
1118
+ from rem.models.core import CoreModel
1119
+
1120
+ @rem.register_model
1121
+ class MyCustomEntity(CoreModel):
1122
+ name: str
1123
+
1124
+ # Then run schema generation
1125
+ rem db schema generate # Includes MyCustomEntity
1126
+ """
1127
+
1128
+ model_config = SettingsConfigDict(
1129
+ env_prefix="MODELS__",
1130
+ extra="ignore",
1131
+ )
1132
+
1133
+ import_modules: str = Field(
1134
+ default="",
1135
+ description=(
1136
+ "Semicolon-separated list of Python modules to import for model registration. "
1137
+ "These modules are imported before schema generation to ensure custom models "
1138
+ "decorated with @rem.register_model are discovered. "
1139
+ "Example: 'models;myapp.entities'"
1140
+ ),
1141
+ )
1142
+
1143
+ @property
1144
+ def module_list(self) -> list[str]:
1145
+ """
1146
+ Get modules as a list, filtering empty strings.
1147
+
1148
+ Auto-detects ./models folder if it exists and is importable.
1149
+ """
1150
+ modules = []
1151
+ if self.import_modules:
1152
+ modules = [m.strip() for m in self.import_modules.split(";") if m.strip()]
1153
+
1154
+ # Auto-detect ./models if it exists and is a Python package (convention over configuration)
1155
+ from pathlib import Path
1156
+
1157
+ models_path = Path("./models")
1158
+ if models_path.exists() and models_path.is_dir():
1159
+ # Check if it's a Python package (has __init__.py)
1160
+ if (models_path / "__init__.py").exists():
1161
+ if "models" not in modules:
1162
+ modules.insert(0, "models")
1163
+
1164
+ return modules
1165
+
1166
+
983
1167
  class SchemaSettings(BaseSettings):
984
1168
  """
985
1169
  Schema search path settings for agent and evaluator schemas.
@@ -1163,6 +1347,110 @@ class GitSettings(BaseSettings):
1163
1347
  )
1164
1348
 
1165
1349
 
1350
+ class DBListenerSettings(BaseSettings):
1351
+ """
1352
+ PostgreSQL LISTEN/NOTIFY database listener settings.
1353
+
1354
+ The DB Listener is a lightweight worker that subscribes to PostgreSQL
1355
+ NOTIFY events and dispatches them to external systems (SQS, REST, custom).
1356
+
1357
+ Architecture:
1358
+ - Single-replica deployment (to avoid duplicate processing)
1359
+ - Dedicated connection for LISTEN (not from connection pool)
1360
+ - Automatic reconnection with exponential backoff
1361
+ - Graceful shutdown on SIGTERM
1362
+
1363
+ Use Cases:
1364
+ - Sync data changes to external systems (Phoenix, webhooks)
1365
+ - Trigger async jobs without polling
1366
+ - Event-driven architectures with PostgreSQL as event source
1367
+
1368
+ Example PostgreSQL trigger:
1369
+ CREATE OR REPLACE FUNCTION notify_feedback_insert()
1370
+ RETURNS TRIGGER AS $$
1371
+ BEGIN
1372
+ PERFORM pg_notify('feedback_sync', json_build_object(
1373
+ 'id', NEW.id,
1374
+ 'table', 'feedbacks',
1375
+ 'action', 'insert'
1376
+ )::text);
1377
+ RETURN NEW;
1378
+ END;
1379
+ $$ LANGUAGE plpgsql;
1380
+
1381
+ Environment variables:
1382
+ DB_LISTENER__ENABLED - Enable the listener worker (default: false)
1383
+ DB_LISTENER__CHANNELS - Comma-separated PostgreSQL channels to listen on
1384
+ DB_LISTENER__HANDLER_TYPE - Handler type: 'sqs', 'rest', or 'custom'
1385
+ DB_LISTENER__SQS_QUEUE_URL - SQS queue URL (for handler_type=sqs)
1386
+ DB_LISTENER__REST_ENDPOINT - REST endpoint URL (for handler_type=rest)
1387
+ DB_LISTENER__RECONNECT_DELAY - Initial reconnect delay in seconds
1388
+ DB_LISTENER__MAX_RECONNECT_DELAY - Maximum reconnect delay in seconds
1389
+
1390
+ References:
1391
+ - PostgreSQL NOTIFY: https://www.postgresql.org/docs/current/sql-notify.html
1392
+ - Brandur's Notifier: https://brandur.org/notifier
1393
+ """
1394
+
1395
+ model_config = SettingsConfigDict(
1396
+ env_prefix="DB_LISTENER__",
1397
+ env_file=".env",
1398
+ env_file_encoding="utf-8",
1399
+ extra="ignore",
1400
+ )
1401
+
1402
+ enabled: bool = Field(
1403
+ default=False,
1404
+ description="Enable the DB Listener worker (disabled by default)",
1405
+ )
1406
+
1407
+ channels: str = Field(
1408
+ default="",
1409
+ description=(
1410
+ "Comma-separated list of PostgreSQL channels to LISTEN on. "
1411
+ "Example: 'feedback_sync,entity_update,user_events'"
1412
+ ),
1413
+ )
1414
+
1415
+ handler_type: str = Field(
1416
+ default="rest",
1417
+ description=(
1418
+ "Handler type for dispatching notifications. Options: "
1419
+ "'sqs' (publish to SQS), 'rest' (POST to endpoint), 'custom' (Python handlers)"
1420
+ ),
1421
+ )
1422
+
1423
+ sqs_queue_url: str = Field(
1424
+ default="",
1425
+ description="SQS queue URL for handler_type='sqs'",
1426
+ )
1427
+
1428
+ rest_endpoint: str = Field(
1429
+ default="http://localhost:8000/api/v1/internal/events",
1430
+ description=(
1431
+ "REST endpoint URL for handler_type='rest'. "
1432
+ "Receives POST with {channel, payload, source} JSON body."
1433
+ ),
1434
+ )
1435
+
1436
+ reconnect_delay: float = Field(
1437
+ default=1.0,
1438
+ description="Initial delay (seconds) between reconnection attempts",
1439
+ )
1440
+
1441
+ max_reconnect_delay: float = Field(
1442
+ default=60.0,
1443
+ description="Maximum delay (seconds) between reconnection attempts (exponential backoff cap)",
1444
+ )
1445
+
1446
+ @property
1447
+ def channel_list(self) -> list[str]:
1448
+ """Get channels as a list, filtering empty strings."""
1449
+ if not self.channels:
1450
+ return []
1451
+ return [c.strip() for c in self.channels.split(",") if c.strip()]
1452
+
1453
+
1166
1454
  class TestSettings(BaseSettings):
1167
1455
  """
1168
1456
  Test environment settings.
@@ -1232,6 +1520,11 @@ class Settings(BaseSettings):
1232
1520
  extra="ignore",
1233
1521
  )
1234
1522
 
1523
+ app_name: str = Field(
1524
+ default="REM",
1525
+ description="Application/API name used in docs, titles, and user-facing text",
1526
+ )
1527
+
1235
1528
  team: str = Field(
1236
1529
  default="rem",
1237
1530
  description="Team or project name for observability",
@@ -1252,16 +1545,12 @@ class Settings(BaseSettings):
1252
1545
  description="Root path for reverse proxy (e.g., /rem for ALB routing)",
1253
1546
  )
1254
1547
 
1255
- sql_dir: str = Field(
1256
- default="src/rem/sql",
1257
- description="Directory for SQL files and migrations",
1258
- )
1259
-
1260
1548
  # Nested settings groups
1261
1549
  api: APISettings = Field(default_factory=APISettings)
1262
1550
  chat: ChatSettings = Field(default_factory=ChatSettings)
1263
1551
  llm: LLMSettings = Field(default_factory=LLMSettings)
1264
1552
  mcp: MCPSettings = Field(default_factory=MCPSettings)
1553
+ models: ModelsSettings = Field(default_factory=ModelsSettings)
1265
1554
  otel: OTELSettings = Field(default_factory=OTELSettings)
1266
1555
  phoenix: PhoenixSettings = Field(default_factory=PhoenixSettings)
1267
1556
  auth: AuthSettings = Field(default_factory=AuthSettings)
@@ -1269,18 +1558,30 @@ class Settings(BaseSettings):
1269
1558
  migration: MigrationSettings = Field(default_factory=MigrationSettings)
1270
1559
  storage: StorageSettings = Field(default_factory=StorageSettings)
1271
1560
  s3: S3Settings = Field(default_factory=S3Settings)
1561
+ data_lake: DataLakeSettings = Field(default_factory=DataLakeSettings)
1272
1562
  git: GitSettings = Field(default_factory=GitSettings)
1273
1563
  sqs: SQSSettings = Field(default_factory=SQSSettings)
1564
+ db_listener: DBListenerSettings = Field(default_factory=DBListenerSettings)
1274
1565
  chunking: ChunkingSettings = Field(default_factory=ChunkingSettings)
1275
1566
  content: ContentSettings = Field(default_factory=ContentSettings)
1276
1567
  schema_search: SchemaSettings = Field(default_factory=SchemaSettings)
1277
1568
  test: TestSettings = Field(default_factory=TestSettings)
1278
1569
 
1279
1570
 
1571
+ # Auto-load .env file from current directory if it exists
1572
+ # This happens BEFORE config file loading, so .env takes precedence
1573
+ from pathlib import Path
1574
+ from dotenv import load_dotenv
1575
+
1576
+ _dotenv_path = Path(".env")
1577
+ if _dotenv_path.exists():
1578
+ load_dotenv(_dotenv_path, override=False) # Don't override existing env vars
1579
+ logger.debug(f"Loaded environment from {_dotenv_path.resolve()}")
1580
+
1280
1581
  # Load configuration from ~/.rem/config.yaml before initializing settings
1281
1582
  # This allows user configuration to be merged with environment variables
1282
- # Set REM_SKIP_CONFIG_FILE=true to disable (useful for development with .env)
1283
- if not os.getenv("REM_SKIP_CONFIG_FILE", "").lower() in ("true", "1", "yes"):
1583
+ # Set REM_SKIP_CONFIG=1 to disable (useful for development with .env)
1584
+ if not os.getenv("REM_SKIP_CONFIG", "").lower() in ("true", "1", "yes"):
1284
1585
  try:
1285
1586
  from rem.config import load_config, merge_config_to_env
1286
1587
 
@@ -1,9 +1,9 @@
1
1
  -- Background index creation
2
2
  -- Run AFTER initial data load to avoid blocking writes
3
3
 
4
- -- HNSW vector index for embeddings_users
5
- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_users_vector_hnsw
6
- ON embeddings_users
4
+ -- HNSW vector index for embeddings_files
5
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_files_vector_hnsw
6
+ ON embeddings_files
7
7
  USING hnsw (embedding vector_cosine_ops);
8
8
 
9
9
  -- HNSW vector index for embeddings_image_resources
@@ -11,24 +11,14 @@ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_image_resources_vector_hn
11
11
  ON embeddings_image_resources
12
12
  USING hnsw (embedding vector_cosine_ops);
13
13
 
14
- -- HNSW vector index for embeddings_moments
15
- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_moments_vector_hnsw
16
- ON embeddings_moments
17
- USING hnsw (embedding vector_cosine_ops);
18
-
19
- -- HNSW vector index for embeddings_resources
20
- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_resources_vector_hnsw
21
- ON embeddings_resources
22
- USING hnsw (embedding vector_cosine_ops);
23
-
24
14
  -- HNSW vector index for embeddings_messages
25
15
  CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_messages_vector_hnsw
26
16
  ON embeddings_messages
27
17
  USING hnsw (embedding vector_cosine_ops);
28
18
 
29
- -- HNSW vector index for embeddings_files
30
- CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_files_vector_hnsw
31
- ON embeddings_files
19
+ -- HNSW vector index for embeddings_moments
20
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_moments_vector_hnsw
21
+ ON embeddings_moments
32
22
  USING hnsw (embedding vector_cosine_ops);
33
23
 
34
24
  -- HNSW vector index for embeddings_ontology_configs
@@ -36,7 +26,22 @@ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_ontology_configs_vector_h
36
26
  ON embeddings_ontology_configs
37
27
  USING hnsw (embedding vector_cosine_ops);
38
28
 
29
+ -- HNSW vector index for embeddings_resources
30
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_resources_vector_hnsw
31
+ ON embeddings_resources
32
+ USING hnsw (embedding vector_cosine_ops);
33
+
39
34
  -- HNSW vector index for embeddings_schemas
40
35
  CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_schemas_vector_hnsw
41
36
  ON embeddings_schemas
42
37
  USING hnsw (embedding vector_cosine_ops);
38
+
39
+ -- HNSW vector index for embeddings_sessions
40
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_sessions_vector_hnsw
41
+ ON embeddings_sessions
42
+ USING hnsw (embedding vector_cosine_ops);
43
+
44
+ -- HNSW vector index for embeddings_users
45
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_embeddings_users_vector_hnsw
46
+ ON embeddings_users
47
+ USING hnsw (embedding vector_cosine_ops);