@invictus-group-ai/orchestra 0.5.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/LICENSE +21 -0
- package/LICENSING.md +49 -0
- package/README.md +507 -0
- package/assets/settings-template.json +99 -0
- package/bin/invi.js +6 -0
- package/content-dist/LICENSE +95 -0
- package/content-dist/PIPELINE.md +823 -0
- package/content-dist/README.md +128 -0
- package/content-dist/agents/README.md +135 -0
- package/content-dist/agents/mapping.json +476 -0
- package/content-dist/agents/stacks/backend-django.md +66 -0
- package/content-dist/agents/stacks/backend-dotnet.md +72 -0
- package/content-dist/agents/stacks/backend-fastapi.md +66 -0
- package/content-dist/agents/stacks/backend-laravel.md +66 -0
- package/content-dist/agents/stacks/backend-node.md +66 -0
- package/content-dist/agents/stacks/backend-spring.md +66 -0
- package/content-dist/agents/stacks/desktop-delphi.md +73 -0
- package/content-dist/agents/stacks/frontend-angular.md +65 -0
- package/content-dist/agents/stacks/frontend-react.md +67 -0
- package/content-dist/agents/stacks/frontend-svelte.md +67 -0
- package/content-dist/agents/stacks/frontend-vue.md +66 -0
- package/content-dist/agents/stacks/mobile-flutter.md +68 -0
- package/content-dist/agents/stacks/wordpress.md +66 -0
- package/content-dist/agents/universal/invi-qa.md +57 -0
- package/content-dist/agents/universal/invi-reviewer.md +61 -0
- package/content-dist/agents/universal/invi-security.md +55 -0
- package/content-dist/agents/universal/invi-tester.md +55 -0
- package/content-dist/agents/universal/invi-ui.md +85 -0
- package/content-dist/fragments/base.md +37 -0
- package/content-dist/fragments/domain/api-publica-rate-limiting.md +83 -0
- package/content-dist/fragments/domain/autenticacao-enterprise.md +86 -0
- package/content-dist/fragments/domain/busca-elasticsearch.md +86 -0
- package/content-dist/fragments/domain/dashboard-admin-rbac.md +80 -0
- package/content-dist/fragments/domain/design-system.md +71 -0
- package/content-dist/fragments/domain/ecommerce-completo.md +86 -0
- package/content-dist/fragments/domain/filas-jobs.md +80 -0
- package/content-dist/fragments/domain/integracao-crm-erp.md +82 -0
- package/content-dist/fragments/domain/lgpd.md +84 -0
- package/content-dist/fragments/domain/multi-tenancy.md +79 -0
- package/content-dist/fragments/domain/notificacoes-multicanal.md +81 -0
- package/content-dist/fragments/domain/pagamentos-brasil.md +85 -0
- package/content-dist/fragments/domain/plataforma-conteudo.md +77 -0
- package/content-dist/fragments/domain/realtime-websockets.md +92 -0
- package/content-dist/fragments/domain/relatorios-analytics.md +80 -0
- package/content-dist/fragments/domain/saas-stripe-billing.md +79 -0
- package/content-dist/fragments/domain/sistema-pagamentos.md +81 -0
- package/content-dist/fragments/domain/upload-midia.md +81 -0
- package/content-dist/fragments/domain/whatsapp-business.md +82 -0
- package/content-dist/fragments/index.json +1670 -0
- package/content-dist/fragments/references/angular-ngrx/app-config-and-testing.md +81 -0
- package/content-dist/fragments/references/angular-ngrx/store-pattern.md +155 -0
- package/content-dist/fragments/references/ansible-server-setup/layout-and-config.md +143 -0
- package/content-dist/fragments/references/ansible-server-setup/roles.md +238 -0
- package/content-dist/fragments/references/api-publica-rate-limiting/patterns.md +68 -0
- package/content-dist/fragments/references/astro-static/content-and-islands.md +117 -0
- package/content-dist/fragments/references/autenticacao-enterprise/pitfalls.md +70 -0
- package/content-dist/fragments/references/busca-elasticsearch/patterns.md +100 -0
- package/content-dist/fragments/references/chrome-extension-mv3/messaging-and-storage.md +109 -0
- package/content-dist/fragments/references/cli-typescript-commander/commands-and-config.md +136 -0
- package/content-dist/fragments/references/cloud-run-gcp/build-and-deploy.md +127 -0
- package/content-dist/fragments/references/cloud-run-gcp/iam-secrets-networking.md +65 -0
- package/content-dist/fragments/references/computer-vision-yolo/serving-and-export.md +182 -0
- package/content-dist/fragments/references/computer-vision-yolo/training-and-validation.md +131 -0
- package/content-dist/fragments/references/convex-react/functions.md +117 -0
- package/content-dist/fragments/references/convex-react/react-and-storage.md +109 -0
- package/content-dist/fragments/references/dashboard-admin-rbac/patterns.md +73 -0
- package/content-dist/fragments/references/data-pipeline-airflow/dag-patterns.md +149 -0
- package/content-dist/fragments/references/data-pipeline-airflow/operations.md +74 -0
- package/content-dist/fragments/references/delphi-object-pascal/legacy-extraction.md +175 -0
- package/content-dist/fragments/references/django-drf-celery/celery-tasks.md +47 -0
- package/content-dist/fragments/references/django-drf-celery/viewsets-and-serializers.md +92 -0
- package/content-dist/fragments/references/docker-compose-dev/compose-files.md +146 -0
- package/content-dist/fragments/references/docker-compose-dev/dockerfile-and-proxy.md +108 -0
- package/content-dist/fragments/references/dotnet-aspnet/data-and-di.md +90 -0
- package/content-dist/fragments/references/dotnet-aspnet/web-layer.md +88 -0
- package/content-dist/fragments/references/ecommerce-completo/patterns.md +76 -0
- package/content-dist/fragments/references/electron-app/ipc-bridge.md +123 -0
- package/content-dist/fragments/references/electron-app/security-and-packaging.md +134 -0
- package/content-dist/fragments/references/elixir-phoenix/context-and-web.md +112 -0
- package/content-dist/fragments/references/elixir-phoenix/processes.md +65 -0
- package/content-dist/fragments/references/filas-jobs/patterns.md +116 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/data-and-export.md +114 -0
- package/content-dist/fragments/references/fine-tuning-huggingface/training-and-lora.md +123 -0
- package/content-dist/fragments/references/flutter/platform-channels-and-goldens.md +68 -0
- package/content-dist/fragments/references/flutter/state-and-widgets.md +95 -0
- package/content-dist/fragments/references/github-actions-cicd/workflows.md +235 -0
- package/content-dist/fragments/references/go-chi-gorm/http-layer.md +87 -0
- package/content-dist/fragments/references/go-chi-gorm/service-layer.md +58 -0
- package/content-dist/fragments/references/graphql-apollo/resolvers-and-loaders.md +128 -0
- package/content-dist/fragments/references/hono-bun/patterns.md +144 -0
- package/content-dist/fragments/references/integracao-crm-erp/patterns.md +100 -0
- package/content-dist/fragments/references/kubernetes-helm/chart-templates.md +162 -0
- package/content-dist/fragments/references/kubernetes-helm/secrets-storage-deploy.md +78 -0
- package/content-dist/fragments/references/langchain-python-agent/agent-and-cost.md +120 -0
- package/content-dist/fragments/references/langchain-python-agent/memory-and-resilience.md +76 -0
- package/content-dist/fragments/references/laravel/eloquent-and-queues.md +126 -0
- package/content-dist/fragments/references/laravel/http-layer.md +110 -0
- package/content-dist/fragments/references/lgpd/patterns.md +110 -0
- package/content-dist/fragments/references/llm-ops-production/routing-and-budget.md +118 -0
- package/content-dist/fragments/references/llm-ops-production/tracing-eval-ab.md +102 -0
- package/content-dist/fragments/references/microservices-docker/compose-and-gateway.md +93 -0
- package/content-dist/fragments/references/microservices-docker/events-and-correlation.md +88 -0
- package/content-dist/fragments/references/ml-fastapi-serving/metrics-drift-docker.md +97 -0
- package/content-dist/fragments/references/ml-fastapi-serving/serving-core.md +155 -0
- package/content-dist/fragments/references/ml-training-pipeline/dvc-pipeline.md +102 -0
- package/content-dist/fragments/references/ml-training-pipeline/mlflow-registry-ci.md +139 -0
- package/content-dist/fragments/references/monitoring-observability/alerts-and-config.md +169 -0
- package/content-dist/fragments/references/monitoring-observability/instrumentation-node.md +139 -0
- package/content-dist/fragments/references/multi-tenancy/patterns.md +85 -0
- package/content-dist/fragments/references/nestjs-typescript/guards-and-decorators.md +103 -0
- package/content-dist/fragments/references/nestjs-typescript/modules-dtos-setup.md +106 -0
- package/content-dist/fragments/references/nextjs-app-router/patterns.md +177 -0
- package/content-dist/fragments/references/nextjs-prisma-postgres/billing.md +167 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/data-and-auth.md +121 -0
- package/content-dist/fragments/references/nextjs-trpc-drizzle/trpc-setup.md +62 -0
- package/content-dist/fragments/references/nodejs-express-typescript/config-and-tokens.md +48 -0
- package/content-dist/fragments/references/nodejs-express-typescript/middleware.md +108 -0
- package/content-dist/fragments/references/notificacoes-multicanal/patterns.md +78 -0
- package/content-dist/fragments/references/nuxt3-tailwind/server-routes.md +79 -0
- package/content-dist/fragments/references/nuxt3-tailwind/state-and-fetching.md +129 -0
- package/content-dist/fragments/references/openai-api-integration/calls.md +210 -0
- package/content-dist/fragments/references/openai-api-integration/client-and-cost.md +71 -0
- package/content-dist/fragments/references/pagamentos-brasil/gateways-reconciliation.md +92 -0
- package/content-dist/fragments/references/pagamentos-brasil/pix-boleto.md +115 -0
- package/content-dist/fragments/references/plataforma-conteudo/patterns.md +74 -0
- package/content-dist/fragments/references/python-fastapi/dependency-injection.md +99 -0
- package/content-dist/fragments/references/python-fastapi/settings-and-tasks.md +47 -0
- package/content-dist/fragments/references/rag-pipeline/ingestion.md +92 -0
- package/content-dist/fragments/references/rag-pipeline/retrieval-and-eval.md +148 -0
- package/content-dist/fragments/references/react-express-monolith/auth-and-client.md +110 -0
- package/content-dist/fragments/references/react-express-monolith/monorepo.md +71 -0
- package/content-dist/fragments/references/react-native-expo/native-patterns.md +103 -0
- package/content-dist/fragments/references/react-native-expo/navigation-and-auth.md +55 -0
- package/content-dist/fragments/references/react-ts-zustand-query/store-and-query.md +152 -0
- package/content-dist/fragments/references/react-typescript/feature-module.md +64 -0
- package/content-dist/fragments/references/react-typescript/forms-and-state.md +69 -0
- package/content-dist/fragments/references/react-typescript/recipes.md +37 -0
- package/content-dist/fragments/references/react-typescript/testing.md +40 -0
- package/content-dist/fragments/references/realtime-websockets/patterns.md +92 -0
- package/content-dist/fragments/references/relatorios-analytics/patterns.md +81 -0
- package/content-dist/fragments/references/remix-express-full/auth-and-uploads.md +88 -0
- package/content-dist/fragments/references/remix-express-full/express-server.md +54 -0
- package/content-dist/fragments/references/remix-typescript/auth-and-db.md +68 -0
- package/content-dist/fragments/references/remix-typescript/loaders-and-actions.md +98 -0
- package/content-dist/fragments/references/rust-axum/error-and-state.md +99 -0
- package/content-dist/fragments/references/rust-axum/handlers.md +87 -0
- package/content-dist/fragments/references/saas-stripe-billing/patterns.md +86 -0
- package/content-dist/fragments/references/serverless-lambda/handler-patterns.md +107 -0
- package/content-dist/fragments/references/sistema-pagamentos/pitfalls.md +54 -0
- package/content-dist/fragments/references/spring-boot/service-and-data.md +96 -0
- package/content-dist/fragments/references/spring-boot/web-layer.md +100 -0
- package/content-dist/fragments/references/supabase-nextjs/clients-and-middleware.md +102 -0
- package/content-dist/fragments/references/supabase-nextjs/rls-and-storage.md +86 -0
- package/content-dist/fragments/references/svelte-sveltekit/hooks-and-state.md +67 -0
- package/content-dist/fragments/references/svelte-sveltekit/load-and-actions.md +80 -0
- package/content-dist/fragments/references/t3-stack/routers-and-callers.md +75 -0
- package/content-dist/fragments/references/t3-stack/trpc-setup.md +60 -0
- package/content-dist/fragments/references/terraform-aws/modules-and-ci.md +114 -0
- package/content-dist/fragments/references/terraform-aws/state-and-workspaces.md +66 -0
- package/content-dist/fragments/references/turborepo-monorepo/pipeline-and-packages.md +84 -0
- package/content-dist/fragments/references/upload-midia/patterns.md +80 -0
- package/content-dist/fragments/references/vector-search-pinecone/client-and-upsert.md +98 -0
- package/content-dist/fragments/references/vector-search-pinecone/query-and-hybrid.md +81 -0
- package/content-dist/fragments/references/vps-deploy-producao/compose-prod.md +97 -0
- package/content-dist/fragments/references/vps-deploy-producao/proxy-and-operations.md +118 -0
- package/content-dist/fragments/references/vscode-extension/activation-and-tree.md +98 -0
- package/content-dist/fragments/references/vscode-extension/webview-csp.md +57 -0
- package/content-dist/fragments/references/vue3-pinia-vite/components-and-stores.md +73 -0
- package/content-dist/fragments/references/vue3-pinia-vite/queries-forms-testing.md +100 -0
- package/content-dist/fragments/references/whatsapp-business/patterns.md +107 -0
- package/content-dist/fragments/references/wordpress/hooks-and-security.md +92 -0
- package/content-dist/fragments/references/wordpress/wp-cli-gates.md +64 -0
- package/content-dist/fragments/stack/angular-ngrx.md +75 -0
- package/content-dist/fragments/stack/ansible-server-setup.md +69 -0
- package/content-dist/fragments/stack/astro-static.md +72 -0
- package/content-dist/fragments/stack/chrome-extension-mv3.md +66 -0
- package/content-dist/fragments/stack/cli-typescript-commander.md +66 -0
- package/content-dist/fragments/stack/cloud-run-gcp.md +63 -0
- package/content-dist/fragments/stack/computer-vision-yolo.md +62 -0
- package/content-dist/fragments/stack/convex-react.md +65 -0
- package/content-dist/fragments/stack/data-pipeline-airflow.md +64 -0
- package/content-dist/fragments/stack/delphi-object-pascal.md +63 -0
- package/content-dist/fragments/stack/django-drf-celery.md +63 -0
- package/content-dist/fragments/stack/docker-compose-dev.md +69 -0
- package/content-dist/fragments/stack/dotnet-aspnet.md +62 -0
- package/content-dist/fragments/stack/electron-app.md +70 -0
- package/content-dist/fragments/stack/elixir-phoenix.md +65 -0
- package/content-dist/fragments/stack/fine-tuning-huggingface.md +69 -0
- package/content-dist/fragments/stack/flutter.md +61 -0
- package/content-dist/fragments/stack/github-actions-cicd.md +73 -0
- package/content-dist/fragments/stack/go-chi-gorm.md +73 -0
- package/content-dist/fragments/stack/graphql-apollo.md +70 -0
- package/content-dist/fragments/stack/hono-bun.md +62 -0
- package/content-dist/fragments/stack/kubernetes-helm.md +67 -0
- package/content-dist/fragments/stack/langchain-python-agent.md +64 -0
- package/content-dist/fragments/stack/laravel.md +64 -0
- package/content-dist/fragments/stack/llm-ops-production.md +63 -0
- package/content-dist/fragments/stack/microservices-docker.md +70 -0
- package/content-dist/fragments/stack/ml-fastapi-serving.md +64 -0
- package/content-dist/fragments/stack/ml-training-pipeline.md +67 -0
- package/content-dist/fragments/stack/monitoring-observability.md +68 -0
- package/content-dist/fragments/stack/nestjs-typescript.md +68 -0
- package/content-dist/fragments/stack/nextjs-app-router.md +65 -0
- package/content-dist/fragments/stack/nextjs-prisma-postgres.md +61 -0
- package/content-dist/fragments/stack/nextjs-trpc-drizzle.md +63 -0
- package/content-dist/fragments/stack/nodejs-express-typescript.md +60 -0
- package/content-dist/fragments/stack/nuxt3-tailwind.md +62 -0
- package/content-dist/fragments/stack/openai-api-integration.md +58 -0
- package/content-dist/fragments/stack/python-fastapi.md +64 -0
- package/content-dist/fragments/stack/rag-pipeline.md +62 -0
- package/content-dist/fragments/stack/react-express-monolith.md +61 -0
- package/content-dist/fragments/stack/react-native-expo.md +68 -0
- package/content-dist/fragments/stack/react-ts-zustand-query.md +64 -0
- package/content-dist/fragments/stack/react-typescript.md +73 -0
- package/content-dist/fragments/stack/remix-express-full.md +63 -0
- package/content-dist/fragments/stack/remix-typescript.md +66 -0
- package/content-dist/fragments/stack/rust-axum.md +63 -0
- package/content-dist/fragments/stack/serverless-lambda.md +65 -0
- package/content-dist/fragments/stack/spring-boot.md +63 -0
- package/content-dist/fragments/stack/supabase-nextjs.md +64 -0
- package/content-dist/fragments/stack/svelte-sveltekit.md +67 -0
- package/content-dist/fragments/stack/t3-stack.md +63 -0
- package/content-dist/fragments/stack/terraform-aws.md +65 -0
- package/content-dist/fragments/stack/turborepo-monorepo.md +61 -0
- package/content-dist/fragments/stack/vector-search-pinecone.md +63 -0
- package/content-dist/fragments/stack/vps-deploy-producao.md +64 -0
- package/content-dist/fragments/stack/vscode-extension.md +64 -0
- package/content-dist/fragments/stack/vue3-pinia-vite.md +65 -0
- package/content-dist/fragments/stack/wordpress.md +63 -0
- package/content-dist/skills/invi-commit/SKILL.md +85 -0
- package/content-dist/skills/invi-journal/SKILL.md +67 -0
- package/content-dist/skills/invi-map/SKILL.md +118 -0
- package/content-dist/skills/invi-mode/SKILL.md +176 -0
- package/content-dist/skills/invi-pr/SKILL.md +142 -0
- package/content-dist/skills/invi-qa/SKILL.md +75 -0
- package/content-dist/skills/invi-refactor-legacy/SKILL.md +90 -0
- package/content-dist/skills/invi-review/SKILL.md +83 -0
- package/content-dist/skills/invi-security/SKILL.md +89 -0
- package/content-dist/skills/invi-status/SKILL.md +72 -0
- package/content-dist/skills/invi-task/SKILL.md +143 -0
- package/content-dist/skills/invi-test/SKILL.md +97 -0
- package/content-dist/skills/po-handoff/SKILL.md +130 -0
- package/content-dist/skills/po-intake/SKILL.md +115 -0
- package/content-dist/skills/po-lint/SKILL.md +82 -0
- package/content-dist/skills/po-spec/SKILL.md +138 -0
- package/content-dist/skills/po-status/SKILL.md +130 -0
- package/content-dist/skills/po-verify/SKILL.md +124 -0
- package/content-dist/templates/requirements/REQ-TEMPLATE.md +110 -0
- package/content-dist/templates/requirements/constitution-TEMPLATE.md +77 -0
- package/dist/baseline.d.ts +21 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +43 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +345 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +31 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +173 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/export.d.ts +49 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +95 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/gate.d.ts +42 -0
- package/dist/commands/gate.d.ts.map +1 -0
- package/dist/commands/gate.js +97 -0
- package/dist/commands/gate.js.map +1 -0
- package/dist/commands/init.d.ts +88 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +540 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/journalCmd.d.ts +47 -0
- package/dist/commands/journalCmd.d.ts.map +1 -0
- package/dist/commands/journalCmd.js +89 -0
- package/dist/commands/journalCmd.js.map +1 -0
- package/dist/commands/keys.d.ts +68 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +240 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/map.d.ts +123 -0
- package/dist/commands/map.d.ts.map +1 -0
- package/dist/commands/map.js +383 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/plan.d.ts +28 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +64 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/req.d.ts +92 -0
- package/dist/commands/req.d.ts.map +1 -0
- package/dist/commands/req.js +270 -0
- package/dist/commands/req.js.map +1 -0
- package/dist/commands/review.d.ts +40 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +101 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +33 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +151 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/ship.d.ts +45 -0
- package/dist/commands/ship.d.ts.map +1 -0
- package/dist/commands/ship.js +252 -0
- package/dist/commands/ship.js.map +1 -0
- package/dist/commands/status.d.ts +36 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +152 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +91 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +331 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/syncCommits.d.ts +56 -0
- package/dist/commands/syncCommits.d.ts.map +1 -0
- package/dist/commands/syncCommits.js +97 -0
- package/dist/commands/syncCommits.js.map +1 -0
- package/dist/commands/task.d.ts +108 -0
- package/dist/commands/task.d.ts.map +1 -0
- package/dist/commands/task.js +217 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/update.d.ts +92 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +541 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verifyTask.d.ts +50 -0
- package/dist/commands/verifyTask.d.ts.map +1 -0
- package/dist/commands/verifyTask.js +172 -0
- package/dist/commands/verifyTask.js.map +1 -0
- package/dist/content.d.ts +128 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +177 -0
- package/dist/content.js.map +1 -0
- package/dist/detect.d.ts +122 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/detect.js +594 -0
- package/dist/detect.js.map +1 -0
- package/dist/events.d.ts +36 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +76 -0
- package/dist/events.js.map +1 -0
- package/dist/frontmatter.d.ts +15 -0
- package/dist/frontmatter.d.ts.map +1 -0
- package/dist/frontmatter.js +74 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/i18n/en.d.ts +421 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +443 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/index.d.ts +40 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +66 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/pt-BR.d.ts +11 -0
- package/dist/i18n/pt-BR.d.ts.map +1 -0
- package/dist/i18n/pt-BR.js +435 -0
- package/dist/i18n/pt-BR.js.map +1 -0
- package/dist/identity.d.ts +78 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +152 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/insights.d.ts +86 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +199 -0
- package/dist/insights.js.map +1 -0
- package/dist/interview.d.ts +81 -0
- package/dist/interview.d.ts.map +1 -0
- package/dist/interview.js +283 -0
- package/dist/interview.js.map +1 -0
- package/dist/inventory.d.ts +79 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +86 -0
- package/dist/inventory.js.map +1 -0
- package/dist/journal.d.ts +22 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +88 -0
- package/dist/journal.js.map +1 -0
- package/dist/migrations/legacyNames.d.ts +45 -0
- package/dist/migrations/legacyNames.d.ts.map +1 -0
- package/dist/migrations/legacyNames.js +118 -0
- package/dist/migrations/legacyNames.js.map +1 -0
- package/dist/plan.d.ts +42 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +126 -0
- package/dist/plan.js.map +1 -0
- package/dist/render/agents.d.ts +327 -0
- package/dist/render/agents.d.ts.map +1 -0
- package/dist/render/agents.js +356 -0
- package/dist/render/agents.js.map +1 -0
- package/dist/render/claudeMd.d.ts +29 -0
- package/dist/render/claudeMd.d.ts.map +1 -0
- package/dist/render/claudeMd.js +110 -0
- package/dist/render/claudeMd.js.map +1 -0
- package/dist/render/githooks.d.ts +41 -0
- package/dist/render/githooks.d.ts.map +1 -0
- package/dist/render/githooks.js +168 -0
- package/dist/render/githooks.js.map +1 -0
- package/dist/render/markers.d.ts +13 -0
- package/dist/render/markers.d.ts.map +1 -0
- package/dist/render/markers.js +35 -0
- package/dist/render/markers.js.map +1 -0
- package/dist/render/requirements.d.ts +56 -0
- package/dist/render/requirements.d.ts.map +1 -0
- package/dist/render/requirements.js +86 -0
- package/dist/render/requirements.js.map +1 -0
- package/dist/render/settings.d.ts +43 -0
- package/dist/render/settings.d.ts.map +1 -0
- package/dist/render/settings.js +94 -0
- package/dist/render/settings.js.map +1 -0
- package/dist/render/transparency.d.ts +7 -0
- package/dist/render/transparency.d.ts.map +1 -0
- package/dist/render/transparency.js +164 -0
- package/dist/render/transparency.js.map +1 -0
- package/dist/requirements.d.ts +84 -0
- package/dist/requirements.d.ts.map +1 -0
- package/dist/requirements.js +229 -0
- package/dist/requirements.js.map +1 -0
- package/dist/sizing.d.ts +63 -0
- package/dist/sizing.d.ts.map +1 -0
- package/dist/sizing.js +104 -0
- package/dist/sizing.js.map +1 -0
- package/dist/tasks.d.ts +199 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +320 -0
- package/dist/tasks.js.map +1 -0
- package/dist/util/diff3.d.ts +26 -0
- package/dist/util/diff3.d.ts.map +1 -0
- package/dist/util/diff3.js +112 -0
- package/dist/util/diff3.js.map +1 -0
- package/dist/util/fsx.d.ts +33 -0
- package/dist/util/fsx.d.ts.map +1 -0
- package/dist/util/fsx.js +153 -0
- package/dist/util/fsx.js.map +1 -0
- package/dist/util/git.d.ts +58 -0
- package/dist/util/git.d.ts.map +1 -0
- package/dist/util/git.js +171 -0
- package/dist/util/git.js.map +1 -0
- package/dist/util/merge.d.ts +27 -0
- package/dist/util/merge.d.ts.map +1 -0
- package/dist/util/merge.js +78 -0
- package/dist/util/merge.js.map +1 -0
- package/dist/util/out.d.ts +18 -0
- package/dist/util/out.d.ts.map +1 -0
- package/dist/util/out.js +23 -0
- package/dist/util/out.js.map +1 -0
- package/dist/util/proc.d.ts +12 -0
- package/dist/util/proc.d.ts.map +1 -0
- package/dist/util/proc.js +45 -0
- package/dist/util/proc.js.map +1 -0
- package/dist/util/registry.d.ts +58 -0
- package/dist/util/registry.d.ts.map +1 -0
- package/dist/util/registry.js +240 -0
- package/dist/util/registry.js.map +1 -0
- package/dist/verify.d.ts +52 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +205 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +18 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/busca-elasticsearch
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Search-engine discipline: explicit mappings, alias-based zero-downtime reindex, async DB→index sync with the database as source of truth, bounded queries, measured relevance tuning."
|
|
6
|
+
source: "dominio/10-busca-elasticsearch.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "@elastic/elasticsearch": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 5
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 970
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Search (Elasticsearch/OpenSearch)
|
|
19
|
+
|
|
20
|
+
A wrong mapping cannot be fixed without a reindex; untuned relevance quietly ruins the product; DB→index sync is eventually consistent, and teams forget search can serve stale data. Exemplar mappings and runbooks live in `references/busca-elasticsearch/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Mapping
|
|
23
|
+
|
|
24
|
+
- Define the mapping EXPLICITLY before indexing the first document; dynamic mapping in production is forbidden.
|
|
25
|
+
- `keyword` for filterable/aggregatable fields (id, status, category); `text` for full-text fields; both on one field via multi-fields.
|
|
26
|
+
- Numeric fields use numeric types, dates use `date` with an explicit format — never `text`.
|
|
27
|
+
|
|
28
|
+
## Analyzers and relevance
|
|
29
|
+
|
|
30
|
+
- Use the language analyzer matching the content (stemming); test with `_analyze` against real content BEFORE creating the index.
|
|
31
|
+
- Autocomplete: `search_as_you_type` or a custom edge-ngram analyzer.
|
|
32
|
+
- Synonyms via an external synonyms file, so updates need no reindex.
|
|
33
|
+
- Boost hierarchy: title > category > tags > description; combine text relevance with a recency decay and a popularity factor.
|
|
34
|
+
- Log query + results + clicks to measure relevance (CTR) — tuning without measurement is guessing.
|
|
35
|
+
|
|
36
|
+
## Aliases and reindex
|
|
37
|
+
|
|
38
|
+
- Application code queries ONLY through an alias, never the physical index name.
|
|
39
|
+
- Zero-downtime reindex: create the new index → reindex into it (dual-writing new documents to both) → validate counts + spot checks → swap the alias → delete the old index only after a verification window.
|
|
40
|
+
- Never delete an index you cannot rebuild from the database; never delete-and-recreate under the same name.
|
|
41
|
+
|
|
42
|
+
## Sync (DB → search)
|
|
43
|
+
|
|
44
|
+
- The database is the source of truth; the search engine is a projection, never the primary store.
|
|
45
|
+
- Never index inside a database transaction — persist first, then index asynchronously (event/queue, CDC such as Debezium, or polling as the simple-but-laggy fallback).
|
|
46
|
+
- A search-engine failure must NOT fail the primary operation; the data is safe in the DB and can be re-projected.
|
|
47
|
+
- Monitor sync lag and alert when it exceeds the agreed threshold.
|
|
48
|
+
|
|
49
|
+
## Query discipline
|
|
50
|
+
|
|
51
|
+
- Every search query sets an explicit timeout.
|
|
52
|
+
- Deep pagination is forbidden — use `search_after` with a stable sort beyond the first pages.
|
|
53
|
+
- Aggregations only on `keyword` (sub)fields, never on `text`.
|
|
54
|
+
- Log query execution times to catch performance regressions.
|
|
55
|
+
|
|
56
|
+
## Trigger → action
|
|
57
|
+
|
|
58
|
+
| Trigger | Action |
|
|
59
|
+
|---------|--------|
|
|
60
|
+
| Entity created/updated/deleted | enqueue async index/update/delete job |
|
|
61
|
+
| Mapping change needed | new index → reindex → alias swap (zero downtime) |
|
|
62
|
+
| Search request | alias query with filters, facets, timeout, bounded pagination |
|
|
63
|
+
| Relevance complaint | check query/click logs → adjust boosts → measure again |
|
|
64
|
+
| Sync-lag alert | inspect queue/CDC health → re-project from the DB |
|
|
65
|
+
|
|
66
|
+
## Quality gates
|
|
67
|
+
|
|
68
|
+
- Explicit mapping in place before the first document; all application queries go through the alias.
|
|
69
|
+
- Pagination via `search_after` beyond shallow pages; aggregations only on `keyword` fields; timeouts on every query.
|
|
70
|
+
- Sync lag monitored with alerting; search-engine failure proven not to break the primary operation.
|
|
71
|
+
- Zero-downtime reindex procedure documented and tested; analyzers tested with real content.
|
|
72
|
+
- Relevance validated with regular test queries against click data.
|
|
73
|
+
|
|
74
|
+
## Forbidden
|
|
75
|
+
|
|
76
|
+
- Dynamic mapping in production.
|
|
77
|
+
- Aggregations on `text` fields.
|
|
78
|
+
- Deep pagination with large `from` offsets.
|
|
79
|
+
- Physical index names in application code (alias only).
|
|
80
|
+
- Indexing inside a database transaction.
|
|
81
|
+
- Using the search engine as the primary data store.
|
|
82
|
+
- Deleting and recreating an index under the same name.
|
|
83
|
+
|
|
84
|
+
## References (read on demand)
|
|
85
|
+
|
|
86
|
+
- `references/busca-elasticsearch/patterns.md` — explicit mapping JSON, zero-downtime reindex runbook, async sync patterns, `search_after` pagination, relevance-scoring sketch.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/dashboard-admin-rbac
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "RBAC as security, not UX: centralized resource:action checks in the backend, deny-by-default, immutable audit logs, streamed exports, async bulk operations, audited impersonation."
|
|
6
|
+
source: "dominio/03-dashboard-admin-rbac.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 948
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Admin dashboard with RBAC
|
|
19
|
+
|
|
20
|
+
RBAC done wrong is a security vulnerability, not a UX bug. Hardcoded role enums and scattered if/else guarantee every new feature breaks access control. The model is resource + action (+ conditions), enforced consistently in the API. Exemplar code lives in `references/dashboard-admin-rbac/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Permission model
|
|
23
|
+
|
|
24
|
+
- Permission = `resource:action` (e.g. `users:read`, `orders:write`, `reports:export`), optionally constrained by conditions (own-only, same organization/region).
|
|
25
|
+
- Roles group permissions and may form a hierarchy; deny-by-default — no explicit permission means no access.
|
|
26
|
+
- Super-admin is a separate flag, NOT a role — prevents accidental inheritance.
|
|
27
|
+
|
|
28
|
+
## Enforcement
|
|
29
|
+
|
|
30
|
+
- Authorization happens in the backend on EVERY admin route; frontend guards are UX, never security.
|
|
31
|
+
- One centralized permission service (`can(user, 'orders:write', context?)`) — zero inline role checks anywhere else.
|
|
32
|
+
- Resolved permissions cached per user (Redis) and invalidated IMMEDIATELY when a role or its permissions change.
|
|
33
|
+
- Row-level scoping is applied as an automatic filter in the repository layer.
|
|
34
|
+
- Expose UUIDs in admin URLs, never sequential ids.
|
|
35
|
+
|
|
36
|
+
## Audit logging
|
|
37
|
+
|
|
38
|
+
- Every mutation of a sensitive resource is audited: actor, action, resource type/id, before/after state, IP, user agent, timestamp.
|
|
39
|
+
- Audit logs are immutable — no UPDATE/DELETE, ever; partition by month at high volume.
|
|
40
|
+
- Auditing is automatic (middleware/decorator) — manual calls get forgotten.
|
|
41
|
+
- Impersonation requires its own permission, a mandatory audit entry naming the admin, and a short session TTL.
|
|
42
|
+
|
|
43
|
+
## Data tables, exports, bulk operations
|
|
44
|
+
|
|
45
|
+
- Server-side cursor pagination (not offset) for large tables; filters and sorts validated against a whitelist of allowed fields.
|
|
46
|
+
- Exports stream to the client — never materialize the dataset in memory; beyond the size cap (e.g. 100k rows), run async and deliver by link/email.
|
|
47
|
+
- Bulk operations are always async via queue: return a job id, validate items individually, report successes and failures per item; destructive bulk requires explicit confirmation showing the affected count.
|
|
48
|
+
- Deleting users is a soft delete with a deactivation cascade, audited like any sensitive mutation.
|
|
49
|
+
|
|
50
|
+
## Trigger → action
|
|
51
|
+
|
|
52
|
+
| Trigger | Action |
|
|
53
|
+
|---------|--------|
|
|
54
|
+
| Admin request | authenticate → authorize via the permission service → scoped query |
|
|
55
|
+
| Role/permission change | persist → invalidate permission caches → audit |
|
|
56
|
+
| Bulk action | enqueue → return job id → per-item success/failure report |
|
|
57
|
+
| Large export | stream; above the cap → async job + delivery |
|
|
58
|
+
| Impersonation | check dedicated permission → audit entry → short-TTL session |
|
|
59
|
+
|
|
60
|
+
## Quality gates
|
|
61
|
+
|
|
62
|
+
- Zero role checks outside the centralized permission service; every admin route has authn + authz middleware.
|
|
63
|
+
- Audit log covers 100% of sensitive mutations; audit table proven immutable.
|
|
64
|
+
- Exports streamed; bulk operations async with job ids; permission caches invalidated on role change.
|
|
65
|
+
- Cursor pagination on large tables; filter/sort whitelists enforced.
|
|
66
|
+
- Frontend hides what the user cannot do (UX) but the API never relies on it.
|
|
67
|
+
|
|
68
|
+
## Forbidden
|
|
69
|
+
|
|
70
|
+
- Hardcoded role if/else outside the centralized permission service.
|
|
71
|
+
- Optional or conditional audit logging on sensitive actions.
|
|
72
|
+
- Loading a full dataset into memory for export.
|
|
73
|
+
- Synchronous bulk operations inside an HTTP request.
|
|
74
|
+
- Physically deleting audit logs.
|
|
75
|
+
- Exposing stack traces or SQL errors to admin users (return an error id instead).
|
|
76
|
+
- Treating the frontend as a line of defense for access control.
|
|
77
|
+
|
|
78
|
+
## References (read on demand)
|
|
79
|
+
|
|
80
|
+
- `references/dashboard-admin-rbac/patterns.md` — centralized permission check, streamed CSV export, automatic audit decorator, permission-cache invalidation.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/design-system
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Design-system discipline: a closed token set — 8-point spacing, role-named colour, one accent, two type families, three elevations, one easing — that components reference instead of raw values."
|
|
6
|
+
detect:
|
|
7
|
+
deps: { "tailwindcss": "*", "styled-components": "*", "@emotion/react": "*", "sass": "*" }
|
|
8
|
+
files: ["tailwind.config.js", "tailwind.config.ts", "postcss.config.js"]
|
|
9
|
+
score: 2
|
|
10
|
+
confirm: true
|
|
11
|
+
requires: []
|
|
12
|
+
conflicts: []
|
|
13
|
+
tokens: 1054
|
|
14
|
+
migrated: false
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Domain: design system
|
|
18
|
+
|
|
19
|
+
Interfaces read as expensive because of what is *absent*. Cohesion comes from a small closed set of decisions repeated without exception — not from adding polish. The first off-system value is permission for the next fifty.
|
|
20
|
+
|
|
21
|
+
## The closed set
|
|
22
|
+
|
|
23
|
+
- Every visual value comes from a named token in one `:root` block. If a component needs a value that is not a token, the token is missing — add it, then reference it.
|
|
24
|
+
- Name tokens by meaning (`--accent`, `--space-3`, `--radius-md`), never by appearance (`--blue`, `--px-24`). Semantic names survive a redesign; literal ones become lies.
|
|
25
|
+
- Components reference `var(--token)` only — no raw hex, no magic pixel values. A hardcoded value inside a component is where drift begins.
|
|
26
|
+
|
|
27
|
+
## Spacing
|
|
28
|
+
|
|
29
|
+
- One 8-point scale: 8 / 16 / 24 / 32 / 48 / 64. Nothing between. Something needing 20px chooses 16 or 24.
|
|
30
|
+
- Hold one large value (64) as the rhythm between major sections, everywhere.
|
|
31
|
+
- Optical over mathematical: arrows, triangles and italics look off-centre when their bounding box is centred. Nudge 1–2px toward the visual mass.
|
|
32
|
+
|
|
33
|
+
## Colour
|
|
34
|
+
|
|
35
|
+
- Roles, not a palette: a warm off-white canvas (never pure `#FFFFFF`), a near-black ink (never `#000`), two greys, one accent with a hover and a pressed variant, and a hairline built from alpha.
|
|
36
|
+
- **The accent is a moment, never a surface.** Links, the primary action, the focus ring — nothing else. Flooding a hero or card with it drops the page back to template.
|
|
37
|
+
- Hairlines are low-opacity ink on light surfaces and low-opacity white on dark ones — a soft edge of light, never an opaque grey line.
|
|
38
|
+
- Test in greyscale: if the hierarchy still reads, value is doing the work and colour is free to be emphasis, not a crutch.
|
|
39
|
+
|
|
40
|
+
## Typography
|
|
41
|
+
|
|
42
|
+
- Two families: one display (headings), one neutral sans (everything else). Delete every other font from the project.
|
|
43
|
+
- One fixed size scale, declared as tokens.
|
|
44
|
+
- **Line height tightens as size grows**: body loose (~1.5), 56px display collapsed to ~0.95–1.0 so the heading reads as one shape.
|
|
45
|
+
- **Tracking moves opposite to size**: small uppercase opens (+1 to +1.5px); large display tightens (-0.5px).
|
|
46
|
+
- Uppercase is a function, not decoration: labels and buttons only — never headings, never body.
|
|
47
|
+
|
|
48
|
+
## Surfaces, radii, elevation
|
|
49
|
+
|
|
50
|
+
- No raw `0` corners; floor is 8px. Match radius to element size so a small control and a large card read equally rounded: inputs 8, cards 12–16, buttons 24, pills 999.
|
|
51
|
+
- **Separate surfaces in a strict order — take the first that works, never stack all three:** fill (background) → shadow (elevation) → border (only when it must sit flush).
|
|
52
|
+
- Three elevation tokens plus at most one accent glow. Blur and offset grow together; opacity stays low (cap ~0.16). Tint shadows toward ink — pure black reads colder.
|
|
53
|
+
- On dark surfaces ink shadows vanish: separate with the alpha hairline and let the glow be the only light. Spend the glow on at most one element per screen.
|
|
54
|
+
|
|
55
|
+
## Motion
|
|
56
|
+
|
|
57
|
+
- **One signature easing token, applied to every transition and animation.** A single curve is the fingerprint of a single hand controlling the interface.
|
|
58
|
+
- Two duration bands: UI feedback 0.3–0.5s, section entrances 1.0–1.4s.
|
|
59
|
+
- Reveals are a fade plus a small `translateY` (24–40px) — never a slide in from off-screen. Stagger grouped items 0.1–0.2s.
|
|
60
|
+
- On hover, drop opacity (~0.6) rather than swapping colours. Quieter reads as more expensive.
|
|
61
|
+
- **No bounces, no springs.** They read as playful, not premium, and break the single-hand illusion.
|
|
62
|
+
- `prefers-reduced-motion` is mandatory, not a finish: neutralise motion and reveal content instantly.
|
|
63
|
+
|
|
64
|
+
## Components
|
|
65
|
+
|
|
66
|
+
- Define the core set — button/CTA, chip, card, input, header/nav — before adding more.
|
|
67
|
+
- Every interactive component defines all five states: rest, hover, focus, active, disabled. What is undefined gets improvised later.
|
|
68
|
+
|
|
69
|
+
## Review triggers
|
|
70
|
+
|
|
71
|
+
Reject on sight: a second accent; the accent used as a surface; a third font family; an off-scale spacing value; a raw hex inside a component; three separators on one card edge; display type set at body line height; a bounce or spring; a missing `prefers-reduced-motion` block; an interactive component with undefined focus or disabled states.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/ecommerce-completo
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "E-commerce discipline: locked stock decrement with reservations, server-side price revalidation, immutable checkout snapshots, a validated order state machine, soft-deleted catalog."
|
|
6
|
+
source: "dominio/02-ecommerce-completo.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 1048
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: E-commerce
|
|
19
|
+
|
|
20
|
+
E-commerce looks simple until the first broken order: negative inventory, wrong tax, an order state no system agrees on. The heart of the system is an order state machine — model it wrong and the debt is unpayable. Exemplar SQL and code live in `references/ecommerce-completo/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Catalog
|
|
23
|
+
|
|
24
|
+
- Separate `Product` (catalog info) from `ProductVariant` (SKU, price, stock); the SKU is the sellable unit.
|
|
25
|
+
- Product images are CDN URLs, never base64 in the database; thumbnails are generated at upload, not on the fly.
|
|
26
|
+
- Slugs are globally unique (SEO), not just per category.
|
|
27
|
+
- Products are soft-deleted — historical orders must keep referencing them.
|
|
28
|
+
- An out-of-stock variant returns `available: false`, never 404.
|
|
29
|
+
|
|
30
|
+
## Cart
|
|
31
|
+
|
|
32
|
+
- Anonymous cart: id in a cookie, data in cache with a TTL; authenticated cart: persisted in the database.
|
|
33
|
+
- On login, merge anonymous into authenticated: same SKU sums quantities, capped by stock.
|
|
34
|
+
- The cart price is display-only — the charge ALWAYS recalculates from the database at checkout.
|
|
35
|
+
- Abandoned carts (no checkout after the agreed window) trigger the recovery automation.
|
|
36
|
+
|
|
37
|
+
## Inventory
|
|
38
|
+
|
|
39
|
+
- Stock decrement happens only inside a database transaction with a pessimistic lock (`SELECT … FOR UPDATE`).
|
|
40
|
+
- Add-to-cart/checkout reserves via `reserved_quantity`; the real `quantity` decrements only on confirmed payment.
|
|
41
|
+
- Expired reservations (checkout not completed in time) are released by a scheduled job.
|
|
42
|
+
- Quantity can never go negative: database constraint AND application validation.
|
|
43
|
+
- Manual stock adjustments require a reason and an audit entry.
|
|
44
|
+
|
|
45
|
+
## Orders and checkout
|
|
46
|
+
|
|
47
|
+
- Order state machine: pending → payment_processing → confirmed → processing → shipped → delivered, with branches to payment_failed, canceled, and return_requested → returned → refunded.
|
|
48
|
+
- Every transition is validated against an explicit allowed-transitions map; skipping states is forbidden. Transitions emit events (notification, inventory update, ERP webhook).
|
|
49
|
+
- Cancellation is allowed only from pending, payment_failed, or confirmed; a shipped order can only be returned. A return is a new flow — it never rewinds the original order.
|
|
50
|
+
- Checkout creates an immutable `CheckoutSession` snapshot (products, DB prices, quantities) before charging; the charge uses the snapshot, never the live cart.
|
|
51
|
+
- Tax is calculated at final checkout with the delivery address — never in the cart, never with the profile address.
|
|
52
|
+
- Every payment-gateway call carries an idempotency key — no double charges on retry.
|
|
53
|
+
- Multi-currency: store the base price in cents plus the base currency; convert at display time.
|
|
54
|
+
|
|
55
|
+
## Trigger → action
|
|
56
|
+
|
|
57
|
+
| Trigger | Action |
|
|
58
|
+
|---------|--------|
|
|
59
|
+
| Add to cart | check availability → reserve stock |
|
|
60
|
+
| Login with anonymous cart | merge carts, quantities capped by stock |
|
|
61
|
+
| Checkout start | snapshot session → final-address tax → reserve |
|
|
62
|
+
| Payment confirmed | validated transition → decrement real stock → release hold |
|
|
63
|
+
| Payment failed | release reservation → notify user |
|
|
64
|
+
| Cancel/return request | validate against allowed states → release stock / start return flow |
|
|
65
|
+
|
|
66
|
+
## Quality gates
|
|
67
|
+
|
|
68
|
+
- Stock proven non-negative under concurrency (constraint + lock test).
|
|
69
|
+
- Checkout total always recomputed from database prices; `CheckoutSession` immutable after creation.
|
|
70
|
+
- Every state transition validated; an illegal transition raises a business error.
|
|
71
|
+
- Idempotency key on 100% of gateway calls.
|
|
72
|
+
- Notifications fired on every relevant order-state change.
|
|
73
|
+
- Soft-deleted products still render inside historical orders.
|
|
74
|
+
|
|
75
|
+
## Forbidden
|
|
76
|
+
|
|
77
|
+
- Charging a price stored in the cart or sent by the frontend.
|
|
78
|
+
- Decrementing stock outside a locked database transaction.
|
|
79
|
+
- Order state transitions without validation (e.g. delivered → pending).
|
|
80
|
+
- Physically deleting a product that has order history.
|
|
81
|
+
- Tax from the profile address instead of the checkout delivery address.
|
|
82
|
+
- Skipping the `CheckoutSession` snapshot and charging from live cart data.
|
|
83
|
+
|
|
84
|
+
## References (read on demand)
|
|
85
|
+
|
|
86
|
+
- `references/ecommerce-completo/patterns.md` — locked stock decrement, reservation vs real decrement, server-side price revalidation, state-transition validation.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/filas-jobs
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Queue and background-job discipline: idempotent jobs, graceful shutdown, priority-separated queues, alerting dead letters, enqueue-after-commit, reference-only payloads."
|
|
6
|
+
source: "dominio/15-filas-jobs.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: { "bullmq": "*" }
|
|
9
|
+
files: []
|
|
10
|
+
score: 4
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 949
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Queues and background jobs
|
|
19
|
+
|
|
20
|
+
Queues break in ways that are hard to debug: a worker dies without graceful shutdown and the job is never processed, a non-idempotent job double-processes, an unhandled error becomes an infinite retry loop. Job infrastructure is critical and chronically under-reviewed. Exemplar code lives in `references/filas-jobs/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Job design
|
|
23
|
+
|
|
24
|
+
- EVERY job is idempotent — processing it twice must not double any side effect. Use an atomic lock key or a status check on the target record; verify existence before creating (invoices, emails, charges).
|
|
25
|
+
- Payloads are small and serializable: reference ids only — large data lives in the database/object storage, never in the queue backend.
|
|
26
|
+
- Every job has an explicit timeout, and that timeout is shorter than the graceful-shutdown wait.
|
|
27
|
+
- Long jobs (minutes) report progress and checkpoint state in the database so a crashed worker can resume; very long work is split into batches/child jobs.
|
|
28
|
+
|
|
29
|
+
## Queues and workers
|
|
30
|
+
|
|
31
|
+
- Separate queues by priority (e.g. `critical` / `default` / `bulk`), each with its own concurrency, timeout, and retry budget — bulk work must never starve critical jobs.
|
|
32
|
+
- Graceful shutdown is mandatory: on SIGTERM the worker finishes the in-flight job (bounded by its timeout), closes connections, then exits.
|
|
33
|
+
- Scheduled/cron jobs take a distributed lock so multi-instance deployments run exactly one execution.
|
|
34
|
+
- Workers calling rate-limited external APIs use the queue's limiter — respect the provider's budget.
|
|
35
|
+
|
|
36
|
+
## Failure handling
|
|
37
|
+
|
|
38
|
+
- Retries use exponential backoff with a bounded attempt count — never unlimited retry.
|
|
39
|
+
- After max attempts the job moves to a dead-letter store persisted in the database (it must survive a cache flush) AND fires an ops alert — a silently dead job is silently lost data.
|
|
40
|
+
- Keep failed jobs inspectable; provide an admin path to retry one or all dead-lettered jobs of a queue, and to pause/resume a queue for maintenance.
|
|
41
|
+
- Expose queue health (depth, lag, error rate, active workers) to the ops team.
|
|
42
|
+
|
|
43
|
+
## Enqueueing
|
|
44
|
+
|
|
45
|
+
- NEVER enqueue inside a database transaction — the worker can run before the commit and miss the data. Persist first, enqueue after commit (or use a transactional outbox).
|
|
46
|
+
|
|
47
|
+
## Trigger → action
|
|
48
|
+
|
|
49
|
+
| Trigger | Action |
|
|
50
|
+
|---------|--------|
|
|
51
|
+
| Business event | commit the write → enqueue job with reference-id payload |
|
|
52
|
+
| Job dequeued | idempotency check → process → success removes / failure retries with backoff |
|
|
53
|
+
| Max retries exceeded | persist to dead-letter store + alert ops |
|
|
54
|
+
| SIGTERM | finish in-flight job → close connections → exit |
|
|
55
|
+
| Cron trigger | acquire distributed lock → run single instance |
|
|
56
|
+
| Dead-letter review | inspect error + payload → fix cause → re-enqueue |
|
|
57
|
+
|
|
58
|
+
## Quality gates
|
|
59
|
+
|
|
60
|
+
- 100% of jobs have an idempotency mechanism, proven by a re-delivery test.
|
|
61
|
+
- Graceful shutdown implemented in every worker; SIGTERM never kills a job mid-flight.
|
|
62
|
+
- Dead-letter store persisted with alerting configured in production.
|
|
63
|
+
- Queues separated by priority; every job has a timeout.
|
|
64
|
+
- Enqueueing verified to happen outside database transactions.
|
|
65
|
+
- Payloads carry reference ids only; queue dashboard accessible to ops.
|
|
66
|
+
|
|
67
|
+
## Forbidden
|
|
68
|
+
|
|
69
|
+
- Jobs without an idempotency mechanism.
|
|
70
|
+
- SIGTERM handlers that exit without awaiting the current job.
|
|
71
|
+
- Dead letters without alerts.
|
|
72
|
+
- Large objects in job payloads — pass ids.
|
|
73
|
+
- Enqueueing jobs inside database transactions.
|
|
74
|
+
- Scheduled jobs without a distributed lock on multi-instance deployments.
|
|
75
|
+
- One single queue for every job type.
|
|
76
|
+
- Jobs without a configured timeout.
|
|
77
|
+
|
|
78
|
+
## References (read on demand)
|
|
79
|
+
|
|
80
|
+
- `references/filas-jobs/patterns.md` — idempotency patterns, backoff options, dead-letter handling with alerts, graceful shutdown, rate-limited workers, enqueue-after-commit.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/integracao-crm-erp
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "External CRM/ERP integration discipline: verified async webhook ingestion, idempotent event processing, adapter anti-corruption layer, incremental sync with cursors, alerting dead letters."
|
|
6
|
+
source: "dominio/14-integracao-crm-erp.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: []
|
|
10
|
+
score: 0
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 963
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: External CRM/ERP integration
|
|
19
|
+
|
|
20
|
+
Integrations with external systems fail silently, process the same event twice, or drift out of sync after one network failure. The biggest mistake is treating the integration as a plain HTTP call instead of a distributed flow with partial failures, retries, and periodic reconciliation; the second biggest is having no alerting dead-letter queue. Exemplar code lives in `references/integracao-crm-erp/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Webhook ingestion
|
|
23
|
+
|
|
24
|
+
- Verify the HMAC/signature BEFORE parsing the payload; reject on mismatch.
|
|
25
|
+
- Return HTTP 200 immediately — never process synchronously in the handler; a slow handler makes the provider redeliver and double-process.
|
|
26
|
+
- Persist the raw event (`event_id`, source, payload, received_at) and enqueue it; a worker does the real processing.
|
|
27
|
+
|
|
28
|
+
## Idempotency
|
|
29
|
+
|
|
30
|
+
- Check the event's external id against the processed-events record before any processing; duplicates are skipped, not errors.
|
|
31
|
+
- Apply the event and mark it processed inside ONE transaction — a crash between the two must not reprocess or drop the event.
|
|
32
|
+
|
|
33
|
+
## Adapter (anti-corruption) layer
|
|
34
|
+
|
|
35
|
+
- External schemas (field names, types) NEVER leak into internal models — every integration goes through an adapter with `toInternal`/`toExternal` mappings.
|
|
36
|
+
- External ids live in a dedicated mapping table (`internal_id`, `source`, `external_id`), not as columns on domain entities.
|
|
37
|
+
- Pin and record the external API contract version; a provider version change is a code change, not a surprise.
|
|
38
|
+
|
|
39
|
+
## Sync
|
|
40
|
+
|
|
41
|
+
- Incremental sync only, driven by a cursor (modified-since); full syncs of large sources are forbidden outside explicit, admin-triggered rebuilds.
|
|
42
|
+
- The cursor advances atomically with the sync result — a crash mid-sync re-fetches, never skips.
|
|
43
|
+
- Conflict resolution follows a documented rule per entity (timestamp wins, or a configured authoritative source); never overwrite divergent data silently — log every conflict for review.
|
|
44
|
+
|
|
45
|
+
## Outbound calls and failures
|
|
46
|
+
|
|
47
|
+
- Every external HTTP call has a timeout and retries with exponential backoff.
|
|
48
|
+
- Rate-limit outbound calls to respect the provider's budget.
|
|
49
|
+
- After max retries an event goes to a persisted dead-letter store AND alerts ops with event id, source, last errors, and payload; an admin surface lists, retries (one or all), and pauses a source. Dead letters are triaged within the agreed SLA.
|
|
50
|
+
|
|
51
|
+
## Trigger → action
|
|
52
|
+
|
|
53
|
+
| Trigger | Action |
|
|
54
|
+
|---------|--------|
|
|
55
|
+
| Webhook received | verify HMAC → persist raw → enqueue → 200 |
|
|
56
|
+
| Event job | idempotency check → adapter transform → apply → mark processed |
|
|
57
|
+
| Sync schedule | incremental fetch from cursor → upsert → advance cursor atomically |
|
|
58
|
+
| Internal business event | enqueue outbound job (create/update in CRM/ERP) |
|
|
59
|
+
| Max retries exceeded | dead-letter + ops alert |
|
|
60
|
+
| Data conflict | apply documented resolution rule + conflict log |
|
|
61
|
+
|
|
62
|
+
## Quality gates
|
|
63
|
+
|
|
64
|
+
- Webhook acks fast (before processing) with signature verified on 100% of deliveries.
|
|
65
|
+
- Duplicate delivery proven harmless by an idempotency test.
|
|
66
|
+
- Zero external field names/types in internal models; id mapping table in place.
|
|
67
|
+
- Sync cursor persisted atomically with synced data.
|
|
68
|
+
- Timeouts, backoff retries, and rate limiting on every external call.
|
|
69
|
+
- Dead-letter store with alerts and an admin retry path.
|
|
70
|
+
|
|
71
|
+
## Forbidden
|
|
72
|
+
|
|
73
|
+
- Business logic inside the webhook HTTP handler.
|
|
74
|
+
- External-system schema in internal models.
|
|
75
|
+
- Full sync without an incremental cursor on sources beyond trivial size.
|
|
76
|
+
- Silently overwriting conflicting data without a rule and a log.
|
|
77
|
+
- External HTTP calls without timeout or backoff retries.
|
|
78
|
+
- A dead-letter queue without alerts.
|
|
79
|
+
|
|
80
|
+
## References (read on demand)
|
|
81
|
+
|
|
82
|
+
- `references/integracao-crm-erp/patterns.md` — async webhook ack, idempotent event processing, adapter layer + id mapping, incremental sync with a persisted cursor.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/lgpd
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "LGPD as engineering: legal-basis mapping, schema minimization, titular rights (pseudonymize + orphan under immutable logs), retention, ANPD incident response, aggregated-by-default people analytics."
|
|
6
|
+
# Human-confirmed domain — detection only SUGGESTS (suggest-not-auto): personal-data
|
|
7
|
+
# handling rarely leaves a dependency signature, so only weak file-name signals with a
|
|
8
|
+
# low score and confirm: true; the init interview is the real gate.
|
|
9
|
+
detect:
|
|
10
|
+
deps: {}
|
|
11
|
+
files: ["**/*lgpd*", "**/*consent*", "**/*privacy*", "**/*data-subject*", "**/*titular*"]
|
|
12
|
+
score: 1
|
|
13
|
+
confirm: true
|
|
14
|
+
requires: []
|
|
15
|
+
conflicts: []
|
|
16
|
+
tokens: 1099
|
|
17
|
+
migrated: true
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Domain: LGPD (Brazilian data protection)
|
|
21
|
+
|
|
22
|
+
Personal data of people in Brazil puts the system under the LGPD; a leak or an unlawful use is an ANPD-reportable incident, not a bug. Compliance lives in schemas, jobs, and logs, not in a policy PDF. Exemplars live in `references/lgpd/` — read on demand.
|
|
23
|
+
|
|
24
|
+
## Legal-basis mapping
|
|
25
|
+
|
|
26
|
+
Every processing purpose maps to ONE documented basis before code ships:
|
|
27
|
+
|
|
28
|
+
| Basis | Use when | Engineering consequence |
|
|
29
|
+
|-------|----------|-------------------------|
|
|
30
|
+
| Consentimento (consent) | marketing and anything refusable | granular per purpose, versioned, timestamped, revocable in one step; revocation halts processing |
|
|
31
|
+
| Legítimo interesse | fraud prevention, security, expected uses | documented balancing test (LIA); opt-out honored; never for sensitive data |
|
|
32
|
+
| Contract execution | data required to deliver what the titular signed up for | scope hard-limited to delivery |
|
|
33
|
+
| Legal obligation | fiscal/labor retention duties | overrides deletion requests; cite the specific law |
|
|
34
|
+
|
|
35
|
+
## Critical rules
|
|
36
|
+
|
|
37
|
+
1. Data inventory: every personal-data column maps to a basis + purpose + retention period — no basis, no column.
|
|
38
|
+
2. Minimization is a schema-design act: collect only what the declared purpose needs; "might be useful later" is not a purpose. New personal columns get basis review at migration time.
|
|
39
|
+
3. Titular rights are shipped, authenticated features — access, correction, deletion, portability (open formats) — with deadline tracking, not ad-hoc SQL run by support.
|
|
40
|
+
4. Deletion under immutable stores (git history, append-only logs, backups) = pseudonymize + orphan: replace identifiers with a pseudonym key, destroy the key mapping — the record survives but names no identifiable person.
|
|
41
|
+
5. Retention is enforced by scheduled purge jobs per data class, never by policy prose; a legal-obligation hold survives deletion requests, and the response names the law.
|
|
42
|
+
6. Incident response is a rehearsed runbook: contain → assess risk to titulares → DPO (encarregado) decision → notify ANPD and titulares within the regulatory window when risk is relevant.
|
|
43
|
+
7. People analytics aggregate by default; individual-level views are the audited, role-gated exception with a minimum group size (k-anonymity floor).
|
|
44
|
+
8. Personal data never enters logs, URLs, error traces, or telemetry — pseudonymous IDs only.
|
|
45
|
+
9. Test/staging/dev environments use synthetic or anonymized data — never a production copy.
|
|
46
|
+
10. Processors (operadores) and cross-border transfers are documented and contractually bound to the same deletion and incident duties.
|
|
47
|
+
|
|
48
|
+
## Common pitfalls
|
|
49
|
+
|
|
50
|
+
- A soft-delete flag sold as deletion — every query still reads the data.
|
|
51
|
+
- Consent bundled into the terms-of-service checkbox: not granular, not valid.
|
|
52
|
+
- A production dump seeding staging: one leak now equals two.
|
|
53
|
+
|
|
54
|
+
## Trigger → action
|
|
55
|
+
|
|
56
|
+
| Trigger | Action |
|
|
57
|
+
|---------|--------|
|
|
58
|
+
| New personal-data column | record basis + purpose + retention in the inventory → migration review |
|
|
59
|
+
| Access/portability request | authenticate titular → async export job → open formats, deadline tracked |
|
|
60
|
+
| Deletion request | check legal holds → cascade delete + pseudonymize immutable stores → confirm to titular |
|
|
61
|
+
| Consent revoked / opt-out | stop that purpose immediately → propagate to processors |
|
|
62
|
+
| Suspected incident | contain → assess → DPO decision → ANPD/titular notification within window |
|
|
63
|
+
| Retention expiry | scheduled purge → audit-log entry |
|
|
64
|
+
|
|
65
|
+
## Quality gates
|
|
66
|
+
|
|
67
|
+
- Inventory covers 100% of personal columns (basis, purpose, retention).
|
|
68
|
+
- Deletion tested end to end, including pseudonymize + orphan on immutable stores.
|
|
69
|
+
- CI scans logs and fixtures for personal-data patterns (CPF, email, phone).
|
|
70
|
+
- Incident runbook has named roles and an executed drill.
|
|
71
|
+
- Analytics endpoints return aggregates; individual drill-down demands role + audit log.
|
|
72
|
+
|
|
73
|
+
## Forbidden
|
|
74
|
+
|
|
75
|
+
- Collecting personal fields without a documented basis and purpose.
|
|
76
|
+
- Production personal data in staging, tests, or fixtures.
|
|
77
|
+
- Personal identifiers in logs, telemetry, or anything entering git history.
|
|
78
|
+
- Treating soft delete as deletion.
|
|
79
|
+
- Individual-level people analytics as the default view.
|
|
80
|
+
- Ignoring a revocation because the campaign "already started".
|
|
81
|
+
|
|
82
|
+
## References (read on demand)
|
|
83
|
+
|
|
84
|
+
- `references/lgpd/patterns.md` — legal-basis registry schema, pseudonymize + orphan deletion, titular-rights endpoints, retention purge job, incident runbook.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: domain/multi-tenancy
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
lang: en
|
|
5
|
+
summary: "Tenant isolation done right: RLS plus explicit tenant filters, tenant-prefixed caching, transactional provisioning, LGPD/GDPR export and deletion."
|
|
6
|
+
source: "dominio/12-multi-tenancy.md"
|
|
7
|
+
detect:
|
|
8
|
+
deps: {}
|
|
9
|
+
files: ["db/migrations/**", "supabase/migrations/**"]
|
|
10
|
+
score: 2
|
|
11
|
+
confirm: true
|
|
12
|
+
requires: []
|
|
13
|
+
conflicts: []
|
|
14
|
+
tokens: 929
|
|
15
|
+
migrated: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# Domain: Multi-tenancy
|
|
19
|
+
|
|
20
|
+
The isolation strategy is the most expensive architectural decision to reverse, and cross-tenant data leakage is a legal incident (LGPD/GDPR), not just a bug. Decide the isolation model before the first line of code. Exemplar SQL and middleware live in `references/multi-tenancy/` — read on demand.
|
|
21
|
+
|
|
22
|
+
## Isolation strategy
|
|
23
|
+
|
|
24
|
+
| Strategy | Isolation | Cost | Complexity | Use when |
|
|
25
|
+
|----------|-----------|------|------------|----------|
|
|
26
|
+
| Row-level (`tenant_id` column) | Low | $ | Low | SMB, <1000 tenants, no strict compliance |
|
|
27
|
+
| Schema per tenant | Medium | $$ | Medium | 100–10k tenants, moderate compliance |
|
|
28
|
+
| Database per tenant | High | $$$ | High | Enterprise, strict compliance, <100 tenants |
|
|
29
|
+
|
|
30
|
+
## Critical rules
|
|
31
|
+
|
|
32
|
+
1. `tenant_id` is resolved from the authenticated context (subdomain, JWT, or header) — NEVER from the request body.
|
|
33
|
+
2. Row-level security enabled on EVERY multi-tenant table, no exceptions.
|
|
34
|
+
3. Defense in depth: every repository query still filters by `tenant_id` explicitly, even with RLS active — each layer catches the other's misses.
|
|
35
|
+
4. Cache keys are always tenant-prefixed (`tenant:<id>:…`); zero cache sharing across tenants.
|
|
36
|
+
5. Tenant provisioning is one transaction — any failed step rolls back everything; side effects (welcome email) run only after commit.
|
|
37
|
+
6. Per-tenant feature flags cached with a short TTL (≤60s) so changes propagate predictably.
|
|
38
|
+
7. Data export (LGPD/GDPR) in open formats (JSON + CSV) within the regulatory deadline; deletion is a full cascade, tested in staging, executed only after a retention window post-cancellation.
|
|
39
|
+
8. Cross-tenant queries are forbidden except on super-admin paths with an audit log.
|
|
40
|
+
9. Reserved subdomains (`admin`, `api`, `www`, `mail`, `app`) are rejected at provisioning.
|
|
41
|
+
10. Test data uses its own tenant id — never mixed with production tenants.
|
|
42
|
+
|
|
43
|
+
## Common pitfalls
|
|
44
|
+
|
|
45
|
+
- One query missing the tenant filter is a mass data leak; the explicit where-clause plus RLS redundancy exists precisely for this.
|
|
46
|
+
- An unprefixed cache key silently serves tenant A's data to tenant B.
|
|
47
|
+
- Partial provisioning (schema created, admin missing) strands tenants in unusable states — wrap every step in one transaction.
|
|
48
|
+
|
|
49
|
+
## Trigger → action
|
|
50
|
+
|
|
51
|
+
| Trigger | Action |
|
|
52
|
+
|---------|--------|
|
|
53
|
+
| Every request | resolve tenant → inject into request context → set the RLS session variable |
|
|
54
|
+
| New tenant | transactional provision: schema/rows + seed data + default admin |
|
|
55
|
+
| Tenant cancels | suspend access → retention window → scheduled cascade purge |
|
|
56
|
+
| Feature-flag change | update flag → invalidate that tenant's prefixed cache keys |
|
|
57
|
+
| Export request | async job → open-format archive → audited delivery |
|
|
58
|
+
|
|
59
|
+
## Quality gates
|
|
60
|
+
|
|
61
|
+
- RLS active on 100% of multi-tenant tables; zero repository queries without a tenant filter.
|
|
62
|
+
- Tenant-resolution middleware tested against unknown and reserved tenants.
|
|
63
|
+
- Provisioning rollback proven by a failing-step test.
|
|
64
|
+
- Export and cascade deletion exercised end-to-end in staging.
|
|
65
|
+
- Audit-log entries for every super-admin/cross-tenant access, export, and deletion.
|
|
66
|
+
|
|
67
|
+
## Forbidden
|
|
68
|
+
|
|
69
|
+
- Accepting `tenant_id` from the request body without validating it against the authenticated session.
|
|
70
|
+
- Queries on multi-tenant tables without a tenant filter (even with RLS on).
|
|
71
|
+
- Cache keys without a tenant prefix.
|
|
72
|
+
- Cross-tenant read/write outside an audited super-admin context.
|
|
73
|
+
- Non-transactional tenant provisioning.
|
|
74
|
+
- Deleting tenant data without the post-cancellation retention window.
|
|
75
|
+
- Handing reserved subdomains to tenants.
|
|
76
|
+
|
|
77
|
+
## References (read on demand)
|
|
78
|
+
|
|
79
|
+
- `references/multi-tenancy/patterns.md` — RLS policy SQL, tenant-context middleware, tenant-aware caching/feature flags, transactional provisioning.
|