@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,110 @@
|
|
|
1
|
+
# Reference: Laravel HTTP layer (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/laravel` — thin controller, Form Request, Policy, API Resource. Read when adding or changing an endpoint.
|
|
4
|
+
|
|
5
|
+
## Form Request (validation + authorization trigger)
|
|
6
|
+
|
|
7
|
+
```php
|
|
8
|
+
// app/Http/Requests/StoreOrderRequest.php
|
|
9
|
+
namespace App\Http\Requests;
|
|
10
|
+
|
|
11
|
+
use Illuminate\Foundation\Http\FormRequest;
|
|
12
|
+
|
|
13
|
+
class StoreOrderRequest extends FormRequest
|
|
14
|
+
{
|
|
15
|
+
public function authorize(): bool
|
|
16
|
+
{
|
|
17
|
+
// Policy check at the boundary — no permission ifs inside services.
|
|
18
|
+
return $this->user()->can('create', \App\Models\Order::class);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public function rules(): array
|
|
22
|
+
{
|
|
23
|
+
return [
|
|
24
|
+
'customer_id' => ['required', 'uuid', 'exists:customers,id'],
|
|
25
|
+
'items' => ['required', 'array', 'min:1'],
|
|
26
|
+
'items.*.sku' => ['required', 'string'],
|
|
27
|
+
'items.*.qty' => ['required', 'integer', 'min:1'],
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Thin controller (wire, don't decide)
|
|
34
|
+
|
|
35
|
+
```php
|
|
36
|
+
// app/Http/Controllers/OrderController.php
|
|
37
|
+
namespace App\Http\Controllers;
|
|
38
|
+
|
|
39
|
+
use App\Actions\Orders\PlaceOrder;
|
|
40
|
+
use App\Http\Requests\StoreOrderRequest;
|
|
41
|
+
use App\Http\Resources\OrderResource;
|
|
42
|
+
|
|
43
|
+
class OrderController extends Controller
|
|
44
|
+
{
|
|
45
|
+
// Service/action resolved from the container — constructor injection.
|
|
46
|
+
public function __construct(private readonly PlaceOrder $placeOrder)
|
|
47
|
+
{
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public function store(StoreOrderRequest $request): OrderResource
|
|
51
|
+
{
|
|
52
|
+
$order = $this->placeOrder->handle(
|
|
53
|
+
$request->user(),
|
|
54
|
+
$request->validated(),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return new OrderResource($order);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Policy (one authorization home per model)
|
|
63
|
+
|
|
64
|
+
```php
|
|
65
|
+
// app/Policies/OrderPolicy.php
|
|
66
|
+
namespace App\Policies;
|
|
67
|
+
|
|
68
|
+
use App\Models\Order;
|
|
69
|
+
use App\Models\User;
|
|
70
|
+
|
|
71
|
+
class OrderPolicy
|
|
72
|
+
{
|
|
73
|
+
public function view(User $user, Order $order): bool
|
|
74
|
+
{
|
|
75
|
+
return $order->customer->team_id === $user->team_id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public function create(User $user): bool
|
|
79
|
+
{
|
|
80
|
+
return $user->hasVerifiedEmail();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## API Resource (never raw model serialization)
|
|
86
|
+
|
|
87
|
+
```php
|
|
88
|
+
// app/Http/Resources/OrderResource.php
|
|
89
|
+
namespace App\Http\Resources;
|
|
90
|
+
|
|
91
|
+
use Illuminate\Http\Request;
|
|
92
|
+
use Illuminate\Http\Resources\Json\JsonResource;
|
|
93
|
+
|
|
94
|
+
class OrderResource extends JsonResource
|
|
95
|
+
{
|
|
96
|
+
public function toArray(Request $request): array
|
|
97
|
+
{
|
|
98
|
+
return [
|
|
99
|
+
'id' => $this->id,
|
|
100
|
+
'status' => $this->status,
|
|
101
|
+
'total' => $this->total,
|
|
102
|
+
// whenLoaded: the resource never triggers lazy loads.
|
|
103
|
+
'items' => OrderItemResource::collection($this->whenLoaded('items')),
|
|
104
|
+
'created_at' => $this->created_at->toIso8601String(),
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Route registration stays declarative (`routes/api.php`): named routes, controller references, middleware groups — no closures with logic.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Reference: LGPD patterns (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `domain/lgpd` — legal-basis registry schema, pseudonymize + orphan deletion, titular-rights endpoints, retention purge job, and the incident runbook skeleton. Evicted from the standing fragment; read when implementing one of these mechanisms.
|
|
4
|
+
|
|
5
|
+
## Legal-basis registry (data inventory as a table)
|
|
6
|
+
|
|
7
|
+
```sql
|
|
8
|
+
-- The inventory is data, not a wiki page: reviewable in migrations, queryable in CI.
|
|
9
|
+
CREATE TABLE data_inventory (
|
|
10
|
+
table_name TEXT NOT NULL,
|
|
11
|
+
column_name TEXT NOT NULL,
|
|
12
|
+
category TEXT NOT NULL, -- identifier | contact | financial | sensitive | behavioral
|
|
13
|
+
legal_basis TEXT NOT NULL, -- consent | legitimate_interest | contract | legal_obligation
|
|
14
|
+
purpose TEXT NOT NULL, -- one declared purpose per row
|
|
15
|
+
retention TEXT NOT NULL, -- e.g. 'account_lifetime', '5y_after_termination (Lei X art. Y)'
|
|
16
|
+
PRIMARY KEY (table_name, column_name, purpose)
|
|
17
|
+
);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
CI gate: introspect the schema, flag any personal-data column (name heuristics + reviewer tagging) missing from the inventory — the migration that adds a column ships the inventory row.
|
|
21
|
+
|
|
22
|
+
## Consent record (granular, versioned, revocable)
|
|
23
|
+
|
|
24
|
+
```sql
|
|
25
|
+
CREATE TABLE consents (
|
|
26
|
+
titular_id UUID NOT NULL,
|
|
27
|
+
purpose TEXT NOT NULL, -- one purpose per row, never a bundle
|
|
28
|
+
policy_version TEXT NOT NULL, -- what text the titular actually saw
|
|
29
|
+
granted_at TIMESTAMPTZ NOT NULL,
|
|
30
|
+
revoked_at TIMESTAMPTZ, -- NULL = active; revocation is one UPDATE
|
|
31
|
+
channel TEXT NOT NULL, -- where opt-in happened (form, api, import)
|
|
32
|
+
PRIMARY KEY (titular_id, purpose, granted_at)
|
|
33
|
+
);
|
|
34
|
+
-- Every processing path for a consent-based purpose starts with:
|
|
35
|
+
-- WHERE revoked_at IS NULL AND purpose = $1
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Pseudonymize + orphan (deletion under immutable stores)
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
// Mutable stores: cascade delete. Immutable stores (event logs, git history,
|
|
42
|
+
// backups): the identifiers were only ever pseudonyms — destroy the key mapping
|
|
43
|
+
// and the immutable record orphans itself.
|
|
44
|
+
async function deleteTitular(titularId) {
|
|
45
|
+
const holds = await legalHolds(titularId); // fiscal/labor retention etc.
|
|
46
|
+
await db.transaction(async (trx) => {
|
|
47
|
+
await trx.raw(cascadeDeleteMutable(titularId), { skip: holds });
|
|
48
|
+
// pseudonym_keys: { pseudonym, titular_id } — the ONLY link between the
|
|
49
|
+
// pseudonymous ids in immutable stores and a real person
|
|
50
|
+
await trx.pseudonymKeys.deleteWhere({ titular_id: titularId });
|
|
51
|
+
await trx.deletionLog.insert({ titular_id_hash: hash(titularId), holds });
|
|
52
|
+
});
|
|
53
|
+
return { deleted: true, retainedUnderLegalHold: holds }; // response names the law
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Backups: deletion is completed when the last backup containing the key mapping expires — document the backup retention window in the deletion response.
|
|
58
|
+
|
|
59
|
+
## Titular-rights endpoints
|
|
60
|
+
|
|
61
|
+
```javascript
|
|
62
|
+
// Authenticated, deadline-tracked features — not support tickets.
|
|
63
|
+
router.post('/privacy/export', auth, async (req, res) => {
|
|
64
|
+
const job = await jobs.enqueue('titular-export', { titularId: req.user.id });
|
|
65
|
+
await slaTracker.start('access_request', job.id); // regulatory deadline clock
|
|
66
|
+
res.status(202).json({ jobId: job.id }); // async: JSON + CSV archive
|
|
67
|
+
});
|
|
68
|
+
router.post('/privacy/delete', auth, confirmIdentity, async (req, res) => {
|
|
69
|
+
res.status(202).json(await jobs.enqueue('titular-delete', { titularId: req.user.id }));
|
|
70
|
+
});
|
|
71
|
+
router.patch('/privacy/correct', auth, async (req, res) => {
|
|
72
|
+
res.json(await titulars.correct(req.user.id, validate(correctionSchema, req.body)));
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Retention purge job
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
// Retention lives in the inventory; the job enforces it. Policy prose purges nothing.
|
|
80
|
+
async function purgeExpired() {
|
|
81
|
+
for (const rule of await db.dataInventory.withFiniteRetention()) {
|
|
82
|
+
const purged = await db.raw(purgeSql(rule)); // DELETE ... WHERE created_at < now() - retention
|
|
83
|
+
await db.auditLog.insert({ kind: 'retention_purge', rule: rule.id, rows: purged.count });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Aggregation-by-default analytics
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// ❌ WRONG: individual-level people analytics as the default view
|
|
92
|
+
router.get('/analytics/messages-per-agent', ...); // names one person
|
|
93
|
+
|
|
94
|
+
// ✅ RIGHT: aggregates with a minimum group size; drill-down is the exception
|
|
95
|
+
const MIN_GROUP = 5; // k-anonymity floor
|
|
96
|
+
router.get('/analytics/team-metrics', auth, async (req, res) => {
|
|
97
|
+
const rows = await metrics.teamAggregates(req.query);
|
|
98
|
+
res.json(rows.filter((r) => r.group_size >= MIN_GROUP));
|
|
99
|
+
});
|
|
100
|
+
router.get('/analytics/person/:id', auth, requireRole('people-analytics'),
|
|
101
|
+
auditAccess('individual_analytics'), handler); // role-gated + logged
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Incident runbook skeleton
|
|
105
|
+
|
|
106
|
+
1. **Contain** — revoke exposed credentials, isolate the system; preserve evidence.
|
|
107
|
+
2. **Assess** — what data, which titulares, how many, sensitive categories involved? Risk to titulares is the notification criterion.
|
|
108
|
+
3. **Decide** — the DPO (encarregado) owns the call; the engineering lead feeds facts, not conclusions.
|
|
109
|
+
4. **Notify** — ANPD and affected titulares within the regulatory window when risk is relevant; record the decision either way.
|
|
110
|
+
5. **Review** — post-mortem with schema/log changes as action items; rehearse the runbook at least yearly (drill, not document review).
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Reference: model routing table and per-feature budgets (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/llm-ops-production` — one central routing table (feature → tier), cost logging with budget alerts. Model identifiers and token prices live in configuration (a versioned models config), never in feature code.
|
|
4
|
+
|
|
5
|
+
## Central routing table
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/routing/model_router.py
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from langchain.chat_models import init_chat_model
|
|
12
|
+
from app.config import settings # tier → model id mapping loaded from config
|
|
13
|
+
|
|
14
|
+
class ModelTier(Enum):
|
|
15
|
+
FAST = "fast" # cheap/low-latency tier
|
|
16
|
+
SMART = "smart" # high-quality tier (with provider fallback)
|
|
17
|
+
LOCAL = "local" # local model — free, private
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class RoutingConfig:
|
|
21
|
+
"""Per-feature routing declared in one place."""
|
|
22
|
+
feature: str
|
|
23
|
+
tier: ModelTier
|
|
24
|
+
max_tokens: int
|
|
25
|
+
temperature: float = 0.0
|
|
26
|
+
monthly_budget_usd: float = 50.0
|
|
27
|
+
|
|
28
|
+
# Change models/tiers here (or in the config it loads from) — never in feature code.
|
|
29
|
+
ROUTING_TABLE: dict[str, RoutingConfig] = {
|
|
30
|
+
"chat": RoutingConfig("chat", ModelTier.SMART, 2048, 0.7, 500.0),
|
|
31
|
+
"summarize": RoutingConfig("summarize", ModelTier.FAST, 1024, 0.0, 100.0),
|
|
32
|
+
"classify": RoutingConfig("classify", ModelTier.FAST, 256, 0.0, 50.0),
|
|
33
|
+
"extraction": RoutingConfig("extraction", ModelTier.FAST, 512, 0.0, 50.0),
|
|
34
|
+
"batch_process": RoutingConfig("batch_process", ModelTier.LOCAL, 2048, 0.0, 0.0),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
def get_llm_for_feature(feature: str):
|
|
38
|
+
config = ROUTING_TABLE.get(feature)
|
|
39
|
+
if not config:
|
|
40
|
+
raise ValueError(f"Unknown feature: {feature}. Add it to ROUTING_TABLE.")
|
|
41
|
+
|
|
42
|
+
model_id = settings.tier_models[config.tier.value] # from config, not literals
|
|
43
|
+
llm = init_chat_model(model_id, temperature=config.temperature,
|
|
44
|
+
max_tokens=config.max_tokens)
|
|
45
|
+
|
|
46
|
+
if config.tier == ModelTier.SMART:
|
|
47
|
+
fallback = init_chat_model(settings.tier_models["fallback"],
|
|
48
|
+
temperature=config.temperature,
|
|
49
|
+
max_tokens=config.max_tokens)
|
|
50
|
+
return llm.with_fallbacks([fallback])
|
|
51
|
+
return llm
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Cost logging with budget alert
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
# app/cost/tracker.py
|
|
58
|
+
import asyncpg
|
|
59
|
+
import logging
|
|
60
|
+
from datetime import datetime, timezone
|
|
61
|
+
from app.routing.model_router import ROUTING_TABLE
|
|
62
|
+
from app.config import settings # settings.cost_per_1k: model → {"input","output"} rates
|
|
63
|
+
|
|
64
|
+
logger = logging.getLogger(__name__)
|
|
65
|
+
|
|
66
|
+
async def log_and_check_budget(
|
|
67
|
+
feature: str,
|
|
68
|
+
model: str,
|
|
69
|
+
input_tokens: int,
|
|
70
|
+
output_tokens: int,
|
|
71
|
+
db_pool: asyncpg.Pool,
|
|
72
|
+
) -> None:
|
|
73
|
+
rates = settings.cost_per_1k.get(model, {"input": 0.0, "output": 0.0})
|
|
74
|
+
cost = (input_tokens / 1000 * rates["input"]) + (output_tokens / 1000 * rates["output"])
|
|
75
|
+
|
|
76
|
+
async with db_pool.acquire() as conn:
|
|
77
|
+
await conn.execute(
|
|
78
|
+
"""INSERT INTO llm_cost_log
|
|
79
|
+
(feature, model, input_tokens, output_tokens, cost_usd, created_at)
|
|
80
|
+
VALUES ($1, $2, $3, $4, $5, $6)""",
|
|
81
|
+
feature, model, input_tokens, output_tokens, cost,
|
|
82
|
+
datetime.now(timezone.utc),
|
|
83
|
+
)
|
|
84
|
+
monthly_spend = await conn.fetchval(
|
|
85
|
+
"""SELECT COALESCE(SUM(cost_usd), 0) FROM llm_cost_log
|
|
86
|
+
WHERE feature = $1
|
|
87
|
+
AND date_trunc('month', created_at) = date_trunc('month', NOW())""",
|
|
88
|
+
feature,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
budget = ROUTING_TABLE[feature].monthly_budget_usd
|
|
92
|
+
if budget and monthly_spend > budget * 0.95:
|
|
93
|
+
# Alert at ~95% — alert first, then decide whether to block.
|
|
94
|
+
logger.warning({
|
|
95
|
+
"event": "budget_alert",
|
|
96
|
+
"feature": feature,
|
|
97
|
+
"spent_usd": float(monthly_spend),
|
|
98
|
+
"budget_usd": budget,
|
|
99
|
+
"pct_used": round(monthly_spend / budget * 100, 1),
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Latency SLO declaration
|
|
104
|
+
|
|
105
|
+
```yaml
|
|
106
|
+
# SLO definitions — enforced with metric alerts, reviewed per class
|
|
107
|
+
SLOs:
|
|
108
|
+
interactive:
|
|
109
|
+
features: [chat, classify, extraction]
|
|
110
|
+
p95_target_ms: 2000
|
|
111
|
+
p99_target_ms: 3000
|
|
112
|
+
error_budget_monthly_pct: 0.1
|
|
113
|
+
async_batch:
|
|
114
|
+
features: [summarize, batch_process]
|
|
115
|
+
p95_target_ms: 15000
|
|
116
|
+
p99_target_ms: 30000
|
|
117
|
+
error_budget_monthly_pct: 1
|
|
118
|
+
```
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Reference: tracing, registry prompts, LLM-as-judge, stable A/B (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/llm-ops-production` — trace decoration, prompt fetch by registry label, judge-based evaluation, and consistent per-user A/B assignment.
|
|
4
|
+
|
|
5
|
+
## Trace decoration (Langfuse)
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/tracing.py
|
|
9
|
+
from langfuse import Langfuse
|
|
10
|
+
from langfuse.decorators import langfuse_context, observe
|
|
11
|
+
|
|
12
|
+
langfuse = Langfuse() # keys/host from environment
|
|
13
|
+
|
|
14
|
+
@observe(name="SummarizeChain")
|
|
15
|
+
async def summarize_document(text: str, user_id: str) -> str:
|
|
16
|
+
langfuse_context.update_current_trace(
|
|
17
|
+
user_id=user_id,
|
|
18
|
+
tags=["summarize", "v1"],
|
|
19
|
+
metadata={"text_length": len(text)}, # never personal data or secrets
|
|
20
|
+
)
|
|
21
|
+
result = await llm_chain.ainvoke({"text": text}) # traced automatically
|
|
22
|
+
langfuse_context.score_current_observation(name="output_length", value=len(result))
|
|
23
|
+
return result
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Registry-versioned prompts
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
# app/prompts/registry.py
|
|
30
|
+
from app.tracing import langfuse
|
|
31
|
+
|
|
32
|
+
def get_prompt(prompt_name: str, version: int | None = None):
|
|
33
|
+
"""version=None → the 'production' label (latest approved).
|
|
34
|
+
version=N → a pinned version for A/B testing."""
|
|
35
|
+
lf_prompt = langfuse.get_prompt(
|
|
36
|
+
name=prompt_name,
|
|
37
|
+
version=version,
|
|
38
|
+
label="production" if version is None else None,
|
|
39
|
+
type="chat",
|
|
40
|
+
)
|
|
41
|
+
return lf_prompt.get_langchain_prompt()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## LLM-as-judge evaluation
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
# app/evaluation/judge.py
|
|
48
|
+
from langchain.chat_models import init_chat_model
|
|
49
|
+
from langchain_core.prompts import ChatPromptTemplate
|
|
50
|
+
from pydantic import BaseModel, Field
|
|
51
|
+
from app.config import settings
|
|
52
|
+
|
|
53
|
+
class JudgeScore(BaseModel):
|
|
54
|
+
score: int = Field(ge=1, le=10, description="Quality score 1-10")
|
|
55
|
+
reasoning: str = Field(description="Brief explanation of the score")
|
|
56
|
+
passed: bool = Field(description="Meets the production bar (score >= 7)")
|
|
57
|
+
|
|
58
|
+
JUDGE_PROMPT = ChatPromptTemplate.from_messages([
|
|
59
|
+
("system", """You are an expert evaluator assessing LLM output quality.
|
|
60
|
+
Score 1-10 on: accuracy (grounded in the context), completeness, clarity.
|
|
61
|
+
Score >= 7 = production quality."""),
|
|
62
|
+
("human", "Question: {question}\n\nContext: {context}\n\nResponse to evaluate: {response}"),
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
judge_llm = init_chat_model(settings.judge_model, temperature=0)
|
|
66
|
+
|
|
67
|
+
async def evaluate_with_judge(question: str, context: str, response: str) -> JudgeScore:
|
|
68
|
+
chain = JUDGE_PROMPT | judge_llm.with_structured_output(JudgeScore)
|
|
69
|
+
return await chain.ainvoke({"question": question, "context": context, "response": response})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Calibrate the judge with a periodic human-annotation loop; never compare scores across different prompt versions of the judge itself.
|
|
73
|
+
|
|
74
|
+
## Stable per-user A/B assignment
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
# app/ab_testing/prompt_ab.py
|
|
78
|
+
import hashlib
|
|
79
|
+
from app.tracing import langfuse, langfuse_context
|
|
80
|
+
|
|
81
|
+
def get_ab_prompt(prompt_name: str, user_id: str):
|
|
82
|
+
"""Consistent hashing — same user always gets the same variant.
|
|
83
|
+
Python's built-in hash() is salted per process; use hashlib instead."""
|
|
84
|
+
bucket = int(hashlib.sha256(user_id.encode()).hexdigest(), 16) % 100
|
|
85
|
+
variant = "control" if bucket < 70 else "treatment"
|
|
86
|
+
|
|
87
|
+
version_map = {"control": None, "treatment": 15} # None → production label
|
|
88
|
+
prompt = langfuse.get_prompt(
|
|
89
|
+
name=prompt_name,
|
|
90
|
+
version=version_map[variant],
|
|
91
|
+
label="production" if version_map[variant] is None else None,
|
|
92
|
+
)
|
|
93
|
+
langfuse_context.update_current_trace(
|
|
94
|
+
metadata={"ab_variant": variant, "prompt_version": version_map[variant]},
|
|
95
|
+
)
|
|
96
|
+
return prompt.get_langchain_prompt(), variant
|
|
97
|
+
|
|
98
|
+
# Analysis — only after the pre-declared sample size is reached per variant:
|
|
99
|
+
# SELECT variant, AVG(score), COUNT(*) FROM evaluation_results
|
|
100
|
+
# WHERE prompt_name = 'summarize-document'
|
|
101
|
+
# GROUP BY variant HAVING COUNT(*) >= 200;
|
|
102
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Reference: Compose skeleton and gateway routing (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/microservices-docker` — shared service defaults via anchors, healthchecks with dependency conditions, and nginx gateway routing. The top-level `version` key is obsolete under the Compose Specification — omit it.
|
|
4
|
+
|
|
5
|
+
## docker-compose.yml
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
x-service-defaults: &service-defaults
|
|
9
|
+
restart: unless-stopped
|
|
10
|
+
networks: [app-net]
|
|
11
|
+
logging:
|
|
12
|
+
driver: json-file
|
|
13
|
+
options: { max-size: "10m", max-file: "3" }
|
|
14
|
+
|
|
15
|
+
services:
|
|
16
|
+
gateway:
|
|
17
|
+
<<: *service-defaults
|
|
18
|
+
image: nginx:alpine # pin an explicit tag in production
|
|
19
|
+
ports: ["80:80"]
|
|
20
|
+
volumes: ["./services/gateway/nginx.conf:/etc/nginx/nginx.conf:ro"]
|
|
21
|
+
depends_on: [auth-service, user-service, post-service]
|
|
22
|
+
|
|
23
|
+
auth-service:
|
|
24
|
+
<<: *service-defaults
|
|
25
|
+
build: { context: ./services/auth-service, target: production }
|
|
26
|
+
environment:
|
|
27
|
+
DATABASE_URL: postgres://auth:${AUTH_DB_PASSWORD}@auth-db:5432/auth
|
|
28
|
+
JWT_SECRET: ${JWT_SECRET}
|
|
29
|
+
REDIS_URL: redis://redis:6379
|
|
30
|
+
depends_on:
|
|
31
|
+
auth-db: { condition: service_healthy }
|
|
32
|
+
redis: { condition: service_healthy }
|
|
33
|
+
healthcheck:
|
|
34
|
+
test: ["CMD", "wget", "-qO-", "http://localhost:3001/health"]
|
|
35
|
+
interval: 10s
|
|
36
|
+
timeout: 5s
|
|
37
|
+
retries: 3
|
|
38
|
+
|
|
39
|
+
auth-db:
|
|
40
|
+
image: postgres:alpine # pin an explicit tag in production
|
|
41
|
+
environment:
|
|
42
|
+
POSTGRES_USER: auth
|
|
43
|
+
POSTGRES_PASSWORD: ${AUTH_DB_PASSWORD}
|
|
44
|
+
POSTGRES_DB: auth
|
|
45
|
+
volumes: [auth-db-data:/var/lib/postgresql/data]
|
|
46
|
+
healthcheck:
|
|
47
|
+
test: ["CMD-SHELL", "pg_isready -U auth"]
|
|
48
|
+
interval: 5s
|
|
49
|
+
|
|
50
|
+
redis:
|
|
51
|
+
image: redis:alpine
|
|
52
|
+
healthcheck:
|
|
53
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
54
|
+
interval: 5s
|
|
55
|
+
volumes: [redis-data:/data]
|
|
56
|
+
|
|
57
|
+
notification-service:
|
|
58
|
+
<<: *service-defaults
|
|
59
|
+
build: { context: ./services/notification-service, target: production }
|
|
60
|
+
environment:
|
|
61
|
+
REDIS_URL: redis://redis:6379
|
|
62
|
+
SMTP_HOST: ${SMTP_HOST}
|
|
63
|
+
depends_on:
|
|
64
|
+
redis: { condition: service_healthy }
|
|
65
|
+
|
|
66
|
+
networks:
|
|
67
|
+
app-net:
|
|
68
|
+
|
|
69
|
+
volumes:
|
|
70
|
+
auth-db-data:
|
|
71
|
+
redis-data:
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Layering: `docker-compose.override.yml` holds dev-only volumes/ports; `docker-compose.prod.yml` selects the production build target. Same Dockerfile everywhere — only environment differs.
|
|
75
|
+
|
|
76
|
+
## nginx gateway
|
|
77
|
+
|
|
78
|
+
```nginx
|
|
79
|
+
# services/gateway/nginx.conf
|
|
80
|
+
upstream auth { server auth-service:3001; }
|
|
81
|
+
upstream users { server user-service:3002; }
|
|
82
|
+
upstream posts { server post-service:3003; }
|
|
83
|
+
|
|
84
|
+
server {
|
|
85
|
+
listen 80;
|
|
86
|
+
add_header X-Request-ID $request_id always;
|
|
87
|
+
|
|
88
|
+
location /api/auth/ { proxy_pass http://auth/; proxy_set_header X-Correlation-ID $request_id; }
|
|
89
|
+
location /api/users/ { proxy_pass http://users/; proxy_set_header X-Correlation-ID $request_id; }
|
|
90
|
+
location /api/posts/ { proxy_pass http://posts/; proxy_set_header X-Correlation-ID $request_id; }
|
|
91
|
+
location /health { return 200 '{"status":"ok"}'; add_header Content-Type application/json; }
|
|
92
|
+
}
|
|
93
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Reference: correlation IDs and event-driven side effects (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/microservices-docker` — correlation middleware and propagation, typed event schemas, queue producer/consumer with retries.
|
|
4
|
+
|
|
5
|
+
## Correlation ID middleware and propagation
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// shared/middleware/correlation.ts
|
|
9
|
+
import { randomUUID } from 'node:crypto'
|
|
10
|
+
import type { Request, Response, NextFunction } from 'express'
|
|
11
|
+
|
|
12
|
+
export const CORRELATION_HEADER = 'x-correlation-id'
|
|
13
|
+
|
|
14
|
+
export function correlationMiddleware(req: Request, res: Response, next: NextFunction): void {
|
|
15
|
+
const correlationId = (req.headers[CORRELATION_HEADER] as string) ?? randomUUID()
|
|
16
|
+
req.correlationId = correlationId
|
|
17
|
+
res.setHeader(CORRELATION_HEADER, correlationId)
|
|
18
|
+
next()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Outgoing HTTP call — always propagate the correlation ID
|
|
22
|
+
export function makeRequest(
|
|
23
|
+
url: string,
|
|
24
|
+
init: RequestInit,
|
|
25
|
+
correlationId: string,
|
|
26
|
+
): Promise<Response> {
|
|
27
|
+
return fetch(url, {
|
|
28
|
+
...init,
|
|
29
|
+
headers: { ...init.headers, [CORRELATION_HEADER]: correlationId },
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare global { namespace Express { interface Request { correlationId: string } } }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Every log line includes the correlation ID; debugging a cross-service request means following one ID through each service's logs.
|
|
37
|
+
|
|
38
|
+
## Typed event schemas
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// shared/events/index.ts — the contract between producers and consumers
|
|
42
|
+
export type AppEvent =
|
|
43
|
+
| { type: 'USER_CREATED'; payload: { userId: string; email: string; name: string } }
|
|
44
|
+
| { type: 'POST_PUBLISHED'; payload: { postId: string; authorId: string; title: string } }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Producer with retry policy (BullMQ)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// services/user-service/src/producers/user.ts
|
|
51
|
+
import { Queue } from 'bullmq'
|
|
52
|
+
import Redis from 'ioredis'
|
|
53
|
+
import type { AppEvent } from '../../../shared/events'
|
|
54
|
+
|
|
55
|
+
const connection = new Redis(process.env.REDIS_URL!, { maxRetriesPerRequest: null })
|
|
56
|
+
const eventQueue = new Queue<AppEvent>('app-events', { connection })
|
|
57
|
+
|
|
58
|
+
export async function emitUserCreated(userId: string, email: string, name: string): Promise<void> {
|
|
59
|
+
await eventQueue.add('USER_CREATED', {
|
|
60
|
+
type: 'USER_CREATED',
|
|
61
|
+
payload: { userId, email, name },
|
|
62
|
+
}, {
|
|
63
|
+
attempts: 3,
|
|
64
|
+
backoff: { type: 'exponential', delay: 1000 },
|
|
65
|
+
removeOnComplete: true,
|
|
66
|
+
// failed jobs are kept — wire a dead-letter/failed-jobs review process
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Idempotent consumer
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// services/notification-service/src/consumers/events.ts
|
|
75
|
+
import { Worker } from 'bullmq'
|
|
76
|
+
import Redis from 'ioredis'
|
|
77
|
+
import type { AppEvent } from '../../../shared/events'
|
|
78
|
+
|
|
79
|
+
const connection = new Redis(process.env.REDIS_URL!, { maxRetriesPerRequest: null })
|
|
80
|
+
|
|
81
|
+
new Worker<AppEvent>('app-events', async (job) => {
|
|
82
|
+
const { type, payload } = job.data
|
|
83
|
+
// Handlers must be idempotent — retries redeliver the same job.
|
|
84
|
+
if (type === 'USER_CREATED') {
|
|
85
|
+
await sendWelcomeEmail(payload.email, payload.name)
|
|
86
|
+
}
|
|
87
|
+
}, { connection, concurrency: 5 })
|
|
88
|
+
```
|