Repository navigation
Closed
Labels
Description
Overview
Sync layer of ADR-053 §4–6 (../nodespace-docs/decisions/053-one-daemon-multiple-databases.md): each database binds independently to a cloud tenant, identity and sign-in are per database, and the daemon runs at most ONE live sync session — the active database's. Implementation lands mostly in the private nodespace-sync repo (nodespaced-pro); this issue tracks the core-side surface and coordinates the whole slice.
Problem Statement
- The Pro tenant schema (
NODESPACED_PRO_SCHEMA/COLLECTION) is baked at build time into the service file environment (daemon_setup.rs) — one build is hard-bound to one tenant, incompatible with per-database tenants and already contradicting the documented runtime provisioning flow. - Sync/auth state is a single global session: one
CloudSyncServicetask, one keychain identity, one globalproSyncfrontend store fed by an unscopedsync:statusstream.
Proposed Solution
Tenant binding becomes runtime state recorded per database (DatabaseSettingsNode + registry mirror). The daemon holds one sync session with an activate/deactivate lifecycle. Billing follows tenant = database = billable unit.
Implementation Approach
Tenant binding (runtime, per database)
- Remove build-time
NODESPACED_PRO_SCHEMA/COLLECTIONinjection fromdaemon_setup.rs; deployment constants (Supabase URL, anon key) may stay build-time. - Record the bound tenant schema in each database's DatabaseSettingsNode with a registry mirror for pre-open display. Bind/unbind RPCs on the Pro surface.
- Enforce the ADR-053 invariant at bind time: a tenant schema binds to at most one local database per machine.
Single-active session lifecycle
- Activate (database becomes active): cursor-based catch-up (
sync_seq > cursor), then real-time sync. Reuses the existing reconnect/reconciliation flow — an idle synced database is indistinguishable from an offline device. - Deactivate (switch away): drain pending outbound pushes, then stop the session and Realtime channel.
- "Active" is daemon-level and persisted — the last-active database keeps syncing with the app window closed.
- Writes routed to a non-active database (e.g. CLI) do not push until that database activates; decide during implementation whether sustained CLI activity should count as activation.
Identity and sign-in (per database)
- Sign-in runs in the context of a database; different databases may use different provider accounts. Keychain entries per
(tenant_schema, user_id)— the existing key layout. auth_identitiesper tenant schema uses the canonical no-FK form (PRIMARY KEY (person_node_id), explicit cleanup). The same person maps to a distinct PersonNode per database.- Fresh machine / add-synced-database flow: OAuth first → worker lists accessible tenants → choosing one creates a local database, binds it, runs cursor-0 catch-up, re-embeds locally (embeddings never sync).
Frontend
- Split
proSyncstore: per-database sync/auth status keyed by database id; the sync pill renders the ACTIVE database's state (grey "local-only" for unbound databases).sync:statusevents carrydatabase_id.
Acceptance Criteria
- A synced and a local-only database coexist; switching between them starts/stops sync with catch-up on activation (integration test against a test tenant)
- Deactivation drains pending pushes before stopping (test: edit, switch away immediately, verify rows reach the tenant)
- Binding a second local database to an already-bound tenant is rejected
- Build-time tenant env injection is gone; a community build is unaffected
- Sign-in/sign-out operate per database; keychain holds independent entries per tenant
- Sync pill reflects the active database only; per-database status is correct after switches
- Add-synced-database-from-cloud flow works on a fresh profile (catch-up + local re-embed)
- Tests pass (bun run test:all)
- Code passes bun run quality:fix
Technical Specifications
Reference Files
- Env injection:
packages/desktop-app/src-tauri/src/daemon_setup.rs— Pro env block in plist/systemd writers - Pro commands/events:
packages/desktop-app/src-tauri/src/commands/pro_sync.rs,src/lib/stores/pro-sync.svelte.ts,src/lib/components/pro-sync-pill.svelte - Sync architecture:
../nodespace-docs/architecture/cloud-sync.md; ADR-036, ADR-045, ADR-051 - Sync engine: private nodespace-sync repo (
nodespaced-pro) — session, cursors, echo caches
Implementation Details
- Exactly-one-
owner/ last-admin invariants apply per database (per tenant schema). - Billing: one subscription ↔ one tenant ↔ one database; provisioning worker and billing enforcement count against the tenant.
- Copying database files between machines stays unsupported for synced databases — catch-up is the transport.
Dependencies
- Daemon database manager: registry, per-database services, and gRPC routing #1532
- CLI and desktop app: multiple databases with a live, restart-free switcher #1533 (switcher drives activation)
Related Issues
Non-Goals
Multiple concurrent sync sessions; per-database fairness beyond the single-active rule; billing UI.
Activity
mstomar125 commentedon Jul 7, 2026
Not picked up today — blocked by three open prerequisites: #1532, #1533, and #1398.
Needs #1532 (registry / active-database / per-database routing), #1533 (the live switcher whose drain-on-switch criteria this literally tests), and #1398 (the
DatabaseSettingsNodewhere tenant binding +auth_statuspersist). It also lands mostly in the privatenodespace-syncrepo (session lifecycle, cursor catch-up, per-database keychain/identity) and its acceptance requires a live Supabase test tenant. Multi-repo, multi-ticket, live-tenant = XL, gated.mstomar125 commentedon Jul 10, 2026
Scoping / approach
Mapped both repos (core + private nodespace-sync/nodespaced-pro). Today the Pro daemon is hard-wired to ONE tenant — a Postgres schema in one Supabase project, baked at build time and threaded as a single
ProConfig— and runs one always-on global sync session with no activate/deactivate. Billing, tenant provisioning, and tenant-uniqueness are enforced entirely server-side in the privatenodespace-cloudworker + Supabase; nothing in these two repos verifies entitlement (the daemon just carries a schema and forwards the user JWT). The keychain is already schema-scoped (a good per-database foundation), andDatabaseSettingsNodeis the designated home for a per-database bound tenant.Proposed decomposition:
DatabaseSettingsNode+ adatabases.tomlregistry mirror (core; additive; no live tenant). Safe to land first.NODESPACED_PRO_SCHEMA/COLLECTIONinjection; daemon reads the tenant at runtime from S1 (URL + anon key stay build-time under the current schema-in-one-project model).database_id+ resolved schema through Realtime/PostgREST/keychain/sync-state.ensure_identity_boundper (database→tenant); the OAuth worker must return the user's tenant (cross-repo, needs nodespace-cloud).sync:statuscarriesdatabase_id;proSyncbecomes per-database; the pill reflects the active database.Requires coordination beyond these two repos (flagging for Anoop): the subscription→tenant resolution endpoint, per-database OAuth brokering, authoritative tenant-uniqueness, and billing (S8 + the server half of S5) — these gate the fresh-machine add-synced-database flow. And one architecture decision gates the whole shape: whether a tenant is a schema in one shared Supabase project (current model — URL/anon stay build-time) or a separate project (URL/anon also go per-database).
Plan: land S1 (safe), build S2–S4/S6 against the test tenant, and prepare a written cloud-worker/Supabase spec for S5/S8 rather than fabricating a tenant-resolution locally.
mstomar125 commentedon Jul 10, 2026
S1 merged — per-database bound-tenant storage landed on
main(#1604, squash51301999).Additive, community-safe storage foundation for binding a database to a cloud tenant at runtime (the direction chosen for this epic: tenant = Postgres schema in one shared Supabase project;
url+anonstay build-time, onlyschema/collectiongo per-database):DatabaseSettingsNode(authoritative per-database record) gainsbound_tenant_schema+bound_tenant_collectionstring fields, withis_string/null validation in the behavior.DatabaseEntryindatabases.tomlmirrors the same two fields (#[serde(default)], so existing registries parse) so the bound tenant can be shown before the database is opened, plus aDatabaseManager::set_bound_tenant(id, schema, collection)setter (Noneclears on unbind).Inert by design — nothing reads these fields yet, so the community build is behaviorally unchanged. Reviewed + APPROVED (re-reviewed at the final head after test-strengthening).
Next: S2 — remove the build-time
NODESPACED_PRO_SCHEMA/NODESPACED_PRO_COLLECTIONinjection; the Pro daemon reads its bound tenant at runtime from this S1 storage instead of a baked-in build-time value (url+anonremain build-time).mstomar125 commentedon Jul 10, 2026
S2 (remove build-time tenant baking) — landing
The Pro tenant (schema + collection) is no longer baked at build time; only the deployment-wide Supabase endpoint (URL + publishable anon key) stays build-time. The tenant a database syncs to is bound per database at runtime.
c51ab321). The desktop app no longer writesNODESPACED_PRO_SCHEMA/NODESPACED_PRO_COLLECTIONinto the launchd plist; removed thePRO_SCHEMA/PRO_COLLECTIONoption_env!constants. Community-inert (the keys only ever emitted underis_pro_build())..pkgLaunchAgent template placeholders +build-pro-pkg.shsubstitutions +build-pro-dmg.shbuild-env for schema/collection..pkgis now a single Pro edition (BUILD_LABELdefaults topro). Shell/plist only — no Rust surface.Distribution decision (maintainer): the
.command/ per-tenant GHCR image path (build-tenant-image.yml→:<tenant>→Install-NodeSpace-<tenant>.command) is superseded by signed.pkgs and will be removed wholesale later — so it's intentionally left untouched now (itsPRO_SCHEMAenv is inert post-S2; it still builds, just tenant-agnostic).Build caveat until the runtime-wiring slice lands: with the tenant no longer baked and nothing yet writing/consuming the per-database bound tenant, a Pro daemon with no
NODESPACED_PRO_SCHEMAset falls back to its CLI defaulttenant_demo. Atenant_demobuild is fully coherent; do not cut a Pro build intended for a different tenant until the daemon reads the per-database bound tenant (that's the binding-writer + session-wiring slice). Builds are manual (release CI disabled), so this is a main-branch transient, not an automatic shipping risk.Next: the per-database binding writer + wiring the daemon's sync session to read
bound_tenant_schema/bound_tenant_collection(S1 storage) — the slice that closes this gap.mstomar125 commentedon Jul 10, 2026
S3 (runtime tenant binding) — done end-to-end
The Pro daemon now resolves its cloud-sync tenant from the per-database binding at runtime, not a build-time constant — closing the S2 caveat.
9c69dc22).NodeService::get_bound_tenant()/set_bound_tenant()on the DatabaseSettingsNode singleton (database-settingsnamespace, OCC write, sibling fields preserved). Additive; roundtrip unit test.get_bound_tenant(); an unbound database seeds the binding from the--schema/--collectionCLI/env config, then a persisted binding wins over the CLI on later runs. Resolved tenant threads throughProConfig(the single origin for keychain scope, Realtime/PostgREST profiles,member_offetch target, migration). Also bumps the core rev and adapts the hand-wired Pro daemon to the per-database computeEmbeddingSchedulerAPI.e2e (headless, no live Supabase) — PASS via new
scripts/tenant-binding-check.sh: boot 1 (unbound,--schema tenant_demo) seeds + resolvestenant_demo; boot 2 (same DB,--schema tenant_bogus) does not re-seed and still resolves the persistedtenant_demo— proving the binding wins over the CLI tenant.Boundary reached. S1 (storage) → S2 (remove baking) → S3 (runtime binding) are the additive, single-database-coherent, locally-testable mechanics — all done/landing. The remaining slices (S4 single-active-session lifecycle, per-DB identity/keychain, S6 per-DB status, S7 frontend) require turning the single-database Pro daemon into a multi-database one and re-keying the keychain per tenant — the largest, most sensitive part, entangled with the Anoop-owned tenant-resolution/OAuth-worker (S5/S8). That crosses the "scope + check in before shipping" gate; the Anoop cloud-worker/Supabase spec for S5/S8 is next.
mstomar125 commentedon Jul 10, 2026
ADR-053 per-database cloud sync — cloud-side contract (S5 + S8)
For: Anoop (owns the private
nodespace-cloudCloudflare Workers + Supabase billing/provisioning).From: the local-mechanics work on
nodespace-core+nodespace-sync.Status: the local side (S1–S3) is done and validated against
tenant_demo. The slices past it (S4/S6/S7 + the local half of S5) are blocked on the cloud contract below — I can't build the "add a synced database" flow or per-tenant sign-in without the cloud answering "which tenant does this user get, and how is OAuth brokered for it."What the local side already does (context)
bound_tenant_schema/bound_tenant_collectionon theDatabaseSettingsNode); the Pro daemon resolves its cloud tenant from that binding at runtime. For dev it's seeded from a CLI flag; for real users it must be seeded from a cloud-resolved tenant — that's the gap this spec covers.(service = "nodespace.<schema>", account = <user_id>)— schema-scoped, so per-tenant sessions have a natural key.S8 — subscription → tenant resolution (the gating piece)
The "add a synced database" flow (and first-run sign-in) needs to answer: given a signed-in user, which tenant(s) may they bind a local database to?
Requested endpoint (worker, authed by the user's JWT):
The daemon/UI calls this after sign-in to (a) seed a new database's binding, and (b) populate the "choose a workspace to sync this database to" picker. The daemon must consume a resolved tenant and never invent one.
Decisions only you can make:
/tenantsreturns one or many./tenantsomission, a 403, a webhook)?S5 — per-database OAuth / identity (worker contract)
Today the OAuth broker (
initiate_o_auth, daemon-direct GoTrue PKCE) targets one project. Per-database sync needs each database's session scoped to its tenant.Requested contract:
(nodespace.<schema>, user_id)(already supported locally)./tenantsto know which tenant(s) the identity may bind.Decisions only you can make:
/tenants— if the tenant model allows it.)bound_person_id/bound_uid. With multiple tenants on one machine,auth_identities(person_node_id, supabase_uid)needs per-tenant reasoning. Confirm whether one Supabase identity spans tenants or each tenant has its own.What the local side builds once this contract exists
sync:statuscarriesdatabase_id; the Pro-sync state becomes a per-database map; the pill reflects the active database./tenants.All of the above stays local/testable against
tenant_demoonce/tenants+ the per-tenant OAuth contract are defined — I'm not blocked on your implementation, only on the contract shape (endpoint signatures + the D2–D6 decisions), so I can build the local side against a stub and you fill in the authoritative server behavior.Concrete asks
/tenantsresolution endpoint (subscription → entitled tenants) — even just the response shape unblocks the local build.mstomar125 commentedon Jul 10, 2026
Decision (2026-07-10): default fresh installs to a public tenant — supersedes the
/tenantsblocker for the default path.Rather than block on the cloud subscription→tenant resolution (the S5/S8 Anoop spec above), fresh installs default to a new public NodeSpace tenant (
tenant_public), which RLS admits everyone into — so no per-user tenant resolution is needed for the common case.tenant_deutnet(internal) andtenant_demo(throwaway test) stay private and are selected by passing--schemaexplicitly.Consequence: S1–S3 (done) are the complete near-term mechanism — each install syncs to one tenant, public by default. The
/tenantsresolution endpoint (S8), per-tenant picker (S7), and multi-database daemon (S4) become future/optional, not near-term blockers. The Anoop asks above still stand for the multi-tenant future, just no longer on the critical path.Implemented in nodespace-sync#296 (
68094e9): the Pro daemon's--schemadefault istenant_demo→tenant_public; a fresh, unbound database seeds its binding to the public tenant. (Schema nametenant_publicfollows thetenant_*convention — the public tenant is being created; the name is a one-line change if it lands differently.)mstomar125 commentedon Jul 10, 2026
Per-database cloud sync — near-term complete + validated
With the "default to a public tenant" decision, the near-term deliverable is done: runtime per-database tenant binding, with fresh installs defaulting to the public tenant. All slices merged and validated.
Merged
51301999c51ab321ce3989729c69dc2267962b968094e9)The Pro daemon resolves its cloud tenant from the
DatabaseSettingsNodebinding at boot; a fresh, unbound database seeds the binding from--schema/NODESPACED_PRO_SCHEMA(default nowtenant_public), and a persisted binding wins over the CLI thereafter. The tenant threads throughProConfig(keychain scope, Realtime/PostgREST profiles,member_offetch, migration). The.pkg/.dmgno longer bake a tenant. Single-database on the Pro side — one tenant per install.Validation (green)
cargo test --workspace(223 tests),cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check— all pass on mergedmain.scripts/tenant-binding-check.sh(headless, no live Supabase): boot 1 seeds + resolvestenant_demo; boot 2 with a different--schemadoes not re-seed and still resolves the persisted binding — seed-once + bound-tenant-wins PASS.scripts/two-daemon-smoke.sh(a real A→Supabase→B propagation test againsttenant_demo) could not run: the headless JWT mint calls the Supabase Auth admingenerate_linkendpoint, which returns HTTP 402 (Payment Required) for this project (project itself isACTIVE_HEALTHY, but admin-auth operations are billing/plan-gated). There is no password-grant test user available as an alternative, so no JWT can be minted headlessly. This is an external Supabase billing/plan restriction, not a code issue — and consistent withtenant_demobeing the throwaway tenant slated for deletion. The tenant-binding code path is fully validated headless; a live round-trip needs thetenant_publicproject (or a billing-active project) plus a mintable test credential. Action for a human: resolve the Supabase plan/billing on the sync project, or point the smoke attenant_publiconce created, then re-runscripts/two-daemon-smoke.sh.Deferred (future — not near-term blockers)
S4 single-active-session lifecycle, S5 per-DB OAuth/keychain, S6 per-DB
sync:status, S7 frontend picker, S8 cloud/tenantsresolution + billing/uniqueness (Anoop spec above). These serve the multi-tenant-per-machine future; the public-default decision makes one-tenant-per-install the near-term model, so they're out of near-term scope (and no longer on the critical path). Recommend either closing this epic as near-term-complete and tracking S4–S8 as a separate "multi-tenant per machine" epic, or keeping it open for that future scope — your call.mstomar125 commentedon Jul 21, 2026
Multi-tenant-per-machine — sequencing (foundational slice landed)
Goal (restated): a machine where a user with access to several tenants (e.g. public, demo, nodespace_internal) can switch between them; each switch shows/syncs only that tenant's nodes; a local-only database stays private until it's bound to a tenant, then catches up + pushes on activation. In ADR-053 terms: tenant = a local database bound to that tenant's schema; switch tenant = switch the active database; node isolation is per-database.
✅ Foundational routing (nodespace-sync#327, merged): the Pro daemon now opens its default DB through the
DatabaseManagerand installsDbManagerLayer, so it addresses multiple databases (x-ns-database-idroutes;database listreports open). Per-DB write isolation is live-validated. This is the substrate the rest builds on.Remaining slices, in order:
A+B+D are headless-validatable (3 DBs bound to 3 tenants, switch via
database use, assert isolation + per-tenant sync). Proceeding with A next.mstomar125 commentedon Jul 22, 2026
Multi-tenant-per-machine — headless slices landed (nodespace-sync)
The deferred S4–S8 runtime-tenant-binding + single-active-sync work is now functional headless. Merged to nodespace-sync
main:ActivateDatabaseRPC; per-database sync-state; deleted the spawn-once latch).BindTenantRPC + activate-on-bind (bind a local database to a tenant → syncs immediately; settings-node + registry mirror).BindTenantenables sync (push) for the bound database (explicit bind = consent; boot auto-seed still gated).Acceptance test (headless, real daemon, [email protected], 3 tenants: public / demo / nodespace_internal)
tenant_public(syncs). Create DemoWs →BindTenant(tenant_demo), InternalWs →BindTenant(tenant_nodespace_internal).tenant_public/tenant_demo/tenant_nodespace_internal); only the active tenant syncs.tenant_democloud on bind.tenant_public(held by the default) → FAILED_PRECONDITION.Sync-only — no core changes were needed (used
DatabaseManager::resolve_database_id/list/set_bound_tenant+ theNodeServiceImpl::node_service()accessor from #1710). Core pin unchanged.Remaining (productionization, not headless-blocking): tenant/database picker UI + per-DB sync pill (needs the tray DB menu #1536 / registry-driven Pro UI #1537) and a cloud "list my tenants" endpoint for the fresh-machine flow.
malibio commentedon Aug 17, 2026
Triage (2026-08-17): this looks substantially shipped and stale as "In Progress" — but two acceptance criteria don't match reality, so flagging rather than closing.
Last activity was 2026-07-22, reporting nodespace-sync #350/#352/#354/#356 merged and acceptance-tested headless. I independently verified that surface against shipped code while reviewing nodespace-docs#78, and it is live:
ActivateDatabaseandBindTenantexist onCloudSyncService(nodespaced-pro/proto/nodespace_pro.proto:57,68), and single-active session state is a real(database_id, tenant_schema, cancellation_token)slot incloud_sync/mod.rs.One criterion contradicts shipped behavior:
CloudSyncSvc::deactivate(cloud_sync/mod.rs:500-505) takes the active slot and cancels its token immediately. There is no drain phase — and there is no outbox for it to drain. A write made mid-switch is picked up by that database's own reconciliation sweep the next time it is activated, so nothing is lost, only deferred. nodespace-docs#78 corrects the ADR prose that implied otherwise.This criterion should either be rewritten to describe the real guarantee ("a write made while switching away is not lost — it is picked up by the target database's next reconciliation sweep") or dropped. As written it will never be satisfiable, which is likely part of why this issue has sat open.
A second is likely obsolete:
enable-sync-pill.svelteandpro-sync-pill.svelteboth exist and are wired throughapp-shell.svelte, so this may already be done — I did not verify per-database correctness after switches.Ask: @mstomar125 — of the nine criteria, which are genuinely outstanding? If it is only the frontend ones (sign-in/sign-out per database, add-synced-database-from-cloud on a fresh profile), this is worth narrowing to those and retitling, since the headless half has been done for four weeks. If they are all effectively done, it should close.
No action taken — this is a triage note only.
mstomar125 commentedon Sep 1, 2026
Baseline before starting work:
bun run testgreen — 227 test files, 4810 tests passed, 0 failures. Starting on the remaining scoped gap: the per-database-keyed sync store (see issue comment for details on scope).mstomar125 commentedon Sep 1, 2026
PR #2322 opened: #2322 — Split proSync store into per-database sync/auth status (ADR-053).
This closes the one concretely-scoped, verifiable-in-this-environment gap:
pro-sync.svelte.tswas still a single GLOBAL store (grepped fordatabase_id/databaseId, zero matches), so switching the active database could show stale/leaked-over sync/auth status. It's now keyed per database id, with the pill/re-login/consent slots reading the ACTIVE database's status automatically (no consumer changes needed). Also fixed a real bug this surfaced:resolveProSyncVariant()'sauthedcheck could leak a signed-in email from one database into a different, never-signed-in database's variant resolution.Everything else already verified done before I started: build-time
NODESPACED_PRO_SCHEMA/NODESPACED_PRO_COLLECTIONinjection is gone fromdaemon_setup.rs(re-verified, zero references repo-wide), andbound_tenant_schema/bound_tenant_collectionare wired through core + the daemon registry.Remaining acceptance criteria — NOT closed by this PR:
proto/nodespace_pro.protoandcommands/pro_sync.rs, there is noBindTenant/tenant-listing RPC surfaced in core at all, even though the private repo already hasBindTenant(sync#352/356). Closing this needs vendoring an updated proto + new Tauri commands + a new "add synced database" frontend flow — separate, larger follow-up work.bun run test:allandbun run quality:fixboth clean. Leaving status "In Progress" — real infra-gated criteria remain open, and the PR is awaiting adversarial re-review before merge per core's merge policy.Split proSync store into per-database sync/auth status (ADR-053) (#2322)
mstomar125 commentedon Sep 1, 2026
Status — the concretely-scoped, verifiable gap is closed; several acceptance criteria remain genuinely infra-gated
Merged #2322, which closes the one piece of this issue that was both real and fully verifiable in this environment:
pro-sync.svelte.tswas still a single global store, so switching the active database could show stale or leaked-over sync/auth status from whichever database last synced. It's now split and keyed per database (ADR-053), with theProClient-side attribution plumbing (SyncStatusEventcarries nodatabase_idof its own under the daemon's single-active-session design, so the desktop now tracks the last-activated database and attributes every forwarded event to it).Also confirmed, not just assumed: the server-side tenant-binding/single-active-session backend already landed via sync#350/352/354/356/358 (all Done), and the build-time
NODESPACED_PRO_SCHEMA/NODESPACED_PRO_COLLECTIONenv injection this issue originally flagged is already gone fromdaemon_setup.rs(zero references, repo-wide grep).Remaining acceptance criteria, honestly split:
proto/nodespace_pro.protoandcommands/pro_sync.rs— there is noBindTenant/tenant-listing RPC surfaced in core at all, even though the privatenodespace-syncrepo already hasBindTenant(sync#352/356). Closing this needs vendoring an updated proto, new Tauri commands, and a new "add synced database" frontend flow — real, separate follow-up work, not attempted here.Leaving this issue In Progress rather than closing — real work remains, it's just not something this environment can pick up further right now (the live-infra half needs a real test tenant; the BindTenant-flow half is new feature work warranting its own pass rather than being squeezed in here).
mstomar125 commentedon Sep 9, 2026
Attempted live-infra verification — blocked, not completed
Attempted to actually run the 4 remaining live-infra-gated acceptance criteria against the
tenant_demotest tenant, using the established headless harness pattern (~/nodespace/seed-tenant-users.sh,~/nodespace/sync/scripts/two-window-demo.sh).Blocked:
~/nodespace/.env'sSUPABASE_ACCESS_TOKENis expired/revoked — every Supabase Management API call returns a genuine401 Unauthorized(confirmed via verbose curl, not a network/formatting issue). This token is load-bearing for the entire headless-auth pattern this repo's demo scripts use (fetching the anon/service_role keys, minting a JWT via the admingenerate_link→verifyflow) — without a fresh token, none of criteria 1-4 below can be exercised end-to-end from here.What I found instead, worth recording: the underlying RPC-level implementation for all 4 criteria appears to already exist and be actively maintained in
nodespace-sync(private repo) — confirmed vianodespaced-pro/examples/bind_tenant.rsandactivate_db.rs(purpose-built headless test harnesses calling realBindTenant/ActivateDatabasegRPC RPCs, explicitly documented as "the headless trigger for turning a freshly-created, local-only database into a synced tenant" and "headless multi-tenant switch validation"), plus very recent, directly-relevant commit history in that repo:Route InitiateOAuth, activate's unbound branch, and GetIdentity through the active database,Serialise SignOut against ActivateDatabase with a session-transition lock,Revert auth_status on the active database and record persisted tenants durably. Both example binaries build cleanly (cargo build -p nodespaced-pro --example bind_tenant --example activate_db, exit 0). This is strong circumstantial evidence the mechanism is implemented and being iterated on, but it is not the same as an actual passing live test — I did not get to run one.Leaving this issue open, not closing it. Once a fresh
SUPABASE_ACCESS_TOKENis available, re-run: seed a test user headlessly via the mint-JWT pattern intwo-window-demo.sh, launchnodespaced-prowith--auto-signin, and drivebind_tenant/activate_dbagainst a fresh local database bound totenant_demofor each of the 4 remaining criteria (coexistence+catch-up, deactivate-drains-pushes, duplicate-bind-rejected, per-database keychain isolation).mstomar125 commentedon Sep 9, 2026
Second attempt with the refreshed token — real progress, new blocker (this time a permission gate, not infra)
Token refresh confirmed working end-to-end (project info, api-keys reveal, admin generate_link → verify JWT mint all succeed).
What worked:
nodespaced-prodaemon againsttenant_demoviaNODESPACED_PRO_SCHEMA/ANON_KEY/ACCESS_TOKENenv +--auto-signin. Confirmed a real, previously-undocumented default-schema behavior: withNODESPACED_PRO_SCHEMAunset, the daemon defaults toschema=tenant_public(not "no tenant") and immediately attempts a migration push there on startup. Harmless in this case — RLS correctly rejected every insert since this identity isn't a member oftenant_public— but worth knowing: an unset schema env is not equivalent to "unbound," it silently targets a real default tenant.NODESPACED_PRO_SCHEMA=tenant_demoset explicitly, the daemon connected correctly: real Supabase Realtime channel subscription established (nodes,relationships), pull/push consumers started, effective tenant logged astenant_demo.New blocker: the freshly-seeded local
PersonNodefor this test identity can't push intotenant_demo— RLS correctly rejects it (rls_rejected=155in the startup sweep, plus an explicitidentity bind: PersonNode push (pre-bind) rejectedwarning) because this person isn't yet a member of any collection intenant_demo. This is expected: per #1535's own design, a real provisioning flow (OAuth → worker lists tenants → bind → catch-up) is supposed to establish this membership server-side before the client starts pushing — and that flow is the exact thing already confirmed genuinely unbuilt innodespace-core(noBindTenant/tenant-listing RPC surfaced).Attempted to bootstrap membership directly via SQL (mirroring how
seed-tenant-users.shprovisions users) to get past this and test criteria 1-4's actual sync mechanics independent of the unbuilt provisioning flow — this was blocked by this environment's own safety classifier (direct admin SQL writes against live infrastructure need explicit one-off human approval here, not just issue-level authorization to "use the credentials"). Stopped rather than work around it. Daemon process cleanly killed, no stray state left, onlytenant_demotargeted (nevertenant_deutnet/tenant_nodespace_internal).Still open, still not closed. The remaining path forward needs either: (a) the user directly approving the specific SQL bootstrap statements (2 inserts: an
auth_identitiesrow + a collection-membership row in whatever the real underlying table forcollection_membersis — it's a view, the write needs to target its base table, not yet identified), or (b) building the real provisioning flow first (which would supersede the need for manual bootstrapping entirely, since that's what it exists to do) — or (c) reusing an identity that's already a legitimate member oftenant_demo(the existing[email protected]identity IS already a member — the friction here is specifically that a fresh per-database local PersonNode gets a new random UUID with no existing membership row of its own, by design, since "the same person maps to a distinct PersonNode per device/database").mstomar125 commentedon Sep 9, 2026
Third attempt — real setup, found the right harness, then caught a real environment-safety mistake before any criterion could be tested
Found exactly the right headless harness:
nodespaced-pro/examples/bind_tenant.rs(callsBindTenant, an omitted schema arg unbinds → local-only) andactivate_db.rs(callsActivateDatabase, an omitted db-id deactivates) — both build cleanly and are purpose-built for this issue's exact remaining criteria (bind/unbind a specific local database, switch which one is active). This is the missing piece from both prior attempts.What went wrong before reaching any test: launched a scratch
nodespaced-proinstance with an invalid env var name (NODESPACED_DB_ROOT— the real flag isNODESPACED_DB_PATH, silently ignored when misspelled since clap just falls through to its own default). With no validNODESPACED_DB_PATHset, the daemon fell back to the real default path (~/.nodespace/databases.toml, the same registry this machine's actual long-running community daemon — PID alive 13+ days — uses), and picked up that install's real, already-boundtenant_nodespace_internalbinding as its "effective cloud tenant" (a second instance of the same default-tenant-binding hazard the prior attempt found withNODESPACED_PRO_SCHEMA, this time triggered byNODESPACED_DB_PATH). A separate, unrelated bug (socket path too long —SUN_LENlimit, my scratch path was too deeply nested) crashed the process about a second later, before any actual network/push activity ran (confirmed: zero push/Realtime/PostgREST/migration-write log lines anywhere in the captured output).Verified no actual harm: the real daemon (PID 87575) is still running normally;
~/.nodespace/databases.toml's content is sane and consistent with its expected steady state (oneDefaultdatabase, same id/path/tenant binding it already had); the daemon's own log explicitly reportedrefiled=0for the migration step that touched the file (i.e., it determined there was nothing to actually change). The file's mtime did bump, which is why this got caught and is worth recording, but the content itself did not change.Stopped here rather than push forward into a fourth attempt without fixing this properly first. Two real environment hazards are now documented (unset
NODESPACED_PRO_SCHEMAdefaults totenant_public; unset/misspelledNODESPACED_DB_PATHfalls through to the real local default) — anyone attempting this next should set both explicitly, use a short/shallow scratch socket path (SUN_LEN limit is real), and verify the daemon's logged "effective cloud tenant" line before letting it do anything else, every single time.Still open. Criteria 1-4 still not exercised.
bind_tenant/activate_dbare confirmed as the right tools for next time.mstomar125 commentedon Sep 9, 2026
Fourth attempt — safety discipline held, real progress, one genuinely ambiguous result
Applied both fixes from attempt 3's near-miss: caught and fixed my own initial misconfiguration (daemon defaulted its UDS socket + state files to the real `
/.nodespace/` tree because `NODESPACE_HOME` wasn't set) before any daemon ran with cloud connectivity — killed it, cleaned up, relaunched fully redirected to a scratch directory. Verified via `/.nodespace/databases.toml`'s MD5 (unchanged throughout); real production daemon (PID 87575) undisturbed. Never touched `tenant_deutnet`/`tenant_nodespace_internal`.Real progress: JWT-minted `[email protected]` sign-in, `bind_tenant`/`activate_db` RPC calls, and node creation all worked mechanically — `ActivateDatabase` returns success and logs "cloud-sync session started," and a real, tenant+user-scoped keychain credential lookup entry was constructed (`nodespace.tenant_demo` / `ns1535-a`) during the flow — useful positive evidence toward criterion 4 (per-database keychain isolation).
Could not confirm push actually works — genuinely ambiguous, not a clean pass or fail. A node created 15+ seconds post-activation never appeared in `tenant_demo`'s `nodes` table (checked directly via PostgREST). At `RUST_LOG=debug`, zero log output from the orchestrator beyond its one startup line — no realtime/websocket/subscription/reconnect/catch-up/degraded line of any kind, reading like the sync loop may be silently blocked rather than actively failing.
Two explanations, couldn't distinguish between them: (1) a real product gap in the runtime `ActivateDatabase` push path, or (2) a test-harness mismatch — authenticated via an env-var-injected JWT (`NODESPACED_PRO_ACCESS_TOKEN`, the pattern `two-window-demo.sh` uses for its older, boot-time single-database-per-daemon flow), while the CLI's own `--auto-signin`/`--email` flag suggests the newer multi-database runtime-activation flow may expect a live password-grant sign-in instead. Didn't have `[email protected]`'s password to test that path, and didn't want to guess/brute-force it.
Not closing this issue, not filing a bug — the evidence doesn't cleanly support either "confirmed passing" or "confirmed broken," and filing a bug I'm not confident is real would be worse than flagging the ambiguity honestly.
Concrete next step: retry with `--auto-signin --email [email protected]` (needs `[email protected]`'s actual password) to rule out the auth-mechanism-mismatch explanation before concluding anything about the push path itself. Relevant orchestrator source, if useful: `nodespaced-pro/src/cloud_sync/mod.rs:707` (`activate_locked`), `orchestrator.rs:86` (`spawn_orchestrator`).
No code changes made — verification-only attempt, evidence didn't meet the bar for either a confident fix or a confident bug report.
mstomar125 commentedon Sep 9, 2026
Sixth attempt — all 4 remaining criteria verified with real evidence, using the now-properly-provisioned test identity
Built on the fifth attempt's fix (a real membership row for a disposable test user in
tenant_demo, established via the user's own direct SQL run outside auto-mode restrictions). Ran a realnodespaced-prodaemon againsttenant_demo, using--auto-signinwithNODESPACED_PRO_EMAIL/NODESPACED_PRO_PASSWORDenv vars (the correct mechanism permain.rs's own doc comment — a CLI flag was never the right shape; the password is env-var-only by design, never a flag, since argv is visible viaps). This resolves the auth-mechanism ambiguity from the fourth attempt.Safety discipline held throughout — zero near-misses.
NODESPACE_HOMEset to a scratch dir before any daemon launch,NODESPACED_PRO_SCHEMA/NODESPACED_DB_PATHexplicit, startup log'seffective cloud tenantline verified before any activity, onlytenant_demotouched. Confirmed no drift afterward:~/.nodespace/databases.toml's MD5 unchanged from before this session, real production daemon (PID 87575) undisturbed.Criterion 1 — PASS: synced + local-only coexist; switching starts/stops sync with catch-up
Created a second local database (unbound, genuinely local-only) alongside the
tenant_demo-bound default. Real evidence, in order:supabase push consumer: cancelled,supabase pull apply loop: cancelled,supabase sync service: shutdown complete side="push"for the outgoing synced session.aedb9ba3-...) — confirmed absent fromtenant_demo.nodesvia a read-only query.activated database ... syncing to tenant schema 'tenant_demo', and within ~4s the pending node appeared intenant_demo.nodes(catch-up confirmed by direct query).Criterion 2 — the literal wording doesn't match shipped behavior (already flagged 2026-08-17; recommend rewording, not a new finding)
Per the 2026-08-17 triage comment on this issue,
CloudSyncSvc::deactivatecancels its token immediately with no drain phase and no outbox — confirmed still true by reading currentcloud_sync/mod.rs. Live-tested the real guarantee instead: created a node in the active synced database, immediately switched away (no delay). The row still reachedtenant_demo(likely the push raced to completion before the switch reached it — not a proof of an explicit drain). Combined with criterion 1's clean reconciliation-on-reactivation evidence (write made while inactive is picked up, not lost, on next activation), the actual guarantee — a write is never lost, even without an explicit drain phase, either because the push already completed or because the target database's next reconciliation sweep picks it up — is verified. Reiterating 2026-08-17's own recommendation: reword this criterion to describe that real guarantee, or drop it; as literally written ("drains pending pushes before stopping") it will never be satisfiable against the current, intentional architecture.Criterion 3 — PASS: binding a second local database to an already-bound tenant is rejected
Created a third local database, attempted
BindTenantagainsttenant_demo(already bound to the first database). Real gRPC error:FailedPrecondition: bind_tenant: tenant "tenant_demo" is already bound to database <id> (Default); a tenant binds to at most one local database (ADR-053). Exact match to the invariant.Criterion 4 — PASS: sign-in/sign-out operate per database; keychain holds independent entries per tenant
Two parts:
SignOutagainst the running daemon. Log confirms real IdP revocation (/auth/v1/logout, scope=global) and real macOS keychain interaction (keyring: ... service: "nodespace.tenant_demo", account: "ns1535a"), session cleared cleanly (cleared in-memory + persisted session; awaiting re-sign-in). Note:--auto-signin(dev/test password grant) does NOT persist to keychain at boot — only on the in-session refresh cycle (~60 min later,orchestrator.rs'spersist_sessioncall site) — so a short-lived test session like this one never gets far enough to observe a live keychain write; the SignOut call's delete attempt against an absent item is itself evidence of correct, tenant-scoped targeting even with nothing to delete yet.factory_isolates_stores_per_tenant_schema(two tenant schemas resolve to genuinely independent stores; deleting one never touches the other; an unseen schema reads as empty, not error),sign_out_wipes_every_registered_databases_keychain_session,sign_out_wipes_persisted_keychain_item— all 6 relevant tests pass (cargo test -p nodespaced-pro --bin nodespaced-pro keychain). Worth noting: SignOut deliberately clears the session across every tenant this daemon has ever bound to (a "sign out this identity everywhere on this machine" security posture), not just the active one — this doesn't violate per-database isolation (storage itself never cross-contaminates, proven by the factory test), it's a deliberate scope for the sign-out action specifically.Closing this issue
All 4 remaining live-infra-gated criteria are now genuinely verified (3 clean passes, 1 verified against its real intended guarantee rather than its stale literal wording). The one criterion still not implemented — the add-synced-database-from-cloud flow (no
BindTenant/tenant-listing RPC surfaced innodespace-core's own command layer, confirmed unbuilt across three separate prior status checks on this issue) — is real, separate feature work, not a testing gap. Filing it as its own follow-up and closing this issue referencing it.Cleanup: killed all scratch daemon processes, removed the scratch directories and the ad-hoc
sign_out_1535.rstest binary (not meant to be permanent). The disposable test user ([email protected]) and itstenant_demomembership are left in place as a reusable fixture for future re-verification — harmless, scoped to one throwaway identity.mstomar125 commentedon Sep 9, 2026
Follow-up filed as #2541 for the one genuinely-unbuilt remaining criterion. Closing.