@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,97 @@
|
|
|
1
|
+
# Reference: serving metrics, drift detection and container (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/ml-fastapi-serving` — Prometheus metric definitions, background drift detection, multi-stage Dockerfile with healthcheck.
|
|
4
|
+
|
|
5
|
+
## Prometheus metrics
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/middleware/metrics.py
|
|
9
|
+
from prometheus_client import Counter, Histogram, Gauge, make_asgi_app
|
|
10
|
+
|
|
11
|
+
prediction_counter = Counter(
|
|
12
|
+
"ml_predictions_total", "Total predictions", ["model_version", "status"],
|
|
13
|
+
)
|
|
14
|
+
prediction_latency = Histogram(
|
|
15
|
+
"ml_prediction_duration_seconds", "Prediction latency", ["model_version"],
|
|
16
|
+
buckets=[0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0],
|
|
17
|
+
)
|
|
18
|
+
prediction_errors = Counter(
|
|
19
|
+
"ml_prediction_errors_total", "Prediction errors by type", ["error_type"],
|
|
20
|
+
)
|
|
21
|
+
model_loaded = Gauge(
|
|
22
|
+
"ml_model_loaded", "Whether model is loaded (1=yes)", ["model_version"],
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
metrics_app = make_asgi_app()
|
|
26
|
+
|
|
27
|
+
def add_metrics_route(app):
|
|
28
|
+
app.mount("/metrics", metrics_app) # Prometheus scrape endpoint, always available
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Background drift detection
|
|
32
|
+
|
|
33
|
+
Drift checks run in a background loop over buffered prediction features — never in the request path.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
# app/drift/detector.py
|
|
37
|
+
from evidently.report import Report
|
|
38
|
+
from evidently.metric_preset import DataDriftPreset
|
|
39
|
+
import pandas as pd
|
|
40
|
+
import asyncio, logging
|
|
41
|
+
|
|
42
|
+
logger = logging.getLogger(__name__)
|
|
43
|
+
|
|
44
|
+
DRIFT_CHECK_INTERVAL = 3600 # seconds between checks
|
|
45
|
+
DRIFT_THRESHOLD = 0.3 # alert when share of drifted columns exceeds this
|
|
46
|
+
|
|
47
|
+
class DriftDetector:
|
|
48
|
+
def __init__(self, reference_data: pd.DataFrame):
|
|
49
|
+
self.reference = reference_data
|
|
50
|
+
self.predictions_buffer: list[dict] = []
|
|
51
|
+
|
|
52
|
+
def add_prediction(self, features: dict):
|
|
53
|
+
self.predictions_buffer.append(features)
|
|
54
|
+
|
|
55
|
+
async def check_drift_loop(self):
|
|
56
|
+
while True:
|
|
57
|
+
await asyncio.sleep(DRIFT_CHECK_INTERVAL)
|
|
58
|
+
if len(self.predictions_buffer) >= 100:
|
|
59
|
+
self._run_drift_check()
|
|
60
|
+
|
|
61
|
+
def _run_drift_check(self):
|
|
62
|
+
current = pd.DataFrame(self.predictions_buffer[-1000:])
|
|
63
|
+
report = Report(metrics=[DataDriftPreset()])
|
|
64
|
+
report.run(reference_data=self.reference, current_data=current)
|
|
65
|
+
drift_share = report.as_dict()["metrics"][0]["result"]["share_of_drifted_columns"]
|
|
66
|
+
logger.info({"event": "drift_check", "drift_share": drift_share})
|
|
67
|
+
if drift_share > DRIFT_THRESHOLD:
|
|
68
|
+
logger.warning({
|
|
69
|
+
"event": "feature_drift_detected",
|
|
70
|
+
"drift_share": drift_share,
|
|
71
|
+
"action": "Consider retraining model",
|
|
72
|
+
})
|
|
73
|
+
self.predictions_buffer.clear()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Multi-stage Dockerfile
|
|
77
|
+
|
|
78
|
+
```dockerfile
|
|
79
|
+
FROM python:slim AS base
|
|
80
|
+
WORKDIR /app
|
|
81
|
+
RUN apt-get update && apt-get install -y --no-install-recommends gcc && \
|
|
82
|
+
rm -rf /var/lib/apt/lists/*
|
|
83
|
+
|
|
84
|
+
FROM base AS builder
|
|
85
|
+
COPY requirements.txt .
|
|
86
|
+
RUN pip install --no-cache-dir --user -r requirements.txt
|
|
87
|
+
|
|
88
|
+
FROM base AS production
|
|
89
|
+
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 PORT=8000
|
|
90
|
+
COPY --from=builder /root/.local /root/.local
|
|
91
|
+
COPY . .
|
|
92
|
+
ENV PATH=/root/.local/bin:$PATH
|
|
93
|
+
|
|
94
|
+
HEALTHCHECK --interval=30s --timeout=5s CMD wget -qO- http://localhost:8000/healthz || exit 1
|
|
95
|
+
EXPOSE 8000
|
|
96
|
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]
|
|
97
|
+
```
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Reference: ML serving core (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/ml-fastapi-serving` — startup model loading, strict schemas, and the versioned predict endpoint. Read when scaffolding or reviewing the serving path.
|
|
4
|
+
|
|
5
|
+
## Singleton model loader + lifespan
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# app/models/loader.py
|
|
9
|
+
import joblib, json, logging
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
class ModelLoader:
|
|
14
|
+
_model = None
|
|
15
|
+
_feature_config: dict | None = None
|
|
16
|
+
|
|
17
|
+
@classmethod
|
|
18
|
+
def load(cls, model_path: str = "artifacts/model_v1.pkl",
|
|
19
|
+
config_path: str = "artifacts/feature_config.json") -> None:
|
|
20
|
+
if cls._model is not None:
|
|
21
|
+
return
|
|
22
|
+
logger.info(f"Loading model from {model_path}")
|
|
23
|
+
cls._model = joblib.load(model_path) # joblib for sklearn; TorchScript/ONNX for deep models
|
|
24
|
+
with open(config_path) as f:
|
|
25
|
+
cls._feature_config = json.load(f)
|
|
26
|
+
logger.info("Model loaded successfully")
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def get_model(cls):
|
|
30
|
+
if cls._model is None:
|
|
31
|
+
raise RuntimeError("Model not loaded. Call ModelLoader.load() at startup.")
|
|
32
|
+
return cls._model
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# app/main.py
|
|
36
|
+
from contextlib import asynccontextmanager
|
|
37
|
+
from fastapi import FastAPI
|
|
38
|
+
from app.models.loader import ModelLoader
|
|
39
|
+
|
|
40
|
+
@asynccontextmanager
|
|
41
|
+
async def lifespan(app: FastAPI):
|
|
42
|
+
ModelLoader.load() # load before accepting traffic
|
|
43
|
+
yield
|
|
44
|
+
|
|
45
|
+
app = FastAPI(lifespan=lifespan, title="ML Prediction API")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Strict request/response schemas
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
# app/schemas/request.py
|
|
52
|
+
from pydantic import BaseModel, Field, model_validator
|
|
53
|
+
from typing import Annotated
|
|
54
|
+
|
|
55
|
+
class PredictRequest(BaseModel):
|
|
56
|
+
model_config = {"strict": True} # reject wrong types outright
|
|
57
|
+
|
|
58
|
+
bedrooms: Annotated[int, Field(ge=1, le=20)]
|
|
59
|
+
bathrooms: Annotated[float, Field(ge=0.5, le=15)]
|
|
60
|
+
sqft: Annotated[int, Field(ge=100, le=20000)]
|
|
61
|
+
year_built: Annotated[int, Field(ge=1800, le=2100)]
|
|
62
|
+
zip_code: Annotated[str, Field(pattern=r"^\d{5}$")]
|
|
63
|
+
|
|
64
|
+
@model_validator(mode="after")
|
|
65
|
+
def validate_cross_field(self) -> "PredictRequest":
|
|
66
|
+
if self.bathrooms > self.bedrooms * 2:
|
|
67
|
+
raise ValueError("Implausible bathroom/bedroom ratio")
|
|
68
|
+
return self
|
|
69
|
+
|
|
70
|
+
def to_feature_array(self) -> list[float]:
|
|
71
|
+
return [float(self.bedrooms), float(self.bathrooms), float(self.sqft)]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# app/schemas/response.py
|
|
75
|
+
from pydantic import BaseModel, Field
|
|
76
|
+
from uuid import UUID, uuid4
|
|
77
|
+
|
|
78
|
+
class PredictResponse(BaseModel):
|
|
79
|
+
prediction_id: UUID = Field(default_factory=uuid4)
|
|
80
|
+
predicted_value: float
|
|
81
|
+
confidence_interval: tuple[float, float]
|
|
82
|
+
model_version: str
|
|
83
|
+
features_used: list[str]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Versioned predict endpoint
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# app/routes/predict_v1.py
|
|
90
|
+
from fastapi import APIRouter, HTTPException
|
|
91
|
+
from app.schemas.request import PredictRequest
|
|
92
|
+
from app.schemas.response import PredictResponse
|
|
93
|
+
from app.models.loader import ModelLoader
|
|
94
|
+
from app.middleware.metrics import prediction_counter, prediction_latency, prediction_errors
|
|
95
|
+
from app.middleware.logging import log_prediction
|
|
96
|
+
import time, logging
|
|
97
|
+
import numpy as np
|
|
98
|
+
|
|
99
|
+
router = APIRouter(prefix="/v1")
|
|
100
|
+
logger = logging.getLogger(__name__)
|
|
101
|
+
|
|
102
|
+
MODEL_VERSION = "v1" # served-model version label, set at deploy time
|
|
103
|
+
FEATURE_NAMES = ["bedrooms", "bathrooms", "sqft"]
|
|
104
|
+
|
|
105
|
+
@router.post("/predict", response_model=PredictResponse)
|
|
106
|
+
async def predict(body: PredictRequest):
|
|
107
|
+
start = time.monotonic()
|
|
108
|
+
try:
|
|
109
|
+
model = ModelLoader.get_model()
|
|
110
|
+
features = np.array([body.to_feature_array()])
|
|
111
|
+
prediction = model.predict(features)[0]
|
|
112
|
+
|
|
113
|
+
response = PredictResponse(
|
|
114
|
+
predicted_value=round(float(prediction), 2),
|
|
115
|
+
confidence_interval=(float(prediction) * 0.9, float(prediction) * 1.1),
|
|
116
|
+
model_version=MODEL_VERSION,
|
|
117
|
+
features_used=FEATURE_NAMES,
|
|
118
|
+
)
|
|
119
|
+
# Mandatory: log features + output for monitoring and retraining
|
|
120
|
+
await log_prediction(
|
|
121
|
+
prediction_id=str(response.prediction_id),
|
|
122
|
+
features=body.model_dump(),
|
|
123
|
+
prediction=float(prediction),
|
|
124
|
+
model_version=MODEL_VERSION,
|
|
125
|
+
)
|
|
126
|
+
prediction_counter.labels(model_version=MODEL_VERSION, status="success").inc()
|
|
127
|
+
return response
|
|
128
|
+
except Exception as e:
|
|
129
|
+
prediction_errors.labels(error_type=type(e).__name__).inc()
|
|
130
|
+
logger.error({"event": "prediction_error", "error": str(e)})
|
|
131
|
+
raise HTTPException(status_code=500, detail="Prediction failed")
|
|
132
|
+
finally:
|
|
133
|
+
prediction_latency.labels(model_version=MODEL_VERSION).observe(time.monotonic() - start)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## A/B variant routing
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# app/routes/ab_test.py — weighted routing between served model variants
|
|
140
|
+
import random
|
|
141
|
+
from fastapi import APIRouter
|
|
142
|
+
from app.models.loader import ModelLoader
|
|
143
|
+
from app.schemas.request import PredictRequest
|
|
144
|
+
|
|
145
|
+
router = APIRouter()
|
|
146
|
+
|
|
147
|
+
AB_CONFIG = {"model_v1": 0.8, "model_v2": 0.2}
|
|
148
|
+
|
|
149
|
+
@router.post("/predict")
|
|
150
|
+
async def predict_ab(body: PredictRequest):
|
|
151
|
+
variant = random.choices(list(AB_CONFIG.keys()), weights=list(AB_CONFIG.values()))[0]
|
|
152
|
+
model = ModelLoader.get_model(variant)
|
|
153
|
+
prediction = model.predict([body.to_feature_array()])[0]
|
|
154
|
+
return {"prediction": float(prediction), "model_variant": variant} # always log the variant
|
|
155
|
+
```
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Reference: DVC pipeline and data versioning (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/ml-training-pipeline` — pipeline stages, tunable params, and the data-versioning workflow.
|
|
4
|
+
|
|
5
|
+
## dvc.yaml — pipeline stages
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
stages:
|
|
9
|
+
preprocess:
|
|
10
|
+
cmd: python src/data/preprocessing.py
|
|
11
|
+
deps:
|
|
12
|
+
- src/data/preprocessing.py
|
|
13
|
+
- data/raw/
|
|
14
|
+
params:
|
|
15
|
+
- params.yaml:
|
|
16
|
+
- preprocessing.test_size
|
|
17
|
+
- preprocessing.random_seed
|
|
18
|
+
outs:
|
|
19
|
+
- data/processed/
|
|
20
|
+
|
|
21
|
+
train:
|
|
22
|
+
cmd: python src/models/train.py
|
|
23
|
+
deps:
|
|
24
|
+
- src/models/train.py
|
|
25
|
+
- src/models/architecture.py
|
|
26
|
+
- data/processed/
|
|
27
|
+
params:
|
|
28
|
+
- params.yaml:
|
|
29
|
+
- training.epochs
|
|
30
|
+
- training.lr
|
|
31
|
+
- training.batch_size
|
|
32
|
+
- model.hidden_size
|
|
33
|
+
metrics:
|
|
34
|
+
- metrics/train_metrics.json:
|
|
35
|
+
cache: false
|
|
36
|
+
outs:
|
|
37
|
+
- models/best_model.pt
|
|
38
|
+
|
|
39
|
+
evaluate:
|
|
40
|
+
cmd: python src/evaluation/metrics.py
|
|
41
|
+
deps:
|
|
42
|
+
- src/evaluation/metrics.py
|
|
43
|
+
- models/best_model.pt
|
|
44
|
+
- data/processed/test/
|
|
45
|
+
metrics:
|
|
46
|
+
- metrics/eval_metrics.json:
|
|
47
|
+
cache: false
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## params.yaml — every tunable in one tracked file
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
preprocessing:
|
|
54
|
+
test_size: 0.2
|
|
55
|
+
val_size: 0.1
|
|
56
|
+
random_seed: 42
|
|
57
|
+
normalize: true
|
|
58
|
+
|
|
59
|
+
training:
|
|
60
|
+
epochs: 50
|
|
61
|
+
lr: 0.001
|
|
62
|
+
lr_scheduler: cosine
|
|
63
|
+
batch_size: 64
|
|
64
|
+
early_stopping_patience: 5
|
|
65
|
+
gradient_clip: 1.0
|
|
66
|
+
|
|
67
|
+
model:
|
|
68
|
+
architecture: resnet50
|
|
69
|
+
num_classes: 10
|
|
70
|
+
dropout: 0.3
|
|
71
|
+
hidden_size: 512
|
|
72
|
+
pretrained: true
|
|
73
|
+
|
|
74
|
+
evaluation:
|
|
75
|
+
metrics: [accuracy, f1_macro, roc_auc]
|
|
76
|
+
threshold: 0.5
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Data versioning workflow
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# One-time setup
|
|
83
|
+
dvc init
|
|
84
|
+
dvc remote add -d storage s3://my-bucket/dvc-store
|
|
85
|
+
|
|
86
|
+
# Track a dataset
|
|
87
|
+
dvc add data/raw/dataset.csv
|
|
88
|
+
git add data/raw/dataset.csv.dvc data/raw/.gitignore
|
|
89
|
+
git commit -m "data: add raw dataset v1.0"
|
|
90
|
+
git tag "data-v1.0"
|
|
91
|
+
|
|
92
|
+
# Run the pipeline (only changed stages re-run)
|
|
93
|
+
dvc repro
|
|
94
|
+
dvc repro --force # force all stages
|
|
95
|
+
|
|
96
|
+
# Push data to remote storage
|
|
97
|
+
dvc push
|
|
98
|
+
|
|
99
|
+
# Switch to an earlier dataset version
|
|
100
|
+
git checkout data-v0.9
|
|
101
|
+
dvc checkout
|
|
102
|
+
```
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Reference: experiment tracking, registry promotion and training CI (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/ml-training-pipeline` — MLflow-instrumented training loop, alias-based registry promotion, and the CI quality gate. Registry lifecycle uses model-version aliases (the older stage-transition API is deprecated).
|
|
4
|
+
|
|
5
|
+
## Training loop with tracking
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
# src/models/train.py
|
|
9
|
+
import mlflow, mlflow.pytorch
|
|
10
|
+
import torch, yaml, os, json
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
|
|
13
|
+
with open("params.yaml") as f:
|
|
14
|
+
params = yaml.safe_load(f)
|
|
15
|
+
|
|
16
|
+
EXPERIMENT_NAME = "image-classification"
|
|
17
|
+
RUN_NAME = f"{params['model']['architecture']}_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
|
|
18
|
+
|
|
19
|
+
def train():
|
|
20
|
+
mlflow.set_tracking_uri(os.environ["MLFLOW_TRACKING_URI"])
|
|
21
|
+
mlflow.set_experiment(EXPERIMENT_NAME)
|
|
22
|
+
|
|
23
|
+
with mlflow.start_run(run_name=RUN_NAME) as run:
|
|
24
|
+
# Log ALL params upfront, plus code and data provenance
|
|
25
|
+
mlflow.log_params({**params["training"], **params["model"]})
|
|
26
|
+
mlflow.log_param("git_commit", os.popen("git rev-parse HEAD").read().strip())
|
|
27
|
+
|
|
28
|
+
model = build_model(params["model"])
|
|
29
|
+
optimizer = torch.optim.AdamW(model.parameters(), lr=params["training"]["lr"])
|
|
30
|
+
scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(
|
|
31
|
+
optimizer, T_max=params["training"]["epochs"])
|
|
32
|
+
|
|
33
|
+
best_val_loss, patience_counter = float("inf"), 0
|
|
34
|
+
for epoch in range(params["training"]["epochs"]):
|
|
35
|
+
train_loss, train_acc = train_epoch(model, train_loader, optimizer)
|
|
36
|
+
val_loss, val_acc = validate(model, val_loader)
|
|
37
|
+
scheduler.step()
|
|
38
|
+
|
|
39
|
+
# Log every epoch — disk is cheap, missing data is not
|
|
40
|
+
mlflow.log_metrics({
|
|
41
|
+
"train_loss": train_loss, "train_acc": train_acc,
|
|
42
|
+
"val_loss": val_loss, "val_acc": val_acc,
|
|
43
|
+
"learning_rate": scheduler.get_last_lr()[0],
|
|
44
|
+
}, step=epoch)
|
|
45
|
+
|
|
46
|
+
if val_loss < best_val_loss:
|
|
47
|
+
best_val_loss, patience_counter = val_loss, 0
|
|
48
|
+
torch.save(model.state_dict(), "models/best_model.pt")
|
|
49
|
+
mlflow.log_artifact("models/best_model.pt")
|
|
50
|
+
else:
|
|
51
|
+
patience_counter += 1
|
|
52
|
+
if patience_counter >= params["training"]["early_stopping_patience"]:
|
|
53
|
+
mlflow.log_param("early_stopped_at_epoch", epoch)
|
|
54
|
+
break
|
|
55
|
+
|
|
56
|
+
mlflow.pytorch.log_model(model, "model")
|
|
57
|
+
with open("metrics/train_metrics.json", "w") as f:
|
|
58
|
+
json.dump({"best_val_loss": best_val_loss, "final_epoch": epoch}, f)
|
|
59
|
+
return run.info.run_id
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Registry promotion via aliases
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# src/registry/promote.py
|
|
66
|
+
import mlflow, os
|
|
67
|
+
from mlflow.tracking import MlflowClient
|
|
68
|
+
|
|
69
|
+
client = MlflowClient(tracking_uri=os.environ["MLFLOW_TRACKING_URI"])
|
|
70
|
+
MODEL_NAME = "image-classifier"
|
|
71
|
+
|
|
72
|
+
def register_model(run_id: str, model_name: str = MODEL_NAME) -> str:
|
|
73
|
+
"""CI registers the trained model and points the 'staging' alias at it."""
|
|
74
|
+
result = mlflow.register_model(f"runs:/{run_id}/model", model_name)
|
|
75
|
+
client.set_model_version_tag(model_name, result.version, "dvc_commit",
|
|
76
|
+
os.popen("git rev-parse HEAD").read().strip())
|
|
77
|
+
client.set_model_version_tag(model_name, result.version, "trained_by", "training_ci")
|
|
78
|
+
client.set_registered_model_alias(model_name, "staging", result.version)
|
|
79
|
+
return result.version
|
|
80
|
+
|
|
81
|
+
def promote_to_production(version: str, model_name: str = MODEL_NAME):
|
|
82
|
+
"""Human-triggered: repoint the 'production' alias. Never automated."""
|
|
83
|
+
client.set_registered_model_alias(model_name, "production", version)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Training CI with a metric quality gate
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
# .github/workflows/training_ci.yml
|
|
90
|
+
name: Training CI
|
|
91
|
+
on:
|
|
92
|
+
push:
|
|
93
|
+
paths: ['params.yaml', 'src/**', 'dvc.yaml']
|
|
94
|
+
|
|
95
|
+
jobs:
|
|
96
|
+
train-and-evaluate:
|
|
97
|
+
runs-on: [self-hosted, gpu]
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v4
|
|
100
|
+
|
|
101
|
+
- name: Setup DVC
|
|
102
|
+
run: pip install "dvc[s3]" mlflow
|
|
103
|
+
env:
|
|
104
|
+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
105
|
+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
106
|
+
|
|
107
|
+
- name: Pull data
|
|
108
|
+
run: dvc pull
|
|
109
|
+
|
|
110
|
+
- name: Run pipeline
|
|
111
|
+
env:
|
|
112
|
+
MLFLOW_TRACKING_URI: ${{ secrets.MLFLOW_URI }}
|
|
113
|
+
run: dvc repro
|
|
114
|
+
|
|
115
|
+
- name: Quality gate on eval metrics
|
|
116
|
+
run: |
|
|
117
|
+
python - <<'EOF'
|
|
118
|
+
import json
|
|
119
|
+
acc = json.load(open("metrics/eval_metrics.json"))["val_accuracy"]
|
|
120
|
+
assert acc >= 0.85, f"Accuracy {acc} below threshold"
|
|
121
|
+
print(f"Quality gate passed: accuracy={acc}")
|
|
122
|
+
EOF
|
|
123
|
+
|
|
124
|
+
- name: Register to staging (never production)
|
|
125
|
+
run: python src/registry/promote.py
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Experiment naming and mandatory tags
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Run name: {task}_{model}_{variant}_{YYYYMMDD}
|
|
132
|
+
e.g. classification_resnet50_baseline_20240315
|
|
133
|
+
|
|
134
|
+
Tags on every run/model version:
|
|
135
|
+
git_commit — code SHA
|
|
136
|
+
dvc_commit — data version SHA
|
|
137
|
+
trained_by — ci | manual | scheduled
|
|
138
|
+
dataset_version — e.g. v1.2
|
|
139
|
+
```
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Reference: alert rules, scrape config, dashboards, collector (read on demand)
|
|
2
|
+
|
|
3
|
+
Exemplar for `stack/monitoring-observability` — symptom-based alert rules, Prometheus scrape config, dashboard-as-code, OpenTelemetry Collector pipelines.
|
|
4
|
+
|
|
5
|
+
## Alert rules — symptoms, not causes
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
# monitoring/alerts/app.yml
|
|
9
|
+
groups:
|
|
10
|
+
- name: app.rules
|
|
11
|
+
rules:
|
|
12
|
+
- alert: HighErrorRate
|
|
13
|
+
expr: |
|
|
14
|
+
rate(http_requests_total{status_code=~"5.."}[5m])
|
|
15
|
+
/ rate(http_requests_total[5m]) > 0.05
|
|
16
|
+
for: 2m
|
|
17
|
+
labels:
|
|
18
|
+
severity: critical
|
|
19
|
+
team: backend
|
|
20
|
+
annotations:
|
|
21
|
+
summary: "High error rate on {{ $labels.service }}"
|
|
22
|
+
description: "Error rate is {{ $value | humanizePercentage }} (threshold: 5%)"
|
|
23
|
+
runbook: "https://runbooks.internal/high-error-rate"
|
|
24
|
+
|
|
25
|
+
- alert: HighLatencyP99
|
|
26
|
+
expr: |
|
|
27
|
+
histogram_quantile(0.99,
|
|
28
|
+
rate(http_request_duration_seconds_bucket[5m])
|
|
29
|
+
) > 2.0
|
|
30
|
+
for: 5m
|
|
31
|
+
labels:
|
|
32
|
+
severity: warning
|
|
33
|
+
annotations:
|
|
34
|
+
summary: "P99 latency > 2s on {{ $labels.service }}"
|
|
35
|
+
|
|
36
|
+
- alert: ServiceDown
|
|
37
|
+
expr: up{job="my-app"} == 0
|
|
38
|
+
for: 1m
|
|
39
|
+
labels:
|
|
40
|
+
severity: critical
|
|
41
|
+
|
|
42
|
+
# Log-based alert via the log-store ruler
|
|
43
|
+
- alert: PanicInLogs
|
|
44
|
+
expr: |
|
|
45
|
+
count_over_time({app="my-app"} |= "panic" [5m]) > 0
|
|
46
|
+
labels:
|
|
47
|
+
severity: critical
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Prometheus scrape config
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
# prometheus/prometheus.yml
|
|
54
|
+
global:
|
|
55
|
+
scrape_interval: 15s
|
|
56
|
+
evaluation_interval: 15s
|
|
57
|
+
|
|
58
|
+
rule_files:
|
|
59
|
+
- /etc/prometheus/rules/*.yml
|
|
60
|
+
|
|
61
|
+
alerting:
|
|
62
|
+
alertmanagers:
|
|
63
|
+
- static_configs:
|
|
64
|
+
- targets: ['alertmanager:9093']
|
|
65
|
+
|
|
66
|
+
scrape_configs:
|
|
67
|
+
- job_name: my-app
|
|
68
|
+
static_configs:
|
|
69
|
+
- targets: ['app:3000']
|
|
70
|
+
metrics_path: /metrics
|
|
71
|
+
|
|
72
|
+
- job_name: node-exporter
|
|
73
|
+
static_configs:
|
|
74
|
+
- targets: ['node-exporter:9100']
|
|
75
|
+
|
|
76
|
+
- job_name: postgres-exporter
|
|
77
|
+
static_configs:
|
|
78
|
+
- targets: ['postgres-exporter:9187']
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Dashboard as code (RED panel set)
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"title": "App RED Dashboard",
|
|
86
|
+
"uid": "app-red-v1",
|
|
87
|
+
"tags": ["app", "red"],
|
|
88
|
+
"panels": [
|
|
89
|
+
{
|
|
90
|
+
"title": "Request Rate",
|
|
91
|
+
"type": "timeseries",
|
|
92
|
+
"targets": [{
|
|
93
|
+
"expr": "sum(rate(http_requests_total[5m])) by (route)",
|
|
94
|
+
"legendFormat": "{{ route }}"
|
|
95
|
+
}]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"title": "Error Rate",
|
|
99
|
+
"type": "stat",
|
|
100
|
+
"targets": [{
|
|
101
|
+
"expr": "sum(rate(http_requests_total{status_code=~'5..'}[5m])) / sum(rate(http_requests_total[5m]))"
|
|
102
|
+
}],
|
|
103
|
+
"thresholds": {
|
|
104
|
+
"steps": [
|
|
105
|
+
{"color": "green", "value": null},
|
|
106
|
+
{"color": "yellow", "value": 0.01},
|
|
107
|
+
{"color": "red", "value": 0.05}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"title": "P95 Latency",
|
|
113
|
+
"type": "timeseries",
|
|
114
|
+
"targets": [{
|
|
115
|
+
"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, route))",
|
|
116
|
+
"legendFormat": "p95 {{ route }}"
|
|
117
|
+
}]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Store dashboard JSON in `monitoring/dashboards/` and provision it — never click-to-build only.
|
|
124
|
+
|
|
125
|
+
## OpenTelemetry Collector pipelines
|
|
126
|
+
|
|
127
|
+
```yaml
|
|
128
|
+
# otel-collector/config.yml
|
|
129
|
+
receivers:
|
|
130
|
+
otlp:
|
|
131
|
+
protocols:
|
|
132
|
+
grpc:
|
|
133
|
+
endpoint: 0.0.0.0:4317
|
|
134
|
+
http:
|
|
135
|
+
endpoint: 0.0.0.0:4318
|
|
136
|
+
|
|
137
|
+
processors:
|
|
138
|
+
memory_limiter:
|
|
139
|
+
limit_mib: 512
|
|
140
|
+
check_interval: 5s
|
|
141
|
+
batch:
|
|
142
|
+
send_batch_size: 1024
|
|
143
|
+
timeout: 5s
|
|
144
|
+
|
|
145
|
+
exporters:
|
|
146
|
+
prometheus:
|
|
147
|
+
endpoint: 0.0.0.0:8889
|
|
148
|
+
loki:
|
|
149
|
+
endpoint: http://loki:3100/loki/api/v1/push
|
|
150
|
+
otlp/tempo:
|
|
151
|
+
endpoint: tempo:4317
|
|
152
|
+
tls:
|
|
153
|
+
insecure: true
|
|
154
|
+
|
|
155
|
+
service:
|
|
156
|
+
pipelines:
|
|
157
|
+
traces:
|
|
158
|
+
receivers: [otlp]
|
|
159
|
+
processors: [memory_limiter, batch]
|
|
160
|
+
exporters: [otlp/tempo]
|
|
161
|
+
metrics:
|
|
162
|
+
receivers: [otlp]
|
|
163
|
+
processors: [batch]
|
|
164
|
+
exporters: [prometheus]
|
|
165
|
+
logs:
|
|
166
|
+
receivers: [otlp]
|
|
167
|
+
processors: [batch]
|
|
168
|
+
exporters: [loki]
|
|
169
|
+
```
|