@voltro/cli 0.32.0 → 0.34.0
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.
- package/CHANGELOG.md +2006 -0
- package/THIRD-PARTY-NOTICES.md +1 -29
- package/bin/nodeEnvironment.d.mts +30 -0
- package/bin/nodeEnvironment.mjs +158 -0
- package/bin/voltro.mjs +69 -5
- package/dist/addCommand-BNeoeSxe.js +124 -0
- package/dist/addCommand-aXSQveak.js +2 -0
- package/dist/agentsMd-BTchIZku.js +2 -0
- package/dist/agentsMd-mhQMF1bx.js +254 -0
- package/dist/apiBuild-BICVGnEC.js +2 -0
- package/dist/{apiBuild-C4uEbs3s.js → apiBuild-DZF_f0_I.js} +46 -46
- package/dist/appPort-B_HpJ_ck.js +48 -0
- package/dist/baselineCommand-C2ClWZN3.js +2 -0
- package/dist/baselineCommand-DIttzO8A.js +227 -0
- package/dist/bin.js +71 -28
- package/dist/build-CE7Ca9gm.js +711 -0
- package/dist/cacheCommand-DA4OH9xt.js +42 -0
- package/dist/capabilitiesCommand-nq_pz5xd.js +123 -0
- package/dist/checkCommand-Dv8r9tGO.js +231 -0
- package/dist/checkCommand-YZDmkAGd.js +2 -0
- package/dist/{cliArgs-qdZSElM3.js → cliArgs-D4p8n7EE.js} +12 -1
- package/dist/cliError-BmdYnghb.js +10 -0
- package/dist/cliOutput-D1tSBoRM.js +15 -0
- package/dist/{cliRuntime-Oh517vCV.js → cliRuntime-Dh7UDinH.js} +20 -20
- package/dist/cloudClient-DWL-Hw_T.js +67 -0
- package/dist/cloudCmd-Cvv5HGaZ.js +364 -0
- package/dist/clusterCmd-CNXKlcvD.js +54 -0
- package/dist/codegen-CYM3Zqrf.js +605 -0
- package/dist/codegen-ChBi_hVa.js +2 -0
- package/dist/codegenCommand-DC6w2tNZ.js +30 -0
- package/dist/codemodRunner-DRRqXR74.js +5243 -0
- package/dist/commandRunner-BLAEFLjp.js +47 -0
- package/dist/commands-gutsz-Ac.js +808 -0
- package/dist/connectionConfig-UFlIEiys.js +66 -0
- package/dist/dashboardCommand-3YG8p-UA.js +25 -0
- package/dist/dataCommand-qL0r7fPO.js +535 -0
- package/dist/dataProfile-dW-PsfLB.js +15 -0
- package/dist/dbCommand-B6X0FZbq.js +1621 -0
- package/dist/dbCommand-CpdKLeQq.js +2 -0
- package/dist/{dev-5ficNnvF.js → dev-CerMd0mW.js} +3155 -3110
- package/dist/dev-CoG-ZPx8.js +3 -0
- package/dist/devActivity-Dx_3nnGv.js +100 -0
- package/dist/devActivity.js +1 -1
- package/dist/dialectDriver-CgXnDfec.js +39 -0
- package/dist/discover-C9XKJDco.js +25 -0
- package/dist/doctorCommand-BvqGBwNG.js +2 -0
- package/dist/{checkCommand-dm7OHtPt.js → doctorCommand-CnDXQxfa.js} +520 -1278
- package/dist/dormancyCommand-Dszo57d6.js +69 -0
- package/dist/e2eCmd-BRabZww-.js +147 -0
- package/dist/embeddingsCommand-C0sKVRo1.js +73 -0
- package/dist/envCommand-DPgdV1Bq.js +60 -0
- package/dist/evalCommand-6RUfPen4.js +118 -0
- package/dist/evolveCommand-DHpkgjgH.js +281 -0
- package/dist/fileTaxonomy-CJfgOllU.js +457 -0
- package/dist/frameworkTableAssembly-BGHmck-x.js +2 -0
- package/dist/{frameworkTableAssembly-BwIrO5nv.js → frameworkTableAssembly-DkkP6BgC.js} +184 -148
- package/dist/generateCommand-oibemh97.js +147 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +4 -3
- package/dist/infoCommand-BJw9nLUR.js +60 -0
- package/dist/{inspect-BUUjt773.js → inspect-CBqFtAKA.js} +82 -40
- package/dist/inspect-C_T_WGvl.js +2 -0
- package/dist/inspectCmd-Bppy-GGw.js +224 -0
- package/dist/inspectFetch-Cm8_wVvp.js +151 -0
- package/dist/inspectMetrics-CfdKLh6t.js +72 -0
- package/dist/loadEnv-D9nEOClM.js +44 -0
- package/dist/logFileSink-C_D2wRN1.js +105 -0
- package/dist/logsCmd-CCca3KRZ.js +260 -0
- package/dist/manifestBuild-ChsKAhmn.js +2 -0
- package/dist/{manifestBuild-BLrVuSlM.js → manifestBuild-sxpwdKY1.js} +1 -1
- package/dist/metaCommands-7MJfZ5cf.js +196 -0
- package/dist/migrate-CBwOt_iV.js +83 -0
- package/dist/mssqlClusterPatch-_4cE_nun.js +44 -0
- package/dist/newCommand-COWOJ1_E.js +156 -0
- package/dist/nodeEnvironment-cGFAj1J8.js +28 -0
- package/dist/packageCommand-Cug_3Ogl.js +271 -0
- package/dist/pageConvention-cEiRxdab.js +5 -0
- package/dist/privacyCommand-C-Df56U_.js +146 -0
- package/dist/projectScaffold-DmzEKHib.js +2 -0
- package/dist/projectScaffold-LMMtaavR.js +814 -0
- package/dist/renderModeScan-D7J1B7Kw.js +105 -0
- package/dist/renderProfile-1OWWAAtx.js +81 -0
- package/dist/runtimeRegistry-DMeKfTHP.js +81 -0
- package/dist/runtimeTrace-CRxalXTs.js +91 -0
- package/dist/scheduleCmd--jksTrf6.js +69 -0
- package/dist/scheduleManifestCmd-D2x0CTTY.js +249 -0
- package/dist/schemaIr-UJybUUZW.js +103 -0
- package/dist/{sdkgen-B_5mHQS2.js → sdkgen-CYJscZC7.js} +111 -209
- package/dist/seedRunner-TFHHiToI.js +329 -0
- package/dist/serveCommand-B_isw7q4.js +1647 -0
- package/dist/serveCommand-DOvbgRnQ.js +2 -0
- package/dist/serveEntry.js +5 -5
- package/dist/serverlessCommand-CfJZy6dS.js +482 -0
- package/dist/start-9LiUOfES.js +1087 -0
- package/dist/start-B-9Nsp-S.js +3 -0
- package/dist/startEntry.js +2 -2
- package/dist/staticCommand-Dr2M6tpU.js +304 -0
- package/dist/storageCommand-Co6NfLqN.js +42 -0
- package/dist/templates-De8IR5-c.js +102 -0
- package/dist/test-CI6iDsYc.js +115 -0
- package/dist/tracesCmd-CkEZQrtt.js +232 -0
- package/dist/tsconfigPaths-BWXBWgcl.js +107 -0
- package/dist/tsxLoader-EuXmSJ1K.js +51 -0
- package/dist/typecheckCommand-BlsWiCNq.js +61 -0
- package/dist/updateCommand-Bkptutss.js +585 -0
- package/dist/updateCommand-us1_hdIC.js +2 -0
- package/dist/{inspectMetrics-BqO4E9G0.js → webDev-CBYvPqQr.js} +1006 -1567
- package/dist/webDev-Cg-fFiyd2.js +2 -0
- package/dist/webhookDiscovery-CrGAfhIG.js +2 -0
- package/dist/webhookDiscovery-D7VaeMlz.js +51 -0
- package/dist/webhooksCommand-CID96Rga.js +267 -0
- package/dist/workflowsCmd-D1VTmLMY.js +608 -0
- package/package.json +193 -18
- package/templates/AGENTS.core.md +58 -3
- package/templates/AGENTS.md +64 -7
- package/templates/agent-docs/_index.md +6 -4
- package/templates/agent-docs/_manifest.json +22 -5
- package/templates/agent-docs/ai.md +370 -0
- package/templates/agent-docs/authentication.md +265 -31
- package/templates/agent-docs/caching.md +6 -0
- package/templates/agent-docs/cli.md +794 -50
- package/templates/agent-docs/data.md +550 -11
- package/templates/agent-docs/database/migrations.md +174 -25
- package/templates/agent-docs/database/misc.md +193 -40
- package/templates/agent-docs/database/querying.md +19 -1
- package/templates/agent-docs/database/scaling.md +60 -0
- package/templates/agent-docs/database/schema.md +5 -2
- package/templates/agent-docs/database/seedsdialects.md +208 -19
- package/templates/agent-docs/database/transactions.md +68 -0
- package/templates/agent-docs/deployment.md +156 -4
- package/templates/agent-docs/introduction.md +87 -16
- package/templates/agent-docs/local-first-mobile.md +79 -4
- package/templates/agent-docs/multi-tenancy.md +95 -20
- package/templates/agent-docs/observability.md +58 -3
- package/templates/agent-docs/plugins/ai-flows.md +161 -2
- package/templates/agent-docs/plugins/analytics-postgres.md +1 -1
- package/templates/agent-docs/plugins/audit.md +37 -1
- package/templates/agent-docs/plugins/auth-social.md +143 -0
- package/templates/agent-docs/plugins/auth-workos.md +4 -2
- package/templates/agent-docs/plugins/auth.md +131 -6
- package/templates/agent-docs/plugins/billing.md +132 -15
- package/templates/agent-docs/plugins/cdc-out.md +46 -7
- package/templates/agent-docs/plugins/clickhouse.md +1 -1
- package/templates/agent-docs/plugins/duckdb.md +1 -1
- package/templates/agent-docs/plugins/flags.md +132 -0
- package/templates/agent-docs/plugins/governance.md +105 -7
- package/templates/agent-docs/plugins/multitenancy.md +9 -4
- package/templates/agent-docs/plugins/presence.md +13 -2
- package/templates/agent-docs/plugins/ratelimit.md +9 -0
- package/templates/agent-docs/plugins/search.md +157 -6
- package/templates/agent-docs/plugins/sso-saml.md +47 -8
- package/templates/agent-docs/plugins/webhooks.md +105 -0
- package/templates/agent-docs/plugins.md +200 -18
- package/templates/agent-docs/reference.md +60 -3
- package/templates/agent-docs/releases.md +1117 -0
- package/templates/agent-docs/routing.md +43 -25
- package/templates/agent-docs/scheduling.md +14 -1
- package/templates/agent-docs/schema-driven-ui.md +92 -12
- package/templates/agent-docs/security.md +449 -2
- package/templates/agent-docs/templates/apibackends.md +87 -18
- package/templates/agent-docs/templates/appshells.md +32 -14
- package/templates/agent-docs/templates/overview.md +13 -8
- package/templates/agent-docs/testing.md +211 -14
- package/templates/agent-docs/whats-new.md +1722 -84
- package/templates/agent-docs/workflows.md +130 -14
- package/templates/apps/api-ai/actions/summarize.action.ts +11 -0
- package/templates/apps/api-ai/package.json +8 -7
- package/templates/apps/api-auth/actions/me.action.ts +13 -0
- package/templates/apps/api-auth/package.json +9 -8
- package/templates/apps/api-backend/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend/package.json +12 -8
- package/templates/apps/api-backend/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-deactivation/actions/users.get.action.ts +14 -0
- package/templates/apps/api-backend-deactivation/mutations/users.create.mutation.ts +8 -0
- package/templates/apps/api-backend-deactivation/mutations/users.deactivate.mutation.ts +10 -0
- package/templates/apps/api-backend-deactivation/package.json +8 -7
- package/templates/apps/api-backend-mail/actions/sendWelcome.action.ts +17 -0
- package/templates/apps/api-backend-mail/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-mail/package.json +9 -8
- package/templates/apps/api-backend-mail/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-mariadb/.env.example +14 -0
- package/templates/apps/api-backend-mariadb/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-mariadb/package.json +10 -9
- package/templates/apps/api-backend-mariadb/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-sqlite/.env.example +14 -0
- package/templates/apps/api-backend-sqlite/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-sqlite/package.json +9 -8
- package/templates/apps/api-backend-sqlite/queries/notes.query.ts +30 -8
- package/templates/apps/api-backend-storage/actions/uploadAvatar.action.ts +13 -0
- package/templates/apps/api-backend-storage/actions/uploadDocument.action.ts +12 -0
- package/templates/apps/api-backend-storage/mutations/notes.create.mutation.ts +9 -0
- package/templates/apps/api-backend-storage/package.json +9 -8
- package/templates/apps/api-backend-storage/queries/notes.query.ts +30 -8
- package/templates/apps/api-cms/actions/content.get.action.ts +7 -0
- package/templates/apps/api-cms/actions/content.types.action.ts +6 -0
- package/templates/apps/api-cms/actions/me.action.ts +13 -0
- package/templates/apps/api-cms/app.config.ts +19 -0
- package/templates/apps/api-cms/authz.ts +63 -0
- package/templates/apps/api-cms/mutations/content.publish.mutation.ts +10 -0
- package/templates/apps/api-cms/mutations/content.saveDraft.mutation.ts +10 -0
- package/templates/apps/api-cms/mutations/content.unpublish.mutation.ts +5 -0
- package/templates/apps/api-cms/package.json +11 -10
- package/templates/apps/api-cms/queries/content.list.query.ts +23 -7
- package/templates/apps/api-cms/tests/accessDecisions.test.ts +121 -0
- package/templates/apps/api-cms/tests/content.descriptors.test.ts +8 -4
- package/templates/apps/api-collab/mutations/documents.create.mutation.ts +8 -0
- package/templates/apps/api-collab/mutations/documents.setBody.mutation.ts +13 -0
- package/templates/apps/api-collab/package.json +9 -8
- package/templates/apps/api-collab/queries/documents.query.ts +19 -7
- package/templates/apps/api-data-advanced/package.json +9 -8
- package/templates/apps/api-data-advanced/queries/authors.withBooks.query.ts +12 -0
- package/templates/apps/api-data-advanced/queries/books.search.query.ts +9 -0
- package/templates/apps/api-durable/mutations/orders.approve.mutation.ts +17 -0
- package/templates/apps/api-durable/mutations/orders.place.mutation.ts +9 -0
- package/templates/apps/api-durable/package.json +9 -8
- package/templates/apps/api-feature-flags/actions/notes.export.action.ts +16 -0
- package/templates/apps/api-feature-flags/mutations/notes.create.mutation.ts +12 -0
- package/templates/apps/api-feature-flags/package.json +10 -9
- package/templates/apps/api-governance/README.md +30 -8
- package/templates/apps/api-governance/actions/profiles.get.action.server.ts +17 -1
- package/templates/apps/api-governance/actions/profiles.get.action.ts +29 -4
- package/templates/apps/api-governance/database/schema.ts +16 -4
- package/templates/apps/api-governance/mutations/profiles.create.mutation.ts +12 -0
- package/templates/apps/api-governance/package.json +9 -8
- package/templates/apps/api-kv/actions/sync.pull.action.ts +15 -0
- package/templates/apps/api-kv/actions/sync.reset.action.ts +13 -0
- package/templates/apps/api-kv/actions/sync.status.action.ts +7 -0
- package/templates/apps/api-kv/package.json +9 -8
- package/templates/apps/api-kv/queries/events.list.query.ts +19 -8
- package/templates/apps/api-moderation/mutations/comments.create.mutation.ts +11 -0
- package/templates/apps/api-moderation/mutations/posts.create.mutation.ts +13 -0
- package/templates/apps/api-moderation/package.json +9 -8
- package/templates/apps/api-observability/mutations/notes.create.mutation.ts +8 -0
- package/templates/apps/api-observability/package.json +9 -8
- package/templates/apps/api-observability/queries/notes.list.query.ts +13 -0
- package/templates/apps/api-ratelimit/mutations/notes.create.mutation.ts +14 -0
- package/templates/apps/api-ratelimit/package.json +9 -8
- package/templates/apps/api-rbac/package.json +9 -8
- package/templates/apps/api-rest/package.json +8 -7
- package/templates/apps/api-saas/mutations/projects.create.mutation.ts +13 -0
- package/templates/apps/api-saas/package.json +12 -11
- package/templates/apps/api-saas/queries/projects.list.query.ts +11 -0
- package/templates/apps/api-saas-starter/actions/me.action.ts +13 -0
- package/templates/apps/api-saas-starter/app.config.ts +19 -0
- package/templates/apps/api-saas-starter/authz.ts +75 -0
- package/templates/apps/api-saas-starter/mutations/invites.create.mutation.ts +10 -0
- package/templates/apps/api-saas-starter/mutations/projects.create.mutation.ts +9 -0
- package/templates/apps/api-saas-starter/package.json +15 -11
- package/templates/apps/api-saas-starter/queries/invites.list.query.ts +19 -8
- package/templates/apps/api-saas-starter/queries/projects.list.query.ts +18 -7
- package/templates/apps/api-saas-starter/tests/accessDecisions.test.ts +135 -0
- package/templates/apps/api-search/mutations/articles.create.mutation.ts +14 -0
- package/templates/apps/api-search/package.json +9 -8
- package/templates/apps/api-search/queries/articles.list.query.ts +21 -8
- package/templates/apps/api-status/README.md +10 -3
- package/templates/apps/api-status/app.config.ts +8 -3
- package/templates/apps/api-status/authz.ts +5 -3
- package/templates/apps/api-status/package.json +9 -8
- package/templates/apps/api-status/queries/components.list.query.ts +14 -6
- package/templates/apps/api-status/queries/incidents.live.query.ts +23 -10
- package/templates/apps/api-status/queries/updates.list.query.ts +16 -9
- package/templates/apps/api-status/tests/status.test.ts +9 -1
- package/templates/apps/api-versioning/actions/documents.asOf.action.ts +12 -0
- package/templates/apps/api-versioning/actions/documents.history.action.ts +13 -0
- package/templates/apps/api-versioning/mutations/documents.create.mutation.ts +9 -0
- package/templates/apps/api-versioning/mutations/documents.update.mutation.ts +12 -0
- package/templates/apps/api-versioning/package.json +9 -8
- package/templates/apps/api-webhooks/mutations/orders.fulfill.mutation.ts +16 -0
- package/templates/apps/api-webhooks/package.json +10 -9
- package/templates/apps/api-webhooks/queries/orders.list.query.ts +10 -0
- package/templates/apps/changelog/package.json +8 -6
- package/templates/apps/edge-functions/package.json +2 -2
- package/templates/apps/frontend-admin/package.json +10 -8
- package/templates/apps/frontend-admin/src/lib/admin.ts +20 -9
- package/templates/apps/frontend-admin/src/locales/de.ts +11 -1
- package/templates/apps/frontend-admin/src/locales/en.ts +13 -1
- package/templates/apps/frontend-admin/src/pages/admin/[entity]/page.tsx +65 -22
- package/templates/apps/frontend-admin/src/pages/admin/entity.test.tsx +130 -23
- package/templates/apps/frontend-admin/src/pages/admin/layout.tsx +3 -2
- package/templates/apps/frontend-admin/src/pages/admin/page.test.tsx +19 -2
- package/templates/apps/frontend-admin/src/pages/admin/page.tsx +9 -4
- package/templates/apps/frontend-app/app.config.ts +4 -3
- package/templates/apps/frontend-app/package.json +11 -8
- package/templates/apps/frontend-app/src/lib/api.ts +25 -0
- package/templates/apps/frontend-app/src/pages/page.test.tsx +130 -82
- package/templates/apps/frontend-app/src/pages/page.tsx +14 -18
- package/templates/apps/frontend-auth/package.json +10 -8
- package/templates/apps/frontend-blank/package.json +9 -7
- package/templates/apps/frontend-cms/package.json +11 -9
- package/templates/apps/frontend-collab/package.json +12 -9
- package/templates/apps/frontend-collab/src/pages/page.test.tsx +122 -78
- package/templates/apps/frontend-contact/package.json +9 -7
- package/templates/apps/frontend-dashboard/package.json +9 -7
- package/templates/apps/frontend-docs/package.json +9 -7
- package/templates/apps/frontend-i18n/package.json +8 -6
- package/templates/apps/frontend-landing/package.json +9 -7
- package/templates/apps/frontend-portal/package.json +10 -8
- package/templates/apps/frontend-saas/app.config.ts +10 -6
- package/templates/apps/frontend-saas/package.json +10 -8
- package/templates/apps/frontend-saas/src/lib/api.ts +27 -32
- package/templates/apps/frontend-saas/src/pages/dashboard/billing/page.tsx +7 -8
- package/templates/apps/frontend-saas/src/pages/dashboard/page.test.tsx +27 -3
- package/templates/apps/frontend-saas/src/pages/dashboard/page.tsx +4 -4
- package/templates/apps/frontend-saas/src/pages/dashboard/team/page.tsx +3 -4
- package/templates/apps/frontend-spa/package.json +9 -7
- package/templates/apps/frontend-ssr/package.json +9 -7
- package/templates/apps/frontend-ssr-api/package.json +10 -8
- package/templates/apps/frontend-static-blog/package.json +8 -6
- package/templates/apps/frontend-status/package.json +10 -8
- package/templates/apps/mobile-app/README.md +1 -0
- package/templates/apps/mobile-app/package.json +4 -2
- package/templates/apps/mobile-app/src/app/index.tsx +22 -12
- package/templates/apps/mobile-app/src/app/orders/[id].tsx +1 -1
- package/templates/apps/mobile-app/src/lib/api.ts +34 -0
- package/templates/apps/mobile-app/voltro.mobile.ts +4 -2
- package/templates/baselines/bare/.env.example +14 -0
- package/templates/baselines/bare/baseline.json +4 -4
- package/templates/baselines/compose/.env.example +14 -0
- package/templates/baselines/compose/README.md +1 -1
- package/templates/baselines/compose/baseline.json +5 -5
- package/templates/baselines/compose-mariadb/.env.example +14 -0
- package/templates/baselines/compose-mariadb/README.md +1 -1
- package/templates/baselines/compose-mariadb/baseline.json +5 -5
- package/templates/baselines/helm/.env.example +14 -0
- package/templates/baselines/helm/baseline.json +4 -4
- package/dist/apiBuild-OJEjtwcn.js +0 -2
- package/dist/checkCommand-CwMrzAgV.js +0 -2
- package/dist/commands-C0nEePif.js +0 -11457
- package/dist/dbCommand-By__Ev0R.js +0 -2
- package/dist/dbCommand-ifOMafuG.js +0 -1311
- package/dist/dev-rc3fwPSZ.js +0 -3
- package/dist/devActivity-BhIu6ncs.js +0 -159
- package/dist/frameworkTableAssembly-D-EebUQX.js +0 -2
- package/dist/inspect-mmBuRXmy.js +0 -2
- package/dist/manifestBuild-Dj8Jjoto.js +0 -2
- package/dist/seedRunner-Bqxgp7HZ.js +0 -230
- package/dist/serveCommand-PxMmn96o.js +0 -1578
- package/dist/start-D1-8eKrO.js +0 -1084
- /package/templates/apps/api-ai/actions/{summarize.action.server.tsx → summarize.action.server.ts} +0 -0
|
@@ -44,6 +44,11 @@ export default {
|
|
|
44
44
|
maxAttempts: 5, // per-record delivery attempts before dead-letter
|
|
45
45
|
backoffBaseMs: 200, // first retry delay; doubles per attempt, jittered
|
|
46
46
|
deliveryTimeoutMs: 10_000, // per-attempt timeout — aborts the sink call
|
|
47
|
+
leaseTtlMs: 15_000, // leader lease; heartbeat renews at ttl/3
|
|
48
|
+
// Fleet-scope handoff (see "Delivery guarantees"):
|
|
49
|
+
dedupWindowMs: 60_000, // how long an enqueue claim is kept — must exceed leaseTtlMs
|
|
50
|
+
handoffBufferMs: 60_000, // how far back each replica buffers for a takeover to drain
|
|
51
|
+
handoffBufferSize: 10_000, // hard ceiling on buffered changes per replica
|
|
47
52
|
}),
|
|
48
53
|
],
|
|
49
54
|
}
|
|
@@ -73,12 +78,44 @@ via `extendSchema`, migrated by `voltro dev`). The row's TypeID id **is** the
|
|
|
73
78
|
record's `deliveryKey` — unique across replicas, stable across restarts and
|
|
74
79
|
retries.
|
|
75
80
|
|
|
76
|
-
- **
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
- **Enqueue is de-duplicated per observed change, fleet-wide, across leadership
|
|
82
|
+
handovers — with one hole: a replica that dies between winning a change's
|
|
83
|
+
claim and inserting its outbox row loses that change, because the claim
|
|
84
|
+
survives and nothing rescans orphan claims.** (Those are two statements with
|
|
85
|
+
no transaction around them, which is why this does not say "exactly-once".)
|
|
86
|
+
|
|
87
|
+
On `changeScope: 'local'` stores each replica enqueues only its OWN commits
|
|
88
|
+
(injected cross-replica events are skipped), so a change is observed by
|
|
89
|
+
exactly one process and needs nothing further.
|
|
90
|
+
|
|
91
|
+
On `'fleet'` stores (postgres `changeStrategy: 'cdc'` LISTEN/NOTIFY, mysql
|
|
92
|
+
binlog) EVERY replica sees the full stream, so every replica **buffers** it
|
|
93
|
+
in memory (`handoffBufferMs`, capped at `handoffBufferSize` entries, oldest
|
|
94
|
+
dropped first). The holder of the leader lease (`_voltro_cdcout_leases`,
|
|
95
|
+
TTL-heartbeat) enqueues as it goes; a replica that WINS the lease drains the
|
|
96
|
+
window its predecessor never got to. Enqueue is **idempotent per change
|
|
97
|
+
identity**: each change is keyed by a `changeKey` every replica computes
|
|
98
|
+
alike — a digest of `(pipe, op, row id, new image, old image)` plus an
|
|
99
|
+
occurrence counter that keeps two byte-identical changes to one row apart —
|
|
100
|
+
and claimed in `_voltro_cdcout_claims` under `unique(pipe, changeKey)`. So
|
|
101
|
+
the rows the dying leader already wrote collapse instead of duplicating, and
|
|
102
|
+
the ones it never reached are written by its successor.
|
|
103
|
+
|
|
104
|
+
A replica that boots into a fleet that is **already running** adopts the
|
|
105
|
+
fleet's occurrence counters from the claims already in the database before it
|
|
106
|
+
keys anything — otherwise its first sighting of an already-claimed change
|
|
107
|
+
would key occurrence 0, collide, and be dropped as a duplicate it is not.
|
|
108
|
+
`GET /_voltro/inspect/plugins/cdc-out/sinks` reports `handoff.seeded` and
|
|
109
|
+
`handoff.awaitingSeed` so you can see that happen rather than assume it.
|
|
110
|
+
|
|
111
|
+
What still bounds it, stated plainly: a change **no surviving replica
|
|
112
|
+
observed** is gone (the transport delivered it only to the dead process); a
|
|
113
|
+
handoff that takes longer than `handoffBufferMs` loses whatever aged out of
|
|
114
|
+
the buffer, and that count is reported as `handoff.dropped` on
|
|
115
|
+
`GET /_voltro/inspect/plugins/cdc-out/sinks` rather than dropped silently.
|
|
116
|
+
`dedupWindowMs` (default `max(60_000, 4 × leaseTtlMs)`) is how long a claim
|
|
117
|
+
is kept; it **must exceed `leaseTtlMs`** — a claim that expires mid-handoff
|
|
118
|
+
is a duplicate window, and the plugin refuses to boot with one.
|
|
82
119
|
- **At-least-once FROM ENQUEUE.** The tap is post-commit — a crash in the
|
|
83
120
|
narrow window between commit and the outbox insert loses that one event;
|
|
84
121
|
the plugin does not claim better. From enqueue on, delivery survives
|
|
@@ -92,7 +129,9 @@ retries.
|
|
|
92
129
|
`GET /_voltro/inspect/plugins/cdc-out/dead-letter` — and unblocks the pipe.
|
|
93
130
|
- **Bounded storage.** Delivered/dead rows are purged by the framework
|
|
94
131
|
retention sweep after `retentionHours` (default 72, env
|
|
95
|
-
`CDCOUT_RETENTION_HOURS`); pending rows are never purged.
|
|
132
|
+
`CDCOUT_RETENTION_HOURS`); pending rows are never purged. Enqueue claims are
|
|
133
|
+
short-lived by design — purged after `dedupWindowMs`, which only has to
|
|
134
|
+
outlive a leadership handoff.
|
|
96
135
|
|
|
97
136
|
## Multi-tenancy
|
|
98
137
|
|
|
@@ -61,7 +61,7 @@ on graceful shutdown.
|
|
|
61
61
|
| `password` | `string` | — | |
|
|
62
62
|
| `database` | `string` | `'default'` | The plugin creates the events table inside it on first boot. |
|
|
63
63
|
| `table` | `string` | `'events'` | Override the events-table name. |
|
|
64
|
-
| `mirrorTables` | `ReadonlyArray<string>` | `[]` (events-only) | Reactive tables to CDC-mirror into `voltro_mirror_<table>` (a `ReplacingMergeTree`) so analytical queries JOIN events against live user data. |
|
|
64
|
+
| `mirrorTables` | `ReadonlyArray<string>` | `[]` (events-only) | Reactive tables to CDC-mirror into `voltro_mirror_<table>` (a `ReplacingMergeTree(version)` over `{ id, data, version, is_deleted }`) so analytical queries JOIN events against live user data. The version is the framework's commit-order stamp, so a change that arrives late loses the collapse. |
|
|
65
65
|
| `mirrorPrimaryKey` | `string` | `'id'` | Primary-key column on the mirrored source rows. |
|
|
66
66
|
|
|
67
67
|
`database`, `table`, and each `mirrorTables` entry are validated as SQL
|
|
@@ -53,7 +53,7 @@ connection + instance are closed on graceful shutdown.
|
|
|
53
53
|
| Option | Type | Default | Notes |
|
|
54
54
|
|---|---|---|---|
|
|
55
55
|
| `path` | `string` | in-memory | A file path (`.voltro/analytics.duckdb`) → durable across restarts, single-process. Omit or pass `:memory:` → events live in process memory, lost on restart (ephemeral dev / tests). |
|
|
56
|
-
| `mirrorTables` | `ReadonlyArray<string>` | `[]` (events-only) | Reactive tables to CDC-mirror into `voltro_mirror_<table>` inside DuckDB so analytical queries JOIN events against live user data. |
|
|
56
|
+
| `mirrorTables` | `ReadonlyArray<string>` | `[]` (events-only) | Reactive tables to CDC-mirror into `voltro_mirror_<table>` (`{ id, data, version, is_deleted }`) inside DuckDB so analytical queries JOIN events against live user data. Deletes write a tombstone — filter `is_deleted = false`. |
|
|
57
57
|
| `mirrorPrimaryKey` | `string` | `'id'` | Primary-key column on the mirrored source rows. |
|
|
58
58
|
|
|
59
59
|
```ts
|
|
@@ -109,6 +109,138 @@ GET /_voltro/inspect/plugins/flags/audit?flag=beta # one flag's history
|
|
|
109
109
|
|
|
110
110
|
The `POST /toggle` body accepts an optional `actor` (the acting admin id) that is stored on the audit row. On the `memory` tier there is no durable audit (the endpoint returns an empty trail with a note).
|
|
111
111
|
|
|
112
|
+
## Typed flags — `defineFlag()`
|
|
113
|
+
|
|
114
|
+
A flag's VALUE had no type. `FlagVariant.value` is the `FlagVariantValue` union (`string | number | boolean | null | array | object`), so `{ name: 'big', value: 'lots' }` on a flag every reader treats as a number typechecked, and the mistake showed up at the call site as `NaN`.
|
|
115
|
+
|
|
116
|
+
`defineFlag()` gives a flag a value **Schema**, and the flag is browser-safe by construction — ONE declaration, imported by `app.config.ts` and by the component that reads it.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
// apps/api/lib/flags.ts
|
|
120
|
+
import { Schema } from 'effect'
|
|
121
|
+
import { defineFlag } from '@voltro/plugin-flags'
|
|
122
|
+
|
|
123
|
+
export const checkoutButton = defineFlag({
|
|
124
|
+
key: 'checkout.button',
|
|
125
|
+
value: Schema.Literal('blue', 'green'),
|
|
126
|
+
default: 'blue',
|
|
127
|
+
variants: [{ name: 'control', value: 'blue' }, { name: 'green', value: 'green' }],
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
export const pageSize = defineFlag({
|
|
131
|
+
key: 'search.pageSize',
|
|
132
|
+
value: Schema.Number,
|
|
133
|
+
default: 20,
|
|
134
|
+
// default: 'twenty', ← Type 'string' is not assignable to type 'number'
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Register them with `flagsPlugin({ typedFlags: [checkoutButton, pageSize] })`. Keys share one namespace with `flags: { … }`; declaring a key in both is refused at construction.
|
|
139
|
+
|
|
140
|
+
Read them typed on either side:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { flagValue, flagVariant } from '@voltro/plugin-flags'
|
|
144
|
+
const size: number = flagValue(ctx, pageSize) // server
|
|
145
|
+
const arm = flagVariant(ctx, checkoutButton) // the served variant NAME, or null
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { useFlagValue } from '@voltro/plugin-flags/web'
|
|
150
|
+
const colour = useFlagValue(checkoutButton) // 'blue' | 'green'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Which half a Schema reaches, precisely
|
|
154
|
+
|
|
155
|
+
**Authored** values — `default`, every `variants[].value` — are checked by `tsc`. That is the headline and it is enforced by tests that fail `typecheck` if those lines ever start compiling.
|
|
156
|
+
|
|
157
|
+
**Runtime** values cannot be. A postgres-tier override row, or a dashboard edit, is JSON long after `tsc` ran. So the same Schema is the runtime gate: an override whose variant values do not decode is **refused whole**, the code-declared definition stands, and the refusal is logged and shown in the dashboard panel. Not partially applied — dropping the one bad arm re-normalises the weights of the rest, silently reallocating every subject.
|
|
158
|
+
|
|
159
|
+
Declaration also DECODES the authored default, which catches what a type cannot: `Schema.Int`'s TypeScript type is `number`, so `default: 20.5` typechecks and is a value the flag could never legally serve.
|
|
160
|
+
|
|
161
|
+
## Dead-flag detection
|
|
162
|
+
|
|
163
|
+
Every flag system accumulates flags nobody removes. `GET /_voltro/inspect/plugins/flags/list` carries a lifecycle report (rendered by the dashboard panel) built on two independent axes — and only some of it is a proof.
|
|
164
|
+
|
|
165
|
+
**`shape`** is decided from the DEFINITION alone. No observation, no window:
|
|
166
|
+
|
|
167
|
+
| shape | meaning |
|
|
168
|
+
|---|---|
|
|
169
|
+
| `constantOn` | `rollout` 100, no targeting, no variants, no live schedule — resolves `true` for everyone, forever |
|
|
170
|
+
| `constantOff` | `enabled: false`, or `rollout: 0` |
|
|
171
|
+
| `expired` | a `schedule.deactivateAt` that has passed — it can never be on again |
|
|
172
|
+
| `notYetActive` | a future `activateAt` — pending, not dead |
|
|
173
|
+
| `conditional` | genuinely selects between callers |
|
|
174
|
+
|
|
175
|
+
**`usage`** is decided from observed evaluations, and exactly one state is a proof:
|
|
176
|
+
|
|
177
|
+
| usage | meaning |
|
|
178
|
+
|---|---|
|
|
179
|
+
| `evaluated` | read server-side inside the threshold |
|
|
180
|
+
| `stale` | reads EXIST in the window and the newest is older than the threshold. **Provable** |
|
|
181
|
+
| `neverObserved` | no server-side read at all. Consistent with "dead" AND with "declared last Tuesday" — reported, never asserted, **never a removal candidate** |
|
|
182
|
+
| `untracked` | nothing is recording |
|
|
183
|
+
|
|
184
|
+
`removalCandidate` is set only by a proof: a constant/expired shape, or `stale`.
|
|
185
|
+
|
|
186
|
+
### What it cannot see
|
|
187
|
+
|
|
188
|
+
Shipped in the payload and rendered in the panel, not buried here:
|
|
189
|
+
|
|
190
|
+
- **Reachability is not decided.** "Not evaluated since \<date>" is a measurement; "this code path is dead" is not decidable in general. A Black-Friday flag, a flag behind an admin route nobody visited this month, and a flag whose last call site was deleted are indistinguishable.
|
|
191
|
+
- **Only SERVER-side reads count** — `isFlagEnabled` / `requireFlag` / `flagValue` / a `gatedBy` interception. `useFlag()` in the browser reads from the bulk set the server already sent, so the key never arrives as a named read. Bulk deliveries are recorded separately and never counted as use: one `useFlags()` poll evaluates the whole registry and would otherwise mark every flag in the app alive forever.
|
|
192
|
+
- **The window is finite**, bounded by the observation table's retention. A flag last read BEFORE the window has no observation at all and reads `neverObserved` — exactly what a flag declared this morning reads.
|
|
193
|
+
- On the day you turn tracking on, nothing has been observed, so every flag is `neverObserved` and nothing is proposed for removal. It is that SPLIT that prevents the day-one "everything is dead" report, not a coverage gate on top of it: such a gate is unreachable, because the observation that dates a stale flag is itself inside the window.
|
|
194
|
+
|
|
195
|
+
### Tunables
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
flagsPlugin({
|
|
199
|
+
store: 'postgres',
|
|
200
|
+
usage: {
|
|
201
|
+
track: true, // default: on with store:'postgres' (there is nowhere to write on memory)
|
|
202
|
+
flushIntervalMs: 300_000, // the report resolves to a DAY, so a tighter interval buys nothing
|
|
203
|
+
staleAfterDays: 30,
|
|
204
|
+
retentionDays: 90, // also VOLTRO_FLAG_USAGE_TTL_HOURS; the report's observation ceiling
|
|
205
|
+
},
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Observations land in `_voltro_feature_flag_usage`, one row per (flag, UTC day, source), retention-swept. `track: true` on the `memory` tier is refused at construction rather than silently observing nothing, and `staleAfterDays > retentionDays` is refused because staleness could then never be proven.
|
|
210
|
+
|
|
211
|
+
## A flag can carry an experiment
|
|
212
|
+
|
|
213
|
+
`defineExperiment` (`@voltro/runtime`) maintains standing A/B results as **live IVM aggregates recomputed per-write from CDC deltas** — real-time uplift with no batch pipeline. A flag can name one:
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
export const checkoutButton = defineFlag({
|
|
217
|
+
key: 'checkout.button',
|
|
218
|
+
value: Schema.Literal('blue', 'green'),
|
|
219
|
+
default: 'blue',
|
|
220
|
+
variants: [{ name: 'control', value: 'blue' }, { name: 'green', value: 'green' }],
|
|
221
|
+
experiment: 'checkout-colour',
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
// apps/api/experiments/checkoutColour.experiment.ts
|
|
225
|
+
export default defineExperiment({
|
|
226
|
+
name: 'checkout-colour',
|
|
227
|
+
on: { table: 'orders' },
|
|
228
|
+
variantFrom: 'checkoutArm', // ← the arm the FLAG served
|
|
229
|
+
variants: [{ name: 'control' }, { name: 'green' }],
|
|
230
|
+
metric: { kind: 'conversionRate', column: 'completed' },
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Persist the served arm on the row you want to measure:
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
await ctx.store.insert('orders', { …, checkoutArm: flagVariant(ctx, checkoutButton) })
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Why `variantFrom` and not just a name.** The flag assigns by hashing FNV-1a over `${key}:variant`; an experiment in `subject` mode hashes over the EXPERIMENT name. Both are stable and uniform, and they are INDEPENDENT — roughly half the subjects served `green` land in the experiment's `control` arm. The uplift would be live, precise, and measuring a split nobody experienced. One assignment, persisted, read by the experiment.
|
|
241
|
+
|
|
242
|
+
`flagsPlugin({ typedFlags, experiments })` **refuses to construct** when the link is wrong: a missing experiment, an experiment still in `subject` mode, an experiment-side holdout (carved AT assignment, which this experiment does not do), or arm names that do not match. Each of those is otherwise a wrong number rather than an error — a name mismatch shows up as a permanently-empty arm beside a permanently-full one, which reads as "the treatment has no effect".
|
|
243
|
+
|
|
112
244
|
## Three ways to use a flag
|
|
113
245
|
|
|
114
246
|
**1. Declarative gate** — `gatedBy: { '<rpcTag>': '<flag>' }` (exact tag or `/regex/`). An off flag fails the call with typed `FlagDisabled` before the handler runs (merged into every procedure's wire-error union → typed on the client).
|
|
@@ -29,11 +29,11 @@ export default {
|
|
|
29
29
|
{ table: 'events', ttlMs: 90 * 86_400_000 }, // delete after 90 days
|
|
30
30
|
{ table: 'users', ttlMs: 365 * 86_400_000, action: 'anonymize', anonymizeFields: ['email', 'name'] },
|
|
31
31
|
],
|
|
32
|
-
// GDPR: which tables
|
|
32
|
+
// GDPR: DERIVE which tables hold a subject's data from the schema.
|
|
33
|
+
deriveSubjectScopes: { subjectTable: 'users' },
|
|
34
|
+
// …plus anything the schema cannot encode (see below).
|
|
33
35
|
subjectScopes: [
|
|
34
|
-
{ table: '
|
|
35
|
-
{ table: 'posts', subjectField: 'userId' },
|
|
36
|
-
{ table: 'comments', subjectField: 'authorId' },
|
|
36
|
+
{ table: 'audit_trail', subjectField: 'actorRef' },
|
|
37
37
|
],
|
|
38
38
|
sweepIntervalMs: 3_600_000, // default 1h
|
|
39
39
|
}),
|
|
@@ -47,13 +47,111 @@ export default {
|
|
|
47
47
|
|
|
48
48
|
## GDPR — export + erasure (admin-gated)
|
|
49
49
|
|
|
50
|
-
Two admin-only routes (guarded by `requireScope(ADMIN_SCOPE)`)
|
|
50
|
+
Two admin-only routes (guarded by `requireScope(ADMIN_SCOPE)`):
|
|
51
51
|
|
|
52
|
-
- **`governance.export`** `{ subjectId }` → a portable bundle `{ [table]: rows[] }` of everything
|
|
53
|
-
- **`governance.erase`** `{ subjectId, mode? }` → deletes (or anonymises) the subject across every scope; returns an immutable `ErasureLogEntry` (`{ subjectId, at, mode, affected: [{ table, count }] }`).
|
|
52
|
+
- **`governance.export`** `{ subjectId }` → a portable bundle `{ [table]: rows[] }` of everything belonging to the subject.
|
|
53
|
+
- **`governance.erase`** `{ subjectId, mode? }` → deletes (or anonymises) the subject across every scope; returns an immutable `ErasureLogEntry` (`{ subjectId, at, mode, affected: [{ table, count }], truncated? }`).
|
|
54
54
|
|
|
55
55
|
The same operations are available in-handler via `GovernanceService` (`exportSubject` / `eraseSubject`).
|
|
56
56
|
|
|
57
|
+
Erasure runs **deepest-first** — children before parents — so a real foreign key
|
|
58
|
+
neither refuses the delete nor cascades through rows the log entry never counted.
|
|
59
|
+
|
|
60
|
+
### The subject scope is DERIVED from your schema
|
|
61
|
+
|
|
62
|
+
A hand-written list of "every table holding this person's data" is wrong the day
|
|
63
|
+
after someone adds a table — and that list *is* the compliance claim. So
|
|
64
|
+
`deriveSubjectScopes: { subjectTable: 'users' }` walks the schema instead: the
|
|
65
|
+
relations registry plus the `reference()` column graph, outward from the subject.
|
|
66
|
+
|
|
67
|
+
That reaches rows a flat `{ table, subjectField }` entry cannot even express —
|
|
68
|
+
`users → posts → comments` is two hops, so a comment on the subject's post is in
|
|
69
|
+
the export without anyone listing `comments`.
|
|
70
|
+
|
|
71
|
+
**Only CHILD edges are followed** — a table holding a reference to the subject's
|
|
72
|
+
row. Never a parent or lookup edge, and a `manyToMany` follows the JUNCTION only.
|
|
73
|
+
Getting that backwards would not be an over-broad export; it would be an erasure
|
|
74
|
+
that walks from one member into their organisation and deletes everybody else's
|
|
75
|
+
rows.
|
|
76
|
+
|
|
77
|
+
| declaration | followed? |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `many(posts, { foreignKey: 'authorId' })` | ✓ the target carries the FK |
|
|
80
|
+
| `one(profile)` with the FK on the target | ✓ a 1:1 child |
|
|
81
|
+
| `one(country, { sourceKey: 'countryId' })` | — a lookup this row points AT |
|
|
82
|
+
| `manyToMany(orgs, { through: memberships })` | ✓ `memberships` only, never `orgs` |
|
|
83
|
+
| a `reference()` column with no `relations()` block | ✓ found in the column graph |
|
|
84
|
+
|
|
85
|
+
`subjectScopes` is still first-class and is **unioned on top**, never replaced.
|
|
86
|
+
It is the only way to reach a link the schema does not encode: a subject id in a
|
|
87
|
+
plain (non-`reference()`) column, a polymorphic `(ownerType, ownerId)` pair, an
|
|
88
|
+
id inside JSON.
|
|
89
|
+
|
|
90
|
+
### What the derivation cannot see — and says so
|
|
91
|
+
|
|
92
|
+
A list of reachable tables, printed alone, reads as a completeness claim. So the
|
|
93
|
+
blind spots ship in the same payload:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const gov = yield* GovernanceService
|
|
97
|
+
const { paths, limitations } = gov.subjectGraph()
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
…and at `GET /_voltro/inspect/plugins/governance/subject-graph`. `limitations`
|
|
101
|
+
names every table nothing links to the subject (`unreachable`), everything cut by
|
|
102
|
+
the depth ceiling (`depth-truncated`, default 4 hops) and everything you excluded.
|
|
103
|
+
Structurally outside the graph in every case: **object storage and uploaded
|
|
104
|
+
files, external processors, log and metric sinks, backups, and any subject id
|
|
105
|
+
embedded in JSON or free text.**
|
|
106
|
+
|
|
107
|
+
The plugin also warns at boot if a derived scope reaches one table or fewer —
|
|
108
|
+
that is what a typo'd `subjectTable` looks like, and it is otherwise
|
|
109
|
+
indistinguishable from a working configuration until the first DSAR.
|
|
110
|
+
|
|
111
|
+
### `voltro privacy`
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
voltro privacy scope --subject-table users # the graph + its blind spots, OFFLINE
|
|
115
|
+
voltro privacy scope --json # { reachable, unreachable, depthTruncated }
|
|
116
|
+
voltro privacy export usr_123 --url https://api.example.com --out bundle.json
|
|
117
|
+
voltro privacy erase usr_123 --url https://api.example.com --confirm
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`scope` needs no database and no running app — schema only, so it belongs in CI
|
|
121
|
+
and in a PR review, where "does our erasure still reach every table" is a question
|
|
122
|
+
somebody can still act on.
|
|
123
|
+
|
|
124
|
+
`export` / `erase` deliberately go through the **running app's** admin-gated
|
|
125
|
+
governance endpoint rather than opening their own connection. A CLI that erased
|
|
126
|
+
directly would bypass your configured `anonymizeFields` and exclusions, bypass the
|
|
127
|
+
erasure log (which is the compliance artefact, not a nicety), and work against a
|
|
128
|
+
schema the deployed app may not be running. `erase` refuses without `--confirm`,
|
|
129
|
+
without `--url`, and without an inspect credential.
|
|
130
|
+
|
|
131
|
+
### Scale
|
|
132
|
+
|
|
133
|
+
Every read is `WHERE <column> IN (<keys>)` on an indexed column, chunked at 500
|
|
134
|
+
keys and memoised across paths that share a prefix — not a full table scan per
|
|
135
|
+
scope. Per table, 50 000 rows is the ceiling; hitting it sets `truncated` on the
|
|
136
|
+
erasure-log entry and exits non-zero from the CLI, because a short erasure
|
|
137
|
+
presented as complete is exactly the failure this is built to prevent.
|
|
138
|
+
|
|
139
|
+
### Crypto-shredding is NOT supported — and should not be faked
|
|
140
|
+
|
|
141
|
+
"Erase a subject by destroying their key" needs a key **per subject**. The shipped
|
|
142
|
+
cipher is one app-wide passphrase-derived key, so there is nothing subject-shaped
|
|
143
|
+
to destroy: deleting it would make *every* subject's `.encrypted()` columns
|
|
144
|
+
unreadable, which is an outage, not an erasure. Per-subject shredding needs
|
|
145
|
+
envelope encryption — a DEK per subject, wrapped by a KEK, with every existing
|
|
146
|
+
ciphertext re-wrapped — which is a re-architecture of the cipher rather than a
|
|
147
|
+
mode of `eraseSubject`.
|
|
148
|
+
|
|
149
|
+
What makes its absence cost less than it sounds: `.encrypted()` columns are
|
|
150
|
+
decrypted transparently on read, so `delete` removes the ciphertext row and
|
|
151
|
+
`anonymize` overwrites the ciphertext with a null. Both erase the data itself
|
|
152
|
+
rather than the key guarding it. Crypto-shredding is an optimisation for erasure
|
|
153
|
+
at rest across backups; it is not the only route to Art. 17.
|
|
154
|
+
|
|
57
155
|
## Consent ledger
|
|
58
156
|
|
|
59
157
|
`governance.consent` `{ purpose, granted }` records the calling subject's decision; `governance.hasConsent` `{ purpose }` reads the latest (latest-write-wins per `(subject, purpose)`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Multi-tenancy
|
|
2
2
|
|
|
3
|
-
> The tenant() schema mixin (auto-
|
|
3
|
+
> The tenant() schema mixin (auto-scoped reads, auto-filled inserts, tenant-resolved keyed writes), the assertOwnTenant write-guard, and the typed TenantMismatch error.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<!-- source: en/plugins/multitenancy.md -->
|
|
10
10
|
## Multi-tenancy
|
|
11
11
|
|
|
12
|
-
_The tenant() schema mixin (auto-
|
|
12
|
+
_The tenant() schema mixin (auto-scoped reads, auto-filled inserts, tenant-resolved keyed writes), the assertOwnTenant write-guard, and the typed TenantMismatch error._
|
|
13
13
|
|
|
14
14
|
`@voltro/plugin-multitenancy` is the first-party multi-tenancy primitive. It has two surfaces: a **schema mixin** (`tenant()`) and a **write-time guard** (`assertOwnTenant` + the typed `TenantMismatch` error).
|
|
15
15
|
|
|
@@ -37,11 +37,13 @@ for projects that don't want the full barrel.
|
|
|
37
37
|
What the runtime does for a `tenant()`-marked table:
|
|
38
38
|
|
|
39
39
|
- **Reads are auto-scoped.** The runtime AND-merges `eq('tenantId', subject.tenantId)` into every subscription predicate against the table — tenant A never sees tenant B's rows, and a write in tenant A never wakes a subscription in tenant B.
|
|
40
|
-
- **
|
|
40
|
+
- **Inserts are auto-filled.** On insert, `tenantId` is stamped from `ctx.request.subject.tenantId` when the caller didn't pass it explicitly. The wrapper never overrides a value the caller did pass, and it refuses the insert outright when the subject has no tenant.
|
|
41
|
+
- **Set-based writes are auto-scoped.** `updateMany` / `deleteMany` and the fluent `update(t).where(...)` / `delete(t).where(...)` builders get the same `eq('tenantId', …)` AND-merged onto their `WHERE`, so a tenant-blind predicate is confined rather than executed as written.
|
|
42
|
+
- **Keyed-by-id writes are resolved inside the tenant.** `update(t, id, patch)`, `delete(t, id)`, `hardDelete(t, id)` and `patchJson(t, id, …)` address a row by primary key, so the runtime resolves that key within `subject.tenantId` first and fails with `TenantRowNotFound` (`@voltro/runtime`) when there is no such row there. The error is raised identically whether the row is missing or belongs to another tenant — reporting the two differently would let a caller probe for row ids in other tenants.
|
|
41
43
|
|
|
42
44
|
## The write-guard — `assertOwnTenant`
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
Isolation itself is enforced by the runtime on every path above. What `assertOwnTenant` covers is the one question the framework deliberately does not answer for you: a mutation whose input carries an explicit `tenantId` it intends to USE. Without a check, a client authenticated as tenant A could submit `tenantId: 'B'` and your handler would happily read that claim. Guard such a mutation:
|
|
45
47
|
|
|
46
48
|
```ts
|
|
47
49
|
import { assertOwnTenant, TenantMismatch } from '@voltro/plugin-multitenancy'
|
|
@@ -54,6 +56,8 @@ const execute = async (input: { tenantId: string }, ctx) => {
|
|
|
54
56
|
|
|
55
57
|
`assertOwnTenant(inputTenantId, subject)` throws `TenantMismatch` when `inputTenantId` doesn't equal the subject's `tenantId`. Anonymous subjects have no tenant scope at all, so the guard always throws for them — anonymous + tenant-scoped writes need an `apiKey` / `serviceAccount` subject instead.
|
|
56
58
|
|
|
59
|
+
It checks a **claimed** `input.tenantId`, so a mutation whose input carries none never reaches it. That is why it is an early, typed convenience and not the boundary — the boundary is the store enforcement listed above.
|
|
60
|
+
|
|
57
61
|
## The typed error — `TenantMismatch`
|
|
58
62
|
|
|
59
63
|
`TenantMismatch` is a `Schema.TaggedError` carrying `inputTenantId` + `subjectTenantId` (empty string for anonymous subjects). Declare it on the mutation's `error:` schema so the rpc layer surfaces the rejection typed. **Import it from the browser-safe `@voltro/plugin-multitenancy/guard` subpath in the descriptor (`*.mutation.ts`)** — the package root also re-exports the schema mixin, which pulls `@voltro/database` into the client rpcGroup bundle (a browser-safety violation):
|
|
@@ -65,6 +69,7 @@ import { Schema } from 'effect'
|
|
|
65
69
|
|
|
66
70
|
export const createProject = defineMutation({
|
|
67
71
|
name: 'projects.create',
|
|
72
|
+
guards: [{ scope: 'projects:write' }], // WHO may call; TenantMismatch bounds WHICH tenant
|
|
68
73
|
input: Schema.Struct({ tenantId: Schema.String, name: Schema.String }),
|
|
69
74
|
output: Schema.Struct({ id: Schema.String }),
|
|
70
75
|
error: TenantMismatch,
|
|
@@ -45,7 +45,16 @@ const Room = ({ channel }: { channel: string }) => {
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
`usePresence(channel, opts)` heartbeats on an interval (`heartbeatMs`, default 15s) and publishes per-member `meta` (status, cursor position, …). The roster is **push-driven** — `presence.list` is a reactive plugin query
|
|
48
|
+
`usePresence(channel, opts)` heartbeats on an interval (`heartbeatMs`, default 15s) and publishes per-member `meta` (status, cursor position, …). The roster is **push-driven** — `presence.list` is a reactive plugin query whose `source:` is a [reactivity channel](/docs/data/subscriptions#reactivity-channels), so the framework pushes a fresh roster over the subscription transport with NO client polling. `key` defaults to the subject id; pass an explicit `key` for anonymous members.
|
|
49
|
+
|
|
50
|
+
A member is `{ key, meta }`. **It pushes only when the roster actually moves** — a join, a leave, a change to someone's `meta`, a sweep, a peer's delta, a peer's death. A heartbeat that repeats what the server already knows pushes nothing, which is what keeps a large steady room free.
|
|
51
|
+
|
|
52
|
+
> **There is a second `usePresence`, and it is a different hook.**
|
|
53
|
+
> [`@voltro/local-first/react`](/docs/local-first/overview#presence--awareness)
|
|
54
|
+
> exports one for peer-to-peer *awareness* — `usePresence(roomId, self, { channel })`
|
|
55
|
+
> → `{ presence, others, setPresence }` — carrying high-frequency cursor and
|
|
56
|
+
> selection state over a pub/sub channel. This one is the server-backed roster.
|
|
57
|
+
> Different packages, different signatures; pick by the question you are asking.
|
|
49
58
|
|
|
50
59
|
## Typing indicator
|
|
51
60
|
|
|
@@ -85,7 +94,9 @@ an event declared `delivery: 'latest'` rather than in presence metadata.
|
|
|
85
94
|
|
|
86
95
|
## Notes
|
|
87
96
|
|
|
88
|
-
- The roster is push-driven: `presence.list`
|
|
97
|
+
- The roster is push-driven: `presence.list` declares a [reactivity channel](/docs/data/subscriptions#reactivity-channels) as its `source:`, so the framework re-runs it and pushes deltas over the subscription transport — no client polling. There is **no table**, and there is no longer a table NAME either: presence used to declare `_voltro_presence` and never write to it, purely to own a name the reactivity layer would route on. If you have an existing `_voltro_presence`, it is empty and the upgrade does not drop it (the differ never plans a drop for a framework table no app declares) — remove it by hand when convenient.
|
|
98
|
+
- **A repeat heartbeat does not push.** Measured on this machine at 2.7 µs per subscriber per publish, an unconditional push cost a steady room of N clients N² × that per heartbeat interval — ~107 ms of CPU per 15s at N=200, and a per-node ceiling around 750 subscribers that nothing in the app controlled. Publishing only on a real change removes that term entirely; what remains is linear in actual roster churn. Reproduce with `node --import tsx packages/plugin-presence/scripts/rosterFanoutBody.ts`.
|
|
99
|
+
- **A member has no `lastSeen`.** It used to, and it was the owning replica's clock — "active 3 minutes ago" rendered from it is wrong by whatever the skew between two pods is. Use `meta` for anything you need to show.
|
|
89
100
|
- A member counts as online for `timeoutMs` after its last heartbeat. The sweep runs every `timeoutMs / 3`, so a vanished member is gone within roughly 1.3× the window.
|
|
90
101
|
- The sweep needs **no cluster coordination**, and that follows from the design rather than being a shortcut: every member is owned by exactly one replica and nobody else may touch it, so each replica sweeps its own and there is nothing to contend over. (The table version *did* need coordination — its rows were shared.)
|
|
91
102
|
|
|
@@ -22,6 +22,15 @@ upgrade — never the individual calls. The Effect-native rpc interceptors are
|
|
|
22
22
|
the only surface that sees each call **and** the resolved subject (needed for
|
|
23
23
|
per-tenant limits).
|
|
24
24
|
|
|
25
|
+
> **This plugin is opt-in, and nothing rate-limits your RPC surface until you add it.**
|
|
26
|
+
> There is no built-in per-IP, per-API-key or per-tenant request cap — an app that
|
|
27
|
+
> does not install and configure `@voltro/plugin-ratelimit` accepts calls as fast as
|
|
28
|
+
> they arrive. The one throttle that *is* on by default is `plugin-auth`'s
|
|
29
|
+
> [brute-force lockout](/docs/authentication/passwords#brute-force-lockout) on sign-in,
|
|
30
|
+
> and it only covers credential attempts. Put a per-IP cap at your ingress as well —
|
|
31
|
+
> see [production hardening](/docs/deployment/production-hardening); that layer holds
|
|
32
|
+
> per-IP state across replicas, which an in-process limiter cannot.
|
|
33
|
+
|
|
25
34
|
Live — `demo.limited` is capped at 5/min per visitor; the 6th call within a
|
|
26
35
|
minute fails with the typed `RateLimited` error (carrying `retryAfterMs`):
|
|
27
36
|
|