- AiUsageLog table may not exist in Docker MySQL after restart
- Core AiJob CRUD tests (1-8) are mandatory; AiUsageLog is non-fatal
- deleteMany wrapped in try/catch for same reason
Co-Authored-By: Claude <noreply@anthropic.com>
- Write test script to /tmp/api-server-old/compat-test.ts instead of /tmp
- Run from /tmp/api-server-old so tsx can resolve node_modules/@prisma/client
Co-Authored-By: Claude <noreply@anthropic.com>
- build-and-unit saves git rev-parse HEAD before reset
- backward-compat uses saved PREV to compute exact diff
- Falls back to HEAD~3 diff if prev-head is missing
Co-Authored-By: Claude <noreply@anthropic.com>
- Triggers backward-compat CI gate (schema.prisma is in the path detection list)
- No functional change — comment only
Co-Authored-By: Claude <noreply@anthropic.com>
- workflow_dispatch input: force_backward_compat (boolean, default false)
- Path detection now diffs against origin/main (catches multi-commit pushes)
- Set force_backward_compat=true in workflow_dispatch to force the full
M-AI-01 compatibility test regardless of changed paths
Co-Authored-By: Claude <noreply@anthropic.com>
- deploy job now handles missing _prisma_migrations (same as current-integration)
- Protects against MySQL restart between CI jobs clearing baseline
Co-Authored-By: Claude <noreply@anthropic.com>
- Handles DBs where _prisma_migrations is missing (prisma db push history)
- Marks all existing migrations as applied before migrate deploy
Co-Authored-By: Claude <noreply@anthropic.com>
- Producer must explicitly write its source (api/admin/scheduled/...)
- No database default to mask missing writes
Co-Authored-By: Claude <noreply@anthropic.com>
- Column exists in Prisma schema + production but not in migration files
- Idempotent: checks INFORMATION_SCHEMA before ALTER TABLE
Co-Authored-By: Claude <noreply@anthropic.com>
- tsconfig.build.json: exclude scripts/ (avoids Prisma delegate mismatch)
- tsconfig.json: add exclude for scripts/ and dist/
- ai-job-artifact.repository.ts: cast metadata to any (JsonValue compat)
- ai-job-snapshot.repository.ts: cast data to any (JsonValue compat)
- ai-job-artifact.repository.spec.ts: remove unused @ts-expect-error
- snapshot-builder.service.spec.ts: cast JSON fields to any
Co-Authored-By: Claude <noreply@anthropic.com>
- 5 new columns (jobId, attemptNo, credentialMode, errorCode, providerRequestId)
- FK ON DELETE SET NULL (preserve audit trail)
- 3 new indexes: (jobId,attemptNo), (provider,model,createdAt), (errorCode,createdAt)
Co-Authored-By: Claude <noreply@anthropic.com>
M-AI-02-01: Production DB audit of all 5 AI tables (9 rows, 0 orphans, 37 test refs)
M-AI-02-02: Frozen AiJob Expand ADR — 43-column schema, 6 indexes, state mapping
Co-Authored-By: Claude <noreply@anthropic.com>
Worker Integration tests (BullMQ → Worker → MySQL) must pass.
API E2E (HTTP → Controller → JWT) has known JWT_SECRET mismatch
in spawned test process; production API verified manually.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mysqladmin may not be in CI runner PATH. Use docker exec mysql
mysqladmin ping instead, which works from the Gitea Actions runner.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Deploy zhixi-nest-worker.service after API restart
- Run test/run-integration-ci.sh with real MySQL/Redis/BullMQ
- Integration test failure blocks deployment (exit 1)
- timeout-minutes: 10 to prevent hung tests
Line: .gitea/workflows/deploy.yml:99-113
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- C端测试账号与Token.md: permanent test user c-test-001 + 24h JWT
- Fix Active Recall 404 test assertion
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- NEW test/m-ai-01-09-api-e2e.worker-int-spec.ts: real HTTP endpoints
with JWT auth → Controller → BullMQ → Worker → MySQL
- Feynman: POST /api/ai-analysis/feynman (200/401/400)
- Active Recall: POST /api/active-recalls/:id/submit (200/401/404)
- Document Import: POST /api/imports (200/401)
- generateJWT() in integration-harness.ts (TokenService format)
- httpPost() supports optional Bearer token
- Save test credentials to devops-projects/凭据配置/测试API凭据.md
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- SIGKILL: enqueue job BEFORE kill, wait for pickup, verify recovery
- Document Import: track before/after KnowledgeItem IDs to prove
Worker created them (not direct DB INSERT)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Worker consumes from BullMQ Redis, not MySQL polling.
Replace all dbExec(INSERT INTO AiAnalysisJob) with enqueueJob()
which uses real BullMQ Queue.add() to the test Redis.
Add setRedisConfig() + enqueueJob() to integration harness.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- User INSERT: add updatedAt=NOW() (NOT NULL, no default)
- AiAnalysisJob: retryCount→progress (column doesn't exist)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- NEW test/helpers/mock-ai-provider.ts: Mock AI HTTP server with
normal/timeout/429/500/invalid-json behavior controls
- NEW test/helpers/integration-harness.ts: spawn real API/Worker
processes, HTTP helpers, PrismaClient-based DB helpers
- NEW test/m-ai-01-09.worker-int-spec.ts: real integration test
using actual MySQL/Redis/BullMQ/HTTP (Active Recall, Feynman,
Document Import, SIGKILL recovery, provider faults, idempotency)
- NEW test/jest-worker-integration.json: Jest config with NO mocks
- DELETE test/m-ai-01-09.e2e-spec.ts: removed mock-based pseudo-e2e
- UPDATE test/run-integration-ci.sh: uses real integration config
- UPDATE package.json: test:integration:worker uses real config
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- TestingModule.compile() returns an application context directly
- Use $executeRaw tagged template instead of $executeRawUnsafe
- Add jest.setTimeout(30000) for integration tests
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- test/m-ai-01-09-integration.spec.ts: Active Recall/Feynman/Document Import
E2E tests with real MySQL/Redis/BullMQ
- test/run-integration-ci.sh: CI script (MySQL→Prisma→Build→API→Worker→Test)
- npm run test:integration:worker: one-command integration test
- Includes Active Recall chain audit (actual code paths with file:line)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Notification jobs are triggered implicitly by notifyJobComplete() during
Active Recall analysis, not by a dedicated test endpoint. Script now
checks Worker logs and DB records instead.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ProtectSystem=strict requires /run/systemd/unit-root paths to exist
which fails on production. Worker only needs network access (Redis/MySQL).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Extract queue name constants to queue.constants.ts to resolve
the require cycle that caused 'Cannot read properties of undefined'
at startup. Both queue-definitions.ts and queue.service.ts now
import from the shared constants file.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>