Skip to content

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

Merged
gbirman merged 2 commits into
mainfrom
gbirman/macro-3474-calendar-service-local-stack
Sep 22, 2026
Merged

gbirman merged 2 commits into
mainfrom
gbirman/macro-3474-calendar-service-local-stack

Conversation

@gbirman

@gbirman gbirman commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Runs calendar_service in the local stack on port 8088 and makes it the local owner of calendar, mirroring where dev/prod are heading. calendar_service was already built and deployed dormant; locally it was absent, and the web app reached calendar through email_service. This wires it into the stack the same way its siblings are and hands calendar over to it.

What changed

  • Service inventory (xtask_local): a calendar_service entry (compose calendar_service, bin/package calendar_service, host port 8088, proxy prefix /calendar). The generated Caddyfile now fans /calendar to calendar_service:8080, and its binary joins the local runtime image. New Port::Calendar = 8088, appended so per-instance port offsets stay stable.
  • Compose (docker/docker-compose.yml): a calendar_service service (8088→8080, calendar-service network alias, /health check) and a per-service CALENDAR_SYNC_ENABLED=false override on email_service.
  • Nix: calendar-service added to localStackDeployServiceNames (its binary definition already existed).
  • Local env (xtask_local): OVERRIDE_CALENDAR_SERVICE_URL=http://calendar-service:8080 so in-network callers (the agent calendar tools) reach it by container alias instead of the host-port default. CALENDAR_SYNC_ENABLED=true is already set globally, so calendar_service inherits it.
  • Backfill queue: calendar-service-backfill-queue is provisioned in LocalStack and bound through the queue's own override var in URL form, so the always-on backfill workers dial a full queue URL rather than a bare name.
  • Web (servers.ts): the calendar-service host flips from the email-service stopgap to calendar_servicehttp://localhost:8088/calendar direct, ${proxyOrigin}/calendar through the single-origin proxy.

The local-cutover decision

Both calendar_service and email_service read one CALENDAR_SYNC_ENABLED flag that gates both their calendar sync workers and their /calendar mutation routes. Two services syncing the one shared local MacroDB would double-write, so exactly one may own it. This turns calendar_service on and email_service off, so local reflects the post-cutover world: calendar_service runs the sync scheduler + backfill and serves the mutation routes, email_service serves neither.

calendar_service runs local-only (not under run_dev): its backfill SQS workers spawn unconditionally, so a local instance pointed at shared-dev resources would race the deployed calendar-service for its backfill queue — the same reason scheduled_action is local-only.

Relationship to #6752

Builds directly on #6752 (which moved the web calendar client onto a calendar-service host and, as a stopgap, pointed it back at email_service's /calendar routes). This flips those stopgap values to their final targets now that the service is in the stack. It has to merge after #6752: the frontend_wires_every_inventory_prefix drift test requires the /calendar inventory prefix to have a matching ${proxyOrigin}/calendar entry in proxyServers(), which #6752 introduces.

Config

No Doppler changes. Everything calendar_service requires (MACRO_DB_URL, REDIS_URI, KAFKA_BROKERS, AUTHENTICATION_SERVICE_SECRET_KEY, INTERNAL_API_KEY, and the macro_auth JWT vars) already comes from the code-owned local env and boot stubs, which apply in both Doppler and --no-doppler modes. The email flag is a repo-side compose override, so no lcl value matters.

Left out

The dev/prod cutover (flipping the deployed flags and eventually retiring email_service's calendar routes) is separate infra/Doppler work and is not part of this local-stack change.


Note

Medium Risk
Changes which service owns calendar sync and API routes locally; misconfiguration could break local calendar or double-write MacroDB, but scope is dev/docker/xtask only—not deployed prod cutover.

Overview
Adds calendar_service to the local stack as the sole owner of calendar: compose on 8088, xtask inventory/Caddy /calendar routing, Nix binary packaging, LocalStack backfill queue binding, and OVERRIDE_CALENDAR_SERVICE_URL for in-container callers.

Local cutover: sets CALENDAR_SYNC_ENABLED=false on email_service and email_pubsub_workers so only calendar_service syncs the shared MacroDB (email stops serving /calendar mutations locally). calendar_service is registered as local-only in inventory (same pattern as scheduled_action) to avoid backfill queue races against shared-dev.

Web: servers.ts stops routing calendar through email (8087 / /email/calendar) and points calendar-service at 8088/calendar and ${proxyOrigin}/calendar.

Reviewed by Cursor Bugbot for commit 481ac2b. Bugbot is set up for automated code reviews on this repo. Configure here.

…owner

Add calendar_service to the local stack on port 8088 and make it the local
owner of calendar. It joins the service inventory as a Local-only service
(its backfill SQS workers spawn unconditionally, so running it under run_dev
would race the deployed calendar-service for its backfill queue), which gives
it a generated /calendar Caddy route and includes its binary in the local
runtime image. LocalStack provisions its backfill queue, and an in-network
OVERRIDE_CALENDAR_SERVICE_URL lets service-to-service callers (the agent
calendar tools) reach it by container alias.

The email service's calendar sync is disabled locally (a per-service compose
override) so only one service syncs the shared MacroDB; with sync off it also
stops mounting its /calendar mutation routes. The web client's calendar-service
host is flipped to calendar_service (localhost:8088/calendar directly, the
proxy's /calendar route otherwise).
@macro-application

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: macro-inc/macro/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 8ef4da03-4d71-4f8f-b835-5a05954285c0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: macro-inc/macro/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 186d8f78-13c7-4f2a-8071-37a1c996dc93

📥 Commits

Reviewing files that changed from the base of the PR and between c86febf and bc2e689.

📒 Files selected for processing (8)
  • apps/web/src/lib/core/constant/servers.ts
  • docker/docker-compose.yml
  • nix/cloud-storage.nix
  • tooling/xtask/crates/xtask_local/src/local/instance.rs
  • tooling/xtask/crates/xtask_local/src/local/inventory.rs
  • tooling/xtask/crates/xtask_local/src/local/inventory/test.rs
  • tooling/xtask/crates/xtask_local/src/local/local_env.rs
  • tooling/xtask/crates/xtask_local/src/local/resources.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 1 remains after this review.


📝 Summary

Summary by CodeRabbit

  • New Features

    • Added a dedicated local calendar service on port 8088.
    • Calendar functionality is now available through the /calendar route.
    • Added local calendar backfill queue support and service health monitoring.
  • Bug Fixes

    • Corrected local calendar routing so requests reach the calendar service directly.
    • Updated service connectivity to use the dedicated calendar endpoint.
  • Configuration

    • Disabled calendar synchronization in the email service to prevent competing calendar updates.

Walkthrough

The local stack now uses a dedicated calendar_service on port 8088. Email service calendar synchronization is disabled. Local tooling registers the service, its binary, network URL, port, proxy route, and backfill queue. Docker Compose starts the service with its required dependencies and healthcheck. Web calendar URLs now target the dedicated service directly or through /calendar.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to bc2e6

No actionable merge-blocking risk remains; the new calendar service preserves the intended access controls.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses conventional commits format and accurately describes the change, but it is 74 characters long and exceeds the 72-character limit. Shorten the title to 72 characters or fewer while preserving the conventional commits prefix and the calendar_service local-stack ownership change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the local calendar_service integration, service ownership change, configuration updates, and scope exclusions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bc2e689. Configure here.

Comment thread docker/docker-compose.yml
@github-actions

github-actions Bot commented Sep 21, 2026

Copy link
Copy Markdown

The calendar sync scheduler and outbox drain run in the pubsub_workers
binary (email_service::calendar_outbox::run), not the email HTTP service,
so the CALENDAR_SYNC_ENABLED=false override has to be on email_pubsub_workers
as well — otherwise that worker keeps syncing calendar and double-writes the
shared local MacroDB alongside calendar_service.
@gbirman
gbirman merged commit 47fa117 into main Sep 22, 2026
30 checks passed
@gbirman
gbirman deleted the gbirman/macro-3474-calendar-service-local-stack branch September 22, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant