Skip to content

@codesoul-co/hypha-core / contracts/recovery-knowledge-schemas

模块用法

用于声明并运行时校验契约。Recovery knowledge schemas 模块公开 10 常量、2 函数。

从包入口导入

ts
import {
  recoveryKnowledgeJsonSchema,
  recoveryKnowledgeKeyJsonSchema,
  recoveryKnowledgeKeySchema,
  recoveryKnowledgeSchema,
  recoveryKnowledgeScopeJsonSchema,
  recoveryKnowledgeScopeSchema,
  scopedRecoveryKnowledgeJsonSchema,
  scopedRecoveryKnowledgeKeyJsonSchema,
} from '@codesoul-co/hypha-core';

// 完整导出列表见下方。

使用要点

  • 2 个函数是该模块的直接操作入口;每个 overload 的必需/可选参数与返回类型均在下方列出。
  • 10 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

运行时校验示例

ts
import { recoveryKnowledgeKeySchema } from '@codesoul-co/hypha-core';

declare function loadExternalInput(): unknown;
const input: unknown = loadExternalInput();
const parsed = recoveryKnowledgeKeySchema.parse(input);

配置、网络请求或持久化数据等不可信输入应先通过 Runtime Schema,再传给只接受已校验契约的函数或类。

公共导出

Symbol种类签名说明
recoveryKnowledgeJsonSchema常量const recoveryKnowledgeJsonSchema: JsonSchemaRecovery Knowledge 的 JSON Schema。
recoveryKnowledgeKeyJsonSchema常量const recoveryKnowledgeKeyJsonSchema: JsonSchemaRecovery Knowledge Key 的 JSON Schema。
recoveryKnowledgeKeySchema常量const recoveryKnowledgeKeySchema: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; scope: z.ZodOptional<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string...Recovery Knowledge Key 的运行时 Schema。
recoveryKnowledgeSchema常量const recoveryKnowledgeSchema: z.ZodObject<{ key: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; scope: z.ZodOptional<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; t...Recovery Knowledge 的运行时 Schema。
recoveryKnowledgeScopeJsonSchema常量const recoveryKnowledgeScopeJsonSchema: JsonSchemaRecovery Knowledge Scope 的 JSON Schema。
recoveryKnowledgeScopeSchema常量const recoveryKnowledgeScopeSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId...Recovery Knowledge Scope 的运行时 Schema。
scopedRecoveryKnowledgeJsonSchema常量const scopedRecoveryKnowledgeJsonSchema: JsonSchemaScoped Recovery Knowledge 的 JSON Schema。
scopedRecoveryKnowledgeKeyJsonSchema常量const scopedRecoveryKnowledgeKeyJsonSchema: JsonSchemaScoped Recovery Knowledge Key 的 JSON Schema。
scopedRecoveryKnowledgeKeySchema常量const scopedRecoveryKnowledgeKeySchema: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; policyRevision: z.ZodOptional<z.ZodString>; specRevision: z.ZodOptional<z.ZodString>; providerRevision: z.ZodOptional<z.ZodString>; } & { scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z....Scoped Recovery Knowledge Key 的运行时 Schema。
scopedRecoveryKnowledgeSchema常量const scopedRecoveryKnowledgeSchema: z.ZodObject<{ strategy: z.ZodEnum<["retry", "reconcile", "fallback", "degrade", "compensate", "wait", "human_review", "quarantine", "fail", "cancel"]>; outcome: z.ZodEnum<["recovered", "degraded", "compensated", "failed"]>; evidenceHash: z.ZodString; learnedAt: z.ZodString; expiresAt: z.ZodOptional<z.ZodString>; validation: z.ZodObject<{ status: z.ZodEnum<["verified", "negative...Scoped Recovery Knowledge 的运行时 Schema。
parseRecoveryKnowledge函数parseRecoveryKnowledge(input: unknown): RecoveryKnowledgeParse Recovery Knowledge 函数,提供 1 个公开调用签名;参数与返回类型见下表。
parseScopedRecoveryKnowledge函数parseScopedRecoveryKnowledge(input: unknown): RecoveryKnowledge & { key: RecoveryKnowledgeKey & { scope: RecoveryKnowledgeScope; }; }Parse Scoped Recovery Knowledge 函数,提供 1 个公开调用签名;参数与返回类型见下表。

recoveryKnowledgeJsonSchema

Recovery Knowledge 的 JSON Schema。

声明

text
export declare const recoveryKnowledgeJsonSchema: JsonSchema;

recoveryKnowledgeKeyJsonSchema

Recovery Knowledge Key 的 JSON Schema。

声明

text
export declare const recoveryKnowledgeKeyJsonSchema: JsonSchema;

recoveryKnowledgeKeySchema

Recovery Knowledge Key 的运行时 Schema。

声明

text
export declare const recoveryKnowledgeKeySchema: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; scope: z.ZodOptional<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }>>; policyRevision: z.ZodOptional<z.ZodString>; specRevision: z.ZodOptional<z.ZodString>; providerRevision: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }, { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }>;

recoveryKnowledgeSchema

Recovery Knowledge 的运行时 Schema。

声明

text
export declare const recoveryKnowledgeSchema: z.ZodObject<{ key: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; scope: z.ZodOptional<z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }>>; policyRevision: z.ZodOptional<z.ZodString>; specRevision: z.ZodOptional<z.ZodString>; providerRevision: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }, { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }>; strategy: z.ZodEnum<["retry", "reconcile", "fallback", "degrade", "compensate", "wait", "human_review", "quarantine", "fail", "cancel"]>; outcome: z.ZodEnum<["recovered", "degraded", "compensated", "failed"]>; evidenceHash: z.ZodString; learnedAt: z.ZodString; expiresAt: z.ZodOptional<z.ZodString>; validation: z.ZodObject<{ status: z.ZodEnum<["verified", "negative"]>; sourceEventId: z.ZodOptional<z.ZodString>; proof: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strict", z.ZodTypeAny, { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }, { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }>; }, "strict", z.ZodTypeAny, { validation: { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }; strategy: "wait" | "fail" | "reconcile" | "retry" | "cancel" | "fallback" | "degrade" | "compensate" | "human_review" | "quarantine"; key: { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }; outcome: "failed" | "degraded" | "recovered" | "compensated"; evidenceHash: string; learnedAt: string; expiresAt?: string | undefined; }, { validation: { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }; strategy: "wait" | "fail" | "reconcile" | "retry" | "cancel" | "fallback" | "degrade" | "compensate" | "human_review" | "quarantine"; key: { fingerprint: string; participantId: string; scope?: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; } | undefined; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }; outcome: "failed" | "degraded" | "recovered" | "compensated"; evidenceHash: string; learnedAt: string; expiresAt?: string | undefined; }>;

recoveryKnowledgeScopeJsonSchema

Recovery Knowledge Scope 的 JSON Schema。

声明

text
export declare const recoveryKnowledgeScopeJsonSchema: JsonSchema;

recoveryKnowledgeScopeSchema

Recovery Knowledge Scope 的运行时 Schema。

声明

text
export declare const recoveryKnowledgeScopeSchema: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }>;

scopedRecoveryKnowledgeJsonSchema

Scoped Recovery Knowledge 的 JSON Schema。

声明

text
export declare const scopedRecoveryKnowledgeJsonSchema: JsonSchema;

scopedRecoveryKnowledgeKeyJsonSchema

Scoped Recovery Knowledge Key 的 JSON Schema。

声明

text
export declare const scopedRecoveryKnowledgeKeyJsonSchema: JsonSchema;

scopedRecoveryKnowledgeKeySchema

Scoped Recovery Knowledge Key 的运行时 Schema。

声明

text
export declare const scopedRecoveryKnowledgeKeySchema: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; policyRevision: z.ZodOptional<z.ZodString>; specRevision: z.ZodOptional<z.ZodString>; providerRevision: z.ZodOptional<z.ZodString>; } & { scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }>; }, "strict", z.ZodTypeAny, { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }, { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }>;

scopedRecoveryKnowledgeSchema

Scoped Recovery Knowledge 的运行时 Schema。

声明

text
export declare const scopedRecoveryKnowledgeSchema: z.ZodObject<{ strategy: z.ZodEnum<["retry", "reconcile", "fallback", "degrade", "compensate", "wait", "human_review", "quarantine", "fail", "cancel"]>; outcome: z.ZodEnum<["recovered", "degraded", "compensated", "failed"]>; evidenceHash: z.ZodString; learnedAt: z.ZodString; expiresAt: z.ZodOptional<z.ZodString>; validation: z.ZodObject<{ status: z.ZodEnum<["verified", "negative"]>; sourceEventId: z.ZodOptional<z.ZodString>; proof: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strict", z.ZodTypeAny, { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }, { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }>; } & { key: z.ZodObject<{ fingerprint: z.ZodString; participantId: z.ZodString; policyRevision: z.ZodOptional<z.ZodString>; specRevision: z.ZodOptional<z.ZodString>; providerRevision: z.ZodOptional<z.ZodString>; } & { scope: z.ZodObject<{ tenantId: z.ZodOptional<z.ZodString>; userId: z.ZodString; workspaceId: z.ZodOptional<z.ZodString>; sessionId: z.ZodOptional<z.ZodString>; agentId: z.ZodOptional<z.ZodString>; domainPackId: z.ZodOptional<z.ZodString>; }, "strict", z.ZodTypeAny, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }, { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }>; }, "strict", z.ZodTypeAny, { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }, { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }>; }, "strict", z.ZodTypeAny, { validation: { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }; strategy: "wait" | "fail" | "reconcile" | "retry" | "cancel" | "fallback" | "degrade" | "compensate" | "human_review" | "quarantine"; key: { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }; outcome: "failed" | "degraded" | "recovered" | "compensated"; evidenceHash: string; learnedAt: string; expiresAt?: string | undefined; }, { validation: { status: "verified" | "negative"; sourceEventId?: string | undefined; proof?: Record<string, unknown> | undefined; }; strategy: "wait" | "fail" | "reconcile" | "retry" | "cancel" | "fallback" | "degrade" | "compensate" | "human_review" | "quarantine"; key: { scope: { userId: string; tenantId?: string | undefined; workspaceId?: string | undefined; sessionId?: string | undefined; agentId?: string | undefined; domainPackId?: string | undefined; }; fingerprint: string; participantId: string; providerRevision?: string | undefined; policyRevision?: string | undefined; specRevision?: string | undefined; }; outcome: "failed" | "degraded" | "recovered" | "compensated"; evidenceHash: string; learnedAt: string; expiresAt?: string | undefined; }>;

parseRecoveryKnowledge

Parse Recovery Knowledge 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function parseRecoveryKnowledge(input: unknown): RecoveryKnowledge;

调用签名

text
parseRecoveryKnowledge(input: unknown): RecoveryKnowledge

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: RecoveryKnowledge
  • 说明: 返回值契约由上述类型定义。

parseScopedRecoveryKnowledge

Parse Scoped Recovery Knowledge 函数,提供 1 个公开调用签名;参数与返回类型见下表。

声明

text
export declare function parseScopedRecoveryKnowledge(input: unknown): RecoveryKnowledge & {
    key: RecoveryKnowledgeKey & {
        scope: RecoveryKnowledgeScope;
    };
};

调用签名

text
parseScopedRecoveryKnowledge(input: unknown): RecoveryKnowledge & { key: RecoveryKnowledgeKey & { scope: RecoveryKnowledgeScope; }; }

参数

参数类型必需说明
inputunknown必需参数;接受的值由类型列定义。

返回值

  • 类型: RecoveryKnowledge & { key: RecoveryKnowledgeKey & { scope: RecoveryKnowledgeScope; }; }
  • 说明: 返回值契约由上述类型定义。