feat: implement robustness guards

This commit is contained in:
saturn
2026-03-09 02:53:06 +08:00
parent fba480ae6e
commit be1853534a
25 changed files with 1531 additions and 96 deletions

View File

@@ -8,6 +8,7 @@
},
"scripts": {
"postinstall": "prisma generate",
"prepare": "husky",
"dev": "npm run storage:init && concurrently --kill-others \"npm run dev:next\" \"npm run dev:worker\" \"npm run dev:watchdog\" \"npm run dev:board\"",
"dev:next": "cross-env NODE_OPTIONS=\"--no-deprecation\" next dev --turbopack -H 0.0.0.0",
"dev:worker": "tsx watch --env-file=.env src/lib/workers/index.ts",
@@ -23,7 +24,7 @@
"start:watchdog": "tsx --env-file=.env scripts/watchdog.ts",
"start:board": "tsx --env-file=.env scripts/bull-board.ts",
"stats:errors": "tsx scripts/task-error-stats.ts",
"check:api-handler": "tsx scripts/check-api-handler.ts",
"check:api-handler": "node scripts/guards/api-route-contract-guard.mjs",
"check:logs": "tsx scripts/check-no-console.ts",
"check:log-semantic": "tsx scripts/check-log-semantic.ts",
"check:media-normalization": "tsx scripts/check-media-normalization.ts",
@@ -54,6 +55,9 @@
"check:test-behavior-route-coverage": "node scripts/guards/test-behavior-route-coverage-guard.mjs",
"check:test-behavior-tasktype-coverage": "node scripts/guards/test-behavior-tasktype-coverage-guard.mjs",
"check:test-coverage-guards": "npm run check:test-behavior-quality && npm run check:test-route-coverage && npm run check:test-tasktype-coverage && npm run check:test-behavior-route-coverage && npm run check:test-behavior-tasktype-coverage",
"check:requirements-matrix": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/contracts/requirements-matrix.test.ts",
"check:image-reference-normalization": "node scripts/guards/image-reference-normalization-guard.mjs",
"check:task-submit-compensation": "node scripts/guards/task-submit-compensation-guard.mjs",
"check:locale-navigation": "node scripts/guards/locale-navigation-guard.mjs",
"check:prompt-i18n": "node scripts/guards/prompt-i18n-guard.mjs",
"check:prompt-i18n-regression": "node scripts/guards/prompt-semantic-regression.mjs",
@@ -67,17 +71,21 @@
"test:billing:integration": "cross-env BILLING_TEST_BOOTSTRAP=1 vitest run tests/integration/billing",
"test:billing:concurrency": "cross-env BILLING_TEST_BOOTSTRAP=1 vitest run tests/concurrency/billing",
"test:billing:coverage": "cross-env BILLING_TEST_BOOTSTRAP=1 vitest run --coverage tests/unit/billing tests/integration/billing tests/concurrency/billing",
"test:guards": "npm run check:api-handler && npm run check:no-api-direct-llm-call && npm run check:test-coverage-guards && npm run check:locale-navigation",
"test:guards": "npm run check:api-handler && npm run check:image-reference-normalization && npm run check:task-submit-compensation && npm run check:no-api-direct-llm-call && npm run check:test-coverage-guards && npm run check:requirements-matrix && npm run check:locale-navigation",
"test:unit:all": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/unit",
"test:integration:api": "cross-env BILLING_TEST_BOOTSTRAP=1 vitest run tests/integration/api",
"test:integration:chain": "cross-env BILLING_TEST_BOOTSTRAP=1 vitest run tests/integration/chain",
"test:behavior:unit": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/unit/helpers tests/unit/worker tests/unit/optimistic",
"test:behavior:unit": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/unit/helpers tests/unit/worker tests/unit/optimistic tests/unit/guards",
"test:behavior:api": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/integration/api/contract",
"test:behavior:chain": "cross-env BILLING_TEST_BOOTSTRAP=0 vitest run tests/integration/chain",
"test:behavior:guards": "npm run check:test-coverage-guards",
"test:behavior:guards": "npm run check:api-handler && npm run check:image-reference-normalization && npm run check:task-submit-compensation && npm run check:test-coverage-guards && npm run check:requirements-matrix",
"test:behavior:full": "npm run test:behavior:guards && npm run test:behavior:unit && npm run test:behavior:api && npm run test:behavior:chain",
"test:regression": "npm run test:guards && npm run test:unit:all && npm run test:billing:integration && npm run test:integration:api && npm run test:integration:chain",
"test:pr": "bash scripts/test-regression-runner.sh npm run test:regression",
"typecheck": "tsc --noEmit",
"lint:all": "npm run lint -- .",
"verify:commit": "npm run lint:all && npm run typecheck && npm run test:behavior:full",
"verify:push": "npm run lint:all && npm run typecheck && npm run test:regression && npm run build",
"migrate:image-urls-contract": "tsx scripts/migrate-image-urls-contract.ts",
"migrate:model-config-contract": "tsx scripts/migrations/migrate-model-config-contract.ts",
"migrate:capability-selections": "tsx scripts/migrations/migrate-capability-selections.ts",
@@ -156,6 +164,7 @@
"cross-env": "^10.1.0",
"eslint": "^9",
"eslint-config-next": "15.5.4",
"husky": "^9.1.7",
"rimraf": "^6.1.2",
"tailwindcss": "^4",
"tsx": "^4.20.5",