Real Anthropic Claude integration per explicit product decision: a ticket's AI session diagnoses the problem via a structured-output call, applies a DB-configurable confidence-band policy (FR-005), and on "proceed" reasons and acts through a small permission/risk-gated tool system (FR-011/FR-012), optionally walking a matching runbook step by step with the application — never the model — owning the step index (FR-015/FR-016). Resolution requires real tool evidence, never customer claims alone (FR-018) — verifyProductResolution is a documented fail-closed placeholder mirroring the existing malware-scanner precedent, since no real per-product operational signal exists yet. AISupportSession.status mirrors onto Ticket.status through 003-ticketing's existing AI_ANALYZING/AI_TROUBLESHOOTING/AI_VERIFYING/AI_RESOLVED/ HUMAN_ESCALATION state machine, discovered during planning to have been built anticipating this exact feature. Two circular module dependencies (escalation<->sessions, tools<->sessions) were designed around rather than found as bugs: escalation is a pure summary formatter with no state dependencies of its own, and tools stays a clean leaf module with zero dependency on ai-support/sessions. Ticket creation enqueues the first diagnosis turn via the existing queue infrastructure (off the hot path of the inbound SaaS integration endpoint); a human actor changing ticket status ends the AI session via the event-bus scaffold that existed in this codebase but had never been wired to anything. A real Prisma limitation was found and fixed before it reached tests: compound-unique upsert rejects null for a nullable key column, so AIConfidencePolicy uses find-then-update/create instead, same fix class 004 already used for the same underlying limitation. Adds 9 unit tests (confidence-band, tool-policy-gate, runbook-step- advance) and 6 integration test files, including the two constitution- required standing E2E scenarios. AI-independent tests were run against real Postgres/Redis/MinIO (88 passed, 0 failed across the full suite, including every pre-existing 002/003/004 test). The AI-dependent tests compile and skip cleanly via describe.skipIf but were not run against a live model — no ANTHROPIC_API_KEY was available in this session; a real key must be supplied before this feature can actually run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
22 lines
930 B
TypeScript
22 lines
930 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { advanceRunbookStep } from '@/modules/ai-support/troubleshooting/service/step-advance';
|
|
|
|
describe('advanceRunbookStep', () => {
|
|
it('advances by exactly one step when not resolved and steps remain', () => {
|
|
expect(advanceRunbookStep(3, 0, false)).toEqual({ exhausted: false, nextIndex: 1 });
|
|
expect(advanceRunbookStep(5, 1, false)).toEqual({ exhausted: false, nextIndex: 2 });
|
|
});
|
|
|
|
it('reports exhaustion when the last step still is not resolved', () => {
|
|
expect(advanceRunbookStep(3, 2, false)).toEqual({ exhausted: true });
|
|
});
|
|
|
|
it('reports exhaustion rather than wrapping around for a single-step runbook', () => {
|
|
expect(advanceRunbookStep(1, 0, false)).toEqual({ exhausted: true });
|
|
});
|
|
|
|
it('does not advance the index when resolved', () => {
|
|
expect(advanceRunbookStep(3, 1, true)).toEqual({ exhausted: false, nextIndex: 1 });
|
|
});
|
|
});
|