Phase 2 and 3 of the platform rework. - Neutral request/response contract: external_id, metadata, X-AI-Key, run_id in the response; client-specific fields removed. - AI profile is a revision table: saving creates an inactive revision, activation is separate, try-run does not store a run. One chat-completions gateway serves AIHub and OpenAI-compatible profiles. - Add between and in rule operators. - Contracts moved to contracts/lead-scoring/ with a score-response fixture. - Admin Web updated for revisions, runs and the neutral fixture. - Consolidate tests; remove rewrite_architect.md and the stale handoff doc; rewrite spec, CONTEXT and ARCHITECTURE for the current design. Not verified: live AIHub/OpenAI behavior, Omni/EMS integration.
3.0 KiB
3.0 KiB
Repository workflow
This repository is the rebuilt AI Platform. Historical implementation is retained only in Git history; current code lives under src/ai_platform/ and apps/web/. The approved rebuild plan authorizes implementation; docs/specs/ai-platform-lead-scoring.md is review-ready for cross-service acceptance, so unverified Omni/AIHub wire details are not release claims.
- Before changing Lead Scoring behavior, read
docs/specs/ai-platform-lead-scoring.md,CONTEXT.md, andARCHITECTURE.md. Readstack.mdwhen choosing a runtime or dependency. Generated OpenAPI and small Omni fixtures own exact wire shapes. - Put app/admin authentication, configuration and shared DB setup in
platform; put deterministic rules/metrics and run lifecycle inlead_scoring/domain; orchestration inapplication, I/O ininfrastructure, HTTP mapping inpresentation, and wiring inbootstrap. Churn follows the same layout only when a specification exists. - The client (Omni) owns rules/weights/thresholds/HITL/CRM; AI Platform owns AI profile revisions and the scoring run record. The AI key (
X-AI-Key) is request-scoped RAM only. One app key per installation authenticates the platform. Admin Web uses a distinct session. - Kiểm tra tính nhất quán trước khi tối ưu một phần: đối chiếu API với fixture trong
contracts/lead-scoring/, tên env vớiSettings/Compose/CI, lệnh build với package/lockfile và UI với design system ởARCHITECTURE.md. Web dùng Tailwind CSS v4 cho semantic tokens, shadcn-svelte cho component cần thiết, Bits UI cho tương tác phức tạp; dùng HTML native cho form/bảng đơn giản, không tự tái tạo primitives. - File trên 200 dòng là tín hiệu review: kiểm tra trách nhiệm trộn lẫn, tách tại boundary có nghĩa. Giữ một OpenAPI generated và vài Omni fixtures thật, không tạo hệ schema thứ hai.
- Trước bàn giao, chạy Ruff/Pyright/Import Linter/pytest, Svelte checks/build/tests, migration và contract generation có liên quan. Báo chính xác pass/fail; hook opt-in, CI là gate. Không stage
.env,.env.test, ignored assets hoặc secrets. - Thay đổi ranh giới kiến trúc, dependency direction, DI/composition root hoặc ownership transaction do main agent trực tiếp phân tích, quyết định và triển khai. Có thể giao review/test chỉ đọc độc lập, nhưng không giao phần thiết kế và implementation các thay đổi này.
- Sau khi code hoàn tất và trước mỗi commit, review toàn bộ tracked/untracked changes theo
docs/project_quality.md; báo chính xác các kiểm tra đã chạy, phát hiện còn lại và phần chưa xác minh.
Use README.md for current local commands; stack.md for decisions and deferred production hosting/TLS/secret/backup/alerts. Preserve the user's existing ignored files unless explicitly authorized to replace them. No global tool installs or system configuration changes during repo work.