Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(local): run calendar_service in the local stack as the calendar owner (#6755)

gbirman47fa1175be54
diff --git a/apps/web/src/lib/core/constant/servers.ts b/apps/web/src/lib/core/constant/servers.ts
index 4e2ac89415..e84df82377 100644
--- a/apps/web/src/lib/core/constant/servers.ts
+++ b/apps/web/src/lib/core/constant/servers.ts
@@ -11,11 +11,10 @@ const serverHostLocal: Servers = {
'unfurl-service': 'http://localhost:8095',
contacts: 'http://localhost:8083',
'email-service': 'http://localhost:8087',
- // No gateway locally — requests go straight to a service port. email-service
- // still serves /calendar/* on 8087; switch to calendar_service (8088) once it
- // joins the local stack. The client drops the /calendar segment, so it is
- // carried here.
- 'calendar-service': 'http://localhost:8087/calendar',
+ // calendar_service owns calendar locally on 8088. No gateway locally, so the
+ // client hits the service port directly; it drops the /calendar segment, so
+ // that prefix is carried here.
+ 'calendar-service': 'http://localhost:8088/calendar',
'image-proxy-service': 'http://localhost:8097',
'scheduled-action': 'http://localhost:8099',
'agent-harness': 'http://localhost:8101',
@@ -110,11 +109,10 @@ function proxyServers(): Servers | undefined {
'agent-harness': `${proxyOrigin}/agent-harness`,
contacts: `${proxyOrigin}/contacts`,
'email-service': `${proxyOrigin}/email`,
- // The proxy has no /calendar route yet (calendar_service is not in the local
- // inventory), so reach email-service's /calendar/* through its /email prefix,
- // which the proxy strips. Point at ${proxyOrigin}/calendar once calendar_service
- // joins the stack.
- 'calendar-service': `${proxyOrigin}/email/calendar`,
+ // calendar_service is in the local inventory, so the proxy has a /calendar
+ // route to it (Caddy strips the prefix); the client drops /calendar and
+ // re-appends it via this host.
+ 'calendar-service': `${proxyOrigin}/calendar`,
'image-proxy-service': `${proxyOrigin}/image-proxy`,
'scheduled-action': `${proxyOrigin}/scheduled-action`,
};
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 983fa07447..754ce0793c 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -200,6 +200,14 @@ services:
command: ["/app/out/email_service"]
ports:
- "8087:8080"
+ environment:
+ # Local calendar cutover: calendar_service owns calendar locally. With sync
+ # off the email HTTP service stops mounting its /calendar mutation routes
+ # (see email_service api.rs), so the web client reaches calendar_service
+ # instead. The actual sync workers run in email_pubsub_workers, which is
+ # disabled separately below. Overrides the generated env file's global
+ # CALENDAR_SYNC_ENABLED=true for this service only.
+ CALENDAR_SYNC_ENABLED: "false"
depends_on:
- authentication-service
- document_storage_service
@@ -227,6 +235,12 @@ services:
email_pubsub_workers:
<<: [*common-env, *rust-services-image]
command: ["/app/out/pubsub_workers"]
+ environment:
+ # Local calendar cutover: the calendar sync scheduler + outbox drain run
+ # in this worker (email_service::calendar_outbox::run), so this is where
+ # email's calendar sync is actually turned off. calendar_service is the
+ # sole syncer of the shared local MacroDB.
+ CALENDAR_SYNC_ENABLED: "false"
depends_on:
- postgres
- redis
@@ -239,6 +253,35 @@ services:
- databases
- services
+ # ============================================================================
+ # calendar_service (Port 8088)
+ # Google Calendar sync + calendar API. Local owner of /calendar: email's
+ # calendar sync is disabled locally (CALENDAR_SYNC_ENABLED=false on both
+ # email_service and email_pubsub_workers above) so only one service syncs the
+ # shared MacroDB.
+ # ============================================================================
+ calendar_service:
+ <<: [*common-env, *rust-services-image]
+ command: ["/app/out/calendar_service"]
+ ports:
+ - "8088:8080"
+ depends_on:
+ - postgres
+ - redis
+ - authentication-service
+ - connection_gateway
+ networks:
+ databases:
+ services:
+ aliases:
+ - calendar-service
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ start_period: 10s
+
# ============================================================================
# notification_service (Port 8089)
# User notifications - NotificationDB
diff --git a/nix/cloud-storage.nix b/nix/cloud-storage.nix
index e5fc62a5c1..2977ea8d4d 100644
--- a/nix/cloud-storage.nix
+++ b/nix/cloud-storage.nix
@@ -523,6 +523,7 @@
localStackDeployServiceNames = [
"agent-harness-service"
"agent-schedule-service"
+ "calendar-service"
"connection-gateway"
"contacts-service"
"document-cognition-service"
diff --git a/tooling/xtask/crates/xtask_local/src/local/instance.rs b/tooling/xtask/crates/xtask_local/src/local/instance.rs
index 50a21eeddf..1f04da0b8a 100644
--- a/tooling/xtask/crates/xtask_local/src/local/instance.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/instance.rs
@@ -110,6 +110,10 @@ pub enum Port {
AgentHarnessEgress = 8102,
/// Scheduled actions API and dispatcher (default compose port 8099).
ScheduledAction = 8099,
+ /// Calendar service API (default compose port 8088). Appended at the end so
+ /// existing per-instance port offsets, which come from declaration order,
+ /// stay stable.
+ Calendar = 8088,
}
impl Port {
diff --git a/tooling/xtask/crates/xtask_local/src/local/inventory.rs b/tooling/xtask/crates/xtask_local/src/local/inventory.rs
index 082e67df92..c5f074d95b 100644
--- a/tooling/xtask/crates/xtask_local/src/local/inventory.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/inventory.rs
@@ -199,6 +199,21 @@ pub const RUST_SERVICES: &[RustService] = &[
opt_in: false,
no_default_features: false,
},
+ RustService {
+ compose_name: "calendar_service",
+ cargo_bin: "calendar_service",
+ package: "calendar_service",
+ host_port: Some(Port::Calendar),
+ path_prefix: Some("/calendar"),
+ is_websocket: false,
+ // Local-only: the backfill SQS workers spawn unconditionally (not gated
+ // on CALENDAR_SYNC_ENABLED), so running the binary under `run-dev`
+ // against shared-dev resources would race the deployed calendar-service
+ // for its backfill queue — the same reason scheduled_action is local-only.
+ modes: &[Mode::Local],
+ opt_in: false,
+ no_default_features: false,
+ },
RustService {
compose_name: "notification_service",
cargo_bin: "notification_service",
diff --git a/tooling/xtask/crates/xtask_local/src/local/inventory/test.rs b/tooling/xtask/crates/xtask_local/src/local/inventory/test.rs
index 874e18db99..04679717e1 100644
--- a/tooling/xtask/crates/xtask_local/src/local/inventory/test.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/inventory/test.rs
@@ -3,10 +3,10 @@ use super::*;
#[test]
fn local_binaries_are_unique_and_complete() {
let bins = local_binaries();
- // 17 distinct binaries (the bundled set, including scheduled_action, the local-only
- // search_processing_service, agent harness, mcp_service, and the seed_cli
- // shipped for the gmail_forwarder sidecar).
- assert_eq!(bins.len(), 17, "{bins:?}");
+ // 18 distinct binaries (the bundled set, including scheduled_action,
+ // calendar_service, the local-only search_processing_service, agent harness,
+ // mcp_service, and the seed_cli shipped for the gmail_forwarder sidecar).
+ assert_eq!(bins.len(), 18, "{bins:?}");
assert!(bins.contains(&"pubsub_workers"));
assert!(bins.contains(&"seed_cli"));
assert!(bins.contains(&"document_upload_finalizer_local_worker"));
diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env.rs b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
index 706e25d714..48af6bb842 100644
--- a/tooling/xtask/crates/xtask_local/src/local/local_env.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
@@ -216,6 +216,14 @@ impl InfraEnv {
"OVERRIDE_EMAIL_SERVICE_URL".into(),
"http://email-service:8080".into(),
);
+ // Same host-vs-container split for calendar: `CalendarServiceUrl`'s
+ // Local default is http://localhost:8088, which inside a container is
+ // the caller itself. In-network callers (the agent calendar tools point
+ // at calendar_service) reach it through this override instead.
+ env.insert(
+ "OVERRIDE_CALENDAR_SERVICE_URL".into(),
+ "http://calendar-service:8080".into(),
+ );
env.insert(
"OVERRIDE_AUTH_SERVICE_URL".into(),
"http://authentication-service:8080".into(),
diff --git a/tooling/xtask/crates/xtask_local/src/local/resources.rs b/tooling/xtask/crates/xtask_local/src/local/resources.rs
index 67a3174aed..6fa39290c3 100644
--- a/tooling/xtask/crates/xtask_local/src/local/resources.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/resources.rs
@@ -225,6 +225,17 @@ pub const QUEUES: &[Queue] = &[
Url,
)],
},
+ Queue {
+ // calendar_service's backfill queue, consumed by its always-on backfill
+ // workers (which tight-loop on receive errors if the queue is absent).
+ // Bound through the queue's own override var in URL form so the service
+ // dials the full LocalStack URL rather than the bare name.
+ name: macro_queues::CalendarServiceBackfillQueue::LOCAL,
+ bindings: &[(
+ macro_queues::CalendarServiceBackfillQueue::OVERRIDE_ENV_VAR_NAME,
+ Url,
+ )],
+ },
];
/// Every local S3 bucket and the env var that references it.