symphony-forge 1.2.44__py3-none-any.whl
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.
- forge/__init__.py +4 -0
- forge/app_baseline.py +148 -0
- forge/approval.py +298 -0
- forge/autoreview.py +139 -0
- forge/backfill.py +298 -0
- forge/board.py +1197 -0
- forge/board_app/app.js +276 -0
- forge/board_app/assign.css +91 -0
- forge/board_app/assign.js +157 -0
- forge/board_app/insights.js +80 -0
- forge/board_app/item.css +380 -0
- forge/board_app/item.js +594 -0
- forge/board_app/markdown.js +110 -0
- forge/board_app/now.css +417 -0
- forge/board_app/now.js +248 -0
- forge/board_app/pages.css +178 -0
- forge/board_app/releases.js +203 -0
- forge/board_app/shell.html +31 -0
- forge/board_app/tokens.css +220 -0
- forge/board_facts.py +696 -0
- forge/board_graph.py +38 -0
- forge/board_server.py +431 -0
- forge/board_trends.py +105 -0
- forge/box.py +54 -0
- forge/box_ssh.py +209 -0
- forge/checks.py +743 -0
- forge/citime.py +259 -0
- forge/claude_sdk.py +56 -0
- forge/claude_turn.py +62 -0
- forge/cli.py +185 -0
- forge/close.py +1193 -0
- forge/close_remote.py +85 -0
- forge/codex.py +1200 -0
- forge/codex_turn.py +346 -0
- forge/deny.py +253 -0
- forge/design.py +201 -0
- forge/design_skills.py +16 -0
- forge/docskip.py +175 -0
- forge/doctor.py +578 -0
- forge/event_log.py +128 -0
- forge/fasttest.py +846 -0
- forge/feature.py +318 -0
- forge/feature_api.py +593 -0
- forge/feature_python.py +1107 -0
- forge/feature_python_contracts.py +268 -0
- forge/feature_python_tests.py +1134 -0
- forge/feature_python_tools.py +81 -0
- forge/feature_remove.py +189 -0
- forge/feature_schema.py +156 -0
- forge/feature_tests.py +1062 -0
- forge/fullrun.py +166 -0
- forge/gaps.py +109 -0
- forge/githooks.py +251 -0
- forge/github.py +191 -0
- forge/init.py +494 -0
- forge/intake.py +226 -0
- forge/journey.py +126 -0
- forge/known_issues.py +165 -0
- forge/land.py +882 -0
- forge/machine.py +821 -0
- forge/merge.py +530 -0
- forge/merge_review.py +84 -0
- forge/merge_timings.py +46 -0
- forge/migrate.py +673 -0
- forge/migration_warnings.py +108 -0
- forge/mod/.claude-plugin/plugin.json +20 -0
- forge/mod/hooks/hooks.json +3 -0
- forge/mod/hooks/pane.test.ts +608 -0
- forge/mod/hooks/register.ts +413 -0
- forge/mod/tsconfig.json +18 -0
- forge/native.py +306 -0
- forge/nextstep.py +1184 -0
- forge/node_workers.cjs +26 -0
- forge/noise.py +40 -0
- forge/open_decisions.py +205 -0
- forge/owner_choices.py +167 -0
- forge/payback.py +97 -0
- forge/plain_english.py +20 -0
- forge/plan_scope.py +76 -0
- forge/prcheck.py +640 -0
- forge/quicktest.py +198 -0
- forge/records.py +912 -0
- forge/releases.py +100 -0
- forge/repo.py +1154 -0
- forge/review.py +1199 -0
- forge/review_process.py +86 -0
- forge/review_skip.py +116 -0
- forge/roles.py +141 -0
- forge/round_limits.py +7 -0
- forge/score.py +192 -0
- forge/spotted.py +271 -0
- forge/standards.md +318 -0
- forge/story.py +1200 -0
- forge/sync.py +783 -0
- forge/task.py +1082 -0
- forge/templates/adapters/AGENTS.md +98 -0
- forge/templates/brief.md +834 -0
- forge/templates/cold-read.md +324 -0
- forge/templates/conventions/api.md +144 -0
- forge/templates/conventions/backend.md +171 -0
- forge/templates/conventions/database.md +81 -0
- forge/templates/conventions/demo-data.md +61 -0
- forge/templates/conventions/deploy.md +114 -0
- forge/templates/conventions/frontend.md +187 -0
- forge/templates/conventions/python.md +336 -0
- forge/templates/conventions/security.md +44 -0
- forge/templates/conventions/stack.md +96 -0
- forge/templates/conventions/testing.md +165 -0
- forge/templates/delegation.md +3 -0
- forge/templates/design/render-check.d.mts +25 -0
- forge/templates/design/render-check.mjs +113 -0
- forge/templates/design/support.js +159 -0
- forge/templates/design/ui-checks.js +111 -0
- forge/templates/fde.md +218 -0
- forge/templates/feature/kinds.toml +140 -0
- forge/templates/handover.md +26 -0
- forge/templates/migrate-skill.md +87 -0
- forge/templates/records-only-action.yml +16 -0
- forge/templates/review-light.md +48 -0
- forge/templates/review-tests.py +200 -0
- forge/templates/review.md +661 -0
- forge/templates/run-reference.md +328 -0
- forge/templates/skeleton/.dockerignore +18 -0
- forge/templates/skeleton/Dockerfile +10 -0
- forge/templates/skeleton/docs/decisions/README.md +13 -0
- forge/templates/skeleton/docs/product/BRIEF.md +47 -0
- forge/templates/skeleton/docs/product/DISCOVERY.md +46 -0
- forge/templates/skeleton/docs/specs/README.md +41 -0
- forge/templates/skeleton/services.toml +6 -0
- forge/templates/skill.md +2753 -0
- forge/templates/skills/agents/SKILL.md +446 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/README.md +131 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/__init__.py +5 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/chats.py +60 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/cleanup.py +91 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/models.py +57 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/migrations/versions/20261106_assistant.py +90 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/tests/test_assistant_chats.py +173 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/migrations/20261106000000_assistant/migration.sql +17 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/schema/assistant.prisma +19 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-api.e2e-spec.ts +185 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-chats.e2e-spec.ts +75 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/README.md +107 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/package.json +10 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/src/index.ts +66 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/tsconfig.json +12 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/package.json +23 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.controller.ts +54 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.service.ts +140 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.cleanup.ts +34 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.module.ts +20 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/index.ts +3 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/tsconfig.json +15 -0
- forge/templates/skills/app-baseline/SKILL.md +241 -0
- forge/templates/skills/database/SKILL.md +155 -0
- forge/templates/skills/emil-design-eng/FORGE-NOTICE.md +9 -0
- forge/templates/skills/emil-design-eng/LICENSE +21 -0
- forge/templates/skills/emil-design-eng/SKILL.md +674 -0
- forge/templates/skills/impeccable/FORGE-NOTICE.md +10 -0
- forge/templates/skills/impeccable/LICENSE +191 -0
- forge/templates/skills/impeccable/NOTICE.md +11 -0
- forge/templates/skills/impeccable/SKILL.md +88 -0
- forge/templates/skills/impeccable/reference/adapt.md +318 -0
- forge/templates/skills/impeccable/reference/adapt.native.md +58 -0
- forge/templates/skills/impeccable/reference/android.md +46 -0
- forge/templates/skills/impeccable/reference/animate.md +89 -0
- forge/templates/skills/impeccable/reference/audit.md +139 -0
- forge/templates/skills/impeccable/reference/audit.native.md +139 -0
- forge/templates/skills/impeccable/reference/bolder.md +33 -0
- forge/templates/skills/impeccable/reference/clarify.md +94 -0
- forge/templates/skills/impeccable/reference/colorize.md +86 -0
- forge/templates/skills/impeccable/reference/component-review.md +63 -0
- forge/templates/skills/impeccable/reference/craft-floor.md +44 -0
- forge/templates/skills/impeccable/reference/craft.md +5 -0
- forge/templates/skills/impeccable/reference/critique.md +819 -0
- forge/templates/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- forge/templates/skills/impeccable/reference/degraded/documenter.md +24 -0
- forge/templates/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- forge/templates/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- forge/templates/skills/impeccable/reference/delight.md +70 -0
- forge/templates/skills/impeccable/reference/distill.md +111 -0
- forge/templates/skills/impeccable/reference/doctor.md +54 -0
- forge/templates/skills/impeccable/reference/document.md +416 -0
- forge/templates/skills/impeccable/reference/extract.md +69 -0
- forge/templates/skills/impeccable/reference/generate.md +101 -0
- forge/templates/skills/impeccable/reference/harden.md +362 -0
- forge/templates/skills/impeccable/reference/hooks.md +114 -0
- forge/templates/skills/impeccable/reference/init.md +131 -0
- forge/templates/skills/impeccable/reference/ios.md +51 -0
- forge/templates/skills/impeccable/reference/layout.md +84 -0
- forge/templates/skills/impeccable/reference/live-setup.md +104 -0
- forge/templates/skills/impeccable/reference/live.md +325 -0
- forge/templates/skills/impeccable/reference/mode-operate.md +21 -0
- forge/templates/skills/impeccable/reference/mode-persuade.md +19 -0
- forge/templates/skills/impeccable/reference/mode-read.md +21 -0
- forge/templates/skills/impeccable/reference/new-work.md +154 -0
- forge/templates/skills/impeccable/reference/onboard.md +234 -0
- forge/templates/skills/impeccable/reference/operate.md +61 -0
- forge/templates/skills/impeccable/reference/optimize.md +257 -0
- forge/templates/skills/impeccable/reference/overdrive.md +127 -0
- forge/templates/skills/impeccable/reference/polish.md +105 -0
- forge/templates/skills/impeccable/reference/quieter.md +99 -0
- forge/templates/skills/impeccable/reference/region-map.md +26 -0
- forge/templates/skills/impeccable/reference/routing.md +24 -0
- forge/templates/skills/impeccable/reference/shape.md +59 -0
- forge/templates/skills/impeccable/reference/typeset.md +90 -0
- forge/templates/skills/impeccable/reference/visualize.md +47 -0
- forge/templates/skills/impeccable/scripts/VERSION +1 -0
- forge/templates/skills/impeccable/scripts/command-metadata.json +98 -0
- forge/templates/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- forge/templates/skills/impeccable/scripts/data/font-index.json +1 -0
- forge/templates/skills/impeccable/scripts/engine-checksums.txt +9 -0
- forge/templates/skills/impeccable/scripts/impeccable +249 -0
- forge/templates/skills/impeccable/scripts/impeccable.cmd +278 -0
- forge/templates/skills/impeccable/scripts/live-browser-dom.js +321 -0
- forge/templates/skills/impeccable/scripts/live-browser-ignores.js +247 -0
- forge/templates/skills/impeccable/scripts/live-browser-session.js +184 -0
- forge/templates/skills/impeccable/scripts/live-browser.js +13646 -0
- forge/templates/skills/impeccable/scripts/modern-screenshot.umd.js +15 -0
- forge/templates/skills/remote-approval/SKILL.md +40 -0
- forge/templates/skills/security-audit/AI-AND-LLM.md +83 -0
- forge/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
- forge/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
- forge/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- forge/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- forge/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- forge/templates/skills/security-audit/HUNTING.md +251 -0
- forge/templates/skills/security-audit/LICENSE +21 -0
- forge/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- forge/templates/skills/security-audit/NOTICE.md +6 -0
- forge/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- forge/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
- forge/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- forge/templates/skills/security-audit/SKILL.md +192 -0
- forge/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- forge/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- forge/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- forge/templates/skills/security-audit/report-schema.json +461 -0
- forge/templates/skills/security-audit/validate-coverage-ledger.cjs +873 -0
- forge/templates/skills/security-audit/validate-findings.cjs +774 -0
- forge/templates/skills/simplified-technical-english/LICENSE +28 -0
- forge/templates/skills/simplified-technical-english/NOTICE.md +33 -0
- forge/templates/skills/simplified-technical-english/SKILL.md +127 -0
- forge/templates/skills/simplified-technical-english/examples/before-after.md +86 -0
- forge/templates/skills/simplified-technical-english/references/substitutions.md +113 -0
- forge/templates/skills/simplified-technical-english/references/writing-rules.md +209 -0
- forge/templates/skills/simplified-technical-english/scripts/ste_check.py +301 -0
- forge/templates/skills/test-audit/NOTICE.md +25 -0
- forge/templates/skills/test-audit/SKILL.md +182 -0
- forge/templates/start.md +27 -0
- forge/templates/starter/.env.example +14 -0
- forge/templates/starter/.gitignore +7 -0
- forge/templates/starter/.npmrc +1 -0
- forge/templates/starter/Dockerfile +23 -0
- forge/templates/starter/README.md +121 -0
- forge/templates/starter/apps/api/package.json +15 -0
- forge/templates/starter/apps/api/prisma/migrations/20261022000000_initial/migration.sql +68 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000000_organisations/migration.sql +44 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000100_invites/migration.sql +18 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000200_history/migration.sql +13 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000300_soft_delete_only/migration.sql +10 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000000_extensions/migration.sql +3 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000100_ids_and_updated_at/migration.sql +31 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000150_module_schemas/migration.sql +19 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000200_columns/migration.sql +51 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000300_history_subjects/migration.sql +11 -0
- forge/templates/starter/apps/api/prisma/migrations/20261027000000_agents/migration.sql +12 -0
- forge/templates/starter/apps/api/prisma/migrations/20261027000100_mcp/migration.sql +20 -0
- forge/templates/starter/apps/api/prisma/migrations/20261028000000_via_agent/migration.sql +7 -0
- forge/templates/starter/apps/api/prisma/migrations/20261102000000_sign_in_attempts/migration.sql +13 -0
- forge/templates/starter/apps/api/prisma/migrations/20261104000000_notifications/migration.sql +23 -0
- forge/templates/starter/apps/api/prisma/migrations/migration_lock.toml +1 -0
- forge/templates/starter/apps/api/prisma/schema/auth.prisma +65 -0
- forge/templates/starter/apps/api/prisma/schema/base.prisma +9 -0
- forge/templates/starter/apps/api/prisma/schema/history.prisma +19 -0
- forge/templates/starter/apps/api/prisma/schema/mcp.prisma +18 -0
- forge/templates/starter/apps/api/prisma/schema/notifications.prisma +20 -0
- forge/templates/starter/apps/api/prisma/schema/organisations.prisma +66 -0
- forge/templates/starter/apps/api/prisma/schema/projects.prisma +23 -0
- forge/templates/starter/apps/api/project.json +35 -0
- forge/templates/starter/apps/api/src/app.module.ts +36 -0
- forge/templates/starter/apps/api/src/health/health.controller.ts +16 -0
- forge/templates/starter/apps/api/src/health/health.module.ts +5 -0
- forge/templates/starter/apps/api/src/main.ts +44 -0
- forge/templates/starter/apps/api/src/setup-company.ts +33 -0
- forge/templates/starter/apps/api/test/agents.e2e-spec.ts +99 -0
- forge/templates/starter/apps/api/test/api.e2e-spec.ts +250 -0
- forge/templates/starter/apps/api/test/auth.e2e-spec.ts +287 -0
- forge/templates/starter/apps/api/test/database.e2e-spec.ts +171 -0
- forge/templates/starter/apps/api/test/environment.e2e-spec.ts +56 -0
- forge/templates/starter/apps/api/test/error-reports.e2e-spec.ts +72 -0
- forge/templates/starter/apps/api/test/exports.e2e-spec.ts +85 -0
- forge/templates/starter/apps/api/test/helpers.ts +103 -0
- forge/templates/starter/apps/api/test/history.e2e-spec.ts +93 -0
- forge/templates/starter/apps/api/test/invites.e2e-spec.ts +262 -0
- forge/templates/starter/apps/api/test/mcp.e2e-spec.ts +269 -0
- forge/templates/starter/apps/api/test/notifications.e2e-spec.ts +117 -0
- forge/templates/starter/apps/api/test/one-company.e2e-spec.ts +154 -0
- forge/templates/starter/apps/api/test/organisations.e2e-spec.ts +210 -0
- forge/templates/starter/apps/api/test/projects.e2e-spec.ts +824 -0
- forge/templates/starter/apps/api/test/soft-delete.e2e-spec.ts +31 -0
- forge/templates/starter/apps/api/tsconfig.json +44 -0
- forge/templates/starter/apps/api/tsconfig.test.json +17 -0
- forge/templates/starter/apps/api/vitest.config.ts +13 -0
- forge/templates/starter/apps/web/e2e/motion.spec.ts +88 -0
- forge/templates/starter/apps/web/e2e/rules/accept-invite.spec.ts +59 -0
- forge/templates/starter/apps/web/e2e/rules/members.spec.ts +212 -0
- forge/templates/starter/apps/web/e2e/rules/reset-password.spec.ts +78 -0
- forge/templates/starter/apps/web/e2e/rules/sign-in.spec.ts +87 -0
- forge/templates/starter/apps/web/e2e/served-app.spec.ts +19 -0
- forge/templates/starter/apps/web/index.html +14 -0
- forge/templates/starter/apps/web/package.json +9 -0
- forge/templates/starter/apps/web/playwright.config.ts +21 -0
- forge/templates/starter/apps/web/project.json +36 -0
- forge/templates/starter/apps/web/src/index.css +166 -0
- forge/templates/starter/apps/web/src/main.tsx +14 -0
- forge/templates/starter/apps/web/src/shared-states.test.tsx +40 -0
- forge/templates/starter/apps/web/tsconfig.json +30 -0
- forge/templates/starter/apps/web/vite.config.ts +19 -0
- forge/templates/starter/apps/web/vitest.config.ts +23 -0
- forge/templates/starter/apps/web/vitest.setup.ts +5 -0
- forge/templates/starter/compose.test.yml +66 -0
- forge/templates/starter/eslint.config.mjs +56 -0
- forge/templates/starter/libs/auth/contracts/package.json +17 -0
- forge/templates/starter/libs/auth/contracts/project.json +15 -0
- forge/templates/starter/libs/auth/contracts/src/index.ts +56 -0
- forge/templates/starter/libs/auth/contracts/tsconfig.json +18 -0
- forge/templates/starter/libs/auth/server/package.json +19 -0
- forge/templates/starter/libs/auth/server/project.json +15 -0
- forge/templates/starter/libs/auth/server/src/agents.controller.ts +24 -0
- forge/templates/starter/libs/auth/server/src/auth.controller.ts +136 -0
- forge/templates/starter/libs/auth/server/src/auth.dto.ts +53 -0
- forge/templates/starter/libs/auth/server/src/auth.module.ts +18 -0
- forge/templates/starter/libs/auth/server/src/auth.service.ts +251 -0
- forge/templates/starter/libs/auth/server/src/index.ts +3 -0
- forge/templates/starter/libs/auth/server/src/invites.controller.ts +37 -0
- forge/templates/starter/libs/auth/server/src/members.controller.ts +47 -0
- forge/templates/starter/libs/auth/server/src/session.guard.ts +52 -0
- forge/templates/starter/libs/auth/server/tsconfig.json +29 -0
- forge/templates/starter/libs/core/server/package.json +17 -0
- forge/templates/starter/libs/core/server/project.json +19 -0
- forge/templates/starter/libs/core/server/src/common/account-principal.ts +8 -0
- forge/templates/starter/libs/core/server/src/common/admin-only.decorator.ts +18 -0
- forge/templates/starter/libs/core/server/src/common/all-exceptions.filter.ts +55 -0
- forge/templates/starter/libs/core/server/src/common/api-envelope.decorator.ts +28 -0
- forge/templates/starter/libs/core/server/src/common/api-response.dto.ts +26 -0
- forge/templates/starter/libs/core/server/src/common/api-zod.decorator.ts +21 -0
- forge/templates/starter/libs/core/server/src/common/authenticated-request.ts +7 -0
- forge/templates/starter/libs/core/server/src/common/common.module.ts +7 -0
- forge/templates/starter/libs/core/server/src/common/correlation.middleware.ts +12 -0
- forge/templates/starter/libs/core/server/src/common/csrf.guard.ts +35 -0
- forge/templates/starter/libs/core/server/src/common/csv.ts +14 -0
- forge/templates/starter/libs/core/server/src/common/current-account.decorator.ts +11 -0
- forge/templates/starter/libs/core/server/src/common/envelope.interceptor.ts +10 -0
- forge/templates/starter/libs/core/server/src/common/error-report.ts +43 -0
- forge/templates/starter/libs/core/server/src/common/json-logger.test.ts +95 -0
- forge/templates/starter/libs/core/server/src/common/json-logger.ts +57 -0
- forge/templates/starter/libs/core/server/src/common/permissions.ts +49 -0
- forge/templates/starter/libs/core/server/src/common/prompts.ts +42 -0
- forge/templates/starter/libs/core/server/src/common/public.decorator.ts +4 -0
- forge/templates/starter/libs/core/server/src/common/request-log.middleware.ts +19 -0
- forge/templates/starter/libs/core/server/src/common/resources.ts +88 -0
- forge/templates/starter/libs/core/server/src/common/retry-keys.ts +31 -0
- forge/templates/starter/libs/core/server/src/common/tools.test.ts +205 -0
- forge/templates/starter/libs/core/server/src/common/tools.ts +266 -0
- forge/templates/starter/libs/core/server/src/common/zod-validation.pipe.ts +22 -0
- forge/templates/starter/libs/core/server/src/config/environment.ts +95 -0
- forge/templates/starter/libs/core/server/src/index.ts +27 -0
- forge/templates/starter/libs/core/server/src/mail/mail.module.ts +19 -0
- forge/templates/starter/libs/core/server/src/mail/mail.provider.ts +22 -0
- forge/templates/starter/libs/core/server/src/prisma/prisma.module.ts +7 -0
- forge/templates/starter/libs/core/server/src/prisma/prisma.service.ts +19 -0
- forge/templates/starter/libs/core/server/tsconfig.json +23 -0
- forge/templates/starter/libs/core/web/package.json +16 -0
- forge/templates/starter/libs/core/web/project.json +15 -0
- forge/templates/starter/libs/core/web/src/api-client.ts +42 -0
- forge/templates/starter/libs/core/web/src/error-report.ts +12 -0
- forge/templates/starter/libs/core/web/src/form-errors.ts +18 -0
- forge/templates/starter/libs/core/web/src/index.ts +4 -0
- forge/templates/starter/libs/core/web/src/permissions.ts +9 -0
- forge/templates/starter/libs/core/web/src/query-client.ts +10 -0
- forge/templates/starter/libs/core/web/tsconfig.json +18 -0
- forge/templates/starter/libs/history/contracts/package.json +14 -0
- forge/templates/starter/libs/history/contracts/project.json +15 -0
- forge/templates/starter/libs/history/contracts/src/index.ts +2 -0
- forge/templates/starter/libs/history/contracts/src/service.ts +21 -0
- forge/templates/starter/libs/history/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/history/server/package.json +19 -0
- forge/templates/starter/libs/history/server/project.json +19 -0
- forge/templates/starter/libs/history/server/src/history.controller.ts +45 -0
- forge/templates/starter/libs/history/server/src/history.dto.ts +22 -0
- forge/templates/starter/libs/history/server/src/history.module.ts +12 -0
- forge/templates/starter/libs/history/server/src/history.service.test.ts +18 -0
- forge/templates/starter/libs/history/server/src/history.service.ts +42 -0
- forge/templates/starter/libs/history/server/src/index.ts +2 -0
- forge/templates/starter/libs/history/server/tsconfig.json +29 -0
- forge/templates/starter/libs/mcp/server/package.json +18 -0
- forge/templates/starter/libs/mcp/server/project.json +15 -0
- forge/templates/starter/libs/mcp/server/src/index.ts +1 -0
- forge/templates/starter/libs/mcp/server/src/mcp.controller.ts +102 -0
- forge/templates/starter/libs/mcp/server/src/mcp.module.ts +5 -0
- forge/templates/starter/libs/mcp/server/tsconfig.json +26 -0
- forge/templates/starter/libs/notifications/contracts/package.json +14 -0
- forge/templates/starter/libs/notifications/contracts/project.json +12 -0
- forge/templates/starter/libs/notifications/contracts/src/index.ts +1 -0
- forge/templates/starter/libs/notifications/contracts/src/service.ts +19 -0
- forge/templates/starter/libs/notifications/contracts/tsconfig.json +12 -0
- forge/templates/starter/libs/notifications/server/package.json +18 -0
- forge/templates/starter/libs/notifications/server/project.json +12 -0
- forge/templates/starter/libs/notifications/server/src/index.ts +1 -0
- forge/templates/starter/libs/notifications/server/src/notifications.controller.ts +21 -0
- forge/templates/starter/libs/notifications/server/src/notifications.dto.ts +28 -0
- forge/templates/starter/libs/notifications/server/src/notifications.module.ts +12 -0
- forge/templates/starter/libs/notifications/server/src/notifications.service.ts +36 -0
- forge/templates/starter/libs/notifications/server/tsconfig.json +18 -0
- forge/templates/starter/libs/organisations/contracts/package.json +14 -0
- forge/templates/starter/libs/organisations/contracts/project.json +15 -0
- forge/templates/starter/libs/organisations/contracts/src/index.ts +54 -0
- forge/templates/starter/libs/organisations/contracts/src/service.ts +29 -0
- forge/templates/starter/libs/organisations/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/organisations/server/package.json +20 -0
- forge/templates/starter/libs/organisations/server/project.json +15 -0
- forge/templates/starter/libs/organisations/server/src/index.ts +2 -0
- forge/templates/starter/libs/organisations/server/src/organisations.controller.ts +101 -0
- forge/templates/starter/libs/organisations/server/src/organisations.dto.ts +46 -0
- forge/templates/starter/libs/organisations/server/src/organisations.module.ts +14 -0
- forge/templates/starter/libs/organisations/server/src/organisations.service.ts +221 -0
- forge/templates/starter/libs/organisations/server/tsconfig.json +32 -0
- forge/templates/starter/libs/projects/contracts/package.json +14 -0
- forge/templates/starter/libs/projects/contracts/project.json +15 -0
- forge/templates/starter/libs/projects/contracts/src/index.ts +87 -0
- forge/templates/starter/libs/projects/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/projects/server/package.json +21 -0
- forge/templates/starter/libs/projects/server/project.json +15 -0
- forge/templates/starter/libs/projects/server/src/index.ts +2 -0
- forge/templates/starter/libs/projects/server/src/projects.controller.ts +165 -0
- forge/templates/starter/libs/projects/server/src/projects.dto.ts +77 -0
- forge/templates/starter/libs/projects/server/src/projects.module.ts +19 -0
- forge/templates/starter/libs/projects/server/src/projects.permissions.ts +7 -0
- forge/templates/starter/libs/projects/server/src/projects.service.ts +314 -0
- forge/templates/starter/libs/projects/server/src/projects.tools.ts +28 -0
- forge/templates/starter/libs/projects/server/tsconfig.json +29 -0
- forge/templates/starter/libs/shared/ui/components.json +21 -0
- forge/templates/starter/libs/shared/ui/package.json +27 -0
- forge/templates/starter/libs/shared/ui/project.json +15 -0
- forge/templates/starter/libs/shared/ui/src/components/states.tsx +73 -0
- forge/templates/starter/libs/shared/ui/src/components/theme-provider.tsx +39 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/LICENSE +21 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/alert-dialog.tsx +196 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/alert.tsx +65 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/avatar.tsx +108 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/badge.tsx +47 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/breadcrumb.tsx +108 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/button.tsx +63 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/card.tsx +91 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/checkbox.tsx +29 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/collapsible.tsx +33 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/command.tsx +184 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/dialog.tsx +158 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/dropdown-menu.tsx +256 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/empty.tsx +103 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/form.tsx +167 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/input.tsx +20 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/label.tsx +23 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/popover.tsx +88 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/select.tsx +189 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/separator.tsx +27 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sheet.tsx +142 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sidebar.tsx +726 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/skeleton.tsx +13 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sonner.tsx +40 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/switch.tsx +32 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/table.tsx +115 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/textarea.tsx +17 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/tooltip.tsx +56 -0
- forge/templates/starter/libs/shared/ui/src/hooks/use-mobile.ts +19 -0
- forge/templates/starter/libs/shared/ui/src/lib/utils.ts +6 -0
- forge/templates/starter/libs/shared/ui/tsconfig.json +23 -0
- forge/templates/starter/libs/shared/util/package.json +14 -0
- forge/templates/starter/libs/shared/util/project.json +19 -0
- forge/templates/starter/libs/shared/util/src/csv-field.ts +6 -0
- forge/templates/starter/libs/shared/util/src/envelope.ts +9 -0
- forge/templates/starter/libs/shared/util/src/format.test.ts +33 -0
- forge/templates/starter/libs/shared/util/src/format.ts +43 -0
- forge/templates/starter/libs/shared/util/src/index.ts +12 -0
- forge/templates/starter/libs/shared/util/tsconfig.json +14 -0
- forge/templates/starter/nx.json +7 -0
- forge/templates/starter/package.json +97 -0
- forge/templates/starter/pnpm-lock.yaml +11587 -0
- forge/templates/starter/pnpm-workspace.yaml +4 -0
- forge/templates/starter/prisma.config.ts +13 -0
- forge/templates/starter/scripts/affected.mjs +27 -0
- forge/templates/starter/scripts/test-build.mjs +29 -0
- forge/templates/starter/scripts/test.mjs +107 -0
- forge/templates/starter/services.toml +7 -0
- forge/templates/starter/tsconfig.base.json +15 -0
- forge/templates/starter-python/.env.example +8 -0
- forge/templates/starter-python/.gitignore +13 -0
- forge/templates/starter-python/Dockerfile +30 -0
- forge/templates/starter-python/README.md +101 -0
- forge/templates/starter-python/apps/api/.python-version +1 -0
- forge/templates/starter-python/apps/api/alembic.ini +38 -0
- forge/templates/starter-python/apps/api/app/__init__.py +1 -0
- forge/templates/starter-python/apps/api/app/auth/__init__.py +27 -0
- forge/templates/starter-python/apps/api/app/auth/models.py +111 -0
- forge/templates/starter-python/apps/api/app/auth/routes.py +398 -0
- forge/templates/starter-python/apps/api/app/auth/schema.py +117 -0
- forge/templates/starter-python/apps/api/app/auth/service.py +453 -0
- forge/templates/starter-python/apps/api/app/core/__init__.py +89 -0
- forge/templates/starter-python/apps/api/app/core/admin.py +23 -0
- forge/templates/starter-python/apps/api/app/core/config.py +83 -0
- forge/templates/starter-python/apps/api/app/core/csv.py +40 -0
- forge/templates/starter-python/apps/api/app/core/database.py +21 -0
- forge/templates/starter-python/apps/api/app/core/envelope.py +40 -0
- forge/templates/starter-python/apps/api/app/core/error_report.py +85 -0
- forge/templates/starter-python/apps/api/app/core/errors.py +153 -0
- forge/templates/starter-python/apps/api/app/core/logging.py +66 -0
- forge/templates/starter-python/apps/api/app/core/mail.py +34 -0
- forge/templates/starter-python/apps/api/app/core/permissions.py +59 -0
- forge/templates/starter-python/apps/api/app/core/principal.py +12 -0
- forge/templates/starter-python/apps/api/app/core/prompts.py +96 -0
- forge/templates/starter-python/apps/api/app/core/resources.py +230 -0
- forge/templates/starter-python/apps/api/app/core/retry_keys.py +101 -0
- forge/templates/starter-python/apps/api/app/core/schema.py +13 -0
- forge/templates/starter-python/apps/api/app/core/security.py +197 -0
- forge/templates/starter-python/apps/api/app/core/tools.py +1117 -0
- forge/templates/starter-python/apps/api/app/history/__init__.py +5 -0
- forge/templates/starter-python/apps/api/app/history/models.py +48 -0
- forge/templates/starter-python/apps/api/app/history/routes.py +65 -0
- forge/templates/starter-python/apps/api/app/history/schema.py +29 -0
- forge/templates/starter-python/apps/api/app/history/service.py +77 -0
- forge/templates/starter-python/apps/api/app/main.py +115 -0
- forge/templates/starter-python/apps/api/app/mcp/__init__.py +3 -0
- forge/templates/starter-python/apps/api/app/mcp/server.py +192 -0
- forge/templates/starter-python/apps/api/app/notifications/__init__.py +5 -0
- forge/templates/starter-python/apps/api/app/notifications/models.py +62 -0
- forge/templates/starter-python/apps/api/app/notifications/routes.py +25 -0
- forge/templates/starter-python/apps/api/app/notifications/schema.py +39 -0
- forge/templates/starter-python/apps/api/app/notifications/service.py +70 -0
- forge/templates/starter-python/apps/api/app/openapi.py +17 -0
- forge/templates/starter-python/apps/api/app/organisations/__init__.py +10 -0
- forge/templates/starter-python/apps/api/app/organisations/models.py +128 -0
- forge/templates/starter-python/apps/api/app/organisations/routes.py +176 -0
- forge/templates/starter-python/apps/api/app/organisations/schema.py +76 -0
- forge/templates/starter-python/apps/api/app/organisations/service.py +403 -0
- forge/templates/starter-python/apps/api/app/projects/__init__.py +14 -0
- forge/templates/starter-python/apps/api/app/projects/models.py +67 -0
- forge/templates/starter-python/apps/api/app/projects/permissions.py +13 -0
- forge/templates/starter-python/apps/api/app/projects/routes.py +246 -0
- forge/templates/starter-python/apps/api/app/projects/schema.py +118 -0
- forge/templates/starter-python/apps/api/app/projects/service.py +359 -0
- forge/templates/starter-python/apps/api/app/projects/tools.py +28 -0
- forge/templates/starter-python/apps/api/app/setup_company.py +56 -0
- forge/templates/starter-python/apps/api/migrations/env.py +51 -0
- forge/templates/starter-python/apps/api/migrations/script.py.mako +25 -0
- forge/templates/starter-python/apps/api/migrations/versions/0001_initial.py +167 -0
- forge/templates/starter-python/apps/api/migrations/versions/0002_soft_delete_only.py +31 -0
- forge/templates/starter-python/apps/api/migrations/versions/0003_organisations.py +115 -0
- forge/templates/starter-python/apps/api/migrations/versions/0004_invites.py +58 -0
- forge/templates/starter-python/apps/api/migrations/versions/0005_history.py +51 -0
- forge/templates/starter-python/apps/api/migrations/versions/0006_extensions.py +22 -0
- forge/templates/starter-python/apps/api/migrations/versions/0007_ids_and_updated_at.py +52 -0
- forge/templates/starter-python/apps/api/migrations/versions/0008_module_schemas.py +42 -0
- forge/templates/starter-python/apps/api/migrations/versions/0009_columns.py +97 -0
- forge/templates/starter-python/apps/api/migrations/versions/0010_history_subjects.py +46 -0
- forge/templates/starter-python/apps/api/migrations/versions/0011_agents.py +44 -0
- forge/templates/starter-python/apps/api/migrations/versions/0012_mcp.py +71 -0
- forge/templates/starter-python/apps/api/migrations/versions/0013_via_agent.py +23 -0
- forge/templates/starter-python/apps/api/migrations/versions/20261103_sign_in_attempts.py +48 -0
- forge/templates/starter-python/apps/api/migrations/versions/20261105_notifications.py +84 -0
- forge/templates/starter-python/apps/api/pyproject.toml +86 -0
- forge/templates/starter-python/apps/api/tests/conftest.py +146 -0
- forge/templates/starter-python/apps/api/tests/test_agents.py +169 -0
- forge/templates/starter-python/apps/api/tests/test_api.py +319 -0
- forge/templates/starter-python/apps/api/tests/test_auth.py +428 -0
- forge/templates/starter-python/apps/api/tests/test_config.py +58 -0
- forge/templates/starter-python/apps/api/tests/test_database.py +204 -0
- forge/templates/starter-python/apps/api/tests/test_error_reports.py +119 -0
- forge/templates/starter-python/apps/api/tests/test_history.py +206 -0
- forge/templates/starter-python/apps/api/tests/test_invites.py +427 -0
- forge/templates/starter-python/apps/api/tests/test_logging.py +56 -0
- forge/templates/starter-python/apps/api/tests/test_mcp.py +556 -0
- forge/templates/starter-python/apps/api/tests/test_module_schemas.py +100 -0
- forge/templates/starter-python/apps/api/tests/test_notifications.py +182 -0
- forge/templates/starter-python/apps/api/tests/test_one_company.py +188 -0
- forge/templates/starter-python/apps/api/tests/test_organisations.py +231 -0
- forge/templates/starter-python/apps/api/tests/test_projects.py +874 -0
- forge/templates/starter-python/apps/api/tests/test_soft_delete.py +80 -0
- forge/templates/starter-python/apps/api/tests/test_tools.py +395 -0
- forge/templates/starter-python/apps/api/uv.lock +1277 -0
- forge/templates/starter-python/compose.test.yml +63 -0
- forge/templates/starter-python/eslint.config.mjs +49 -0
- forge/templates/starter-python/libs/auth/contracts/package.json +17 -0
- forge/templates/starter-python/libs/auth/contracts/src/index.ts +51 -0
- forge/templates/starter-python/libs/auth/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/history/contracts/package.json +17 -0
- forge/templates/starter-python/libs/history/contracts/src/index.ts +3 -0
- forge/templates/starter-python/libs/history/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/organisations/contracts/package.json +17 -0
- forge/templates/starter-python/libs/organisations/contracts/src/index.ts +30 -0
- forge/templates/starter-python/libs/organisations/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/projects/contracts/package.json +17 -0
- forge/templates/starter-python/libs/projects/contracts/src/index.ts +65 -0
- forge/templates/starter-python/libs/projects/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/shared/api-types/package.json +14 -0
- forge/templates/starter-python/libs/shared/api-types/tsconfig.json +14 -0
- forge/templates/starter-python/package.json +71 -0
- forge/templates/starter-python/pnpm-lock.yaml +7574 -0
- forge/templates/starter-python/pnpm-workspace.yaml +4 -0
- forge/templates/starter-python/scripts/affected.mjs +20 -0
- forge/templates/starter-python/scripts/test-browser.mjs +39 -0
- forge/templates/starter-python/scripts/test.mjs +86 -0
- forge/templates/starter-python/services.toml +7 -0
- forge/templates/story.md +89 -0
- forge/time_records.py +1022 -0
- forge/ui_checks.py +97 -0
- forge/upgrade.py +368 -0
- forge/worker.py +876 -0
- symphony_forge-1.2.44.dist-info/METADATA +7 -0
- symphony_forge-1.2.44.dist-info/RECORD +623 -0
- symphony_forge-1.2.44.dist-info/WHEEL +4 -0
- symphony_forge-1.2.44.dist-info/entry_points.txt +2 -0
- symphony_forge-1.2.44.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
"""The agent MCP endpoint and tool contract through the running API."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import json
|
|
5
|
+
from typing import cast
|
|
6
|
+
from uuid import uuid4
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
import pytest
|
|
10
|
+
from conftest import add_agent_key, agent_client
|
|
11
|
+
from mcp.client.session import ClientSession
|
|
12
|
+
from mcp.shared.exceptions import MCPError
|
|
13
|
+
from mcp.types import CallToolResult, TextContent, TextResourceContents
|
|
14
|
+
from test_api import sign_up
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _agent(
|
|
18
|
+
client: httpx.Client, csrf: str, role: str = "admin"
|
|
19
|
+
) -> tuple[dict[str, object], str]:
|
|
20
|
+
return add_agent_key(client, csrf, f"mcp-{uuid4().hex[:8]}", role)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _mcp_error(result: CallToolResult) -> dict[str, object]:
|
|
24
|
+
structured = result.structured_content
|
|
25
|
+
assert isinstance(structured, dict)
|
|
26
|
+
error = structured["error"]
|
|
27
|
+
assert isinstance(error, dict)
|
|
28
|
+
return error
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _tool_text(result: CallToolResult) -> str:
|
|
32
|
+
content = result.content
|
|
33
|
+
assert content and isinstance(content[0], TextContent)
|
|
34
|
+
return content[0].text
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
async def _read_json_resource(session: ClientSession, uri: str) -> object:
|
|
38
|
+
result = await session.read_resource(uri)
|
|
39
|
+
assert len(result.contents) == 1
|
|
40
|
+
content = result.contents[0]
|
|
41
|
+
assert isinstance(content, TextResourceContents)
|
|
42
|
+
assert content.mime_type == "application/json"
|
|
43
|
+
return cast(object, json.loads(content.text))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _has_sentence(value: object) -> bool:
|
|
47
|
+
return (
|
|
48
|
+
isinstance(value, str)
|
|
49
|
+
and len(value.split()) >= 3
|
|
50
|
+
and value.rstrip().endswith((".", "!", "?"))
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _schema_has_enum(schema: object, definitions: dict[str, object]) -> bool:
|
|
55
|
+
if not isinstance(schema, dict):
|
|
56
|
+
return False
|
|
57
|
+
if isinstance(schema.get("enum"), list):
|
|
58
|
+
return True
|
|
59
|
+
reference = schema.get("$ref")
|
|
60
|
+
if isinstance(reference, str) and _schema_has_enum(
|
|
61
|
+
definitions.get(reference.rsplit("/", 1)[-1]), definitions
|
|
62
|
+
):
|
|
63
|
+
return True
|
|
64
|
+
for key in ("anyOf", "oneOf", "allOf"):
|
|
65
|
+
variants = schema.get(key)
|
|
66
|
+
if isinstance(variants, list) and any(
|
|
67
|
+
_schema_has_enum(variant, definitions) for variant in variants
|
|
68
|
+
):
|
|
69
|
+
return True
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_the_mcp_server_refuses_a_missing_or_revoked_agent_key(
|
|
74
|
+
client: httpx.Client,
|
|
75
|
+
) -> None:
|
|
76
|
+
# Audit: protects the real /mcp authorization boundary for missing, unknown, valid and
|
|
77
|
+
# revoked keys. The tool calls cannot catch an auth middleware bypass, and unit tests cannot
|
|
78
|
+
# exercise the API transport. This uses the official MCP client for the valid key; no seam.
|
|
79
|
+
_, csrf = sign_up(client)
|
|
80
|
+
|
|
81
|
+
def initialize(headers: dict[str, str] | None = None) -> httpx.Response:
|
|
82
|
+
return client.post(
|
|
83
|
+
"/mcp",
|
|
84
|
+
headers=headers,
|
|
85
|
+
json={
|
|
86
|
+
"jsonrpc": "2.0",
|
|
87
|
+
"id": 1,
|
|
88
|
+
"method": "initialize",
|
|
89
|
+
"params": {
|
|
90
|
+
"protocolVersion": "2025-06-18",
|
|
91
|
+
"capabilities": {},
|
|
92
|
+
"clientInfo": {"name": "test", "version": "1.0"},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
for response in (
|
|
98
|
+
initialize(),
|
|
99
|
+
initialize({"Authorization": "Bearer unknown-agent-key"}),
|
|
100
|
+
):
|
|
101
|
+
assert response.status_code == 401, response.text
|
|
102
|
+
assert response.json()["error"]["code"] == "UNAUTHENTICATED"
|
|
103
|
+
assert response.headers["WWW-Authenticate"].startswith("Bearer")
|
|
104
|
+
|
|
105
|
+
agent, key = _agent(client, csrf)
|
|
106
|
+
|
|
107
|
+
async def listed_tools() -> None:
|
|
108
|
+
async with agent_client(key) as session:
|
|
109
|
+
result = await session.list_tools()
|
|
110
|
+
assert any(tool.name == "projects_search" for tool in result.tools)
|
|
111
|
+
|
|
112
|
+
asyncio.run(listed_tools())
|
|
113
|
+
revoked = client.delete(
|
|
114
|
+
f"/api/v1/members/{agent['accountId']}/key",
|
|
115
|
+
headers={"x-csrf-token": csrf},
|
|
116
|
+
)
|
|
117
|
+
assert revoked.status_code == 200, revoked.text
|
|
118
|
+
response = initialize({"Authorization": f"Bearer {key}"})
|
|
119
|
+
assert response.status_code == 401, response.text
|
|
120
|
+
assert response.json()["error"]["code"] == "UNAUTHENTICATED"
|
|
121
|
+
assert response.headers["WWW-Authenticate"].startswith("Bearer")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_every_tool_has_a_description_annotations_schemas_and_the_error_shape(
|
|
125
|
+
client: httpx.Client,
|
|
126
|
+
) -> None:
|
|
127
|
+
# Audit: protects each tool as an MCP client sees it, including strict schemas and errors.
|
|
128
|
+
# REST tests cannot catch malformed tools/list or tools/call responses; one list-driven case
|
|
129
|
+
# covers generated and hand-written tools at their shared boundary. No production seam.
|
|
130
|
+
_, csrf = sign_up(client)
|
|
131
|
+
_, key = _agent(client, csrf)
|
|
132
|
+
|
|
133
|
+
async def check_tools() -> None:
|
|
134
|
+
async with agent_client(key) as session:
|
|
135
|
+
first_list = (await session.list_tools()).tools
|
|
136
|
+
features = {
|
|
137
|
+
tool.name.removesuffix("_search")
|
|
138
|
+
for tool in first_list
|
|
139
|
+
if tool.name.endswith("_search")
|
|
140
|
+
}
|
|
141
|
+
assert features
|
|
142
|
+
for feature in features:
|
|
143
|
+
access = client.put(
|
|
144
|
+
f"/api/v1/agent-tools/{feature.replace('_', '-')}",
|
|
145
|
+
headers={"x-csrf-token": csrf},
|
|
146
|
+
json={"deleteAndRestore": True},
|
|
147
|
+
)
|
|
148
|
+
assert access.status_code == 200, access.text
|
|
149
|
+
tools = (await session.list_tools()).tools
|
|
150
|
+
for tool in tools:
|
|
151
|
+
assert tool.description and tool.description.count(".") >= 2
|
|
152
|
+
assert tool.annotations is not None
|
|
153
|
+
assert tool.annotations.title
|
|
154
|
+
hints = (
|
|
155
|
+
tool.annotations.read_only_hint,
|
|
156
|
+
tool.annotations.destructive_hint,
|
|
157
|
+
tool.annotations.idempotent_hint,
|
|
158
|
+
tool.annotations.open_world_hint,
|
|
159
|
+
)
|
|
160
|
+
assert all(isinstance(value, bool) for value in hints)
|
|
161
|
+
generated_feature = next(
|
|
162
|
+
(
|
|
163
|
+
feature
|
|
164
|
+
for feature in features
|
|
165
|
+
if tool.name.startswith(f"{feature}_")
|
|
166
|
+
),
|
|
167
|
+
None,
|
|
168
|
+
)
|
|
169
|
+
if generated_feature is not None:
|
|
170
|
+
action = tool.name.removeprefix(f"{generated_feature}_")
|
|
171
|
+
if action in {
|
|
172
|
+
"search",
|
|
173
|
+
"get",
|
|
174
|
+
"create",
|
|
175
|
+
"update",
|
|
176
|
+
"delete",
|
|
177
|
+
"restore",
|
|
178
|
+
}:
|
|
179
|
+
assert tool.annotations.read_only_hint is (
|
|
180
|
+
action in {"search", "get"}
|
|
181
|
+
)
|
|
182
|
+
assert tool.annotations.destructive_hint is (action == "delete")
|
|
183
|
+
assert tool.annotations.idempotent_hint is (
|
|
184
|
+
action in {"update", "delete", "restore"}
|
|
185
|
+
)
|
|
186
|
+
assert tool.annotations.open_world_hint is False
|
|
187
|
+
if generated_feature == "projects" and action in {
|
|
188
|
+
"get",
|
|
189
|
+
"update",
|
|
190
|
+
"delete",
|
|
191
|
+
"restore",
|
|
192
|
+
}:
|
|
193
|
+
assert "project_id" in tool.input_schema["properties"]
|
|
194
|
+
assert "id" not in tool.input_schema["properties"]
|
|
195
|
+
if action == "search":
|
|
196
|
+
assert "query" in tool.input_schema["properties"]
|
|
197
|
+
assert tool.input_schema["type"] == "object"
|
|
198
|
+
assert tool.input_schema["additionalProperties"] is False
|
|
199
|
+
assert tool.output_schema is not None
|
|
200
|
+
assert tool.output_schema["type"] == "object"
|
|
201
|
+
result = await session.call_tool(tool.name, {"unknown_argument": True})
|
|
202
|
+
assert result.is_error is True
|
|
203
|
+
error = _mcp_error(result)
|
|
204
|
+
assert error["kind"] == "invalid_input"
|
|
205
|
+
assert error["retryable"] is False
|
|
206
|
+
assert isinstance(error["message"], str) and error["message"]
|
|
207
|
+
assert _tool_text(result)
|
|
208
|
+
|
|
209
|
+
asyncio.run(check_tools())
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_an_agent_reads_a_project_the_project_fields_and_the_status_values_as_resources(
|
|
213
|
+
client: httpx.Client,
|
|
214
|
+
) -> None:
|
|
215
|
+
# Audit: a missing project registration, changed item data, or broken missing-id error fails.
|
|
216
|
+
# Existing tests only read project data as tools, and none exercise this MCP resource path.
|
|
217
|
+
# This uses the public HTTP/MCP boundary and needs no production seam.
|
|
218
|
+
_, csrf = sign_up(client)
|
|
219
|
+
_, key = _agent(client, csrf, "member")
|
|
220
|
+
|
|
221
|
+
async def read_project_resources() -> None:
|
|
222
|
+
async with agent_client(key) as session:
|
|
223
|
+
name = f"Resource project {uuid4().hex[:8]}"
|
|
224
|
+
created = await session.call_tool(
|
|
225
|
+
"projects_create", {"name": name, "status": "active"}
|
|
226
|
+
)
|
|
227
|
+
assert created.is_error is False
|
|
228
|
+
assert created.structured_content is not None
|
|
229
|
+
project_id = created.structured_content["project_id"]
|
|
230
|
+
assert isinstance(project_id, str)
|
|
231
|
+
|
|
232
|
+
templates = (await session.list_resource_templates()).resource_templates
|
|
233
|
+
assert any(
|
|
234
|
+
template.uri_template == "app://projects/{project_id}"
|
|
235
|
+
for template in templates
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
resources = (await session.list_resources()).resources
|
|
239
|
+
resource_uris = {str(resource.uri) for resource in resources}
|
|
240
|
+
fields_uri = "app://projects/fields"
|
|
241
|
+
values_uri = "app://projects/fields/status/values"
|
|
242
|
+
assert {fields_uri, values_uri} <= resource_uris
|
|
243
|
+
|
|
244
|
+
guide = await _read_json_resource(session, fields_uri)
|
|
245
|
+
assert isinstance(guide, dict)
|
|
246
|
+
fields = guide["fields"]
|
|
247
|
+
assert isinstance(fields, list)
|
|
248
|
+
name_field = next(field for field in fields if field["name"] == "name")
|
|
249
|
+
assert name_field["kind"] == "string"
|
|
250
|
+
assert name_field["required"] is True
|
|
251
|
+
assert name_field["description"]
|
|
252
|
+
assert name_field["example"] == "Quarterly planning"
|
|
253
|
+
status_field = next(field for field in fields if field["name"] == "status")
|
|
254
|
+
assert status_field["kind"] == "string"
|
|
255
|
+
assert status_field["required"] is True
|
|
256
|
+
assert status_field["description"]
|
|
257
|
+
assert status_field["example"] == "active"
|
|
258
|
+
assert status_field["allowed_values"] == ["active", "archived"]
|
|
259
|
+
assert status_field["values_uri"] == values_uri
|
|
260
|
+
assert all(
|
|
261
|
+
field["name"] not in {"response_format", "idempotency_key"}
|
|
262
|
+
for field in fields
|
|
263
|
+
)
|
|
264
|
+
assert await _read_json_resource(session, values_uri) == {
|
|
265
|
+
"values": [
|
|
266
|
+
{"value": "active", "label": "Active"},
|
|
267
|
+
{"value": "archived", "label": "Archived"},
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
detailed = await session.call_tool(
|
|
272
|
+
"projects_get",
|
|
273
|
+
{"project_id": project_id, "response_format": "detailed"},
|
|
274
|
+
)
|
|
275
|
+
assert detailed.is_error is False
|
|
276
|
+
assert detailed.structured_content is not None
|
|
277
|
+
assert (
|
|
278
|
+
await _read_json_resource(session, f"app://projects/{project_id}")
|
|
279
|
+
== detailed.structured_content
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
missing_id = str(uuid4())
|
|
283
|
+
with pytest.raises(MCPError) as missing:
|
|
284
|
+
await session.read_resource(f"app://projects/{missing_id}")
|
|
285
|
+
assert missing.value.code == -32002
|
|
286
|
+
assert isinstance(missing.value.data, dict)
|
|
287
|
+
assert missing.value.data["kind"] == "not_found"
|
|
288
|
+
assert missing.value.data["retryable"] is False
|
|
289
|
+
|
|
290
|
+
asyncio.run(read_project_resources())
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def test_every_feature_has_its_resources_each_with_a_description_and_the_json_type(
|
|
294
|
+
client: httpx.Client,
|
|
295
|
+
) -> None:
|
|
296
|
+
# Audit: missing feature registrations, enum lists, descriptions, JSON types, or readable JSON
|
|
297
|
+
# fail at the MCP boundary. Existing MCP coverage only checks tools; no seam is needed.
|
|
298
|
+
_, csrf = sign_up(client)
|
|
299
|
+
_, key = _agent(client, csrf)
|
|
300
|
+
|
|
301
|
+
async def check_feature_resources() -> None:
|
|
302
|
+
async with agent_client(key) as session:
|
|
303
|
+
tools = (await session.list_tools()).tools
|
|
304
|
+
features = {
|
|
305
|
+
tool.name.removesuffix("_search")
|
|
306
|
+
for tool in tools
|
|
307
|
+
if tool.name.endswith("_search")
|
|
308
|
+
}
|
|
309
|
+
resources = (await session.list_resources()).resources
|
|
310
|
+
templates = (await session.list_resource_templates()).resource_templates
|
|
311
|
+
resource_uris = {str(resource.uri) for resource in resources}
|
|
312
|
+
template_uris = {template.uri_template for template in templates}
|
|
313
|
+
|
|
314
|
+
assert features
|
|
315
|
+
for resource in resources:
|
|
316
|
+
assert _has_sentence(resource.description)
|
|
317
|
+
assert resource.mime_type == "application/json"
|
|
318
|
+
await _read_json_resource(session, str(resource.uri))
|
|
319
|
+
for template in templates:
|
|
320
|
+
assert _has_sentence(template.description)
|
|
321
|
+
assert template.mime_type == "application/json"
|
|
322
|
+
|
|
323
|
+
for feature in features:
|
|
324
|
+
create = next(
|
|
325
|
+
(tool for tool in tools if tool.name == f"{feature}_create"), None
|
|
326
|
+
)
|
|
327
|
+
get = next(
|
|
328
|
+
(tool for tool in tools if tool.name == f"{feature}_get"), None
|
|
329
|
+
)
|
|
330
|
+
assert create is not None
|
|
331
|
+
assert get is not None
|
|
332
|
+
|
|
333
|
+
get_properties = get.input_schema["properties"]
|
|
334
|
+
assert isinstance(get_properties, dict)
|
|
335
|
+
id_fields = [field for field in get_properties if field.endswith("_id")]
|
|
336
|
+
assert len(id_fields) == 1
|
|
337
|
+
feature_path = feature.replace("_", "-")
|
|
338
|
+
assert f"app://{feature_path}/{{{id_fields[0]}}}" in template_uris
|
|
339
|
+
assert f"app://{feature_path}/fields" in resource_uris
|
|
340
|
+
|
|
341
|
+
create_properties = create.input_schema["properties"]
|
|
342
|
+
assert isinstance(create_properties, dict)
|
|
343
|
+
definitions = create.input_schema.get("$defs", {})
|
|
344
|
+
assert isinstance(definitions, dict)
|
|
345
|
+
for field, schema in create_properties.items():
|
|
346
|
+
if field in {"response_format", "idempotency_key"}:
|
|
347
|
+
continue
|
|
348
|
+
if _schema_has_enum(schema, definitions):
|
|
349
|
+
assert (
|
|
350
|
+
f"app://{feature_path}/fields/{field}/values"
|
|
351
|
+
in resource_uris
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
asyncio.run(check_feature_resources())
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def test_the_mcp_server_has_no_prompts_by_default(client: httpx.Client) -> None:
|
|
358
|
+
# Audit: accidentally registering a default prompt fails at the public MCP boundary. Existing
|
|
359
|
+
# tests only list tools; no production seam is needed.
|
|
360
|
+
_, csrf = sign_up(client)
|
|
361
|
+
_, key = _agent(client, csrf)
|
|
362
|
+
|
|
363
|
+
async def list_prompts() -> None:
|
|
364
|
+
async with agent_client(key) as session:
|
|
365
|
+
assert (await session.list_prompts()).prompts == []
|
|
366
|
+
|
|
367
|
+
asyncio.run(list_prompts())
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def test_project_search_pages_with_a_cursor_and_says_how_many_match(
|
|
371
|
+
client: httpx.Client,
|
|
372
|
+
) -> None:
|
|
373
|
+
# Audit: protects the MCP search page and its guidance through the transport and database.
|
|
374
|
+
# REST paging does not exercise tool cursors or summaries. Data is created through HTTP; no seam.
|
|
375
|
+
_, csrf = sign_up(client)
|
|
376
|
+
_, key = _agent(client, csrf, "member")
|
|
377
|
+
prefix = f"MCP page {uuid4().hex[:8]}"
|
|
378
|
+
for index in range(25):
|
|
379
|
+
created = client.post(
|
|
380
|
+
"/api/v1/projects",
|
|
381
|
+
headers={"x-csrf-token": csrf},
|
|
382
|
+
json={"name": f"{prefix} {index:02d}", "status": "active"},
|
|
383
|
+
)
|
|
384
|
+
assert created.status_code == 201, created.text
|
|
385
|
+
|
|
386
|
+
async def check_pages() -> None:
|
|
387
|
+
async with agent_client(key) as session:
|
|
388
|
+
first = await session.call_tool(
|
|
389
|
+
"projects_search",
|
|
390
|
+
{"query": prefix, "sort_by": "name", "sort_order": "asc"},
|
|
391
|
+
)
|
|
392
|
+
assert first.is_error is False
|
|
393
|
+
data = first.structured_content
|
|
394
|
+
assert data is not None
|
|
395
|
+
assert len(data["items"]) == 20
|
|
396
|
+
assert data["total"] == 25
|
|
397
|
+
assert data["next_cursor"]
|
|
398
|
+
summary = _tool_text(first)
|
|
399
|
+
assert "25" in summary
|
|
400
|
+
assert "narrow" in summary.lower()
|
|
401
|
+
second = await session.call_tool(
|
|
402
|
+
"projects_search",
|
|
403
|
+
{
|
|
404
|
+
"query": prefix,
|
|
405
|
+
"sort_by": "name",
|
|
406
|
+
"sort_order": "asc",
|
|
407
|
+
"cursor": data["next_cursor"],
|
|
408
|
+
},
|
|
409
|
+
)
|
|
410
|
+
assert second.is_error is False
|
|
411
|
+
next_data = second.structured_content
|
|
412
|
+
assert next_data is not None
|
|
413
|
+
assert len(next_data["items"]) == 5
|
|
414
|
+
assert next_data["total"] == 25
|
|
415
|
+
assert next_data["next_cursor"] is None
|
|
416
|
+
invalid = await session.call_tool("projects_search", {"limit": 101})
|
|
417
|
+
assert invalid.is_error is True
|
|
418
|
+
assert _mcp_error(invalid)["kind"] == "invalid_input"
|
|
419
|
+
|
|
420
|
+
asyncio.run(check_pages())
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def test_a_retried_project_create_with_the_same_idempotency_key_makes_one_project(
|
|
424
|
+
client: httpx.Client,
|
|
425
|
+
) -> None:
|
|
426
|
+
# Audit: protects the retry contract at the MCP/database boundary. Existing REST create tests
|
|
427
|
+
# have no idempotency key, so they cannot catch duplicate rows on a replay. No production seam.
|
|
428
|
+
_, csrf = sign_up(client)
|
|
429
|
+
_, key = _agent(client, csrf, "member")
|
|
430
|
+
name = f"MCP retry {uuid4().hex[:8]}"
|
|
431
|
+
|
|
432
|
+
async def create_twice() -> None:
|
|
433
|
+
async with agent_client(key) as session:
|
|
434
|
+
args = {
|
|
435
|
+
"name": name,
|
|
436
|
+
"status": "active",
|
|
437
|
+
"idempotency_key": f"retry-{uuid4().hex}",
|
|
438
|
+
}
|
|
439
|
+
first = await session.call_tool("projects_create", args)
|
|
440
|
+
second = await session.call_tool("projects_create", args)
|
|
441
|
+
assert first.is_error is False and second.is_error is False
|
|
442
|
+
assert first.structured_content is not None
|
|
443
|
+
assert second.structured_content is not None
|
|
444
|
+
assert (
|
|
445
|
+
first.structured_content["project_id"]
|
|
446
|
+
== second.structured_content["project_id"]
|
|
447
|
+
)
|
|
448
|
+
search = await session.call_tool("projects_search", {"query": name})
|
|
449
|
+
assert search.structured_content is not None
|
|
450
|
+
assert search.structured_content["total"] == 1
|
|
451
|
+
|
|
452
|
+
asyncio.run(create_twice())
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def test_a_repeated_project_update_changes_nothing(client: httpx.Client) -> None:
|
|
456
|
+
# Audit: protects idempotent updates and the matching actor history row at the running API.
|
|
457
|
+
# REST update coverage does not call the tool twice as an agent. No production seam.
|
|
458
|
+
_, csrf = sign_up(client)
|
|
459
|
+
agent, key = _agent(client, csrf)
|
|
460
|
+
name = f"MCP update {uuid4().hex[:8]}"
|
|
461
|
+
|
|
462
|
+
async def update_twice() -> None:
|
|
463
|
+
async with agent_client(key) as session:
|
|
464
|
+
created = await session.call_tool(
|
|
465
|
+
"projects_create", {"name": name, "status": "active"}
|
|
466
|
+
)
|
|
467
|
+
assert created.is_error is False
|
|
468
|
+
assert created.structured_content is not None
|
|
469
|
+
project_id = created.structured_content["project_id"]
|
|
470
|
+
args = {
|
|
471
|
+
"project_id": project_id,
|
|
472
|
+
"name": f"{name} updated",
|
|
473
|
+
"status": "archived",
|
|
474
|
+
}
|
|
475
|
+
first = await session.call_tool("projects_update", args)
|
|
476
|
+
second = await session.call_tool("projects_update", args)
|
|
477
|
+
assert first.is_error is False and second.is_error is False
|
|
478
|
+
assert first.structured_content is not None
|
|
479
|
+
assert second.structured_content is not None
|
|
480
|
+
assert (
|
|
481
|
+
first.structured_content["updated_at_utc"]
|
|
482
|
+
== second.structured_content["updated_at_utc"]
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
asyncio.run(update_twice())
|
|
486
|
+
project = client.get(f"/api/v1/projects?search={name}%20updated").json()["data"][
|
|
487
|
+
"items"
|
|
488
|
+
][0]
|
|
489
|
+
changes = client.get(f"/api/v1/projects/{project['id']}/changes").json()["data"]
|
|
490
|
+
updates = [
|
|
491
|
+
entry for entry in changes if entry["summary"].startswith("Name changed")
|
|
492
|
+
]
|
|
493
|
+
assert len(updates) == 1
|
|
494
|
+
assert updates[0]["actorEmail"] == agent["email"]
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
def test_an_invalid_project_input_gets_a_non_retryable_error_with_an_example(
|
|
498
|
+
client: httpx.Client,
|
|
499
|
+
) -> None:
|
|
500
|
+
# Audit: protects plain, repairable validation errors at tools/call. REST validation does not
|
|
501
|
+
# prove the MCP error shape or example. The invalid value is sent through the real transport.
|
|
502
|
+
_, csrf = sign_up(client)
|
|
503
|
+
_, key = _agent(client, csrf, "member")
|
|
504
|
+
|
|
505
|
+
async def call_invalid() -> None:
|
|
506
|
+
async with agent_client(key) as session:
|
|
507
|
+
invalid_inputs = (
|
|
508
|
+
(
|
|
509
|
+
{"name": f"Invalid MCP {uuid4().hex[:8]}", "status": "blocked"},
|
|
510
|
+
"status",
|
|
511
|
+
),
|
|
512
|
+
({"name": " ", "status": "active"}, "name"),
|
|
513
|
+
)
|
|
514
|
+
for args, field in invalid_inputs:
|
|
515
|
+
result = await session.call_tool("projects_create", args)
|
|
516
|
+
assert result.is_error is True
|
|
517
|
+
error = _mcp_error(result)
|
|
518
|
+
assert error["kind"] == "invalid_input"
|
|
519
|
+
assert error["retryable"] is False
|
|
520
|
+
assert field in str(error["details"])
|
|
521
|
+
message = error["message"]
|
|
522
|
+
assert isinstance(message, str)
|
|
523
|
+
assert "Example:" in message
|
|
524
|
+
|
|
525
|
+
asyncio.run(call_invalid())
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def test_an_agent_key_over_its_rate_limit_gets_a_retryable_error(
|
|
529
|
+
client: httpx.Client,
|
|
530
|
+
) -> None:
|
|
531
|
+
# Audit: protects per-key throttling and confirms another agent remains usable. No other test
|
|
532
|
+
# exercises the API's MCP rate-limit boundary; the loop makes real calls on a newly issued key.
|
|
533
|
+
_, csrf = sign_up(client)
|
|
534
|
+
_, first_key = _agent(client, csrf, "member")
|
|
535
|
+
_, second_key = _agent(client, csrf, "member")
|
|
536
|
+
|
|
537
|
+
async def exceed_limit() -> None:
|
|
538
|
+
async with agent_client(first_key) as session:
|
|
539
|
+
last = None
|
|
540
|
+
for index in range(121):
|
|
541
|
+
last = await session.call_tool("projects_search", {"query": ""})
|
|
542
|
+
if index < 120:
|
|
543
|
+
assert last.is_error is False
|
|
544
|
+
else:
|
|
545
|
+
assert last.is_error is True
|
|
546
|
+
error = _mcp_error(last)
|
|
547
|
+
assert error["kind"] == "rate_limited"
|
|
548
|
+
assert error["retryable"] is True
|
|
549
|
+
retry_after = error["retry_after_seconds"]
|
|
550
|
+
assert isinstance(retry_after, int)
|
|
551
|
+
assert 1 <= retry_after <= 60
|
|
552
|
+
async with agent_client(second_key) as session:
|
|
553
|
+
result = await session.call_tool("projects_search", {"query": ""})
|
|
554
|
+
assert result.is_error is False
|
|
555
|
+
|
|
556
|
+
asyncio.run(exceed_limit())
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Module schema ownership through the running API and Postgres."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
import pytest
|
|
7
|
+
from test_api import sign_up
|
|
8
|
+
from test_soft_delete import psql
|
|
9
|
+
|
|
10
|
+
EXPECTED_TABLE_SCHEMAS = (
|
|
11
|
+
"core.account",
|
|
12
|
+
"core.invite",
|
|
13
|
+
"core.membership",
|
|
14
|
+
"core.organisation",
|
|
15
|
+
"core.password_reset_token",
|
|
16
|
+
"core.session",
|
|
17
|
+
"core.sign_in_attempt",
|
|
18
|
+
"history.change_record",
|
|
19
|
+
"mcp.idempotency_key",
|
|
20
|
+
"notifications.notification",
|
|
21
|
+
"projects.project",
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@pytest.mark.parametrize(
|
|
26
|
+
"expected_table_schemas",
|
|
27
|
+
[
|
|
28
|
+
pytest.param(
|
|
29
|
+
EXPECTED_TABLE_SCHEMAS,
|
|
30
|
+
id="each module keeps its tables in its own schema",
|
|
31
|
+
)
|
|
32
|
+
],
|
|
33
|
+
)
|
|
34
|
+
def test_each_module_keeps_its_tables_in_its_own_schema(
|
|
35
|
+
client: httpx.Client, expected_table_schemas: tuple[str, ...]
|
|
36
|
+
) -> None:
|
|
37
|
+
# Audit: a migration that leaves a table in public breaks schema ownership, while a
|
|
38
|
+
# cross-schema foreign key couples business modules. Existing API CRUD tests do not check
|
|
39
|
+
# either database rule. This test uses HTTP and the migrated Postgres database directly.
|
|
40
|
+
_, csrf = sign_up(client)
|
|
41
|
+
created = client.post(
|
|
42
|
+
"/api/v1/projects",
|
|
43
|
+
headers={"x-csrf-token": csrf},
|
|
44
|
+
json={"name": "Schema-owned project", "status": "active"},
|
|
45
|
+
)
|
|
46
|
+
assert created.status_code == 201, created.text
|
|
47
|
+
project_id = created.json()["data"]["id"]
|
|
48
|
+
read = client.get(f"/api/v1/projects/{project_id}")
|
|
49
|
+
assert read.status_code == 200, read.text
|
|
50
|
+
assert read.json()["data"]["id"] == project_id
|
|
51
|
+
|
|
52
|
+
tables = psql(
|
|
53
|
+
"SELECT string_agg(table_schema || '.' || table_name, ',' "
|
|
54
|
+
"ORDER BY table_schema, table_name) FROM information_schema.tables "
|
|
55
|
+
"WHERE table_type = 'BASE TABLE' "
|
|
56
|
+
"AND table_schema NOT IN ('pg_catalog', 'information_schema') "
|
|
57
|
+
"AND table_name <> 'alembic_version'"
|
|
58
|
+
)
|
|
59
|
+
assert tables.returncode == 0, tables.stderr
|
|
60
|
+
assert ",".join(expected_table_schemas) in [
|
|
61
|
+
line.strip() for line in tables.stdout.splitlines()
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
foreign_keys = psql(
|
|
65
|
+
"SELECT CASE WHEN EXISTS (SELECT 1 FROM pg_constraint AS c "
|
|
66
|
+
"JOIN pg_class AS source_table ON source_table.oid = c.conrelid "
|
|
67
|
+
"JOIN pg_namespace AS source_schema ON source_schema.oid = source_table.relnamespace "
|
|
68
|
+
"JOIN pg_class AS target_table ON target_table.oid = c.confrelid "
|
|
69
|
+
"JOIN pg_namespace AS target_schema ON target_schema.oid = target_table.relnamespace "
|
|
70
|
+
"WHERE c.contype = 'f' AND source_schema.nspname IN ('history', 'mcp', 'notifications', 'projects') "
|
|
71
|
+
"AND target_schema.nspname IN ('history', 'mcp', 'notifications', 'projects') "
|
|
72
|
+
"AND source_schema.nspname <> target_schema.nspname) "
|
|
73
|
+
"THEN 'cross-schema foreign key found' ELSE 'no cross-schema foreign keys' END"
|
|
74
|
+
)
|
|
75
|
+
assert foreign_keys.returncode == 0, foreign_keys.stderr
|
|
76
|
+
assert "no cross-schema foreign keys" in foreign_keys.stdout
|
|
77
|
+
|
|
78
|
+
drift = subprocess.run(
|
|
79
|
+
[
|
|
80
|
+
"docker",
|
|
81
|
+
"compose",
|
|
82
|
+
"-f",
|
|
83
|
+
"compose.test.yml",
|
|
84
|
+
"exec",
|
|
85
|
+
"-T",
|
|
86
|
+
"api",
|
|
87
|
+
"uv",
|
|
88
|
+
"run",
|
|
89
|
+
"--no-sync",
|
|
90
|
+
"alembic",
|
|
91
|
+
"check",
|
|
92
|
+
],
|
|
93
|
+
cwd="../..",
|
|
94
|
+
capture_output=True,
|
|
95
|
+
text=True,
|
|
96
|
+
encoding="utf-8",
|
|
97
|
+
check=False,
|
|
98
|
+
timeout=30,
|
|
99
|
+
)
|
|
100
|
+
assert drift.returncode == 0, drift.stdout + drift.stderr
|