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;AACjE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACrE,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAC/E,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,OAAO,+BAA+B,CAAC,CAAC","sourcesContent":["import { type Static, Type } from \"typebox\";\n\nexport const ASM_CONTRACT_NAMESPACE = \"ai.aletheion.asm\" as const;\nexport const ASM_CONTRACT_MAJOR = 1 as const;\nexport const ASM_CONTRACT_MINOR = 1 as const;\n\nconst Id = Type.String({ minLength: 1, maxLength: 200 });\nconst Timestamp = Type.String({ format: \"date-time\" });\nconst JsonObject = Type.Record(Type.String(), Type.Unknown());\nconst Score = Type.Number({ minimum: 0, maximum: 1 });\n\nconst Header = Type.Object(\n\t{\n\t\tnamespace: Type.Literal(ASM_CONTRACT_NAMESPACE),\n\t\tmajor: Type.Literal(ASM_CONTRACT_MAJOR),\n\t\tminor: Type.Integer({ minimum: 0 }),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const MemoryContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tmemoryId: Id,\n\t\trevision: Type.Integer({ minimum: 1 }),\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsessionId: Type.Optional(Id),\n\t\tkind: Type.Union([Type.Literal(\"observation\"), Type.Literal(\"fact\"), Type.Literal(\"instruction\")]),\n\t\tcontent: Type.String({ minLength: 1 }),\n\t\tevidenceIds: Type.Array(Id, { uniqueItems: true }),\n\t\tcreatedAt: Timestamp,\n\t\ttombstonedAt: Type.Optional(Timestamp),\n\t\tmetadata: Type.Optional(JsonObject),\n\t},\n\t{ additionalProperties: false, $id: \"asm-memory-v1\" },\n);\n\nexport const EvidenceContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tevidenceId: Id,\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsourceType: Type.Union([\n\t\t\tType.Literal(\"user\"),\n\t\t\tType.Literal(\"tool\"),\n\t\t\tType.Literal(\"document\"),\n\t\t\tType.Literal(\"system\"),\n\t\t]),\n\t\tsourceUri: Type.Optional(Type.String({ maxLength: 4096 })),\n\t\tdigest: Type.String({ pattern: \"^[a-f0-9]{64}$\" }),\n\t\tcapturedAt: Timestamp,\n\t\tcontentType: Type.String({ minLength: 1 }),\n\t\tmetadata: Type.Optional(JsonObject),\n\t},\n\t{ additionalProperties: false, $id: \"asm-evidence-v1\" },\n);\n\nexport const RetrievalContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\trequestId: Id,\n\t\townerId: Id,\n\t\tprojectId: Id,\n\t\tsessionId: Type.Optional(Id),\n\t\tquery: Type.String({ minLength: 1 }),\n\t\tlimit: Type.Integer({ minimum: 1, maximum: 200 }),\n\t\talgorithm: Id,\n\t\tcandidates: Type.Array(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tmemoryId: Id,\n\t\t\t\t\tscore: Score,\n\t\t\t\t\tselected: Type.Boolean(),\n\t\t\t\t\treasonCodes: Type.Array(Id, { uniqueItems: true }),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\tstartedAt: Timestamp,\n\t\tlatencyMs: Type.Integer({ minimum: 0 }),\n\t},\n\t{ additionalProperties: false, $id: \"asm-retrieval-v1\" },\n);\n\nexport const IntentContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tintentId: Id,\n\t\toperation: Type.Union([\n\t\t\tType.Literal(\"diagnose\"),\n\t\t\tType.Literal(\"read\"),\n\t\t\tType.Literal(\"write\"),\n\t\t\tType.Literal(\"execute\"),\n\t\t\tType.Literal(\"communicate\"),\n\t\t\tType.Literal(\"deploy\"),\n\t\t\tType.Literal(\"purchase\"),\n\t\t\tType.Literal(\"delete\"),\n\t\t]),\n\t\tresources: Type.Array(Id, { uniqueItems: true }),\n\t\texternalEffect: Type.Boolean(),\n\t\tidempotencyKey: Type.Optional(Id),\n\t\trequestedAt: Timestamp,\n\t\targuments: JsonObject,\n\t},\n\t{ additionalProperties: false, $id: \"asm-intent-v1\" },\n);\n\nexport const PolicyContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tdecisionId: Id,\n\t\tintentId: Id,\n\t\toutcome: Type.Union([Type.Literal(\"allow\"), Type.Literal(\"deny\"), Type.Literal(\"require_approval\")]),\n\t\treasonCodes: Type.Array(Id, { minItems: 1, uniqueItems: true }),\n\t\trequiredApprovals: Type.Array(Id, { uniqueItems: true }),\n\t\tdecidedAt: Timestamp,\n\t\tpolicyVersion: Id,\n\t},\n\t{ additionalProperties: false, $id: \"asm-policy-v1\" },\n);\n\nexport const FeedbackContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tfeedbackId: Id,\n\t\ttargetType: Type.Union([Type.Literal(\"memory\"), Type.Literal(\"retrieval\"), Type.Literal(\"action\")]),\n\t\ttargetId: Id,\n\t\trating: Type.Union([Type.Literal(\"positive\"), Type.Literal(\"negative\"), Type.Literal(\"correction\")]),\n\t\tcomment: Type.Optional(Type.String({ maxLength: 8000 })),\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-feedback-v1\" },\n);\n\nexport const StateSnapshotContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tsnapshotId: Id,\n\t\tsessionId: Id,\n\t\tsequence: Type.Integer({ minimum: 0 }),\n\t\tstate: JsonObject,\n\t\tdigest: Type.String({ pattern: \"^[a-f0-9]{64}$\" }),\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-state-snapshot-v1\" },\n);\n\nexport const InferenceManifestContractSchema = Type.Object(\n\t{\n\t\theader: Header,\n\t\tmanifestId: Id,\n\t\tmodelId: Id,\n\t\tmodelVersion: Id,\n\t\tbackend: Type.Union([\n\t\t\tType.Literal(\"deterministic\"),\n\t\t\tType.Literal(\"vector\"),\n\t\t\tType.Literal(\"causal_head\"),\n\t\t\tType.Literal(\"dual_asm\"),\n\t\t\tType.Literal(\"asm_cm\"),\n\t\t]),\n\t\tartifactDigest: Type.Optional(Type.String({ pattern: \"^[a-f0-9]{64}$\" })),\n\t\tcontractMajors: Type.Record(Id, Type.Integer({ minimum: 1 })),\n\t\tparameters: JsonObject,\n\t\tcreatedAt: Timestamp,\n\t},\n\t{ additionalProperties: false, $id: \"asm-inference-manifest-v1\" },\n);\n\nexport const ASM_CONTRACT_SCHEMAS = {\n\tmemory: MemoryContractSchema,\n\tevidence: EvidenceContractSchema,\n\tretrieval: RetrievalContractSchema,\n\tintent: IntentContractSchema,\n\tpolicy: PolicyContractSchema,\n\tfeedback: FeedbackContractSchema,\n\tstateSnapshot: StateSnapshotContractSchema,\n\tinferenceManifest: InferenceManifestContractSchema,\n} as const;\n\nexport type AsmContractName = keyof typeof ASM_CONTRACT_SCHEMAS;\nexport type MemoryContract = Static<typeof MemoryContractSchema>;\nexport type EvidenceContract = Static<typeof EvidenceContractSchema>;\nexport type RetrievalContract = Static<typeof RetrievalContractSchema>;\nexport type IntentContract = Static<typeof IntentContractSchema>;\nexport type PolicyContract = Static<typeof PolicyContractSchema>;\nexport type FeedbackContract = Static<typeof FeedbackContractSchema>;\nexport type StateSnapshotContract = Static<typeof StateSnapshotContractSchema>;\nexport type InferenceManifestContract = Static<typeof InferenceManifestContractSchema>;\n"]}