@plasius/ai-game 0.1.12 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +23 -0
- package/dist/index.cjs +492 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -7
- package/dist/index.d.ts +124 -7
- package/dist/index.js +465 -36
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0011-player-system-core-contract-boundary.md +56 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +2 -2
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/training-state.ts","../src/world-events.ts","../src/gossip.ts","../src/quiet-measure.ts"],"sourcesContent":["export * from \"./training-state.js\";\n\nexport interface AiPackageDescriptor {\n readonly packageName: string;\n readonly featureFlagId: string;\n readonly envPrefix: string;\n readonly summary: string;\n}\n\nexport const AI_GAME_PACKAGE = \"@plasius/ai-game\";\nexport const AI_GAME_ENV_PREFIX = \"AI_GAME\";\nexport const AI_GAME_FEATURE_FLAG_ID = \"ai.game.enabled\";\nexport const AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID = \"ai.game.event-recorder.contracts.enabled\";\nexport const AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID = \"ai.game.event-recorder.ingestion.enabled\";\nexport const AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID = \"ai.game.event-recorder.impact.enabled\";\nexport const AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID = \"ai.game.npc-gossip.topics.enabled\";\nexport const AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.perspective.enabled\";\nexport const AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.lifecycle.enabled\";\n\nexport const AI_GAME_FEATURE_FLAGS = {\n workloads: AI_GAME_FEATURE_FLAG_ID,\n ttsCacheEnabled: \"ai.tts.cache.enabled\",\n ttsNearReuseEnabled: \"ai.tts.near-reuse.enabled\",\n} as const;\n\nexport type AiGameFeatureFlagKey =\n (typeof AI_GAME_FEATURE_FLAGS)[keyof typeof AI_GAME_FEATURE_FLAGS];\n\nexport type AiGameFeatureFlagSnapshot = Partial<Record<AiGameFeatureFlagKey, boolean>>;\n\nexport const AI_GAME_TASK_KINDS = [\n \"player-action-validation\",\n \"npc-action\",\n \"npc-dialogue\",\n \"gossip\",\n \"governance-feedback\",\n \"feedback\",\n \"unknown\",\n] as const;\n\nexport type AiGameTaskKind = (typeof AI_GAME_TASK_KINDS)[number];\n\nexport const AI_GAME_TASK_RISK_CLASSES = [\n \"low\",\n \"medium\",\n \"high\",\n \"critical\",\n] as const;\n\nexport type AiGameTaskRiskClass = (typeof AI_GAME_TASK_RISK_CLASSES)[number];\n\nexport const AI_GAME_TASK_AUTHORITY_BOUNDARIES = [\n \"deterministic\",\n \"human-review\",\n \"operator-review\",\n \"blocked\",\n] as const;\n\nexport type AiGameAuthorityBoundary =\n (typeof AI_GAME_TASK_AUTHORITY_BOUNDARIES)[number];\n\nexport const AI_GAME_TASK_DECISIONS = [\"allow\", \"operator-review\", \"blocked\"] as const;\n\nexport type AiGameTaskDecisionResult =\n (typeof AI_GAME_TASK_DECISIONS)[number];\n\nexport const AI_GAME_TASK_RESULTS = [\"allow\", \"defer\", \"deny\"] as const;\n\nexport type AiGameTaskResult = (typeof AI_GAME_TASK_RESULTS)[number];\n\nexport const AI_GAME_TTS_CACHE_POLICIES = [\n \"exact-cache\",\n \"near-cache\",\n \"no-cache\",\n] as const;\n\nexport type AiGameTtsCachePolicy =\n (typeof AI_GAME_TTS_CACHE_POLICIES)[number];\n\nexport const AI_GAME_ACTOR_ROLES = [\"player\", \"npc\", \"operator\", \"system\"] as const;\n\nexport type AiGameActorRole = (typeof AI_GAME_ACTOR_ROLES)[number];\n\nexport interface AiGameTaskRequest {\n readonly taskId: string;\n readonly taskText: string;\n readonly taskKind?: AiGameTaskKind;\n}\n\nexport interface AiGameTaskDecision {\n readonly taskId: string;\n readonly taskKind: AiGameTaskKind;\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly decision: AiGameTaskDecisionResult;\n readonly needsOperatorReview: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGamePolicyAuditBase {\n readonly policyId: string;\n readonly policyVersion: string;\n readonly correlationId: string;\n readonly requestId?: string;\n readonly actorId?: string;\n readonly actorRole: AiGameActorRole;\n readonly evaluatedAtUtc: string;\n}\n\nexport interface ResolveAiGameTaskInput {\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly requests: readonly AiGameTaskRequest[];\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface AiGameTaskResolution {\n readonly requestedTasks: readonly string[];\n readonly taskDecisions: readonly AiGameTaskDecision[];\n readonly allowedTaskIds: readonly string[];\n readonly reviewTaskIds: readonly string[];\n readonly blockedTaskIds: readonly string[];\n readonly needsOperatorReview: boolean;\n readonly featureEnabled: boolean;\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly result: AiGameTaskResult;\n };\n}\n\nexport interface ResolveAiGamePlayerAddressInput {\n readonly playerAddressText: string;\n readonly playerAlias?: string;\n readonly accountAlias?: string;\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface ResolveAiGamePlayerAddressResult {\n readonly sourceText: string;\n readonly renderText: string;\n readonly ttsCachePolicy: AiGameTtsCachePolicy;\n readonly reasonCodes: readonly string[];\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly cachePolicy: AiGameTtsCachePolicy;\n };\n}\n\ninterface AiGameTaskProfile {\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly keywords: readonly string[];\n}\n\nconst AI_GAME_TASK_PROFILE_BY_KIND: Record<AiGameTaskKind, AiGameTaskProfile> = {\n \"player-action-validation\": {\n riskClass: \"medium\",\n authorityBoundary: \"human-review\",\n keywords: [\"move\", \"attack\", \"collect\", \"use\", \"open\", \"pick\", \"trade\", \"target\"],\n },\n \"npc-action\": {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"summon\", \"kill\", \"ban\", \"spawn\", \"eject\", \"resurrect\", \"npc action\", \"npc-action\"],\n },\n \"npc-dialogue\": {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"say\", \"says\", \"reply\", \"chat\", \"dialogue\", \"greet\", \"warn\", \"request\"],\n },\n gossip: {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"rumor\", \"rumors\", \"gossip\", \"hearsay\", \"whisper\", \"spread\", \"denounce\"],\n },\n \"governance-feedback\": {\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n keywords: [\"punish\", \"expel\", \"revoke\", \"ban\", \"forbid\", \"seize\"],\n },\n feedback: {\n riskClass: \"low\",\n authorityBoundary: \"operator-review\",\n keywords: [\"feedback\", \"rating\", \"report\", \"score\", \"review\", \"complaint\"],\n },\n unknown: {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"\"],\n },\n};\n\nconst AI_GAME_TASK_KEYWORD_PATTERNS: Readonly<Record<AiGameTaskKind, RegExp>> = {\n \"player-action-validation\": buildTaskPattern(\n AI_GAME_TASK_PROFILE_BY_KIND[\"player-action-validation\"].keywords,\n ),\n \"npc-action\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-action\"].keywords),\n \"npc-dialogue\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-dialogue\"].keywords),\n gossip: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.gossip.keywords),\n \"governance-feedback\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"governance-feedback\"].keywords),\n feedback: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.feedback.keywords),\n unknown: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.unknown.keywords),\n};\n\nfunction nowIsoString(): string {\n return new Date().toISOString();\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction normalizeToken(value: string): string {\n return value.trim().replace(/\\s+/g, \" \");\n}\n\nfunction buildTaskPattern(keywords: readonly string[]): RegExp {\n return new RegExp(\n keywords.filter((keyword) => keyword.length > 0).map((keyword) => `\\\\b${escapeRegExp(keyword)}\\\\b`).join(\"|\") || \"^$\",\n \"i\",\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n return Array.from(new Set(values.filter((value) => value.length > 0)));\n}\n\nfunction isFeatureEnabled(\n featureFlag: AiGameFeatureFlagKey,\n snapshot: AiGameFeatureFlagSnapshot = {},\n): boolean {\n return snapshot[featureFlag] === true;\n}\n\nfunction normalizeTaskText(value: string): string {\n return value.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\nfunction isActorRole(role?: AiGameActorRole): AiGameActorRole {\n return role ?? \"player\";\n}\n\nfunction normalizeTaskKind(taskKind?: AiGameTaskKind): AiGameTaskKind | undefined {\n if (!taskKind) {\n return undefined;\n }\n\n return (AI_GAME_TASK_KINDS as readonly string[]).includes(taskKind)\n ? taskKind\n : \"unknown\";\n}\n\nexport function classifyAiGameTask(taskText: string): AiGameTaskKind {\n const normalized = normalizeTaskText(taskText);\n\n if (!normalized) {\n return \"unknown\";\n }\n\n for (const taskKind of AI_GAME_TASK_KINDS) {\n if (AI_GAME_TASK_KEYWORD_PATTERNS[taskKind].test(normalized)) {\n return taskKind;\n }\n }\n\n return \"unknown\";\n}\n\nfunction resolveTaskAuthority(taskKind: AiGameTaskKind): AiGameTaskProfile {\n return AI_GAME_TASK_PROFILE_BY_KIND[taskKind];\n}\n\nfunction resolveTaskDecision(\n taskKind: AiGameTaskKind,\n profile: AiGameTaskProfile,\n actorRole: AiGameActorRole,\n): Omit<AiGameTaskDecision, \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"> {\n if (profile.authorityBoundary === \"blocked\") {\n return {\n decision: \"blocked\",\n needsOperatorReview: actorRole !== \"system\",\n };\n }\n\n if (profile.authorityBoundary === \"deterministic\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n if (actorRole === \"system\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n return {\n decision: \"operator-review\",\n needsOperatorReview: true,\n };\n}\n\nfunction buildRequestIds(requests: readonly AiGameTaskRequest[]): string[] {\n return uniqueStrings(requests.map((request) => request.taskId.trim()).filter(Boolean));\n}\n\n/**\n * Resolve game AI task contracts for player actions, NPC actions, gossip, and governance.\n */\nexport function resolveAiGameTaskBatch(\n input: ResolveAiGameTaskInput,\n): AiGameTaskResolution {\n const actorRole = isActorRole(input.actorRole);\n const featureEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.workloads,\n input.featureFlags,\n );\n const reasonCodes = [...(input.reasonCodes ?? [])];\n type ResolvedAiGameTaskRequest = AiGameTaskRequest & { taskKind: AiGameTaskKind };\n const requests: ResolvedAiGameTaskRequest[] = input.requests.map((request): ResolvedAiGameTaskRequest => ({\n ...request,\n taskKind: normalizeTaskKind(request.taskKind) ?? classifyAiGameTask(request.taskText),\n }));\n\n if (!featureEnabled) {\n reasonCodes.push(\"game-feature-disabled\");\n const requestIds = buildRequestIds(requests);\n\n return {\n requestedTasks: requestIds,\n taskDecisions: Object.freeze(\n requestIds.map<AiGameTaskDecision>((taskId) => ({\n taskId,\n taskKind: \"unknown\",\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n decision: \"blocked\",\n needsOperatorReview: false,\n reasonCodes: [\"feature-disabled\"],\n })),\n ),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze(requestIds),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"deny\",\n },\n };\n }\n\n if (requests.length === 0) {\n reasonCodes.push(\"game-task-empty-request\");\n\n return {\n requestedTasks: Object.freeze([] as const),\n taskDecisions: Object.freeze([] as const),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze([] as const),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"allow\",\n },\n };\n }\n const taskDecisions: AiGameTaskDecision[] = [];\n for (const request of requests) {\n const taskKind: AiGameTaskKind = request.taskKind;\n const profile = resolveTaskAuthority(taskKind);\n const decision: Omit<\n AiGameTaskDecision,\n \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"\n > = resolveTaskDecision(taskKind, profile, actorRole);\n\n taskDecisions.push({\n taskId: request.taskId,\n taskKind,\n riskClass: profile.riskClass,\n authorityBoundary: profile.authorityBoundary,\n ...decision,\n reasonCodes: [`task-${taskKind}-${decision.decision}`],\n });\n }\n\n const allowedTaskIds: string[] = [];\n const reviewTaskIds: string[] = [];\n const blockedTaskIds: string[] = [];\n\n for (const decision of taskDecisions) {\n if (decision.decision === \"allow\") {\n allowedTaskIds.push(decision.taskId);\n } else if (decision.decision === \"operator-review\") {\n reviewTaskIds.push(decision.taskId);\n } else {\n blockedTaskIds.push(decision.taskId);\n }\n\n reasonCodes.push(...decision.reasonCodes);\n }\n\n const hasBlockedTasks = blockedTaskIds.length > 0;\n const needsOperatorReview = taskDecisions.some((decision) => decision.needsOperatorReview);\n\n return {\n requestedTasks: Object.freeze(buildRequestIds(requests)),\n taskDecisions: Object.freeze(taskDecisions),\n allowedTaskIds: Object.freeze(uniqueStrings(allowedTaskIds)),\n reviewTaskIds: Object.freeze(uniqueStrings(reviewTaskIds)),\n blockedTaskIds: Object.freeze(uniqueStrings(blockedTaskIds)),\n needsOperatorReview,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: hasBlockedTasks ? \"deny\" : needsOperatorReview ? \"defer\" : \"allow\",\n },\n };\n}\n\n/**\n * Resolve cache policy for player-account text before speech rendering.\n */\nexport function resolveAiGamePlayerAddressText(\n input: ResolveAiGamePlayerAddressInput,\n): ResolveAiGamePlayerAddressResult {\n const actorRole = isActorRole(input.actorRole);\n const cacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n input.featureFlags,\n );\n const sourceText = normalizeToken(input.playerAddressText);\n const reasonCodes = [...(input.reasonCodes ?? [])];\n\n if (!sourceText) {\n reasonCodes.push(\"tts-empty-text\");\n\n return {\n sourceText,\n renderText: \"\",\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const aliasEntries = [\n ...uniqueStrings([normalizeToken(input.playerAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: false,\n })),\n ...uniqueStrings([normalizeToken(input.accountAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: true,\n })),\n ];\n\n let renderText = sourceText;\n let replaced = false;\n\n for (const alias of aliasEntries) {\n const pattern = new RegExp(`\\\\b${escapeRegExp(alias.alias)}\\\\b`, \"gi\");\n\n if (pattern.test(renderText)) {\n renderText = renderText.replace(pattern, alias.isAccountAlias ? \"[ACCOUNT]\" : \"[PLAYER]\");\n replaced = true;\n reasonCodes.push(`tts-redacted-${alias.alias.toLowerCase()}`);\n }\n }\n\n const nearCacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled,\n input.featureFlags,\n );\n\n if (!cacheEnabled) {\n reasonCodes.push(\"tts-cache-disabled\");\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const cachePolicy: AiGameTtsCachePolicy =\n !replaced\n ? \"exact-cache\"\n : nearCacheEnabled\n ? \"near-cache\"\n : \"no-cache\";\n\n if (cachePolicy === \"exact-cache\") {\n reasonCodes.push(\"tts-cache-exact\");\n }\n\n if (cachePolicy === \"near-cache\") {\n reasonCodes.push(\"tts-cache-near\");\n }\n\n if (cachePolicy === \"no-cache\") {\n reasonCodes.push(\"tts-cache-not-available\");\n }\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: cachePolicy,\n reasonCodes,\n enabledFeatureFlags: Object.freeze([\n AI_GAME_FEATURE_FLAGS.workloads,\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n ...(nearCacheEnabled ? [AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled] : []),\n ]),\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy,\n },\n };\n}\n\nexport const packageDescriptor: AiPackageDescriptor = Object.freeze({\n packageName: AI_GAME_PACKAGE,\n featureFlagId: AI_GAME_FEATURE_FLAG_ID,\n envPrefix: AI_GAME_ENV_PREFIX,\n summary: \"Game-domain AI contracts for event recorder, canonical world-state, and NPC gossip projections.\",\n});\n\nexport const aiGameFeatureFlags = Object.freeze({\n contract: AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,\n ingestion: AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,\n incident: AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,\n gossipTopics: AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,\n gossipPerspective: AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,\n gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,\n});\n\nexport const gameEventFeatureFlags = Object.freeze([\n aiGameFeatureFlags.contract,\n aiGameFeatureFlags.ingestion,\n aiGameFeatureFlags.incident,\n aiGameFeatureFlags.gossipTopics,\n aiGameFeatureFlags.gossipPerspective,\n aiGameFeatureFlags.gossipLifecycle,\n]);\n\nexport {\n isCanonicalWorldEvent,\n isCandidateWorldEvent,\n isIncidentResolved,\n normalizeIncidentImpactVector,\n} from \"./world-events.js\";\n\nexport {\n isGossipTopicActive,\n isGossipTopicCorrected,\n projectTopicForAudience,\n} from \"./gossip.js\";\n\nexport {\n AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,\n createQuietMeasureJudgmentEligibility,\n createQuietMeasureJudgmentResponse,\n isQuietMeasureAxis,\n isQuietMeasureMissionProbeMode,\n isQuietMeasureMissionResolutionShape,\n listQuietMeasureMissingEvidence,\n} from \"./quiet-measure.js\";\n\nexport * from \"./world-events.js\";\nexport * from \"./gossip.js\";\nexport * from \"./quiet-measure.js\";\n","import {\n TRAINING_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_TECHNIQUE_TRACKS,\n TRAINING_BARRACKS_DRILL_DELIVERY_MODES,\n TRAINING_MARTIAL_TECHNIQUE_FAMILIES,\n TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES,\n TRAINING_ANTI_SPELL_COUNTER_WINDOWS,\n createTrainingAntiSpellFieldcraftDiscipline,\n createTrainingBarracksDrill,\n createTrainingInstitution,\n createTrainingMartialTechnique,\n createTrainingMissionTechniqueUnlock,\n createTrainingProgressionRecord,\n isMccExpressionTrack,\n isTrainingAntiSpellCounterWindow,\n isTrainingAntiSpellFieldcraftFamily,\n isTrainingBarracksDrillDeliveryMode,\n isTrainingMartialTechniqueFamily,\n isTrainingMartialTechniqueTrack,\n isTrainingTrustLevel,\n type MccExpressionTrack,\n type TrainingAntiSpellCounterWindow,\n type TrainingAntiSpellFieldcraftDiscipline,\n type TrainingAntiSpellFieldcraftFamily,\n type TrainingBarracksDrill,\n type TrainingBarracksDrillDeliveryMode,\n type TrainingInstitution,\n type TrainingInstitutionType,\n type TrainingMartialTechnique,\n type TrainingMartialTechniqueFamily,\n type TrainingMartialTechniqueTrack,\n type TrainingMissionTechniqueUnlock,\n type TrainingProgressionRecord,\n type TrainingTrustLevel,\n} from \"@plasius/training\";\n\nexport {\n isMccExpressionTrack,\n isTrainingAntiSpellCounterWindow as isAiGameTrainingAntiSpellCounterWindow,\n isTrainingAntiSpellFieldcraftFamily as isAiGameTrainingAntiSpellFieldcraftFamily,\n isTrainingBarracksDrillDeliveryMode as isAiGameTrainingBarracksDrillDeliveryMode,\n isTrainingMartialTechniqueFamily as isAiGameTrainingMartialTechniqueFamily,\n isTrainingMartialTechniqueTrack as isAiGameTrainingMartialTechniqueTrack,\n isTrainingTrustLevel,\n TRAINING_FEATURE_FLAG_ID as AI_GAME_TRAINING_INSTITUTIONS_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_FEATURE_FLAG_ID as AI_GAME_TRAINING_MARTIAL_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_TECHNIQUE_TRACKS as AI_GAME_TRAINING_MARTIAL_TECHNIQUE_TRACKS,\n TRAINING_BARRACKS_DRILL_DELIVERY_MODES as AI_GAME_TRAINING_BARRACKS_DRILL_DELIVERY_MODES,\n TRAINING_MARTIAL_TECHNIQUE_FAMILIES as AI_GAME_TRAINING_MARTIAL_TECHNIQUE_FAMILIES,\n TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES as AI_GAME_TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES,\n TRAINING_ANTI_SPELL_COUNTER_WINDOWS as AI_GAME_TRAINING_ANTI_SPELL_COUNTER_WINDOWS,\n};\n\nexport type {\n MccExpressionTrack as AiGameTrainingSpecializationLeaning,\n TrainingAntiSpellCounterWindow as AiGameTrainingAntiSpellCounterWindow,\n TrainingAntiSpellFieldcraftDiscipline as AiGameTrainingAntiSpellFieldcraftDiscipline,\n TrainingAntiSpellFieldcraftFamily as AiGameTrainingAntiSpellFieldcraftFamily,\n TrainingBarracksDrill as AiGameTrainingBarracksDrill,\n TrainingBarracksDrillDeliveryMode as AiGameTrainingBarracksDrillDeliveryMode,\n TrainingInstitution as AiGameTrainingInstitution,\n TrainingInstitutionType as AiGameTrainingInstitutionType,\n TrainingMartialTechnique as AiGameTrainingMartialTechnique,\n TrainingMartialTechniqueFamily as AiGameTrainingMartialTechniqueFamily,\n TrainingMartialTechniqueTrack as AiGameTrainingMartialTechniqueTrack,\n TrainingMissionTechniqueUnlock as AiGameTrainingMissionTechniqueUnlock,\n TrainingProgressionRecord as AiGameTrainingState,\n TrainingTrustLevel as AiGameTrainingTrustLevel,\n};\n\nexport const AI_GAME_TRAINING_STAGE_GATES = [\n \"system-first-awakening\",\n \"field-repetition\",\n \"first-social-institution\",\n \"advanced-specialization\",\n \"dominion-and-divine\",\n] as const;\n\nexport type AiGameTrainingStageGate =\n (typeof AI_GAME_TRAINING_STAGE_GATES)[number];\n\nexport const AI_GAME_TRAINING_TRUST_MARKER_SOURCES = [\n \"system\",\n \"mission\",\n \"institution\",\n \"sponsor\",\n] as const;\n\nexport type AiGameTrainingTrustMarkerSource =\n (typeof AI_GAME_TRAINING_TRUST_MARKER_SOURCES)[number];\n\nexport const AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS = [\n \"low\",\n \"medium\",\n \"high\",\n] as const;\n\nexport type AiGameTrainingRecommendationConfidenceBand =\n (typeof AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS)[number];\n\nexport const AI_GAME_TRAINING_RECOMMENDATION_READINESS = [\n \"ready\",\n \"needs-prerequisites\",\n \"institution-gated\",\n] as const;\n\nexport type AiGameTrainingRecommendationReadiness =\n (typeof AI_GAME_TRAINING_RECOMMENDATION_READINESS)[number];\n\nexport interface AiGameInstitutionEligibility {\n readonly institutionId: string;\n readonly institutionType: TrainingInstitutionType;\n readonly track: MccExpressionTrack;\n readonly eligible: boolean;\n readonly requiredStageGate: AiGameTrainingStageGate;\n readonly trustLevel: TrainingTrustLevel;\n readonly unmetPrerequisiteCodes: readonly string[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameTrainingTrustMarker {\n readonly markerId: string;\n readonly institutionId: string;\n readonly trustLevel: TrainingTrustLevel;\n readonly source: AiGameTrainingTrustMarkerSource;\n readonly awardedAtIso: string;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameSpecializationRecommendation {\n readonly recommendationId: string;\n readonly institutionId: string;\n readonly institutionType: TrainingInstitutionType;\n readonly leaning: MccExpressionTrack;\n readonly recommendedTrack: MccExpressionTrack;\n readonly confidenceBand: AiGameTrainingRecommendationConfidenceBand;\n readonly readiness: AiGameTrainingRecommendationReadiness;\n readonly unmetPrerequisiteCodes: readonly string[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameTrainingStateSnapshot {\n readonly progression: TrainingProgressionRecord;\n readonly institution: TrainingInstitution;\n readonly eligibility: readonly AiGameInstitutionEligibility[];\n readonly trustMarkers: readonly AiGameTrainingTrustMarker[];\n readonly recommendations: readonly AiGameSpecializationRecommendation[];\n}\n\nexport interface AiGameMartialTrainingSnapshot {\n readonly barracksDrills: readonly TrainingBarracksDrill[];\n readonly missionTechniqueUnlocks: readonly TrainingMissionTechniqueUnlock[];\n readonly martialTechniques: readonly TrainingMartialTechnique[];\n readonly antiSpellFieldcraft: readonly TrainingAntiSpellFieldcraftDiscipline[];\n}\n\nfunction freezeReadonlyArray<T>(items: readonly T[]): readonly T[] {\n return Object.freeze([...items]);\n}\n\nfunction assertNonEmptyString(value: string, label: string): void {\n if (value.trim().length === 0) {\n throw new Error(`${label} must be a non-empty string`);\n }\n}\n\nfunction assertIsoTimestamp(value: string, label: string): void {\n assertNonEmptyString(value, label);\n\n if (Number.isNaN(Date.parse(value))) {\n throw new Error(`${label} must be an ISO-8601 timestamp`);\n }\n}\n\nfunction isTrainingInstitutionType(value: string): value is TrainingInstitutionType {\n return value === \"school\"\n || value === \"barracks\"\n || value === \"academy\"\n || value === \"apprenticeship\";\n}\n\nexport function isAiGameTrainingStageGate(\n value: string,\n): value is AiGameTrainingStageGate {\n return (AI_GAME_TRAINING_STAGE_GATES as readonly string[]).includes(value);\n}\n\nexport function isAiGameTrainingTrustMarkerSource(\n value: string,\n): value is AiGameTrainingTrustMarkerSource {\n return (AI_GAME_TRAINING_TRUST_MARKER_SOURCES as readonly string[]).includes(value);\n}\n\nexport function isAiGameTrainingRecommendationConfidenceBand(\n value: string,\n): value is AiGameTrainingRecommendationConfidenceBand {\n return (AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS as readonly string[]).includes(value);\n}\n\nexport function isAiGameTrainingRecommendationReadiness(\n value: string,\n): value is AiGameTrainingRecommendationReadiness {\n return (AI_GAME_TRAINING_RECOMMENDATION_READINESS as readonly string[]).includes(value);\n}\n\nexport function createAiGameInstitutionEligibility(\n input: AiGameInstitutionEligibility,\n): AiGameInstitutionEligibility {\n assertNonEmptyString(input.institutionId, \"institutionId\");\n\n if (!isTrainingInstitutionType(input.institutionType)) {\n throw new Error(\"institutionType must be a supported training institution type\");\n }\n\n if (!isMccExpressionTrack(input.track)) {\n throw new Error(\"track must be a supported MCC expression track\");\n }\n\n if (!isAiGameTrainingStageGate(input.requiredStageGate)) {\n throw new Error(\"requiredStageGate must be a supported training stage gate\");\n }\n\n if (!isTrainingTrustLevel(input.trustLevel)) {\n throw new Error(\"trustLevel must be a supported training trust level\");\n }\n\n return Object.freeze({\n ...input,\n unmetPrerequisiteCodes: freezeReadonlyArray(input.unmetPrerequisiteCodes),\n reasonCodes: freezeReadonlyArray(input.reasonCodes),\n });\n}\n\nexport function createAiGameTrainingTrustMarker(\n input: AiGameTrainingTrustMarker,\n): AiGameTrainingTrustMarker {\n assertNonEmptyString(input.markerId, \"markerId\");\n assertNonEmptyString(input.institutionId, \"institutionId\");\n assertIsoTimestamp(input.awardedAtIso, \"awardedAtIso\");\n\n if (!isTrainingTrustLevel(input.trustLevel)) {\n throw new Error(\"trustLevel must be a supported training trust level\");\n }\n\n if (!isAiGameTrainingTrustMarkerSource(input.source)) {\n throw new Error(\"source must be a supported training trust marker source\");\n }\n\n return Object.freeze({\n ...input,\n reasonCodes: freezeReadonlyArray(input.reasonCodes),\n });\n}\n\nexport function createAiGameSpecializationRecommendation(\n input: AiGameSpecializationRecommendation,\n): AiGameSpecializationRecommendation {\n assertNonEmptyString(input.recommendationId, \"recommendationId\");\n assertNonEmptyString(input.institutionId, \"institutionId\");\n\n if (!isTrainingInstitutionType(input.institutionType)) {\n throw new Error(\"institutionType must be a supported training institution type\");\n }\n\n if (!isMccExpressionTrack(input.leaning)) {\n throw new Error(\"leaning must be a supported MCC expression track\");\n }\n\n if (!isMccExpressionTrack(input.recommendedTrack)) {\n throw new Error(\"recommendedTrack must be a supported MCC expression track\");\n }\n\n if (!isAiGameTrainingRecommendationConfidenceBand(input.confidenceBand)) {\n throw new Error(\"confidenceBand must be a supported training recommendation confidence band\");\n }\n\n if (!isAiGameTrainingRecommendationReadiness(input.readiness)) {\n throw new Error(\"readiness must be a supported training recommendation readiness\");\n }\n\n return Object.freeze({\n ...input,\n unmetPrerequisiteCodes: freezeReadonlyArray(input.unmetPrerequisiteCodes),\n reasonCodes: freezeReadonlyArray(input.reasonCodes),\n });\n}\n\nexport function createAiGameTrainingStateSnapshot(\n input: AiGameTrainingStateSnapshot,\n): AiGameTrainingStateSnapshot {\n return Object.freeze({\n progression: createTrainingProgressionRecord(input.progression),\n institution: createTrainingInstitution(input.institution),\n eligibility: freezeReadonlyArray(\n input.eligibility.map(createAiGameInstitutionEligibility),\n ),\n trustMarkers: freezeReadonlyArray(\n input.trustMarkers.map(createAiGameTrainingTrustMarker),\n ),\n recommendations: freezeReadonlyArray(\n input.recommendations.map(createAiGameSpecializationRecommendation),\n ),\n });\n}\n\nexport function createAiGameMartialTrainingSnapshot(\n input: AiGameMartialTrainingSnapshot,\n): AiGameMartialTrainingSnapshot {\n return Object.freeze({\n barracksDrills: freezeReadonlyArray(\n input.barracksDrills.map(createTrainingBarracksDrill),\n ),\n missionTechniqueUnlocks: freezeReadonlyArray(\n input.missionTechniqueUnlocks.map(createTrainingMissionTechniqueUnlock),\n ),\n martialTechniques: freezeReadonlyArray(\n input.martialTechniques.map(createTrainingMartialTechnique),\n ),\n antiSpellFieldcraft: freezeReadonlyArray(\n input.antiSpellFieldcraft.map(createTrainingAntiSpellFieldcraftDiscipline),\n ),\n });\n}\n","export type Version = string;\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type GameWorldEventType =\n | \"monster.spawned\"\n | \"monster.killed\"\n | \"dungeon.created\"\n | \"dungeon.cleared\"\n | \"war.declared\"\n | \"war.resolved\"\n | \"famine.started\"\n | \"surplus.updated\"\n | \"system.checkpoint\";\n\nexport type GameEventVisibilityClass = \"global\" | \"regional\" | \"local\" | \"faction\" | \"secret\";\nexport type GameEventRecordType = \"candidate\" | \"canonical\";\nexport type GameEventSubmissionChannel = \"player\" | \"system\" | \"admin\" | \"simulation\";\nexport type GameEventActorKind = \"player\" | \"npc\" | \"monster\" | \"system\" | \"faction\" | \"environment\";\nexport type GameEventParticipantRole = \"causer\" | \"target\" | \"witness\" | \"owner\" | \"observer\";\nexport type GameEventSeverity = \"info\" | \"warning\" | \"critical\";\n\nexport interface GameEventActor {\n readonly kind: GameEventActorKind;\n readonly subjectRef: string;\n}\n\nexport interface GameEventParticipant {\n readonly role: GameEventParticipantRole;\n readonly actor: GameEventActor;\n}\n\nexport interface GameEventLocation {\n readonly world: string;\n readonly zone: string;\n readonly x?: number;\n readonly y?: number;\n readonly radiusMeters?: number;\n}\n\nexport interface GameEventCausation {\n readonly rootEventId?: string;\n readonly parentEventIds: readonly string[];\n readonly correlationId?: string;\n}\n\nexport interface GameWorldEventPayloadBase {\n readonly eventKind: GameEventSeverity;\n readonly summary: string;\n}\n\nexport interface MonsterSpawnedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.spawned\";\n readonly monsterType: string;\n readonly monsterRef: string;\n}\n\nexport interface MonsterKilledPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.killed\";\n readonly monsterRef: string;\n readonly killerRef?: string;\n readonly encounterResult: \"vanquished\" | \"escaped\" | \"failed\";\n}\n\nexport interface DungeonCreatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.created\";\n readonly dungeonRef: string;\n readonly dungeonType: string;\n readonly difficulty: number;\n}\n\nexport interface DungeonClearedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.cleared\";\n readonly dungeonRef: string;\n readonly clearedByPartyRef: string;\n readonly durationSeconds: number;\n}\n\nexport interface WarDeclaredPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.declared\";\n readonly aggressorFactionRef: string;\n readonly defenderFactionRef: string;\n readonly disputedZone: string;\n}\n\nexport interface WarResolvedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.resolved\";\n readonly warEventRef: string;\n readonly outcome: \"ceasefire\" | \"victory\" | \"loss\" | \"draw\";\n readonly winnerFactionRef?: string;\n}\n\nexport interface FamineStartedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"famine.started\";\n readonly zoneRef: string;\n readonly severity: \"low\" | \"moderate\" | \"high\" | \"critical\";\n}\n\nexport interface SurplusUpdatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"surplus.updated\";\n readonly commodity: string;\n readonly region: string;\n readonly previousBalance: number;\n readonly delta: number;\n}\n\nexport interface SystemCheckpointPayload extends GameWorldEventPayloadBase {\n readonly kind: \"system.checkpoint\";\n readonly sequence: string;\n readonly checkpointState: JsonValue;\n}\n\nexport type GameWorldEventPayload =\n | MonsterSpawnedPayload\n | MonsterKilledPayload\n | DungeonCreatedPayload\n | DungeonClearedPayload\n | WarDeclaredPayload\n | WarResolvedPayload\n | FamineStartedPayload\n | SurplusUpdatedPayload\n | SystemCheckpointPayload;\n\nexport interface GameWorldEventEnvelope {\n readonly eventId: string;\n readonly eventType: GameWorldEventType;\n readonly occurredAtEpochMs: number;\n readonly recordedAtEpochMs: number;\n readonly schemaVersion: string;\n readonly visibility: GameEventVisibilityClass;\n readonly location: GameEventLocation;\n readonly participants: readonly GameEventParticipant[];\n readonly causation: GameEventCausation;\n readonly source: string;\n readonly payload: GameWorldEventPayload;\n readonly tags: readonly string[];\n}\n\nexport interface GameWorldEventCandidate extends GameWorldEventEnvelope {\n readonly recordType: \"candidate\";\n readonly candidateId: string;\n readonly submittedBy?: GameEventActor;\n readonly submittedAtEpochMs: number;\n readonly submissionChannel: GameEventSubmissionChannel;\n}\n\nexport interface GameWorldEventCanonical extends GameWorldEventEnvelope {\n readonly recordType: \"canonical\";\n readonly canonicalEventId: string;\n readonly sourceCandidateId?: string;\n readonly approvedBy: string;\n readonly approvedAtEpochMs: number;\n}\n\nexport type GameWorldEvent = GameWorldEventCandidate | GameWorldEventCanonical;\n\nexport interface GameEventValidationIssue {\n readonly field: string;\n readonly message: string;\n readonly severity: GameEventSeverity;\n}\n\nexport interface GameEventValidationResult {\n readonly valid: boolean;\n readonly issues: readonly GameEventValidationIssue[];\n}\n\nexport interface GameEventSubmissionReceipt {\n readonly accepted: boolean;\n readonly candidateId: string;\n readonly eventId: string;\n readonly notes: readonly string[];\n}\n\nexport interface GameEventCommitReceipt {\n readonly committed: boolean;\n readonly eventId: string;\n readonly sequence: string;\n}\n\nexport interface ProjectionProjectorCheckpoint {\n readonly streamId: string;\n readonly lastAppliedEventOffset: number;\n readonly lastAppliedEventId: string;\n readonly eventVersion: Version;\n readonly updatedAtEpochMs: number;\n}\n\nexport interface ProjectionCheckpointStore {\n getCheckpoint(streamId: string): Promise<ProjectionProjectorCheckpoint | null>;\n setCheckpoint(checkpoint: ProjectionProjectorCheckpoint): Promise<void>;\n}\n\nexport interface WorldEventIngestionPort {\n submitCandidate(candidate: GameWorldEventCandidate): Promise<GameEventSubmissionReceipt>;\n commitCanonical(event: GameWorldEventCanonical): Promise<GameEventCommitReceipt>;\n validateCandidate(candidate: GameWorldEventCandidate): GameEventValidationResult;\n}\n\nexport interface WorldEventProjectorPort {\n readonly streamId: string;\n readonly checkpointStore: ProjectionCheckpointStore;\n project(event: GameWorldEventCanonical): Promise<void>;\n}\n\nexport type WorldIncidentImpactKey = \"security\" | \"economy\" | \"ecology\" | \"politics\" | \"morale\" | \"magic\" | \"population\";\n\nexport type WorldIncidentScope = \"local\" | \"regional\" | \"global\";\n\nexport type WorldIncidentLifecycle = \"active\" | \"resolved\" | \"superseded\" | \"expired\";\n\nexport interface WorldIncidentImpactVector {\n readonly security: number;\n readonly economy: number;\n readonly ecology: number;\n readonly politics: number;\n readonly morale: number;\n readonly magic: number;\n readonly population: number;\n}\n\nexport interface WorldIncidentResolution {\n readonly resolvedAtEpochMs: number;\n readonly closingEventRef: string;\n readonly summary: string;\n}\n\nexport interface WorldIncidentThread {\n readonly incidentId: string;\n readonly scope: WorldIncidentScope;\n readonly lifecycle: WorldIncidentLifecycle;\n readonly causeEventRef: string;\n readonly impact: WorldIncidentImpactVector;\n readonly openedAtEpochMs: number;\n readonly updatedAtEpochMs: number;\n readonly supersededBy?: string;\n readonly resolution?: WorldIncidentResolution;\n readonly affectedEventRefs: readonly string[];\n}\n\nexport interface WorldIncidentRegistry {\n readonly incidents: readonly WorldIncidentThread[];\n readonly activeCount: number;\n}\n\nexport function isCanonicalWorldEvent(event: GameWorldEvent): event is GameWorldEventCanonical {\n return event.recordType === \"canonical\";\n}\n\nexport function isCandidateWorldEvent(event: GameWorldEvent): event is GameWorldEventCandidate {\n return event.recordType === \"candidate\";\n}\n\nconst WORLD_IMPACT_SCALE_LIMIT = 100;\n\nfunction clampImpactValue(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n return Math.max(0, Math.min(WORLD_IMPACT_SCALE_LIMIT, value));\n}\n\nexport function normalizeIncidentImpactVector(\n impact: Partial<WorldIncidentImpactVector> | Record<string, number>,\n): Readonly<WorldIncidentImpactVector> {\n return Object.freeze({\n security: clampImpactValue(Number(impact.security ?? 0)),\n economy: clampImpactValue(Number(impact.economy ?? 0)),\n ecology: clampImpactValue(Number(impact.ecology ?? 0)),\n politics: clampImpactValue(Number(impact.politics ?? 0)),\n morale: clampImpactValue(Number(impact.morale ?? 0)),\n magic: clampImpactValue(Number(impact.magic ?? 0)),\n population: clampImpactValue(Number(impact.population ?? 0)),\n });\n}\n\nexport function isIncidentResolved(incident: WorldIncidentThread): boolean {\n return incident.lifecycle === \"resolved\" || incident.lifecycle === \"expired\";\n}\n","export type GossipSalience = \"low\" | \"medium\" | \"high\" | \"critical\";\nexport type GossipConfidence = \"uncertain\" | \"possible\" | \"strong\" | \"verified\";\nexport type GossipTopicStatus = \"active\" | \"corrected\" | \"resolved\" | \"stale\";\nexport type GossipAudienceSegment = \"player\" | \"npc\" | \"public\";\nexport type GossipProjectionMode = \"segment-level\" | \"npc-level\";\n\nexport interface EventSourceLink {\n readonly sourceType: \"event\" | \"incident\";\n readonly sourceId: string;\n}\n\nexport interface GossipSpeechHint {\n readonly sentenceTone: \"whisper\" | \"formal\" | \"urgent\";\n readonly localizedHintKey: string;\n}\n\nexport interface GossipTopicPayload {\n readonly factSummary: string;\n readonly certainty: number;\n readonly salience: GossipSalience;\n readonly evidenceRefs: readonly EventSourceLink[];\n readonly speechHint: GossipSpeechHint;\n}\n\nexport interface GossipTopic {\n readonly topicId: string;\n readonly status: GossipTopicStatus;\n readonly emittedAtEpochMs: number;\n readonly expiresAtEpochMs: number;\n readonly sourceLink: EventSourceLink;\n readonly sourceEventRef: string;\n readonly lineageOf?: string;\n readonly replacedBy?: string;\n readonly payload: GossipTopicPayload;\n readonly confidenceLevel: GossipConfidence;\n readonly audienceScope: \"faction\" | \"region\" | \"public\";\n}\n\nexport interface WitnessChannel {\n readonly witnessRef: string;\n readonly seenAtEpochMs: number;\n readonly confidenceWeight: number;\n}\n\nexport interface PerspectiveRule {\n readonly locality: readonly string[];\n readonly factions: readonly string[];\n readonly relationshipScore: number;\n}\n\nexport interface KnowledgeSource {\n readonly sourceType: \"segment\" | \"npc\";\n readonly sourceRef: string;\n readonly relationshipToAudience?: number;\n}\n\nexport interface GossipPerspectiveProjection {\n readonly projectionMode: GossipProjectionMode;\n readonly audienceSegment: GossipAudienceSegment;\n readonly requestedByNpcRef?: string;\n readonly locality: string;\n readonly faction: string;\n readonly segmentRules: readonly PerspectiveRule[];\n readonly witnessChannels: readonly WitnessChannel[];\n}\n\nexport interface ProjectedGossipEnvelope {\n readonly topicId: string;\n readonly visible: boolean;\n readonly redactedPayload?: GossipTopicPayload;\n readonly reasons: readonly string[];\n}\n\nexport interface GossipLifecyclePort {\n readonly topicId: string;\n load(): Promise<GossipTopic | null>;\n applyCorrection(next: GossipTopic): Promise<void>;\n markResolved(topicId: string, replacementTopicId?: string): Promise<void>;\n}\n\nexport interface GossipTopicEnvelope {\n readonly topic: GossipTopic;\n readonly topics: readonly EventSourceLink[];\n}\n\nexport function isGossipTopicActive(topic: GossipTopic, nowEpochMs = Date.now()): boolean {\n return topic.status === \"active\" && topic.expiresAtEpochMs > nowEpochMs && topic.payload.certainty >= 0.35;\n}\n\nexport function isGossipTopicCorrected(topic: GossipTopic): boolean {\n return topic.status === \"corrected\";\n}\n\nfunction matchSegmentAudience(\n sourceValue: readonly string[], targetValue: readonly string[], fallback: boolean,\n): boolean {\n if (sourceValue.length === 0 || targetValue.length === 0) {\n return fallback;\n }\n\n return sourceValue.some((value) => targetValue.includes(value));\n}\n\nexport function projectTopicForAudience(\n topic: GossipTopic,\n projection: GossipPerspectiveProjection,\n nowEpochMs = Date.now(),\n): ProjectedGossipEnvelope {\n if (!isGossipTopicActive(topic, nowEpochMs)) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"inactive-or-expired-topic\"],\n };\n }\n\n const hasMatchingRule = projection.segmentRules.some((rule) =>\n matchSegmentAudience(rule.locality, [projection.locality], true) &&\n matchSegmentAudience(rule.factions, [projection.faction], false)\n );\n\n if (!hasMatchingRule) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"audience-not-authorized\"],\n };\n }\n\n if (projection.projectionMode === \"segment-level\" && topic.audienceScope === \"public\") {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"segment-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope === \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope !== \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"scope-constraints\"],\n };\n}\n","export const AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID =\n \"isekai.player-system.quiet-measure.enabled\";\n\nexport const QUIET_MEASURE_AXES = [\n \"selflessness\",\n \"give\",\n \"mercy\",\n \"duty\",\n \"principle\",\n \"courtesy\",\n] as const;\n\nexport type QuietMeasureAxis = (typeof QUIET_MEASURE_AXES)[number];\n\nexport const QUIET_MEASURE_CONFIDENCE_BANDS = [\"low\", \"medium\", \"high\"] as const;\n\nexport type QuietMeasureConfidenceBand =\n (typeof QUIET_MEASURE_CONFIDENCE_BANDS)[number];\n\nexport const QUIET_MEASURE_SIGNAL_BANDS = [\n \"suppressed\",\n \"latent\",\n \"present\",\n \"dominant\",\n] as const;\n\nexport type QuietMeasureSignalBand = (typeof QUIET_MEASURE_SIGNAL_BANDS)[number];\n\nexport const QUIET_MEASURE_PERSPECTIVES = [\n \"system-truth\",\n \"observed-reputation\",\n] as const;\n\nexport type QuietMeasurePerspective = (typeof QUIET_MEASURE_PERSPECTIVES)[number];\n\nexport const QUIET_MEASURE_EVIDENCE_CLASSES = [\n \"declared-intent\",\n \"costly-choice\",\n \"private-conduct\",\n \"repair-after-harm\",\n \"weak-party-treatment\",\n \"observed-pattern\",\n \"social-mask\",\n] as const;\n\nexport type QuietMeasureEvidenceClass =\n (typeof QUIET_MEASURE_EVIDENCE_CLASSES)[number];\n\nexport const QUIET_MEASURE_DERIVED_READS = [\n \"nature\",\n \"mask\",\n \"veil-gap\",\n \"restitution\",\n] as const;\n\nexport type QuietMeasureDerivedRead =\n (typeof QUIET_MEASURE_DERIVED_READS)[number];\n\nexport const QUIET_MEASURE_MISSION_PROBE_MODES = [\n \"clarify\",\n \"tempt\",\n \"reinforce\",\n] as const;\n\nexport type QuietMeasureMissionProbeMode =\n (typeof QUIET_MEASURE_MISSION_PROBE_MODES)[number];\n\nexport const QUIET_MEASURE_MISSION_RESOLUTION_SHAPES = [\n \"restorative\",\n \"dominant\",\n \"detached\",\n \"performative\",\n] as const;\n\nexport type QuietMeasureMissionResolutionShape =\n (typeof QUIET_MEASURE_MISSION_RESOLUTION_SHAPES)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_DISCLOSURES = [\n \"title-and-verdict-only\",\n] as const;\n\nexport type QuietMeasureJudgmentDisclosure =\n (typeof QUIET_MEASURE_JUDGMENT_DISCLOSURES)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_REQUESTERS = [\n \"player\",\n \"system\",\n \"operator\",\n] as const;\n\nexport type QuietMeasureJudgmentRequester =\n (typeof QUIET_MEASURE_JUDGMENT_REQUESTERS)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [\n \"repeated-meaningful-evidence\",\n \"private-or-low-witness-evidence\",\n \"costly-pressure-event\",\n] as const;\n\nexport type QuietMeasureJudgmentMissingEvidence =\n (typeof QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE)[number];\n\nexport interface QuietMeasureEvidenceWindow {\n readonly evidenceClass: QuietMeasureEvidenceClass;\n readonly sampleBand: \"sparse\" | \"growing\" | \"settled\";\n readonly includesPrivateConduct: boolean;\n readonly includesCostlyPressureEvent: boolean;\n readonly includesRepairAfterHarm: boolean;\n}\n\nexport interface QuietMeasureAxisSummary {\n readonly axis: QuietMeasureAxis;\n readonly signalBand: QuietMeasureSignalBand;\n readonly confidenceBand: QuietMeasureConfidenceBand;\n readonly evidenceWindow: QuietMeasureEvidenceWindow;\n}\n\nexport interface QuietMeasureDerivedReadSummary {\n readonly read: QuietMeasureDerivedRead;\n readonly perspective: QuietMeasurePerspective;\n readonly signalBand: QuietMeasureSignalBand;\n readonly confidenceBand: QuietMeasureConfidenceBand;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureTitleDescriptor {\n readonly titleId: string;\n readonly title: string;\n readonly verdictLabel: string;\n readonly perspective: QuietMeasurePerspective;\n readonly disclosure: QuietMeasureJudgmentDisclosure;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureMissionProbe {\n readonly probeId: string;\n readonly mode: QuietMeasureMissionProbeMode;\n readonly primaryRead: QuietMeasureDerivedRead;\n readonly supportedResolutionShapes: readonly QuietMeasureMissionResolutionShape[];\n readonly hiddenRuntime: true;\n readonly responsePerspective: QuietMeasurePerspective;\n readonly responseBias:\n | \"virtue-biased\"\n | \"vice-viable\"\n | \"ambiguity-preserving\";\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureMissionResolutionMetadata {\n readonly resolutionShape: QuietMeasureMissionResolutionShape;\n readonly surplusTendency:\n | \"compounding-trust\"\n | \"fear-and-tribute\"\n | \"ambiguity-preserving\";\n readonly worldReactionMode: \"fertile\" | \"brittle\" | \"uncertain\";\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentRequest {\n readonly subjectId: string;\n readonly requestedAtUtc: string;\n readonly requestedBy: QuietMeasureJudgmentRequester;\n readonly disclosure: QuietMeasureJudgmentDisclosure;\n}\n\nexport interface QuietMeasureJudgmentEligibility {\n readonly eligible: boolean;\n readonly repeatedMeaningfulEvidence: boolean;\n readonly includesPrivateOrLowWitnessEvidence: boolean;\n readonly includesCostlyPressureEvent: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentInsufficientEvidenceResponse {\n readonly kind: \"insufficient-evidence\";\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility & {\n readonly eligible: false;\n };\n readonly missingEvidence: readonly QuietMeasureJudgmentMissingEvidence[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentVerdictResponse {\n readonly kind: \"verdict\";\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility & {\n readonly eligible: true;\n };\n readonly title: QuietMeasureTitleDescriptor;\n readonly dominantReads: readonly QuietMeasureDerivedReadSummary[];\n readonly reasonCodes: readonly string[];\n}\n\nexport type QuietMeasureJudgmentResponse =\n | QuietMeasureJudgmentInsufficientEvidenceResponse\n | QuietMeasureJudgmentVerdictResponse;\n\nexport interface QuietMeasureJudgmentEligibilityInput {\n readonly repeatedMeaningfulEvidence?: boolean;\n readonly includesPrivateOrLowWitnessEvidence?: boolean;\n readonly includesCostlyPressureEvent?: boolean;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface CreateQuietMeasureJudgmentResponseInput {\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility;\n readonly title?: QuietMeasureTitleDescriptor;\n readonly dominantReads?: readonly QuietMeasureDerivedReadSummary[];\n readonly reasonCodes?: readonly string[];\n}\n\nfunction isMember<T extends string>(\n value: string,\n members: readonly T[],\n): value is T {\n return (members as readonly string[]).includes(value);\n}\n\nfunction assertRecord(value: unknown, label: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(`${label} must be an object.`);\n }\n\n return value as Record<string, unknown>;\n}\n\nfunction normalizeNonEmptyString(value: unknown, label: string): string {\n if (typeof value !== \"string\") {\n throw new TypeError(`${label} must be a non-empty string.`);\n }\n\n const normalized = value.trim();\n if (normalized.length === 0) {\n throw new TypeError(`${label} must be a non-empty string.`);\n }\n\n return normalized;\n}\n\nfunction normalizeBoolean(value: unknown, label: string): boolean {\n if (typeof value !== \"boolean\") {\n throw new TypeError(`${label} must be a boolean.`);\n }\n\n return value;\n}\n\nfunction normalizeOptionalBoolean(value: unknown, fallback: boolean, label: string): boolean {\n if (value === undefined) {\n return fallback;\n }\n\n return normalizeBoolean(value, label);\n}\n\nfunction normalizeTimestamp(value: unknown, label: string): string {\n const normalized = normalizeNonEmptyString(value, label);\n const parsed = Date.parse(normalized);\n\n if (Number.isNaN(parsed)) {\n throw new TypeError(`${label} must be a valid ISO-8601 timestamp.`);\n }\n\n return normalized;\n}\n\nfunction normalizeMember<T extends string>(\n value: unknown,\n members: readonly T[],\n label: string,\n): T {\n const normalized = normalizeNonEmptyString(value, label);\n\n if (!isMember(normalized, members)) {\n throw new TypeError(`${label} must be one of: ${members.join(\", \")}.`);\n }\n\n return normalized;\n}\n\nfunction normalizeReasonCodes(value: unknown, label: string): readonly string[] {\n if (value === undefined) {\n return Object.freeze([]);\n }\n\n if (!Array.isArray(value)) {\n throw new TypeError(`${label} must be an array of strings.`);\n }\n\n for (const [index, entry] of value.entries()) {\n if (typeof entry !== \"string\") {\n throw new TypeError(`${label}[${index}] must be a string.`);\n }\n }\n\n const normalized = value.map((entry) => entry.trim());\n if (normalized.some((entry) => entry.length === 0)) {\n throw new TypeError(`${label} must not contain blank strings.`);\n }\n\n return Object.freeze(Array.from(new Set(normalized)));\n}\n\nfunction normalizeJudgmentRequest(input: unknown): QuietMeasureJudgmentRequest {\n const request = assertRecord(input, \"Quiet Measure judgment request\");\n\n return Object.freeze({\n subjectId: normalizeNonEmptyString(\n request.subjectId,\n \"Quiet Measure judgment request subjectId\",\n ),\n requestedAtUtc: normalizeTimestamp(\n request.requestedAtUtc,\n \"Quiet Measure judgment request requestedAtUtc\",\n ),\n requestedBy: normalizeMember(\n request.requestedBy,\n QUIET_MEASURE_JUDGMENT_REQUESTERS,\n \"Quiet Measure judgment request requestedBy\",\n ),\n disclosure: normalizeMember(\n request.disclosure,\n QUIET_MEASURE_JUDGMENT_DISCLOSURES,\n \"Quiet Measure judgment request disclosure\",\n ),\n });\n}\n\nfunction normalizeJudgmentEligibility(input: unknown): QuietMeasureJudgmentEligibility {\n const eligibility = assertRecord(input, \"Quiet Measure judgment eligibility\");\n const repeatedMeaningfulEvidence = normalizeBoolean(\n eligibility.repeatedMeaningfulEvidence,\n \"Quiet Measure judgment eligibility repeatedMeaningfulEvidence\",\n );\n const includesPrivateOrLowWitnessEvidence = normalizeBoolean(\n eligibility.includesPrivateOrLowWitnessEvidence,\n \"Quiet Measure judgment eligibility includesPrivateOrLowWitnessEvidence\",\n );\n const includesCostlyPressureEvent = normalizeBoolean(\n eligibility.includesCostlyPressureEvent,\n \"Quiet Measure judgment eligibility includesCostlyPressureEvent\",\n );\n\n return Object.freeze({\n eligible:\n repeatedMeaningfulEvidence\n && includesPrivateOrLowWitnessEvidence\n && includesCostlyPressureEvent,\n repeatedMeaningfulEvidence,\n includesPrivateOrLowWitnessEvidence,\n includesCostlyPressureEvent,\n reasonCodes: normalizeReasonCodes(\n eligibility.reasonCodes,\n \"Quiet Measure eligibility reasonCodes\",\n ),\n });\n}\n\nfunction normalizeTitleDescriptor(input: unknown): QuietMeasureTitleDescriptor {\n const title = assertRecord(input, \"Quiet Measure title\");\n\n return Object.freeze({\n titleId: normalizeNonEmptyString(title.titleId, \"Quiet Measure title titleId\"),\n title: normalizeNonEmptyString(title.title, \"Quiet Measure title title\"),\n verdictLabel: normalizeNonEmptyString(\n title.verdictLabel,\n \"Quiet Measure title verdictLabel\",\n ),\n perspective: normalizeMember(\n title.perspective,\n QUIET_MEASURE_PERSPECTIVES,\n \"Quiet Measure title perspective\",\n ),\n disclosure: normalizeMember(\n title.disclosure,\n QUIET_MEASURE_JUDGMENT_DISCLOSURES,\n \"Quiet Measure title disclosure\",\n ),\n reasonCodes: normalizeReasonCodes(title.reasonCodes, \"Quiet Measure title reasonCodes\"),\n });\n}\n\nfunction normalizeDerivedReadSummary(\n input: unknown,\n index: number,\n): QuietMeasureDerivedReadSummary {\n const prefix = `Quiet Measure dominantReads[${index}]`;\n const dominantRead = assertRecord(input, prefix);\n\n return Object.freeze({\n read: normalizeMember(\n dominantRead.read,\n QUIET_MEASURE_DERIVED_READS,\n `${prefix} read`,\n ),\n perspective: normalizeMember(\n dominantRead.perspective,\n QUIET_MEASURE_PERSPECTIVES,\n `${prefix} perspective`,\n ),\n signalBand: normalizeMember(\n dominantRead.signalBand,\n QUIET_MEASURE_SIGNAL_BANDS,\n `${prefix} signalBand`,\n ),\n confidenceBand: normalizeMember(\n dominantRead.confidenceBand,\n QUIET_MEASURE_CONFIDENCE_BANDS,\n `${prefix} confidenceBand`,\n ),\n reasonCodes: normalizeReasonCodes(\n dominantRead.reasonCodes,\n `${prefix} reasonCodes`,\n ),\n });\n}\n\nfunction normalizeDominantReads(\n value: unknown,\n): readonly QuietMeasureDerivedReadSummary[] {\n if (value === undefined) {\n return Object.freeze([]);\n }\n\n if (!Array.isArray(value)) {\n throw new TypeError(\"Quiet Measure dominantReads must be an array.\");\n }\n\n return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));\n}\n\nexport function isQuietMeasureAxis(value: string): value is QuietMeasureAxis {\n return isMember(value, QUIET_MEASURE_AXES);\n}\n\nexport function isQuietMeasureMissionProbeMode(\n value: string,\n): value is QuietMeasureMissionProbeMode {\n return isMember(value, QUIET_MEASURE_MISSION_PROBE_MODES);\n}\n\nexport function isQuietMeasureMissionResolutionShape(\n value: string,\n): value is QuietMeasureMissionResolutionShape {\n return isMember(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);\n}\n\nexport function createQuietMeasureJudgmentEligibility(\n input: QuietMeasureJudgmentEligibilityInput = {},\n): QuietMeasureJudgmentEligibility {\n const repeatedMeaningfulEvidence = normalizeOptionalBoolean(\n input.repeatedMeaningfulEvidence,\n false,\n \"Quiet Measure eligibility repeatedMeaningfulEvidence\",\n );\n const includesPrivateOrLowWitnessEvidence = normalizeOptionalBoolean(\n input.includesPrivateOrLowWitnessEvidence,\n false,\n \"Quiet Measure eligibility includesPrivateOrLowWitnessEvidence\",\n );\n const includesCostlyPressureEvent = normalizeOptionalBoolean(\n input.includesCostlyPressureEvent,\n false,\n \"Quiet Measure eligibility includesCostlyPressureEvent\",\n );\n\n return Object.freeze({\n eligible:\n repeatedMeaningfulEvidence\n && includesPrivateOrLowWitnessEvidence\n && includesCostlyPressureEvent,\n repeatedMeaningfulEvidence,\n includesPrivateOrLowWitnessEvidence,\n includesCostlyPressureEvent,\n reasonCodes: normalizeReasonCodes(input.reasonCodes, \"Quiet Measure eligibility reasonCodes\"),\n });\n}\n\nexport function listQuietMeasureMissingEvidence(\n eligibility: QuietMeasureJudgmentEligibility,\n): readonly QuietMeasureJudgmentMissingEvidence[] {\n const normalizedEligibility = normalizeJudgmentEligibility(eligibility);\n const missing: QuietMeasureJudgmentMissingEvidence[] = [];\n\n if (!normalizedEligibility.repeatedMeaningfulEvidence) {\n missing.push(\"repeated-meaningful-evidence\");\n }\n\n if (!normalizedEligibility.includesPrivateOrLowWitnessEvidence) {\n missing.push(\"private-or-low-witness-evidence\");\n }\n\n if (!normalizedEligibility.includesCostlyPressureEvent) {\n missing.push(\"costly-pressure-event\");\n }\n\n return Object.freeze(missing);\n}\n\nexport function createQuietMeasureJudgmentResponse(\n input: CreateQuietMeasureJudgmentResponseInput,\n): QuietMeasureJudgmentResponse {\n const request = normalizeJudgmentRequest(input.request);\n const eligibility = normalizeJudgmentEligibility(input.eligibility);\n const missingEvidence = listQuietMeasureMissingEvidence(eligibility);\n const reasonCodes = normalizeReasonCodes(\n input.reasonCodes,\n \"Quiet Measure judgment response reasonCodes\",\n );\n const hasRequiredEvidence = missingEvidence.length === 0;\n\n if (!hasRequiredEvidence) {\n return Object.freeze({\n kind: \"insufficient-evidence\",\n request,\n eligibility: Object.freeze({\n ...eligibility,\n eligible: false,\n }),\n missingEvidence,\n reasonCodes,\n });\n }\n\n if (!input.title) {\n throw new TypeError(\n \"Quiet Measure verdict responses require a title descriptor when eligibility is met.\",\n );\n }\n\n return Object.freeze({\n kind: \"verdict\",\n request,\n eligibility: Object.freeze({\n ...eligibility,\n eligible: true,\n }),\n title: normalizeTitleDescriptor(input.title),\n dominantReads: normalizeDominantReads(input.dominantReads),\n reasonCodes,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAmCO;AAoCA,IAAM,+BAA+B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,wCAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,mDAAmD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,4CAA4C;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AACF;AAoDA,SAAS,oBAAuB,OAAmC;AACjE,SAAO,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9B,gBAAY,KAAK,yBAAyB;AAAA,EAC5C;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA,qBAAqB,OAAO,OAAO;AAAA,MACjC,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB,GAAI,mBAAmB,CAAC,sBAAsB,mBAAmB,IAAI,CAAC;AAAA,IACxE,CAAC;AAAA,IACD,QAAQ;AAAA,IACR,OAAO;AAAA,MACL,UAAU,MAAM,YAAY;AAAA,MAC5B,eAAe,MAAM,iBAAiB;AAAA,MACtC,eAAe,MAAM,iBAAiB,OAAO,WAAW;AAAA,MACxD,WAAW,MAAM;AAAA,MACjB,SAAS,MAAM;AAAA,MACf;AAAA,MACA,gBAAgB,aAAa;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,oBAAyC,OAAO,OAAO;AAAA,EAClE,aAAa;AAAA,EACb,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AACX,CAAC;AAEM,IAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,iBAAiB;AACnB,CAAC;AAEM,IAAM,wBAAwB,OAAO,OAAO;AAAA,EACjD,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AACrB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/training-state.ts","../src/player-system.ts","../src/world-events.ts","../src/gossip.ts","../src/quiet-measure.ts"],"sourcesContent":["export * from \"./training-state.js\";\nexport * from \"./player-system.js\";\n\nexport interface AiPackageDescriptor {\n readonly packageName: string;\n readonly featureFlagId: string;\n readonly envPrefix: string;\n readonly summary: string;\n}\n\nexport const AI_GAME_PACKAGE = \"@plasius/ai-game\";\nexport const AI_GAME_ENV_PREFIX = \"AI_GAME\";\nexport const AI_GAME_FEATURE_FLAG_ID = \"ai.game.enabled\";\nexport const AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID = \"ai.game.event-recorder.contracts.enabled\";\nexport const AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID = \"ai.game.event-recorder.ingestion.enabled\";\nexport const AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID = \"ai.game.event-recorder.impact.enabled\";\nexport const AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID = \"ai.game.npc-gossip.topics.enabled\";\nexport const AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.perspective.enabled\";\nexport const AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID = \"ai.game.npc-gossip.lifecycle.enabled\";\n\nexport const AI_GAME_FEATURE_FLAGS = {\n workloads: AI_GAME_FEATURE_FLAG_ID,\n ttsCacheEnabled: \"ai.tts.cache.enabled\",\n ttsNearReuseEnabled: \"ai.tts.near-reuse.enabled\",\n} as const;\n\nexport type AiGameFeatureFlagKey =\n (typeof AI_GAME_FEATURE_FLAGS)[keyof typeof AI_GAME_FEATURE_FLAGS];\n\nexport type AiGameFeatureFlagSnapshot = Partial<Record<AiGameFeatureFlagKey, boolean>>;\n\nexport const AI_GAME_TASK_KINDS = [\n \"player-action-validation\",\n \"npc-action\",\n \"npc-dialogue\",\n \"gossip\",\n \"governance-feedback\",\n \"feedback\",\n \"unknown\",\n] as const;\n\nexport type AiGameTaskKind = (typeof AI_GAME_TASK_KINDS)[number];\n\nexport const AI_GAME_TASK_RISK_CLASSES = [\n \"low\",\n \"medium\",\n \"high\",\n \"critical\",\n] as const;\n\nexport type AiGameTaskRiskClass = (typeof AI_GAME_TASK_RISK_CLASSES)[number];\n\nexport const AI_GAME_TASK_AUTHORITY_BOUNDARIES = [\n \"deterministic\",\n \"human-review\",\n \"operator-review\",\n \"blocked\",\n] as const;\n\nexport type AiGameAuthorityBoundary =\n (typeof AI_GAME_TASK_AUTHORITY_BOUNDARIES)[number];\n\nexport const AI_GAME_TASK_DECISIONS = [\"allow\", \"operator-review\", \"blocked\"] as const;\n\nexport type AiGameTaskDecisionResult =\n (typeof AI_GAME_TASK_DECISIONS)[number];\n\nexport const AI_GAME_TASK_RESULTS = [\"allow\", \"defer\", \"deny\"] as const;\n\nexport type AiGameTaskResult = (typeof AI_GAME_TASK_RESULTS)[number];\n\nexport const AI_GAME_TTS_CACHE_POLICIES = [\n \"exact-cache\",\n \"near-cache\",\n \"no-cache\",\n] as const;\n\nexport type AiGameTtsCachePolicy =\n (typeof AI_GAME_TTS_CACHE_POLICIES)[number];\n\nexport const AI_GAME_ACTOR_ROLES = [\"player\", \"npc\", \"operator\", \"system\"] as const;\n\nexport type AiGameActorRole = (typeof AI_GAME_ACTOR_ROLES)[number];\n\nexport interface AiGameTaskRequest {\n readonly taskId: string;\n readonly taskText: string;\n readonly taskKind?: AiGameTaskKind;\n}\n\nexport interface AiGameTaskDecision {\n readonly taskId: string;\n readonly taskKind: AiGameTaskKind;\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly decision: AiGameTaskDecisionResult;\n readonly needsOperatorReview: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGamePolicyAuditBase {\n readonly policyId: string;\n readonly policyVersion: string;\n readonly correlationId: string;\n readonly requestId?: string;\n readonly actorId?: string;\n readonly actorRole: AiGameActorRole;\n readonly evaluatedAtUtc: string;\n}\n\nexport interface ResolveAiGameTaskInput {\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly requests: readonly AiGameTaskRequest[];\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface AiGameTaskResolution {\n readonly requestedTasks: readonly string[];\n readonly taskDecisions: readonly AiGameTaskDecision[];\n readonly allowedTaskIds: readonly string[];\n readonly reviewTaskIds: readonly string[];\n readonly blockedTaskIds: readonly string[];\n readonly needsOperatorReview: boolean;\n readonly featureEnabled: boolean;\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly result: AiGameTaskResult;\n };\n}\n\nexport interface ResolveAiGamePlayerAddressInput {\n readonly playerAddressText: string;\n readonly playerAlias?: string;\n readonly accountAlias?: string;\n readonly actorRole?: AiGameActorRole;\n readonly actorId?: string;\n readonly requestId?: string;\n readonly correlationId?: string;\n readonly policyId?: string;\n readonly policyVersion?: string;\n readonly featureFlags?: AiGameFeatureFlagSnapshot;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface ResolveAiGamePlayerAddressResult {\n readonly sourceText: string;\n readonly renderText: string;\n readonly ttsCachePolicy: AiGameTtsCachePolicy;\n readonly reasonCodes: readonly string[];\n readonly enabledFeatureFlags: readonly AiGameFeatureFlagKey[];\n readonly source: \"policy\" | \"policy-disabled\" | \"policy-empty\";\n readonly audit: AiGamePolicyAuditBase & {\n readonly cachePolicy: AiGameTtsCachePolicy;\n };\n}\n\ninterface AiGameTaskProfile {\n readonly riskClass: AiGameTaskRiskClass;\n readonly authorityBoundary: AiGameAuthorityBoundary;\n readonly keywords: readonly string[];\n}\n\nconst AI_GAME_TASK_PROFILE_BY_KIND: Record<AiGameTaskKind, AiGameTaskProfile> = {\n \"player-action-validation\": {\n riskClass: \"medium\",\n authorityBoundary: \"human-review\",\n keywords: [\"move\", \"attack\", \"collect\", \"use\", \"open\", \"pick\", \"trade\", \"target\"],\n },\n \"npc-action\": {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"summon\", \"kill\", \"ban\", \"spawn\", \"eject\", \"resurrect\", \"npc action\", \"npc-action\"],\n },\n \"npc-dialogue\": {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"say\", \"says\", \"reply\", \"chat\", \"dialogue\", \"greet\", \"warn\", \"request\"],\n },\n gossip: {\n riskClass: \"high\",\n authorityBoundary: \"operator-review\",\n keywords: [\"rumor\", \"rumors\", \"gossip\", \"hearsay\", \"whisper\", \"spread\", \"denounce\"],\n },\n \"governance-feedback\": {\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n keywords: [\"punish\", \"expel\", \"revoke\", \"ban\", \"forbid\", \"seize\"],\n },\n feedback: {\n riskClass: \"low\",\n authorityBoundary: \"operator-review\",\n keywords: [\"feedback\", \"rating\", \"report\", \"score\", \"review\", \"complaint\"],\n },\n unknown: {\n riskClass: \"low\",\n authorityBoundary: \"deterministic\",\n keywords: [\"\"],\n },\n};\n\nconst AI_GAME_TASK_KEYWORD_PATTERNS: Readonly<Record<AiGameTaskKind, RegExp>> = {\n \"player-action-validation\": buildTaskPattern(\n AI_GAME_TASK_PROFILE_BY_KIND[\"player-action-validation\"].keywords,\n ),\n \"npc-action\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-action\"].keywords),\n \"npc-dialogue\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"npc-dialogue\"].keywords),\n gossip: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.gossip.keywords),\n \"governance-feedback\": buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND[\"governance-feedback\"].keywords),\n feedback: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.feedback.keywords),\n unknown: buildTaskPattern(AI_GAME_TASK_PROFILE_BY_KIND.unknown.keywords),\n};\n\nfunction nowIsoString(): string {\n return new Date().toISOString();\n}\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction normalizeToken(value: string): string {\n return value.trim().replace(/\\s+/g, \" \");\n}\n\nfunction buildTaskPattern(keywords: readonly string[]): RegExp {\n return new RegExp(\n keywords.filter((keyword) => keyword.length > 0).map((keyword) => `\\\\b${escapeRegExp(keyword)}\\\\b`).join(\"|\") || \"^$\",\n \"i\",\n );\n}\n\nfunction uniqueStrings(values: readonly string[]): string[] {\n return Array.from(new Set(values.filter((value) => value.length > 0)));\n}\n\nfunction isFeatureEnabled(\n featureFlag: AiGameFeatureFlagKey,\n snapshot: AiGameFeatureFlagSnapshot = {},\n): boolean {\n return snapshot[featureFlag] === true;\n}\n\nfunction normalizeTaskText(value: string): string {\n return value.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\nfunction isActorRole(role?: AiGameActorRole): AiGameActorRole {\n return role ?? \"player\";\n}\n\nfunction normalizeTaskKind(taskKind?: AiGameTaskKind): AiGameTaskKind | undefined {\n if (!taskKind) {\n return undefined;\n }\n\n return (AI_GAME_TASK_KINDS as readonly string[]).includes(taskKind)\n ? taskKind\n : \"unknown\";\n}\n\nexport function classifyAiGameTask(taskText: string): AiGameTaskKind {\n const normalized = normalizeTaskText(taskText);\n\n if (!normalized) {\n return \"unknown\";\n }\n\n for (const taskKind of AI_GAME_TASK_KINDS) {\n if (AI_GAME_TASK_KEYWORD_PATTERNS[taskKind].test(normalized)) {\n return taskKind;\n }\n }\n\n return \"unknown\";\n}\n\nfunction resolveTaskAuthority(taskKind: AiGameTaskKind): AiGameTaskProfile {\n return AI_GAME_TASK_PROFILE_BY_KIND[taskKind];\n}\n\nfunction resolveTaskDecision(\n taskKind: AiGameTaskKind,\n profile: AiGameTaskProfile,\n actorRole: AiGameActorRole,\n): Omit<AiGameTaskDecision, \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"> {\n if (profile.authorityBoundary === \"blocked\") {\n return {\n decision: \"blocked\",\n needsOperatorReview: actorRole !== \"system\",\n };\n }\n\n if (profile.authorityBoundary === \"deterministic\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n if (actorRole === \"system\") {\n return {\n decision: \"allow\",\n needsOperatorReview: false,\n };\n }\n\n return {\n decision: \"operator-review\",\n needsOperatorReview: true,\n };\n}\n\nfunction buildRequestIds(requests: readonly AiGameTaskRequest[]): string[] {\n return uniqueStrings(requests.map((request) => request.taskId.trim()).filter(Boolean));\n}\n\n/**\n * Resolve game AI task contracts for player actions, NPC actions, gossip, and governance.\n */\nexport function resolveAiGameTaskBatch(\n input: ResolveAiGameTaskInput,\n): AiGameTaskResolution {\n const actorRole = isActorRole(input.actorRole);\n const featureEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.workloads,\n input.featureFlags,\n );\n const reasonCodes = [...(input.reasonCodes ?? [])];\n type ResolvedAiGameTaskRequest = AiGameTaskRequest & { taskKind: AiGameTaskKind };\n const requests: ResolvedAiGameTaskRequest[] = input.requests.map((request): ResolvedAiGameTaskRequest => ({\n ...request,\n taskKind: normalizeTaskKind(request.taskKind) ?? classifyAiGameTask(request.taskText),\n }));\n\n if (!featureEnabled) {\n reasonCodes.push(\"game-feature-disabled\");\n const requestIds = buildRequestIds(requests);\n\n return {\n requestedTasks: requestIds,\n taskDecisions: Object.freeze(\n requestIds.map<AiGameTaskDecision>((taskId) => ({\n taskId,\n taskKind: \"unknown\",\n riskClass: \"critical\",\n authorityBoundary: \"blocked\",\n decision: \"blocked\",\n needsOperatorReview: false,\n reasonCodes: [\"feature-disabled\"],\n })),\n ),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze(requestIds),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"deny\",\n },\n };\n }\n\n if (requests.length === 0) {\n reasonCodes.push(\"game-task-empty-request\");\n\n return {\n requestedTasks: Object.freeze([] as const),\n taskDecisions: Object.freeze([] as const),\n allowedTaskIds: Object.freeze([] as const),\n reviewTaskIds: Object.freeze([] as const),\n blockedTaskIds: Object.freeze([] as const),\n needsOperatorReview: false,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: \"allow\",\n },\n };\n }\n const taskDecisions: AiGameTaskDecision[] = [];\n for (const request of requests) {\n const taskKind: AiGameTaskKind = request.taskKind;\n const profile = resolveTaskAuthority(taskKind);\n const decision: Omit<\n AiGameTaskDecision,\n \"taskId\" | \"taskKind\" | \"riskClass\" | \"authorityBoundary\" | \"reasonCodes\"\n > = resolveTaskDecision(taskKind, profile, actorRole);\n\n taskDecisions.push({\n taskId: request.taskId,\n taskKind,\n riskClass: profile.riskClass,\n authorityBoundary: profile.authorityBoundary,\n ...decision,\n reasonCodes: [`task-${taskKind}-${decision.decision}`],\n });\n }\n\n const allowedTaskIds: string[] = [];\n const reviewTaskIds: string[] = [];\n const blockedTaskIds: string[] = [];\n\n for (const decision of taskDecisions) {\n if (decision.decision === \"allow\") {\n allowedTaskIds.push(decision.taskId);\n } else if (decision.decision === \"operator-review\") {\n reviewTaskIds.push(decision.taskId);\n } else {\n blockedTaskIds.push(decision.taskId);\n }\n\n reasonCodes.push(...decision.reasonCodes);\n }\n\n const hasBlockedTasks = blockedTaskIds.length > 0;\n const needsOperatorReview = taskDecisions.some((decision) => decision.needsOperatorReview);\n\n return {\n requestedTasks: Object.freeze(buildRequestIds(requests)),\n taskDecisions: Object.freeze(taskDecisions),\n allowedTaskIds: Object.freeze(uniqueStrings(allowedTaskIds)),\n reviewTaskIds: Object.freeze(uniqueStrings(reviewTaskIds)),\n blockedTaskIds: Object.freeze(uniqueStrings(blockedTaskIds)),\n needsOperatorReview,\n featureEnabled,\n enabledFeatureFlags: [AI_GAME_FEATURE_FLAGS.workloads],\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n result: hasBlockedTasks ? \"deny\" : needsOperatorReview ? \"defer\" : \"allow\",\n },\n };\n}\n\n/**\n * Resolve cache policy for player-account text before speech rendering.\n */\nexport function resolveAiGamePlayerAddressText(\n input: ResolveAiGamePlayerAddressInput,\n): ResolveAiGamePlayerAddressResult {\n const actorRole = isActorRole(input.actorRole);\n const cacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n input.featureFlags,\n );\n const sourceText = normalizeToken(input.playerAddressText);\n const reasonCodes = [...(input.reasonCodes ?? [])];\n\n if (!sourceText) {\n reasonCodes.push(\"tts-empty-text\");\n\n return {\n sourceText,\n renderText: \"\",\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-empty\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const aliasEntries = [\n ...uniqueStrings([normalizeToken(input.playerAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: false,\n })),\n ...uniqueStrings([normalizeToken(input.accountAlias ?? \"\")])\n .filter(Boolean)\n .map((alias) => ({\n alias,\n isAccountAlias: true,\n })),\n ];\n\n let renderText = sourceText;\n let replaced = false;\n\n for (const alias of aliasEntries) {\n const pattern = new RegExp(`\\\\b${escapeRegExp(alias.alias)}\\\\b`, \"gi\");\n\n if (pattern.test(renderText)) {\n renderText = renderText.replace(pattern, alias.isAccountAlias ? \"[ACCOUNT]\" : \"[PLAYER]\");\n replaced = true;\n reasonCodes.push(`tts-redacted-${alias.alias.toLowerCase()}`);\n }\n }\n\n const nearCacheEnabled = isFeatureEnabled(\n AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled,\n input.featureFlags,\n );\n\n if (!cacheEnabled) {\n reasonCodes.push(\"tts-cache-disabled\");\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: \"no-cache\",\n reasonCodes,\n enabledFeatureFlags: [],\n source: \"policy-disabled\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy: \"no-cache\",\n },\n };\n }\n\n const cachePolicy: AiGameTtsCachePolicy =\n !replaced\n ? \"exact-cache\"\n : nearCacheEnabled\n ? \"near-cache\"\n : \"no-cache\";\n\n if (cachePolicy === \"exact-cache\") {\n reasonCodes.push(\"tts-cache-exact\");\n }\n\n if (cachePolicy === \"near-cache\") {\n reasonCodes.push(\"tts-cache-near\");\n }\n\n if (cachePolicy === \"no-cache\") {\n reasonCodes.push(\"tts-cache-not-available\");\n }\n\n return {\n sourceText,\n renderText,\n ttsCachePolicy: cachePolicy,\n reasonCodes,\n enabledFeatureFlags: Object.freeze([\n AI_GAME_FEATURE_FLAGS.workloads,\n AI_GAME_FEATURE_FLAGS.ttsCacheEnabled,\n ...(nearCacheEnabled ? [AI_GAME_FEATURE_FLAGS.ttsNearReuseEnabled] : []),\n ]),\n source: \"policy\",\n audit: {\n policyId: input.policyId ?? \"game-task-policy-v1\",\n policyVersion: input.policyVersion ?? \"2026-05-01\",\n correlationId: input.correlationId ?? crypto.randomUUID(),\n requestId: input.requestId,\n actorId: input.actorId,\n actorRole,\n evaluatedAtUtc: nowIsoString(),\n cachePolicy,\n },\n };\n}\n\nexport const packageDescriptor: AiPackageDescriptor = Object.freeze({\n packageName: AI_GAME_PACKAGE,\n featureFlagId: AI_GAME_FEATURE_FLAG_ID,\n envPrefix: AI_GAME_ENV_PREFIX,\n summary: \"Game-domain AI contracts for event recorder, canonical world-state, and NPC gossip projections.\",\n});\n\nexport const aiGameFeatureFlags = Object.freeze({\n contract: AI_GAME_EVENT_CONTRACTS_FEATURE_FLAG_ID,\n ingestion: AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,\n incident: AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,\n gossipTopics: AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,\n gossipPerspective: AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,\n gossipLifecycle: AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,\n});\n\nexport const gameEventFeatureFlags = Object.freeze([\n aiGameFeatureFlags.contract,\n aiGameFeatureFlags.ingestion,\n aiGameFeatureFlags.incident,\n aiGameFeatureFlags.gossipTopics,\n aiGameFeatureFlags.gossipPerspective,\n aiGameFeatureFlags.gossipLifecycle,\n]);\n\nexport {\n isCanonicalWorldEvent,\n isCandidateWorldEvent,\n isIncidentResolved,\n normalizeIncidentImpactVector,\n} from \"./world-events.js\";\n\nexport {\n isGossipTopicActive,\n isGossipTopicCorrected,\n projectTopicForAudience,\n} from \"./gossip.js\";\n\nexport {\n AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,\n createQuietMeasureJudgmentEligibility,\n createQuietMeasureJudgmentResponse,\n isQuietMeasureAxis,\n isQuietMeasureMissionProbeMode,\n isQuietMeasureMissionResolutionShape,\n listQuietMeasureMissingEvidence,\n} from \"./quiet-measure.js\";\n\nexport * from \"./world-events.js\";\nexport * from \"./gossip.js\";\nexport * from \"./quiet-measure.js\";\n","import {\n TRAINING_ACADEMIES_FEATURE_FLAG_ID,\n TRAINING_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_FEATURE_FLAG_ID,\n TRAINING_TRUST_MARKER_SOURCES,\n TRAINING_ACADEMIC_PROGRESS_STAGES,\n TRAINING_ACADEMY_ADMISSION_DECISIONS,\n TRAINING_INSTRUCTION_ACCESS_LEVELS,\n TRAINING_TECHNIQUE_MASTERY_STATES,\n TRAINING_MARTIAL_TECHNIQUE_TRACKS,\n TRAINING_BARRACKS_DRILL_DELIVERY_MODES,\n TRAINING_MARTIAL_TECHNIQUE_FAMILIES,\n TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES,\n TRAINING_ANTI_SPELL_COUNTER_WINDOWS,\n createTrainingAcademicMissionPrerequisite,\n createTrainingAcademyAdmission,\n createTrainingAntiSpellFieldcraftDiscipline,\n createTrainingBarracksDrill,\n createTrainingInstitution,\n createTrainingMartialTechnique,\n createTrainingMissionTechniqueUnlock,\n createTrainingProgressionRecord,\n createTrainingSchoolProgression,\n createTrainingTrackSelection,\n createTrainingTrustMarker,\n isTrainingAcademicProgressStage,\n isTrainingAcademyAdmissionDecision,\n isMccExpressionTrack,\n isTrainingAntiSpellCounterWindow,\n isTrainingAntiSpellFieldcraftFamily,\n isTrainingBarracksDrillDeliveryMode,\n isTrainingInstructionAccessLevel,\n isTrainingMartialTechniqueFamily,\n isTrainingMartialTechniqueTrack,\n isTrainingTechniqueMasteryState,\n isTrainingTrustMarkerSource,\n isTrainingTrustLevel,\n type TrainingAcademicMissionPrerequisite,\n type TrainingAcademicProgressStage,\n type TrainingAcademyAdmission,\n type TrainingAcademyAdmissionDecision,\n type MccExpressionTrack,\n type TrainingAntiSpellCounterWindow,\n type TrainingAntiSpellFieldcraftDiscipline,\n type TrainingAntiSpellFieldcraftFamily,\n type TrainingBarracksDrill,\n type TrainingBarracksDrillDeliveryMode,\n type TrainingInstitution,\n type TrainingInstitutionType,\n type TrainingInstructionAccessLevel,\n type TrainingMartialTechnique,\n type TrainingMartialTechniqueFamily,\n type TrainingMartialTechniqueTrack,\n type TrainingMissionTechniqueUnlock,\n type TrainingProgressionRecord,\n type TrainingSchoolProgression,\n type TrainingTrackSelection,\n type TrainingTechniqueMasteryState,\n type TrainingTrustMarker,\n type TrainingTrustMarkerSource,\n type TrainingTrustLevel,\n} from \"@plasius/training\";\n\nexport {\n isMccExpressionTrack,\n isTrainingAcademicProgressStage as isAiGameTrainingAcademicProgressStage,\n isTrainingAcademyAdmissionDecision as isAiGameTrainingAcademyAdmissionDecision,\n isTrainingAntiSpellCounterWindow as isAiGameTrainingAntiSpellCounterWindow,\n isTrainingAntiSpellFieldcraftFamily as isAiGameTrainingAntiSpellFieldcraftFamily,\n isTrainingBarracksDrillDeliveryMode as isAiGameTrainingBarracksDrillDeliveryMode,\n isTrainingInstructionAccessLevel as isAiGameTrainingInstructionAccessLevel,\n isTrainingMartialTechniqueFamily as isAiGameTrainingMartialTechniqueFamily,\n isTrainingMartialTechniqueTrack as isAiGameTrainingMartialTechniqueTrack,\n isTrainingTechniqueMasteryState as isAiGameTrainingTechniqueMasteryState,\n isTrainingTrustMarkerSource as isAiGameTrainingTrustMarkerSource,\n isTrainingTrustLevel,\n createTrainingAcademicMissionPrerequisite as createAiGameTrainingAcademicMissionPrerequisite,\n createTrainingAcademyAdmission as createAiGameTrainingAcademyAdmission,\n createTrainingSchoolProgression as createAiGameTrainingSchoolProgression,\n createTrainingTrackSelection as createAiGameTrainingTrackSelection,\n TRAINING_FEATURE_FLAG_ID as AI_GAME_TRAINING_INSTITUTIONS_FEATURE_FLAG_ID,\n TRAINING_ACADEMIES_FEATURE_FLAG_ID as AI_GAME_TRAINING_ACADEMIES_FEATURE_FLAG_ID,\n TRAINING_MARTIAL_FEATURE_FLAG_ID as AI_GAME_TRAINING_MARTIAL_FEATURE_FLAG_ID,\n TRAINING_TRUST_MARKER_SOURCES as AI_GAME_TRAINING_TRUST_MARKER_SOURCES,\n TRAINING_ACADEMIC_PROGRESS_STAGES as AI_GAME_TRAINING_ACADEMIC_PROGRESS_STAGES,\n TRAINING_ACADEMY_ADMISSION_DECISIONS as AI_GAME_TRAINING_ACADEMY_ADMISSION_DECISIONS,\n TRAINING_INSTRUCTION_ACCESS_LEVELS as AI_GAME_TRAINING_INSTRUCTION_ACCESS_LEVELS,\n TRAINING_TECHNIQUE_MASTERY_STATES as AI_GAME_TRAINING_TECHNIQUE_MASTERY_STATES,\n TRAINING_MARTIAL_TECHNIQUE_TRACKS as AI_GAME_TRAINING_MARTIAL_TECHNIQUE_TRACKS,\n TRAINING_BARRACKS_DRILL_DELIVERY_MODES as AI_GAME_TRAINING_BARRACKS_DRILL_DELIVERY_MODES,\n TRAINING_MARTIAL_TECHNIQUE_FAMILIES as AI_GAME_TRAINING_MARTIAL_TECHNIQUE_FAMILIES,\n TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES as AI_GAME_TRAINING_ANTI_SPELL_FIELDCRAFT_FAMILIES,\n TRAINING_ANTI_SPELL_COUNTER_WINDOWS as AI_GAME_TRAINING_ANTI_SPELL_COUNTER_WINDOWS,\n};\n\nexport type {\n TrainingAcademicMissionPrerequisite as AiGameTrainingAcademicMissionPrerequisite,\n TrainingAcademicProgressStage as AiGameTrainingAcademicProgressStage,\n TrainingAcademyAdmission as AiGameTrainingAcademyAdmission,\n TrainingAcademyAdmissionDecision as AiGameTrainingAcademyAdmissionDecision,\n MccExpressionTrack as AiGameTrainingSpecializationLeaning,\n TrainingAntiSpellCounterWindow as AiGameTrainingAntiSpellCounterWindow,\n TrainingAntiSpellFieldcraftDiscipline as AiGameTrainingAntiSpellFieldcraftDiscipline,\n TrainingAntiSpellFieldcraftFamily as AiGameTrainingAntiSpellFieldcraftFamily,\n TrainingBarracksDrill as AiGameTrainingBarracksDrill,\n TrainingBarracksDrillDeliveryMode as AiGameTrainingBarracksDrillDeliveryMode,\n TrainingInstitution as AiGameTrainingInstitution,\n TrainingInstitutionType as AiGameTrainingInstitutionType,\n TrainingInstructionAccessLevel as AiGameTrainingInstructionAccessLevel,\n TrainingMartialTechnique as AiGameTrainingMartialTechnique,\n TrainingMartialTechniqueFamily as AiGameTrainingMartialTechniqueFamily,\n TrainingMartialTechniqueTrack as AiGameTrainingMartialTechniqueTrack,\n TrainingMissionTechniqueUnlock as AiGameTrainingMissionTechniqueUnlock,\n TrainingProgressionRecord as AiGameTrainingState,\n TrainingSchoolProgression as AiGameTrainingSchoolProgression,\n TrainingTrackSelection as AiGameTrainingTrackSelection,\n TrainingTechniqueMasteryState as AiGameTrainingTechniqueMasteryState,\n TrainingTrustMarkerSource as AiGameTrainingTrustMarkerSource,\n TrainingTrustLevel as AiGameTrainingTrustLevel,\n};\n\nexport const AI_GAME_TRAINING_STAGE_GATES = [\n \"system-first-awakening\",\n \"field-repetition\",\n \"first-social-institution\",\n \"advanced-specialization\",\n \"dominion-and-divine\",\n] as const;\n\nexport type AiGameTrainingStageGate =\n (typeof AI_GAME_TRAINING_STAGE_GATES)[number];\n\nexport const AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS = [\n \"low\",\n \"medium\",\n \"high\",\n] as const;\n\nexport type AiGameTrainingRecommendationConfidenceBand =\n (typeof AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS)[number];\n\nexport const AI_GAME_TRAINING_RECOMMENDATION_READINESS = [\n \"ready\",\n \"needs-prerequisites\",\n \"institution-gated\",\n] as const;\n\nexport type AiGameTrainingRecommendationReadiness =\n (typeof AI_GAME_TRAINING_RECOMMENDATION_READINESS)[number];\n\nexport interface AiGameInstitutionEligibility {\n readonly institutionId: string;\n readonly institutionType: TrainingInstitutionType;\n readonly track: MccExpressionTrack;\n readonly eligible: boolean;\n readonly requiredStageGate: AiGameTrainingStageGate;\n readonly trustLevel: TrainingTrustLevel;\n readonly unmetPrerequisiteCodes: readonly string[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameTrainingTrustMarker {\n readonly markerId: string;\n readonly institutionId: string;\n readonly trustLevel: TrainingTrustLevel;\n readonly source: TrainingTrustMarkerSource;\n readonly awardedAtIso: string;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameSpecializationRecommendation {\n readonly recommendationId: string;\n readonly institutionId: string;\n readonly institutionType: TrainingInstitutionType;\n readonly leaning: MccExpressionTrack;\n readonly recommendedTrack: MccExpressionTrack;\n readonly confidenceBand: AiGameTrainingRecommendationConfidenceBand;\n readonly readiness: AiGameTrainingRecommendationReadiness;\n readonly unmetPrerequisiteCodes: readonly string[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGameTrainingStateSnapshot {\n readonly progression: TrainingProgressionRecord;\n readonly institution: TrainingInstitution;\n readonly eligibility: readonly AiGameInstitutionEligibility[];\n readonly trustMarkers: readonly AiGameTrainingTrustMarker[];\n readonly recommendations: readonly AiGameSpecializationRecommendation[];\n}\n\nexport interface AiGameAcademicTrainingSnapshot {\n readonly schoolProgression: TrainingSchoolProgression;\n readonly academyAdmissions: readonly TrainingAcademyAdmission[];\n readonly trackSelections: readonly TrainingTrackSelection[];\n readonly recommendations: readonly AiGameSpecializationRecommendation[];\n}\n\nexport interface AiGameMartialTrainingSnapshot {\n readonly barracksDrills: readonly TrainingBarracksDrill[];\n readonly missionTechniqueUnlocks: readonly TrainingMissionTechniqueUnlock[];\n readonly martialTechniques: readonly TrainingMartialTechnique[];\n readonly antiSpellFieldcraft: readonly TrainingAntiSpellFieldcraftDiscipline[];\n}\n\nfunction freezeReadonlyArray<T>(items: readonly T[]): readonly T[] {\n return Object.freeze([...items]);\n}\n\nfunction assertNonEmptyString(value: string, label: string): void {\n if (value.trim().length === 0) {\n throw new Error(`${label} must be a non-empty string`);\n }\n}\n\nfunction assertIsoTimestamp(value: string, label: string): void {\n assertNonEmptyString(value, label);\n\n if (Number.isNaN(Date.parse(value))) {\n throw new Error(`${label} must be an ISO-8601 timestamp`);\n }\n}\n\nfunction isTrainingInstitutionType(value: string): value is TrainingInstitutionType {\n return value === \"school\"\n || value === \"barracks\"\n || value === \"academy\"\n || value === \"apprenticeship\";\n}\n\nexport function isAiGameTrainingStageGate(\n value: string,\n): value is AiGameTrainingStageGate {\n return (AI_GAME_TRAINING_STAGE_GATES as readonly string[]).includes(value);\n}\n\nexport function isAiGameTrainingRecommendationConfidenceBand(\n value: string,\n): value is AiGameTrainingRecommendationConfidenceBand {\n return (AI_GAME_TRAINING_RECOMMENDATION_CONFIDENCE_BANDS as readonly string[]).includes(value);\n}\n\nexport function isAiGameTrainingRecommendationReadiness(\n value: string,\n): value is AiGameTrainingRecommendationReadiness {\n return (AI_GAME_TRAINING_RECOMMENDATION_READINESS as readonly string[]).includes(value);\n}\n\nexport function createAiGameInstitutionEligibility(\n input: AiGameInstitutionEligibility,\n): AiGameInstitutionEligibility {\n assertNonEmptyString(input.institutionId, \"institutionId\");\n\n if (!isTrainingInstitutionType(input.institutionType)) {\n throw new Error(\"institutionType must be a supported training institution type\");\n }\n\n if (!isMccExpressionTrack(input.track)) {\n throw new Error(\"track must be a supported MCC expression track\");\n }\n\n if (!isAiGameTrainingStageGate(input.requiredStageGate)) {\n throw new Error(\"requiredStageGate must be a supported training stage gate\");\n }\n\n if (!isTrainingTrustLevel(input.trustLevel)) {\n throw new Error(\"trustLevel must be a supported training trust level\");\n }\n\n return Object.freeze({\n ...input,\n unmetPrerequisiteCodes: freezeReadonlyArray(input.unmetPrerequisiteCodes),\n reasonCodes: freezeReadonlyArray(input.reasonCodes),\n });\n}\n\nexport function createAiGameTrainingTrustMarker(\n input: AiGameTrainingTrustMarker,\n): AiGameTrainingTrustMarker {\n return createTrainingTrustMarker(input);\n}\n\nexport function createAiGameSpecializationRecommendation(\n input: AiGameSpecializationRecommendation,\n): AiGameSpecializationRecommendation {\n assertNonEmptyString(input.recommendationId, \"recommendationId\");\n assertNonEmptyString(input.institutionId, \"institutionId\");\n\n if (!isTrainingInstitutionType(input.institutionType)) {\n throw new Error(\"institutionType must be a supported training institution type\");\n }\n\n if (!isMccExpressionTrack(input.leaning)) {\n throw new Error(\"leaning must be a supported MCC expression track\");\n }\n\n if (!isMccExpressionTrack(input.recommendedTrack)) {\n throw new Error(\"recommendedTrack must be a supported MCC expression track\");\n }\n\n if (!isAiGameTrainingRecommendationConfidenceBand(input.confidenceBand)) {\n throw new Error(\"confidenceBand must be a supported training recommendation confidence band\");\n }\n\n if (!isAiGameTrainingRecommendationReadiness(input.readiness)) {\n throw new Error(\"readiness must be a supported training recommendation readiness\");\n }\n\n return Object.freeze({\n ...input,\n unmetPrerequisiteCodes: freezeReadonlyArray(input.unmetPrerequisiteCodes),\n reasonCodes: freezeReadonlyArray(input.reasonCodes),\n });\n}\n\nexport function createAiGameTrainingStateSnapshot(\n input: AiGameTrainingStateSnapshot,\n): AiGameTrainingStateSnapshot {\n return Object.freeze({\n progression: createTrainingProgressionRecord(input.progression),\n institution: createTrainingInstitution(input.institution),\n eligibility: freezeReadonlyArray(\n input.eligibility.map(createAiGameInstitutionEligibility),\n ),\n trustMarkers: freezeReadonlyArray(\n input.trustMarkers.map(createAiGameTrainingTrustMarker),\n ),\n recommendations: freezeReadonlyArray(\n input.recommendations.map(createAiGameSpecializationRecommendation),\n ),\n });\n}\n\nexport function createAiGameAcademicTrainingSnapshot(\n input: AiGameAcademicTrainingSnapshot,\n): AiGameAcademicTrainingSnapshot {\n return Object.freeze({\n schoolProgression: createTrainingSchoolProgression(input.schoolProgression),\n academyAdmissions: freezeReadonlyArray(\n input.academyAdmissions.map(createTrainingAcademyAdmission),\n ),\n trackSelections: freezeReadonlyArray(\n input.trackSelections.map(createTrainingTrackSelection),\n ),\n recommendations: freezeReadonlyArray(\n input.recommendations.map(createAiGameSpecializationRecommendation),\n ),\n });\n}\n\nexport function createAiGameMartialTrainingSnapshot(\n input: AiGameMartialTrainingSnapshot,\n): AiGameMartialTrainingSnapshot {\n return Object.freeze({\n barracksDrills: freezeReadonlyArray(\n input.barracksDrills.map(createTrainingBarracksDrill),\n ),\n missionTechniqueUnlocks: freezeReadonlyArray(\n input.missionTechniqueUnlocks.map(createTrainingMissionTechniqueUnlock),\n ),\n martialTechniques: freezeReadonlyArray(\n input.martialTechniques.map(createTrainingMartialTechnique),\n ),\n antiSpellFieldcraft: freezeReadonlyArray(\n input.antiSpellFieldcraft.map(createTrainingAntiSpellFieldcraftDiscipline),\n ),\n });\n}\n","export const AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID =\n \"isekai.player-system.core.enabled\";\n\nexport const AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION = \"1.0\" as const;\n\nexport type AiGamePlayerSystemContractVersion =\n typeof AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION;\n\nexport const AI_GAME_PLAYER_SYSTEM_FOCUS_MODES = [\n \"ambient\",\n \"focused\",\n \"combat-safe\",\n] as const;\n\nexport type AiGamePlayerSystemFocusMode =\n (typeof AI_GAME_PLAYER_SYSTEM_FOCUS_MODES)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES = [\"voice\", \"touch\"] as const;\n\nexport type AiGamePlayerSystemInputModality =\n (typeof AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_MODULES = [\n \"identity\",\n \"missions\",\n \"guild-quests\",\n \"event-log\",\n \"mcc\",\n \"tutorial\",\n \"points-store\",\n] as const;\n\nexport type AiGamePlayerSystemModule =\n (typeof AI_GAME_PLAYER_SYSTEM_MODULES)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES = [\n \"critical\",\n \"high\",\n \"normal\",\n \"low\",\n] as const;\n\nexport type AiGamePlayerSystemAlertPriority =\n (typeof AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS = [\n \"combat\",\n \"exploration\",\n \"crafting\",\n \"social\",\n \"governance\",\n] as const;\n\nexport type AiGamePlayerSystemPreferenceKind =\n (typeof AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES = [\n \"explicit\",\n \"observed\",\n] as const;\n\nexport type AiGamePlayerSystemPreferenceSource =\n (typeof AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES)[number];\n\nexport const AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS = [\n \"low\",\n \"medium\",\n \"high\",\n] as const;\n\nexport type AiGamePlayerSystemConfidenceBand =\n (typeof AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS)[number];\n\nexport interface AiGamePlayerSystemFocusModeContract {\n readonly contractVersion: AiGamePlayerSystemContractVersion;\n readonly mode: AiGamePlayerSystemFocusMode;\n readonly acceptsInputModalities: readonly AiGamePlayerSystemInputModality[];\n readonly allowsFullNavigation: boolean;\n readonly maximumVisibleModules: number;\n readonly deliverableAlertPriorities: readonly AiGamePlayerSystemAlertPriority[];\n}\n\nexport interface AiGamePlayerSystemModuleContract {\n readonly contractVersion: AiGamePlayerSystemContractVersion;\n readonly module: AiGamePlayerSystemModule;\n readonly requiresFocusedMode: boolean;\n readonly availableInCombatSafeMode: boolean;\n readonly supportedInputModalities: readonly AiGamePlayerSystemInputModality[];\n}\n\nexport interface AiGamePlayerSystemAlert {\n readonly alertId: string;\n readonly contractVersion: AiGamePlayerSystemContractVersion;\n readonly priority: AiGamePlayerSystemAlertPriority;\n readonly sourceModule: AiGamePlayerSystemModule;\n readonly title: string;\n readonly message: string;\n readonly createdAtIso: string;\n}\n\nexport interface AiGamePlayerSystemPreferenceInput {\n readonly inputId: string;\n readonly kind: AiGamePlayerSystemPreferenceKind;\n readonly source: AiGamePlayerSystemPreferenceSource;\n readonly confidenceScore: number;\n readonly capturedAtIso: string;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface AiGamePlayerSystemPreferenceConfidenceState {\n readonly confidenceScore: number;\n readonly confidenceBand: AiGamePlayerSystemConfidenceBand;\n readonly sampleCount: number;\n readonly lastUpdatedAtIso: string;\n}\n\nexport interface AiGamePlayerSystemPreferenceProfile {\n readonly profileId: string;\n readonly contractVersion: AiGamePlayerSystemContractVersion;\n readonly inputs: readonly AiGamePlayerSystemPreferenceInput[];\n readonly confidence: AiGamePlayerSystemPreferenceConfidenceState;\n}\n\nexport interface AiGamePlayerSystemSession {\n readonly sessionId: string;\n readonly contractVersion: AiGamePlayerSystemContractVersion;\n readonly featureFlagId: typeof AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID;\n readonly focusMode: AiGamePlayerSystemFocusMode;\n readonly activeModule: AiGamePlayerSystemModule | null;\n readonly modules: readonly AiGamePlayerSystemModuleContract[];\n readonly acceptedInputModalities: readonly AiGamePlayerSystemInputModality[];\n readonly pendingAlerts: readonly AiGamePlayerSystemAlert[];\n readonly preferenceProfile: AiGamePlayerSystemPreferenceProfile;\n}\n\nexport interface CreateAiGamePlayerSystemSessionInput {\n readonly sessionId: string;\n readonly focusMode: AiGamePlayerSystemFocusMode;\n readonly activeModule?: AiGamePlayerSystemModule | null;\n readonly modules?: readonly AiGamePlayerSystemModuleContract[];\n readonly acceptedInputModalities?: readonly AiGamePlayerSystemInputModality[];\n readonly pendingAlerts?: readonly AiGamePlayerSystemAlert[];\n readonly preferenceProfile: AiGamePlayerSystemPreferenceProfile;\n}\n\nconst DEFAULT_FOCUS_MODE_CONTRACTS: Readonly<\n Record<AiGamePlayerSystemFocusMode, AiGamePlayerSystemFocusModeContract>\n> = Object.freeze({\n ambient: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n mode: \"ambient\",\n acceptsInputModalities: Object.freeze([]) as readonly AiGamePlayerSystemInputModality[],\n allowsFullNavigation: false,\n maximumVisibleModules: 1,\n deliverableAlertPriorities: Object.freeze([\n \"critical\",\n \"high\",\n \"normal\",\n \"low\",\n ]) as readonly AiGamePlayerSystemAlertPriority[],\n }),\n focused: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n mode: \"focused\",\n acceptsInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n allowsFullNavigation: true,\n maximumVisibleModules: 3,\n deliverableAlertPriorities: Object.freeze([\n \"critical\",\n \"high\",\n \"normal\",\n \"low\",\n ]) as readonly AiGamePlayerSystemAlertPriority[],\n }),\n \"combat-safe\": Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n mode: \"combat-safe\",\n acceptsInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n allowsFullNavigation: false,\n maximumVisibleModules: 1,\n deliverableAlertPriorities: Object.freeze([\n \"critical\",\n \"high\",\n ]) as readonly AiGamePlayerSystemAlertPriority[],\n }),\n});\n\nconst DEFAULT_MODULE_CONTRACTS: Readonly<\n Record<AiGamePlayerSystemModule, AiGamePlayerSystemModuleContract>\n> = Object.freeze({\n identity: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"identity\",\n requiresFocusedMode: false,\n availableInCombatSafeMode: true,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n missions: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"missions\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n \"guild-quests\": Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"guild-quests\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n \"event-log\": Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"event-log\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n mcc: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"mcc\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n tutorial: Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"tutorial\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n \"points-store\": Object.freeze({\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n module: \"points-store\",\n requiresFocusedMode: true,\n availableInCombatSafeMode: false,\n supportedInputModalities: Object.freeze([\n \"voice\",\n \"touch\",\n ]) as readonly AiGamePlayerSystemInputModality[],\n }),\n});\n\nconst DEFAULT_SESSION_MODULES = Object.freeze([DEFAULT_MODULE_CONTRACTS.identity]);\n\nexport const AI_GAME_PLAYER_SYSTEM_FOCUS_MODE_CONTRACTS = Object.freeze(\n AI_GAME_PLAYER_SYSTEM_FOCUS_MODES.map(\n (mode) => DEFAULT_FOCUS_MODE_CONTRACTS[mode],\n ),\n);\n\nexport const AI_GAME_PLAYER_SYSTEM_MODULE_CONTRACTS = Object.freeze(\n AI_GAME_PLAYER_SYSTEM_MODULES.map((module) => DEFAULT_MODULE_CONTRACTS[module]),\n);\n\nfunction freezeReadonlyArray<T>(items: readonly T[]): readonly T[] {\n return Object.freeze([...items]);\n}\n\nfunction assertNonEmptyString(value: string, label: string): void {\n if (value.trim().length === 0) {\n throw new Error(`${label} must be a non-empty string`);\n }\n}\n\nfunction assertContractVersion(\n value: string,\n label = \"contractVersion\",\n): asserts value is AiGamePlayerSystemContractVersion {\n if (value !== AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION) {\n throw new Error(`${label} must be ${AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION}`);\n }\n}\n\nfunction assertIsoTimestamp(value: string, label: string): void {\n assertNonEmptyString(value, label);\n\n if (Number.isNaN(Date.parse(value))) {\n throw new Error(`${label} must be an ISO-8601 timestamp`);\n }\n}\n\nfunction assertConfidenceScore(value: number, label = \"confidenceScore\"): void {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new Error(`${label} must be between 0 and 1`);\n }\n}\n\nfunction assertNonNegativeInteger(value: number, label: string): void {\n if (!Number.isInteger(value) || value < 0) {\n throw new Error(`${label} must be a non-negative integer`);\n }\n}\n\nfunction isMember<T extends string>(value: string, members: readonly T[]): value is T {\n return (members as readonly string[]).includes(value);\n}\n\nexport function isAiGamePlayerSystemFocusMode(\n value: string,\n): value is AiGamePlayerSystemFocusMode {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_FOCUS_MODES);\n}\n\nexport function isAiGamePlayerSystemInputModality(\n value: string,\n): value is AiGamePlayerSystemInputModality {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_INPUT_MODALITIES);\n}\n\nexport function isAiGamePlayerSystemModule(\n value: string,\n): value is AiGamePlayerSystemModule {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_MODULES);\n}\n\nexport function isAiGamePlayerSystemAlertPriority(\n value: string,\n): value is AiGamePlayerSystemAlertPriority {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES);\n}\n\nexport function isAiGamePlayerSystemPreferenceKind(\n value: string,\n): value is AiGamePlayerSystemPreferenceKind {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_KINDS);\n}\n\nexport function isAiGamePlayerSystemPreferenceSource(\n value: string,\n): value is AiGamePlayerSystemPreferenceSource {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_PREFERENCE_SOURCES);\n}\n\nexport function isAiGamePlayerSystemConfidenceBand(\n value: string,\n): value is AiGamePlayerSystemConfidenceBand {\n return isMember(value, AI_GAME_PLAYER_SYSTEM_CONFIDENCE_BANDS);\n}\n\nexport function getAiGamePlayerSystemFocusModeContract(\n mode: AiGamePlayerSystemFocusMode,\n): AiGamePlayerSystemFocusModeContract {\n return DEFAULT_FOCUS_MODE_CONTRACTS[mode];\n}\n\nexport function getAiGamePlayerSystemModuleContract(\n module: AiGamePlayerSystemModule,\n): AiGamePlayerSystemModuleContract {\n return DEFAULT_MODULE_CONTRACTS[module];\n}\n\nexport function isAiGamePlayerSystemAlertDeliverable(\n alert: Pick<AiGamePlayerSystemAlert, \"priority\">,\n mode: AiGamePlayerSystemFocusMode,\n): boolean {\n return getAiGamePlayerSystemFocusModeContract(mode).deliverableAlertPriorities.includes(\n alert.priority,\n );\n}\n\nexport function selectAiGamePlayerSystemAlertsForFocusMode(\n alerts: readonly AiGamePlayerSystemAlert[],\n mode: AiGamePlayerSystemFocusMode,\n): readonly AiGamePlayerSystemAlert[] {\n return freezeReadonlyArray(\n alerts.filter((alert) => isAiGamePlayerSystemAlertDeliverable(alert, mode)),\n );\n}\n\nexport function createAiGamePlayerSystemAlert(\n input: Omit<AiGamePlayerSystemAlert, \"contractVersion\"> & {\n readonly contractVersion?: AiGamePlayerSystemContractVersion;\n },\n): AiGamePlayerSystemAlert {\n assertNonEmptyString(input.alertId, \"alertId\");\n assertNonEmptyString(input.title, \"title\");\n assertNonEmptyString(input.message, \"message\");\n assertIsoTimestamp(input.createdAtIso, \"createdAtIso\");\n assertContractVersion(input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION);\n\n if (!isAiGamePlayerSystemAlertPriority(input.priority)) {\n throw new Error(\"priority must be a supported Player System alert priority\");\n }\n\n if (!isAiGamePlayerSystemModule(input.sourceModule)) {\n throw new Error(\"sourceModule must be a supported Player System module\");\n }\n\n return Object.freeze({\n ...input,\n contractVersion:\n input.contractVersion ?? AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n });\n}\n\nexport function resolveAiGamePlayerSystemConfidenceBand(\n confidenceScore: number,\n): AiGamePlayerSystemConfidenceBand {\n assertConfidenceScore(confidenceScore);\n\n if (confidenceScore >= 0.67) {\n return \"high\";\n }\n\n if (confidenceScore >= 0.34) {\n return \"medium\";\n }\n\n return \"low\";\n}\n\nexport function createAiGamePlayerSystemPreferenceInput(\n input: Omit<AiGamePlayerSystemPreferenceInput, \"reasonCodes\"> & {\n readonly reasonCodes?: readonly string[];\n },\n): AiGamePlayerSystemPreferenceInput {\n assertNonEmptyString(input.inputId, \"inputId\");\n assertIsoTimestamp(input.capturedAtIso, \"capturedAtIso\");\n assertConfidenceScore(input.confidenceScore);\n\n if (!isAiGamePlayerSystemPreferenceKind(input.kind)) {\n throw new Error(\"kind must be a supported Player System preference kind\");\n }\n\n if (!isAiGamePlayerSystemPreferenceSource(input.source)) {\n throw new Error(\"source must be a supported Player System preference source\");\n }\n\n return Object.freeze({\n ...input,\n reasonCodes: freezeReadonlyArray(input.reasonCodes ?? []),\n });\n}\n\nexport function createAiGamePlayerSystemPreferenceConfidenceState(\n input: Omit<AiGamePlayerSystemPreferenceConfidenceState, \"confidenceBand\"> & {\n readonly confidenceBand?: AiGamePlayerSystemConfidenceBand;\n },\n): AiGamePlayerSystemPreferenceConfidenceState {\n assertConfidenceScore(input.confidenceScore);\n assertNonNegativeInteger(input.sampleCount, \"sampleCount\");\n assertIsoTimestamp(input.lastUpdatedAtIso, \"lastUpdatedAtIso\");\n\n const confidenceBand = resolveAiGamePlayerSystemConfidenceBand(\n input.confidenceScore,\n );\n\n if (input.confidenceBand !== undefined && input.confidenceBand !== confidenceBand) {\n throw new Error(\"confidenceBand must match confidenceScore\");\n }\n\n return Object.freeze({\n confidenceScore: input.confidenceScore,\n confidenceBand,\n sampleCount: input.sampleCount,\n lastUpdatedAtIso: input.lastUpdatedAtIso,\n });\n}\n\nexport function createAiGamePlayerSystemPreferenceProfile(input: {\n readonly profileId: string;\n readonly inputs?: readonly AiGamePlayerSystemPreferenceInput[];\n readonly confidence?: Omit<\n AiGamePlayerSystemPreferenceConfidenceState,\n \"confidenceBand\"\n > & { readonly confidenceBand?: AiGamePlayerSystemConfidenceBand };\n}): AiGamePlayerSystemPreferenceProfile {\n assertNonEmptyString(input.profileId, \"profileId\");\n\n const inputs = (input.inputs ?? []).map((preferenceInput) =>\n createAiGamePlayerSystemPreferenceInput(preferenceInput),\n );\n const lastUpdatedAtIso =\n input.confidence?.lastUpdatedAtIso ?? new Date(0).toISOString();\n const confidenceScore =\n input.confidence?.confidenceScore ??\n (inputs.length === 0\n ? 0\n : inputs.reduce((total, preferenceInput) => total + preferenceInput.confidenceScore, 0) /\n inputs.length);\n const confidence = createAiGamePlayerSystemPreferenceConfidenceState({\n confidenceScore,\n sampleCount: input.confidence?.sampleCount ?? inputs.length,\n lastUpdatedAtIso,\n confidenceBand: input.confidence?.confidenceBand,\n });\n\n return Object.freeze({\n profileId: input.profileId,\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n inputs: freezeReadonlyArray(inputs),\n confidence,\n });\n}\n\nexport function createAiGamePlayerSystemSession(\n input: CreateAiGamePlayerSystemSessionInput,\n): AiGamePlayerSystemSession {\n assertNonEmptyString(input.sessionId, \"sessionId\");\n\n if (!isAiGamePlayerSystemFocusMode(input.focusMode)) {\n throw new Error(\"focusMode must be a supported Player System focus mode\");\n }\n\n if (\n input.activeModule !== null &&\n input.activeModule !== undefined &&\n !isAiGamePlayerSystemModule(input.activeModule)\n ) {\n throw new Error(\"activeModule must be a supported Player System module\");\n }\n\n const modeContract = getAiGamePlayerSystemFocusModeContract(input.focusMode);\n const modules = freezeReadonlyArray(\n (input.modules ?? DEFAULT_SESSION_MODULES).map((moduleContract) =>\n Object.freeze({\n ...moduleContract,\n supportedInputModalities: freezeReadonlyArray(\n moduleContract.supportedInputModalities,\n ),\n }),\n ),\n );\n const acceptedInputModalities = freezeReadonlyArray(\n input.acceptedInputModalities ?? modeContract.acceptsInputModalities,\n );\n const pendingAlerts = freezeReadonlyArray(\n (input.pendingAlerts ?? []).map((alert) => createAiGamePlayerSystemAlert(alert)),\n );\n\n if (modules.length > modeContract.maximumVisibleModules) {\n throw new Error(\"modules exceed the focus mode visibility limit\");\n }\n\n for (const modality of acceptedInputModalities) {\n if (!isAiGamePlayerSystemInputModality(modality)) {\n throw new Error(\"acceptedInputModalities contains an unsupported modality\");\n }\n }\n\n if (\n input.focusMode === \"focused\" &&\n (!acceptedInputModalities.includes(\"voice\") ||\n !acceptedInputModalities.includes(\"touch\"))\n ) {\n throw new Error(\"focused sessions must accept both voice and touch input\");\n }\n\n for (const moduleContract of modules) {\n assertContractVersion(moduleContract.contractVersion, \"module contractVersion\");\n\n if (!isAiGamePlayerSystemModule(moduleContract.module)) {\n throw new Error(\"modules contains an unsupported Player System module\");\n }\n\n for (const modality of moduleContract.supportedInputModalities) {\n if (!isAiGamePlayerSystemInputModality(modality)) {\n throw new Error(\"modules contains an unsupported input modality\");\n }\n }\n\n if (\n input.focusMode === \"combat-safe\" &&\n !moduleContract.availableInCombatSafeMode\n ) {\n throw new Error(\"combat-safe sessions cannot expose unsafe modules\");\n }\n }\n\n if (\n input.activeModule !== null &&\n input.activeModule !== undefined &&\n !modules.some((moduleContract) => moduleContract.module === input.activeModule)\n ) {\n throw new Error(\"activeModule must be included in modules\");\n }\n\n return Object.freeze({\n sessionId: input.sessionId,\n contractVersion: AI_GAME_PLAYER_SYSTEM_CONTRACT_VERSION,\n featureFlagId: AI_GAME_PLAYER_SYSTEM_FEATURE_FLAG_ID,\n focusMode: input.focusMode,\n activeModule: input.activeModule ?? null,\n modules,\n acceptedInputModalities,\n pendingAlerts,\n preferenceProfile: createAiGamePlayerSystemPreferenceProfile({\n profileId: input.preferenceProfile.profileId,\n inputs: input.preferenceProfile.inputs,\n confidence: input.preferenceProfile.confidence,\n }),\n });\n}\n","export type Version = string;\nexport type JsonValue =\n | null\n | boolean\n | number\n | string\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type GameWorldEventType =\n | \"monster.spawned\"\n | \"monster.killed\"\n | \"dungeon.created\"\n | \"dungeon.cleared\"\n | \"war.declared\"\n | \"war.resolved\"\n | \"famine.started\"\n | \"surplus.updated\"\n | \"system.checkpoint\";\n\nexport type GameEventVisibilityClass = \"global\" | \"regional\" | \"local\" | \"faction\" | \"secret\";\nexport type GameEventRecordType = \"candidate\" | \"canonical\";\nexport type GameEventSubmissionChannel = \"player\" | \"system\" | \"admin\" | \"simulation\";\nexport type GameEventActorKind = \"player\" | \"npc\" | \"monster\" | \"system\" | \"faction\" | \"environment\";\nexport type GameEventParticipantRole = \"causer\" | \"target\" | \"witness\" | \"owner\" | \"observer\";\nexport type GameEventSeverity = \"info\" | \"warning\" | \"critical\";\n\nexport interface GameEventActor {\n readonly kind: GameEventActorKind;\n readonly subjectRef: string;\n}\n\nexport interface GameEventParticipant {\n readonly role: GameEventParticipantRole;\n readonly actor: GameEventActor;\n}\n\nexport interface GameEventLocation {\n readonly world: string;\n readonly zone: string;\n readonly x?: number;\n readonly y?: number;\n readonly radiusMeters?: number;\n}\n\nexport interface GameEventCausation {\n readonly rootEventId?: string;\n readonly parentEventIds: readonly string[];\n readonly correlationId?: string;\n}\n\nexport interface GameWorldEventPayloadBase {\n readonly eventKind: GameEventSeverity;\n readonly summary: string;\n}\n\nexport interface MonsterSpawnedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.spawned\";\n readonly monsterType: string;\n readonly monsterRef: string;\n}\n\nexport interface MonsterKilledPayload extends GameWorldEventPayloadBase {\n readonly kind: \"monster.killed\";\n readonly monsterRef: string;\n readonly killerRef?: string;\n readonly encounterResult: \"vanquished\" | \"escaped\" | \"failed\";\n}\n\nexport interface DungeonCreatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.created\";\n readonly dungeonRef: string;\n readonly dungeonType: string;\n readonly difficulty: number;\n}\n\nexport interface DungeonClearedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"dungeon.cleared\";\n readonly dungeonRef: string;\n readonly clearedByPartyRef: string;\n readonly durationSeconds: number;\n}\n\nexport interface WarDeclaredPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.declared\";\n readonly aggressorFactionRef: string;\n readonly defenderFactionRef: string;\n readonly disputedZone: string;\n}\n\nexport interface WarResolvedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"war.resolved\";\n readonly warEventRef: string;\n readonly outcome: \"ceasefire\" | \"victory\" | \"loss\" | \"draw\";\n readonly winnerFactionRef?: string;\n}\n\nexport interface FamineStartedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"famine.started\";\n readonly zoneRef: string;\n readonly severity: \"low\" | \"moderate\" | \"high\" | \"critical\";\n}\n\nexport interface SurplusUpdatedPayload extends GameWorldEventPayloadBase {\n readonly kind: \"surplus.updated\";\n readonly commodity: string;\n readonly region: string;\n readonly previousBalance: number;\n readonly delta: number;\n}\n\nexport interface SystemCheckpointPayload extends GameWorldEventPayloadBase {\n readonly kind: \"system.checkpoint\";\n readonly sequence: string;\n readonly checkpointState: JsonValue;\n}\n\nexport type GameWorldEventPayload =\n | MonsterSpawnedPayload\n | MonsterKilledPayload\n | DungeonCreatedPayload\n | DungeonClearedPayload\n | WarDeclaredPayload\n | WarResolvedPayload\n | FamineStartedPayload\n | SurplusUpdatedPayload\n | SystemCheckpointPayload;\n\nexport interface GameWorldEventEnvelope {\n readonly eventId: string;\n readonly eventType: GameWorldEventType;\n readonly occurredAtEpochMs: number;\n readonly recordedAtEpochMs: number;\n readonly schemaVersion: string;\n readonly visibility: GameEventVisibilityClass;\n readonly location: GameEventLocation;\n readonly participants: readonly GameEventParticipant[];\n readonly causation: GameEventCausation;\n readonly source: string;\n readonly payload: GameWorldEventPayload;\n readonly tags: readonly string[];\n}\n\nexport interface GameWorldEventCandidate extends GameWorldEventEnvelope {\n readonly recordType: \"candidate\";\n readonly candidateId: string;\n readonly submittedBy?: GameEventActor;\n readonly submittedAtEpochMs: number;\n readonly submissionChannel: GameEventSubmissionChannel;\n}\n\nexport interface GameWorldEventCanonical extends GameWorldEventEnvelope {\n readonly recordType: \"canonical\";\n readonly canonicalEventId: string;\n readonly sourceCandidateId?: string;\n readonly approvedBy: string;\n readonly approvedAtEpochMs: number;\n}\n\nexport type GameWorldEvent = GameWorldEventCandidate | GameWorldEventCanonical;\n\nexport interface GameEventValidationIssue {\n readonly field: string;\n readonly message: string;\n readonly severity: GameEventSeverity;\n}\n\nexport interface GameEventValidationResult {\n readonly valid: boolean;\n readonly issues: readonly GameEventValidationIssue[];\n}\n\nexport interface GameEventSubmissionReceipt {\n readonly accepted: boolean;\n readonly candidateId: string;\n readonly eventId: string;\n readonly notes: readonly string[];\n}\n\nexport interface GameEventCommitReceipt {\n readonly committed: boolean;\n readonly eventId: string;\n readonly sequence: string;\n}\n\nexport interface ProjectionProjectorCheckpoint {\n readonly streamId: string;\n readonly lastAppliedEventOffset: number;\n readonly lastAppliedEventId: string;\n readonly eventVersion: Version;\n readonly updatedAtEpochMs: number;\n}\n\nexport interface ProjectionCheckpointStore {\n getCheckpoint(streamId: string): Promise<ProjectionProjectorCheckpoint | null>;\n setCheckpoint(checkpoint: ProjectionProjectorCheckpoint): Promise<void>;\n}\n\nexport interface WorldEventIngestionPort {\n submitCandidate(candidate: GameWorldEventCandidate): Promise<GameEventSubmissionReceipt>;\n commitCanonical(event: GameWorldEventCanonical): Promise<GameEventCommitReceipt>;\n validateCandidate(candidate: GameWorldEventCandidate): GameEventValidationResult;\n}\n\nexport interface WorldEventProjectorPort {\n readonly streamId: string;\n readonly checkpointStore: ProjectionCheckpointStore;\n project(event: GameWorldEventCanonical): Promise<void>;\n}\n\nexport type WorldIncidentImpactKey = \"security\" | \"economy\" | \"ecology\" | \"politics\" | \"morale\" | \"magic\" | \"population\";\n\nexport type WorldIncidentScope = \"local\" | \"regional\" | \"global\";\n\nexport type WorldIncidentLifecycle = \"active\" | \"resolved\" | \"superseded\" | \"expired\";\n\nexport interface WorldIncidentImpactVector {\n readonly security: number;\n readonly economy: number;\n readonly ecology: number;\n readonly politics: number;\n readonly morale: number;\n readonly magic: number;\n readonly population: number;\n}\n\nexport interface WorldIncidentResolution {\n readonly resolvedAtEpochMs: number;\n readonly closingEventRef: string;\n readonly summary: string;\n}\n\nexport interface WorldIncidentThread {\n readonly incidentId: string;\n readonly scope: WorldIncidentScope;\n readonly lifecycle: WorldIncidentLifecycle;\n readonly causeEventRef: string;\n readonly impact: WorldIncidentImpactVector;\n readonly openedAtEpochMs: number;\n readonly updatedAtEpochMs: number;\n readonly supersededBy?: string;\n readonly resolution?: WorldIncidentResolution;\n readonly affectedEventRefs: readonly string[];\n}\n\nexport interface WorldIncidentRegistry {\n readonly incidents: readonly WorldIncidentThread[];\n readonly activeCount: number;\n}\n\nexport function isCanonicalWorldEvent(event: GameWorldEvent): event is GameWorldEventCanonical {\n return event.recordType === \"canonical\";\n}\n\nexport function isCandidateWorldEvent(event: GameWorldEvent): event is GameWorldEventCandidate {\n return event.recordType === \"candidate\";\n}\n\nconst WORLD_IMPACT_SCALE_LIMIT = 100;\n\nfunction clampImpactValue(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n return Math.max(0, Math.min(WORLD_IMPACT_SCALE_LIMIT, value));\n}\n\nexport function normalizeIncidentImpactVector(\n impact: Partial<WorldIncidentImpactVector> | Record<string, number>,\n): Readonly<WorldIncidentImpactVector> {\n return Object.freeze({\n security: clampImpactValue(Number(impact.security ?? 0)),\n economy: clampImpactValue(Number(impact.economy ?? 0)),\n ecology: clampImpactValue(Number(impact.ecology ?? 0)),\n politics: clampImpactValue(Number(impact.politics ?? 0)),\n morale: clampImpactValue(Number(impact.morale ?? 0)),\n magic: clampImpactValue(Number(impact.magic ?? 0)),\n population: clampImpactValue(Number(impact.population ?? 0)),\n });\n}\n\nexport function isIncidentResolved(incident: WorldIncidentThread): boolean {\n return incident.lifecycle === \"resolved\" || incident.lifecycle === \"expired\";\n}\n","export type GossipSalience = \"low\" | \"medium\" | \"high\" | \"critical\";\nexport type GossipConfidence = \"uncertain\" | \"possible\" | \"strong\" | \"verified\";\nexport type GossipTopicStatus = \"active\" | \"corrected\" | \"resolved\" | \"stale\";\nexport type GossipAudienceSegment = \"player\" | \"npc\" | \"public\";\nexport type GossipProjectionMode = \"segment-level\" | \"npc-level\";\n\nexport interface EventSourceLink {\n readonly sourceType: \"event\" | \"incident\";\n readonly sourceId: string;\n}\n\nexport interface GossipSpeechHint {\n readonly sentenceTone: \"whisper\" | \"formal\" | \"urgent\";\n readonly localizedHintKey: string;\n}\n\nexport interface GossipTopicPayload {\n readonly factSummary: string;\n readonly certainty: number;\n readonly salience: GossipSalience;\n readonly evidenceRefs: readonly EventSourceLink[];\n readonly speechHint: GossipSpeechHint;\n}\n\nexport interface GossipTopic {\n readonly topicId: string;\n readonly status: GossipTopicStatus;\n readonly emittedAtEpochMs: number;\n readonly expiresAtEpochMs: number;\n readonly sourceLink: EventSourceLink;\n readonly sourceEventRef: string;\n readonly lineageOf?: string;\n readonly replacedBy?: string;\n readonly payload: GossipTopicPayload;\n readonly confidenceLevel: GossipConfidence;\n readonly audienceScope: \"faction\" | \"region\" | \"public\";\n}\n\nexport interface WitnessChannel {\n readonly witnessRef: string;\n readonly seenAtEpochMs: number;\n readonly confidenceWeight: number;\n}\n\nexport interface PerspectiveRule {\n readonly locality: readonly string[];\n readonly factions: readonly string[];\n readonly relationshipScore: number;\n}\n\nexport interface KnowledgeSource {\n readonly sourceType: \"segment\" | \"npc\";\n readonly sourceRef: string;\n readonly relationshipToAudience?: number;\n}\n\nexport interface GossipPerspectiveProjection {\n readonly projectionMode: GossipProjectionMode;\n readonly audienceSegment: GossipAudienceSegment;\n readonly requestedByNpcRef?: string;\n readonly locality: string;\n readonly faction: string;\n readonly segmentRules: readonly PerspectiveRule[];\n readonly witnessChannels: readonly WitnessChannel[];\n}\n\nexport interface ProjectedGossipEnvelope {\n readonly topicId: string;\n readonly visible: boolean;\n readonly redactedPayload?: GossipTopicPayload;\n readonly reasons: readonly string[];\n}\n\nexport interface GossipLifecyclePort {\n readonly topicId: string;\n load(): Promise<GossipTopic | null>;\n applyCorrection(next: GossipTopic): Promise<void>;\n markResolved(topicId: string, replacementTopicId?: string): Promise<void>;\n}\n\nexport interface GossipTopicEnvelope {\n readonly topic: GossipTopic;\n readonly topics: readonly EventSourceLink[];\n}\n\nexport function isGossipTopicActive(topic: GossipTopic, nowEpochMs = Date.now()): boolean {\n return topic.status === \"active\" && topic.expiresAtEpochMs > nowEpochMs && topic.payload.certainty >= 0.35;\n}\n\nexport function isGossipTopicCorrected(topic: GossipTopic): boolean {\n return topic.status === \"corrected\";\n}\n\nfunction matchSegmentAudience(\n sourceValue: readonly string[], targetValue: readonly string[], fallback: boolean,\n): boolean {\n if (sourceValue.length === 0 || targetValue.length === 0) {\n return fallback;\n }\n\n return sourceValue.some((value) => targetValue.includes(value));\n}\n\nexport function projectTopicForAudience(\n topic: GossipTopic,\n projection: GossipPerspectiveProjection,\n nowEpochMs = Date.now(),\n): ProjectedGossipEnvelope {\n if (!isGossipTopicActive(topic, nowEpochMs)) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"inactive-or-expired-topic\"],\n };\n }\n\n const hasMatchingRule = projection.segmentRules.some((rule) =>\n matchSegmentAudience(rule.locality, [projection.locality], true) &&\n matchSegmentAudience(rule.factions, [projection.faction], false)\n );\n\n if (!hasMatchingRule) {\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"audience-not-authorized\"],\n };\n }\n\n if (projection.projectionMode === \"segment-level\" && topic.audienceScope === \"public\") {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"segment-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope === \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n if (\n projection.projectionMode === \"npc-level\" &&\n projection.requestedByNpcRef &&\n topic.audienceScope !== \"public\" &&\n projection.requestedByNpcRef.length > 0\n ) {\n return {\n topicId: topic.topicId,\n visible: true,\n redactedPayload: topic.payload,\n reasons: [\"npc-level-allowed\"],\n };\n }\n\n return {\n topicId: topic.topicId,\n visible: false,\n reasons: [\"scope-constraints\"],\n };\n}\n","export const AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID =\n \"isekai.player-system.quiet-measure.enabled\";\n\nexport const QUIET_MEASURE_AXES = [\n \"selflessness\",\n \"give\",\n \"mercy\",\n \"duty\",\n \"principle\",\n \"courtesy\",\n] as const;\n\nexport type QuietMeasureAxis = (typeof QUIET_MEASURE_AXES)[number];\n\nexport const QUIET_MEASURE_CONFIDENCE_BANDS = [\"low\", \"medium\", \"high\"] as const;\n\nexport type QuietMeasureConfidenceBand =\n (typeof QUIET_MEASURE_CONFIDENCE_BANDS)[number];\n\nexport const QUIET_MEASURE_SIGNAL_BANDS = [\n \"suppressed\",\n \"latent\",\n \"present\",\n \"dominant\",\n] as const;\n\nexport type QuietMeasureSignalBand = (typeof QUIET_MEASURE_SIGNAL_BANDS)[number];\n\nexport const QUIET_MEASURE_PERSPECTIVES = [\n \"system-truth\",\n \"observed-reputation\",\n] as const;\n\nexport type QuietMeasurePerspective = (typeof QUIET_MEASURE_PERSPECTIVES)[number];\n\nexport const QUIET_MEASURE_EVIDENCE_CLASSES = [\n \"declared-intent\",\n \"costly-choice\",\n \"private-conduct\",\n \"repair-after-harm\",\n \"weak-party-treatment\",\n \"observed-pattern\",\n \"social-mask\",\n] as const;\n\nexport type QuietMeasureEvidenceClass =\n (typeof QUIET_MEASURE_EVIDENCE_CLASSES)[number];\n\nexport const QUIET_MEASURE_DERIVED_READS = [\n \"nature\",\n \"mask\",\n \"veil-gap\",\n \"restitution\",\n] as const;\n\nexport type QuietMeasureDerivedRead =\n (typeof QUIET_MEASURE_DERIVED_READS)[number];\n\nexport const QUIET_MEASURE_MISSION_PROBE_MODES = [\n \"clarify\",\n \"tempt\",\n \"reinforce\",\n] as const;\n\nexport type QuietMeasureMissionProbeMode =\n (typeof QUIET_MEASURE_MISSION_PROBE_MODES)[number];\n\nexport const QUIET_MEASURE_MISSION_RESOLUTION_SHAPES = [\n \"restorative\",\n \"dominant\",\n \"detached\",\n \"performative\",\n] as const;\n\nexport type QuietMeasureMissionResolutionShape =\n (typeof QUIET_MEASURE_MISSION_RESOLUTION_SHAPES)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_DISCLOSURES = [\n \"title-and-verdict-only\",\n] as const;\n\nexport type QuietMeasureJudgmentDisclosure =\n (typeof QUIET_MEASURE_JUDGMENT_DISCLOSURES)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_REQUESTERS = [\n \"player\",\n \"system\",\n \"operator\",\n] as const;\n\nexport type QuietMeasureJudgmentRequester =\n (typeof QUIET_MEASURE_JUDGMENT_REQUESTERS)[number];\n\nexport const QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [\n \"repeated-meaningful-evidence\",\n \"private-or-low-witness-evidence\",\n \"costly-pressure-event\",\n] as const;\n\nexport type QuietMeasureJudgmentMissingEvidence =\n (typeof QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE)[number];\n\nexport interface QuietMeasureEvidenceWindow {\n readonly evidenceClass: QuietMeasureEvidenceClass;\n readonly sampleBand: \"sparse\" | \"growing\" | \"settled\";\n readonly includesPrivateConduct: boolean;\n readonly includesCostlyPressureEvent: boolean;\n readonly includesRepairAfterHarm: boolean;\n}\n\nexport interface QuietMeasureAxisSummary {\n readonly axis: QuietMeasureAxis;\n readonly signalBand: QuietMeasureSignalBand;\n readonly confidenceBand: QuietMeasureConfidenceBand;\n readonly evidenceWindow: QuietMeasureEvidenceWindow;\n}\n\nexport interface QuietMeasureDerivedReadSummary {\n readonly read: QuietMeasureDerivedRead;\n readonly perspective: QuietMeasurePerspective;\n readonly signalBand: QuietMeasureSignalBand;\n readonly confidenceBand: QuietMeasureConfidenceBand;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureTitleDescriptor {\n readonly titleId: string;\n readonly title: string;\n readonly verdictLabel: string;\n readonly perspective: QuietMeasurePerspective;\n readonly disclosure: QuietMeasureJudgmentDisclosure;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureMissionProbe {\n readonly probeId: string;\n readonly mode: QuietMeasureMissionProbeMode;\n readonly primaryRead: QuietMeasureDerivedRead;\n readonly supportedResolutionShapes: readonly QuietMeasureMissionResolutionShape[];\n readonly hiddenRuntime: true;\n readonly responsePerspective: QuietMeasurePerspective;\n readonly responseBias:\n | \"virtue-biased\"\n | \"vice-viable\"\n | \"ambiguity-preserving\";\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureMissionResolutionMetadata {\n readonly resolutionShape: QuietMeasureMissionResolutionShape;\n readonly surplusTendency:\n | \"compounding-trust\"\n | \"fear-and-tribute\"\n | \"ambiguity-preserving\";\n readonly worldReactionMode: \"fertile\" | \"brittle\" | \"uncertain\";\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentRequest {\n readonly subjectId: string;\n readonly requestedAtUtc: string;\n readonly requestedBy: QuietMeasureJudgmentRequester;\n readonly disclosure: QuietMeasureJudgmentDisclosure;\n}\n\nexport interface QuietMeasureJudgmentEligibility {\n readonly eligible: boolean;\n readonly repeatedMeaningfulEvidence: boolean;\n readonly includesPrivateOrLowWitnessEvidence: boolean;\n readonly includesCostlyPressureEvent: boolean;\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentInsufficientEvidenceResponse {\n readonly kind: \"insufficient-evidence\";\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility & {\n readonly eligible: false;\n };\n readonly missingEvidence: readonly QuietMeasureJudgmentMissingEvidence[];\n readonly reasonCodes: readonly string[];\n}\n\nexport interface QuietMeasureJudgmentVerdictResponse {\n readonly kind: \"verdict\";\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility & {\n readonly eligible: true;\n };\n readonly title: QuietMeasureTitleDescriptor;\n readonly dominantReads: readonly QuietMeasureDerivedReadSummary[];\n readonly reasonCodes: readonly string[];\n}\n\nexport type QuietMeasureJudgmentResponse =\n | QuietMeasureJudgmentInsufficientEvidenceResponse\n | QuietMeasureJudgmentVerdictResponse;\n\nexport interface QuietMeasureJudgmentEligibilityInput {\n readonly repeatedMeaningfulEvidence?: boolean;\n readonly includesPrivateOrLowWitnessEvidence?: boolean;\n readonly includesCostlyPressureEvent?: boolean;\n readonly reasonCodes?: readonly string[];\n}\n\nexport interface CreateQuietMeasureJudgmentResponseInput {\n readonly request: QuietMeasureJudgmentRequest;\n readonly eligibility: QuietMeasureJudgmentEligibility;\n readonly title?: QuietMeasureTitleDescriptor;\n readonly dominantReads?: readonly QuietMeasureDerivedReadSummary[];\n readonly reasonCodes?: readonly string[];\n}\n\nfunction isMember<T extends string>(\n value: string,\n members: readonly T[],\n): value is T {\n return (members as readonly string[]).includes(value);\n}\n\nfunction assertRecord(value: unknown, label: string): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(`${label} must be an object.`);\n }\n\n return value as Record<string, unknown>;\n}\n\nfunction normalizeNonEmptyString(value: unknown, label: string): string {\n if (typeof value !== \"string\") {\n throw new TypeError(`${label} must be a non-empty string.`);\n }\n\n const normalized = value.trim();\n if (normalized.length === 0) {\n throw new TypeError(`${label} must be a non-empty string.`);\n }\n\n return normalized;\n}\n\nfunction normalizeBoolean(value: unknown, label: string): boolean {\n if (typeof value !== \"boolean\") {\n throw new TypeError(`${label} must be a boolean.`);\n }\n\n return value;\n}\n\nfunction normalizeOptionalBoolean(value: unknown, fallback: boolean, label: string): boolean {\n if (value === undefined) {\n return fallback;\n }\n\n return normalizeBoolean(value, label);\n}\n\nfunction normalizeTimestamp(value: unknown, label: string): string {\n const normalized = normalizeNonEmptyString(value, label);\n const parsed = Date.parse(normalized);\n\n if (Number.isNaN(parsed)) {\n throw new TypeError(`${label} must be a valid ISO-8601 timestamp.`);\n }\n\n return normalized;\n}\n\nfunction normalizeMember<T extends string>(\n value: unknown,\n members: readonly T[],\n label: string,\n): T {\n const normalized = normalizeNonEmptyString(value, label);\n\n if (!isMember(normalized, members)) {\n throw new TypeError(`${label} must be one of: ${members.join(\", \")}.`);\n }\n\n return normalized;\n}\n\nfunction normalizeReasonCodes(value: unknown, label: string): readonly string[] {\n if (value === undefined) {\n return Object.freeze([]);\n }\n\n if (!Array.isArray(value)) {\n throw new TypeError(`${label} must be an array of strings.`);\n }\n\n for (const [index, entry] of value.entries()) {\n if (typeof entry !== \"string\") {\n throw new TypeError(`${label}[${index}] must be a string.`);\n }\n }\n\n const normalized = value.map((entry) => entry.trim());\n if (normalized.some((entry) => entry.length === 0)) {\n throw new TypeError(`${label} must not contain blank strings.`);\n }\n\n return Object.freeze(Array.from(new Set(normalized)));\n}\n\nfunction normalizeJudgmentRequest(input: unknown): QuietMeasureJudgmentRequest {\n const request = assertRecord(input, \"Quiet Measure judgment request\");\n\n return Object.freeze({\n subjectId: normalizeNonEmptyString(\n request.subjectId,\n \"Quiet Measure judgment request subjectId\",\n ),\n requestedAtUtc: normalizeTimestamp(\n request.requestedAtUtc,\n \"Quiet Measure judgment request requestedAtUtc\",\n ),\n requestedBy: normalizeMember(\n request.requestedBy,\n QUIET_MEASURE_JUDGMENT_REQUESTERS,\n \"Quiet Measure judgment request requestedBy\",\n ),\n disclosure: normalizeMember(\n request.disclosure,\n QUIET_MEASURE_JUDGMENT_DISCLOSURES,\n \"Quiet Measure judgment request disclosure\",\n ),\n });\n}\n\nfunction normalizeJudgmentEligibility(input: unknown): QuietMeasureJudgmentEligibility {\n const eligibility = assertRecord(input, \"Quiet Measure judgment eligibility\");\n const repeatedMeaningfulEvidence = normalizeBoolean(\n eligibility.repeatedMeaningfulEvidence,\n \"Quiet Measure judgment eligibility repeatedMeaningfulEvidence\",\n );\n const includesPrivateOrLowWitnessEvidence = normalizeBoolean(\n eligibility.includesPrivateOrLowWitnessEvidence,\n \"Quiet Measure judgment eligibility includesPrivateOrLowWitnessEvidence\",\n );\n const includesCostlyPressureEvent = normalizeBoolean(\n eligibility.includesCostlyPressureEvent,\n \"Quiet Measure judgment eligibility includesCostlyPressureEvent\",\n );\n\n return Object.freeze({\n eligible:\n repeatedMeaningfulEvidence\n && includesPrivateOrLowWitnessEvidence\n && includesCostlyPressureEvent,\n repeatedMeaningfulEvidence,\n includesPrivateOrLowWitnessEvidence,\n includesCostlyPressureEvent,\n reasonCodes: normalizeReasonCodes(\n eligibility.reasonCodes,\n \"Quiet Measure eligibility reasonCodes\",\n ),\n });\n}\n\nfunction normalizeTitleDescriptor(input: unknown): QuietMeasureTitleDescriptor {\n const title = assertRecord(input, \"Quiet Measure title\");\n\n return Object.freeze({\n titleId: normalizeNonEmptyString(title.titleId, \"Quiet Measure title titleId\"),\n title: normalizeNonEmptyString(title.title, \"Quiet Measure title title\"),\n verdictLabel: normalizeNonEmptyString(\n title.verdictLabel,\n \"Quiet Measure title verdictLabel\",\n ),\n perspective: normalizeMember(\n title.perspective,\n QUIET_MEASURE_PERSPECTIVES,\n \"Quiet Measure title perspective\",\n ),\n disclosure: normalizeMember(\n title.disclosure,\n QUIET_MEASURE_JUDGMENT_DISCLOSURES,\n \"Quiet Measure title disclosure\",\n ),\n reasonCodes: normalizeReasonCodes(title.reasonCodes, \"Quiet Measure title reasonCodes\"),\n });\n}\n\nfunction normalizeDerivedReadSummary(\n input: unknown,\n index: number,\n): QuietMeasureDerivedReadSummary {\n const prefix = `Quiet Measure dominantReads[${index}]`;\n const dominantRead = assertRecord(input, prefix);\n\n return Object.freeze({\n read: normalizeMember(\n dominantRead.read,\n QUIET_MEASURE_DERIVED_READS,\n `${prefix} read`,\n ),\n perspective: normalizeMember(\n dominantRead.perspective,\n QUIET_MEASURE_PERSPECTIVES,\n `${prefix} perspective`,\n ),\n signalBand: normalizeMember(\n dominantRead.signalBand,\n QUIET_MEASURE_SIGNAL_BANDS,\n `${prefix} signalBand`,\n ),\n confidenceBand: normalizeMember(\n dominantRead.confidenceBand,\n QUIET_MEASURE_CONFIDENCE_BANDS,\n `${prefix} confidenceBand`,\n ),\n reasonCodes: normalizeReasonCodes(\n dominantRead.reasonCodes,\n `${prefix} reasonCodes`,\n ),\n });\n}\n\nfunction normalizeDominantReads(\n value: unknown,\n): readonly QuietMeasureDerivedReadSummary[] {\n if (value === undefined) {\n return Object.freeze([]);\n }\n\n if (!Array.isArray(value)) {\n throw new TypeError(\"Quiet Measure dominantReads must be an array.\");\n }\n\n return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));\n}\n\nexport function isQuietMeasureAxis(value: string): value is QuietMeasureAxis {\n return isMember(value, QUIET_MEASURE_AXES);\n}\n\nexport function isQuietMeasureMissionProbeMode(\n value: string,\n): value is QuietMeasureMissionProbeMode {\n return isMember(value, QUIET_MEASURE_MISSION_PROBE_MODES);\n}\n\nexport function isQuietMeasureMissionResolutionShape(\n value: string,\n): value is QuietMeasureMissionResolutionShape {\n return isMember(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);\n}\n\nexport function createQuietMeasureJudgmentEligibility(\n input: QuietMeasureJudgmentEligibilityInput = {},\n): QuietMeasureJudgmentEligibility {\n const repeatedMeaningfulEvidence = normalizeOptionalBoolean(\n input.repeatedMeaningfulEvidence,\n false,\n \"Quiet Measure eligibility repeatedMeaningfulEvidence\",\n );\n const includesPrivateOrLowWitnessEvidence = normalizeOptionalBoolean(\n input.includesPrivateOrLowWitnessEvidence,\n false,\n \"Quiet Measure eligibility includesPrivateOrLowWitnessEvidence\",\n );\n const includesCostlyPressureEvent = normalizeOptionalBoolean(\n input.includesCostlyPressureEvent,\n false,\n \"Quiet Measure eligibility includesCostlyPressureEvent\",\n );\n\n return Object.freeze({\n eligible:\n repeatedMeaningfulEvidence\n && includesPrivateOrLowWitnessEvidence\n && includesCostlyPressureEvent,\n repeatedMeaningfulEvidence,\n includesPrivateOrLowWitnessEvidence,\n includesCostlyPressureEvent,\n reasonCodes: normalizeReasonCodes(input.reasonCodes, \"Quiet Measure eligibility reasonCodes\"),\n });\n}\n\nexport function listQuietMeasureMissingEvidence(\n eligibility: QuietMeasureJudgmentEligibility,\n): readonly QuietMeasureJudgmentMissingEvidence[] {\n const normalizedEligibility = normalizeJudgmentEligibility(eligibility);\n const missing: QuietMeasureJudgmentMissingEvidence[] = [];\n\n if (!normalizedEligibility.repeatedMeaningfulEvidence) {\n missing.push(\"repeated-meaningful-evidence\");\n }\n\n if (!normalizedEligibility.includesPrivateOrLowWitnessEvidence) {\n missing.push(\"private-or-low-witness-evidence\");\n }\n\n if (!normalizedEligibility.includesCostlyPressureEvent) {\n missing.push(\"costly-pressure-event\");\n }\n\n return Object.freeze(missing);\n}\n\nexport function createQuietMeasureJudgmentResponse(\n input: CreateQuietMeasureJudgmentResponseInput,\n): QuietMeasureJudgmentResponse {\n const request = normalizeJudgmentRequest(input.request);\n const eligibility = normalizeJudgmentEligibility(input.eligibility);\n const missingEvidence = listQuietMeasureMissingEvidence(eligibility);\n const reasonCodes = normalizeReasonCodes(\n input.reasonCodes,\n \"Quiet Measure judgment response reasonCodes\",\n );\n const hasRequiredEvidence = missingEvidence.length === 0;\n\n if (!hasRequiredEvidence) {\n return Object.freeze({\n kind: \"insufficient-evidence\",\n request,\n eligibility: Object.freeze({\n ...eligibility,\n eligible: false,\n }),\n missingEvidence,\n reasonCodes,\n });\n }\n\n if (!input.title) {\n throw new TypeError(\n \"Quiet Measure verdict responses require a title descriptor when eligibility is met.\",\n );\n }\n\n return Object.freeze({\n kind: \"verdict\",\n request,\n eligibility: Object.freeze({\n ...eligibility,\n eligible: true,\n }),\n title: normalizeTitleDescript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