Skip to content

Drop build-time tenant baking from the Pro daemon plist (ADR-053 per-database cloud sync, S2 core) - #1605

Merged
mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:ns/adr053-s2-drop-buildtime-tenant
Jul 10, 2026
Merged

mstomar125 merged 1 commit into
NodeSpaceAI:mainfrom
mstomar125:ns/adr053-s2-drop-buildtime-tenant

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

S2 (core half) of ADR-053 per-database cloud sync (#1535): stop baking the tenant (schema + collection) into the Pro daemon's launchd plist at build time. Only the deployment-wide Supabase endpoint — project URL + publishable anon key — stays build-time; the tenant a database syncs to is bound per database at runtime and is no longer an install-time constant.

  • Removed the PRO_SCHEMA / PRO_COLLECTION option_env! constants (NODESPACE_PRO_SCHEMA / NODESPACE_PRO_COLLECTION build-time env).
  • Removed the NODESPACED_PRO_SCHEMA / NODESPACED_PRO_COLLECTION keys from the Pro EnvironmentVariables block the app writes into ~/Library/LaunchAgents. NODESPACED_PRO_SUPABASE_URL + NODESPACED_PRO_ANON_KEY remain (deployment-wide, not tenant-specific).

The tenant model for this epic is a Postgres schema in one shared Supabase project, so the URL + anon key are legitimately deployment-wide and correct to keep build-time; only schema/collection are per-tenant. With this change a Pro install no longer carries a single baked tenant — the daemon takes its tenant from its runtime configuration (the per-database bound tenant added in S1, wired into the daemon's session path in a later slice).

Community safety

Fully inert for the community build: these env keys were only ever emitted when is_pro_build() (i.e. a Pro build with NODESPACE_PRO_SUPABASE_URL baked in). The community nodespaced daemon never received them. No behavior change to the community edition.

Tests

  • cargo fmt -p nodespace-app -- --check clean; cargo clippy -p nodespace-app --all-targets -- -D warnings clean; cargo test -p nodespace-app green (no test asserts on the plist tenant keys — the plist writer has no snapshot coverage, and no other code referenced PRO_SCHEMA / PRO_COLLECTION).
  • Change is isolated to the Pro plist generation in daemon_setup.rs — no core-lib, frontend, or e2e surface touched.

The matching sync-repo change (remove the .pkg plist template placeholders + the build-pro-pkg.sh / build-pro-dmg.sh tenant substitutions) lands as a follow-up PR in nodespace-sync and must merge after this one, so a Pro build never emits an empty schema.

Part of #1535 (S2 of the S1–S8 decomposition on the issue).

The Pro edition previously baked the tenant (schema + collection) into the
launchd plist at build time via the NODESPACE_PRO_SCHEMA / NODESPACE_PRO_COLLECTION
option_env constants. The tenant a database syncs to is now bound per database at
runtime (ADR-053 per-database cloud sync), so only the deployment-wide Supabase
endpoint — project URL + publishable anon key — stays build-time.

Remove the PRO_SCHEMA / PRO_COLLECTION constants and the NODESPACED_PRO_SCHEMA /
NODESPACED_PRO_COLLECTION keys from the Pro EnvironmentVariables block the app
writes into the launchd plist. Inert for the community build, which never received
these keys.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE — the diff is correct and community-inert. Two deploy-order flags on the epic (the code is fine; these are about when things can ship together).

Verified

  • Community-safe: the removed NODESPACED_PRO_SCHEMA / NODESPACED_PRO_COLLECTION plist keys (and their PRO_SCHEMA/PRO_COLLECTION option_env! constants + substitutions) live entirely inside the let pro_env = if is_pro_build() { … } block. Community builds (is_pro_build() == false) never emitted them, so removal is a true no-op for the community edition. ✅
  • Correct split: the deployment-wide endpoint (NODESPACED_PRO_SUPABASE_URL + NODESPACED_PRO_ANON_KEY) legitimately stays build-time; only the per-tenant schema/collection moves to runtime. The updated comment states the ADR-053 rationale accurately. +7/−10, one file, CI green (test:all + test:e2e).

⚠️ Flag 1 — cross-repo lock-step (paired sync S2 not open yet)

The PR states the matching nodespace-sync change (remove the .pkg plist template placeholders + the build-pro-pkg.sh / build-pro-dmg.sh tenant substitutions) is a separate PR that must merge after this one. I checked: that sync PR is not open yet (branch feature/adr053-s2-drop-buildtime-tenant exists locally). The stated order (core first, then sync) is right — it ensures no path ever substitutes an empty schema string. Tracking: S2 isn't complete until that sync PR lands; until then the .pkg build path still bakes a tenant while the app-written plist no longer does.

⚠️ Flag 2 — half-wired window (the one to watch)

This PR removes the build-time tenant, but its own text says the daemon "takes its tenant from its runtime configuration (the per-database bound tenant added in S1, wired into the daemon's session path in a later slice)." So the sequence is: S1 stores bound_tenant (inert) → S2 removes the build-time tenant → a later slice wires the daemon's sync session to read bound_tenant. Between S2 and that wiring slice, a Pro daemon has no tenant source at all — build-time removed, runtime not yet consumed.

Consequence: a Pro .pkg/DMG built from a main commit in that window would ship a daemon that can't resolve which tenant to sync to. Since release CI is disabled and Pro builds are cut manually, this is a transient main-branch state, not an automatic shipping risk — but no Pro build should be cut until the runtime-wiring slice lands, else that build's sync is dead. Worth stating explicitly on the epic so it isn't missed when someone next builds a Pro installer.

Reminder — still inside the user-gated #1535

S2 is the first slice that actually changes the Pro tenant mechanism (build-time → runtime). It doesn't yet touch keychain / per-DB OAuth / billing, but it's on the path there. Per the batch plan's carve-out, keep the user + Anoop in the loop before the cross-repo behavioral wiring (and the sync-side tenant/keychain slices) ship.

Net: approve the core change; land the paired sync S2 after it; hold Pro installer builds until the runtime-tenant-wiring slice closes the S2→wiring gap.

@mstomar125
mstomar125 merged commit c51ab32 into NodeSpaceAI:main Jul 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant