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.
POST /v1/lead-scoring/score now evaluates in the request, applies an overall
AI deadline, and stores the completed run only after scoring. Idempotency is
kept by (app_id, account_id, request_id) with a body fingerprint.
Removes the webhook outbox, scheduler/recovery loop, app lead_scoring
permission, credential audit events, seed_demo and generate_secret scripts,
and the tests that covered them. Trims tests to behavior of the new flow.
Replace tenant-key administration with app access listing and revocation. Show the canonical conversation and rules before submitting a fixture, support opt-in medium AI scoring, and keep credentials server-only.