feat(p7): AI tables + enums + migration + events + InferencePort contract
Task 7.1: 7 AI-proposal-layer tables (IiosAiJob, IiosAiModelRun, IiosAiArtifact, IiosAiClaim, IiosAiEvidenceLink, IiosAiToolCall, IiosEmbeddingRef) + enums; migration ai-init. Adds ai.job.created / ai.artifact.proposed / ai.artifact.accepted events and a standalone InferencePort contract (not part of sealed IiosPlatformPorts). resetDb truncates the new tables. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* The AI inference port (P7). A standalone contract — deliberately NOT part of the
|
||||
* sealed `IiosPlatformPorts`: AI is an internal "AI Factory" whose model execution
|
||||
* routes through the Capability Broker in P9. In P7 it is a faked, deterministic,
|
||||
* golden provider (no network). Every result carries the provenance the critics
|
||||
* mandate (model/prompt version, tokens, cost, confidence, abstention, evidence).
|
||||
*/
|
||||
|
||||
export type AiJobType = 'CLASSIFY' | 'SUMMARIZE' | 'EXTRACT';
|
||||
|
||||
export type AiArtifactType = 'CLASSIFICATION' | 'SUMMARY' | 'TRANSCRIPT' | 'DIGEST' | 'EXTRACTION';
|
||||
|
||||
export type AiClaimType = 'MODERATION_FLAG' | 'EVENT' | 'FAQ' | 'INTENT' | 'PRIORITY';
|
||||
|
||||
export interface InferenceRequest {
|
||||
jobType: AiJobType;
|
||||
text: string;
|
||||
purpose: string;
|
||||
scopeId: string;
|
||||
/** The kernel interaction this inference is about — used as the default evidence source. */
|
||||
interactionId?: string;
|
||||
}
|
||||
|
||||
export interface InferenceClaim {
|
||||
claimType: AiClaimType;
|
||||
claimJson: Record<string, unknown>;
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export interface InferenceEvidence {
|
||||
sourceType: string;
|
||||
sourceId: string;
|
||||
spanRef?: string;
|
||||
relevanceScore?: number;
|
||||
}
|
||||
|
||||
export interface InferenceModelRun {
|
||||
model: string;
|
||||
modelVersion: string;
|
||||
promptVersion: string;
|
||||
tokensIn: number;
|
||||
tokensOut: number;
|
||||
costUnits: number;
|
||||
latencyMs: number;
|
||||
}
|
||||
|
||||
export interface InferenceResult {
|
||||
artifactType: AiArtifactType;
|
||||
content: unknown;
|
||||
confidence: number;
|
||||
explanation?: string;
|
||||
/** Set when the model declines to assert a claim (Scenario 7 abstention). */
|
||||
abstentionReason?: string;
|
||||
claims: InferenceClaim[];
|
||||
evidence: InferenceEvidence[];
|
||||
modelRun: InferenceModelRun;
|
||||
}
|
||||
|
||||
export interface InferencePort {
|
||||
infer(req: InferenceRequest): Promise<InferenceResult>;
|
||||
}
|
||||
Reference in New Issue
Block a user