@plasius/ai-game 0.1.2 → 0.1.6

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export 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_FEATURE_FLAG_ID = \"ai.game.enabled\";\nexport const AI_GAME_ENV_PREFIX = \"AI_GAME\";\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 player action validation, NPC actions, gossip, and feedback.\",\n});\n"],"mappings":";AAOO,IAAM,kBAAkB;AACxB,IAAM,0BAA0B;AAChC,IAAM,qBAAqB;AAE3B,IAAM,oBAAyC,OAAO,OAAO;AAAA,EAClE,aAAa;AAAA,EACb,eAAe;AAAA,EACf,WAAW;AAAA,EACX,SAAS;AACX,CAAC;","names":[]}
1
+ {"version":3,"sources":["../src/points-store.ts","../src/world-events.ts","../src/gossip.ts","../src/index.ts"],"sourcesContent":["export const AI_GAME_POINTS_STORE_FEATURE_FLAG_ID = \"isekai.player-system.points-store.enabled\";\n\nexport const AI_GAME_POINTS_LEDGER_IDS = [\"pp\", \"esp\", \"tis\", \"dis\"] as const;\n\nexport type AiGamePointsLedgerId = (typeof AI_GAME_POINTS_LEDGER_IDS)[number];\n\nexport const AI_GAME_PLAYER_EVOLUTION_STAGES = [\"proto-social\", \"social-lock\"] as const;\n\nexport type AiGamePlayerEvolutionStage =\n (typeof AI_GAME_PLAYER_EVOLUTION_STAGES)[number];\n\nexport const AI_GAME_POINTS_AUTHORITY_BANDS = [\n \"self\",\n \"frontier\",\n \"civic\",\n \"divine\",\n] as const;\n\nexport type AiGamePointsAuthorityBand =\n (typeof AI_GAME_POINTS_AUTHORITY_BANDS)[number];\n\nexport const AI_GAME_POINTS_AUTHORITY_SYSTEMS = [\n \"player-system\",\n \"exploration-system\",\n \"territorial-influence-system\",\n \"divine-influence-system\",\n] as const;\n\nexport type AiGamePointsAuthoritySystem =\n (typeof AI_GAME_POINTS_AUTHORITY_SYSTEMS)[number];\n\nexport interface AiGamePointsAuthorityBoundary {\n readonly ledgerId: AiGamePointsLedgerId;\n readonly authorityBand: AiGamePointsAuthorityBand;\n readonly authoritySystem: AiGamePointsAuthoritySystem;\n readonly requiresWorldAuthority: boolean;\n readonly combatSafeOnly: boolean;\n}\n\nexport interface AiGamePointsLedgerSnapshot {\n readonly ledgerId: AiGamePointsLedgerId;\n readonly balance: number;\n readonly earnedTotal: number;\n readonly spentTotal: number;\n readonly committedTotal: number;\n readonly asOfEpochMs?: number;\n}\n\nexport interface AiGamePointsSpendAction {\n readonly actionId: string;\n readonly title: string;\n readonly cost: number;\n readonly prerequisiteCodes: readonly string[];\n readonly consequenceCodes: readonly string[];\n}\n\nexport interface AiGamePointsSpendPolicy {\n readonly policyId: string;\n readonly ledgerId: AiGamePointsLedgerId;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly actions: readonly AiGamePointsSpendAction[];\n}\n\nexport interface AiGameProtoSocialDevolutionPolicy {\n readonly actionId: \"return-to-slime\";\n readonly ledgerId: \"pp\";\n readonly cost: number;\n readonly requiredEvolutionStage: \"proto-social\";\n readonly closesAtEvolutionStage: \"social-lock\";\n readonly singleUse: true;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly prerequisiteCodes: readonly string[];\n readonly consequenceCodes: readonly string[];\n}\n\nexport interface ResolveAiGameProtoSocialDevolutionEligibilityInput {\n readonly evolutionStage: AiGamePlayerEvolutionStage;\n readonly currentBalance: number;\n readonly alreadyUsed: boolean;\n}\n\nexport interface AiGameProtoSocialDevolutionEligibilityResult {\n readonly available: boolean;\n readonly reasonCodes: readonly string[];\n readonly policy: AiGameProtoSocialDevolutionPolicy;\n}\n\nexport interface AiGameProtoSocialDevolutionExecution {\n readonly actionId: \"return-to-slime\";\n readonly ledgerId: \"pp\";\n readonly cost: number;\n readonly authorityBoundary: AiGamePointsAuthorityBoundary;\n readonly previousEvolutionStage: \"proto-social\";\n readonly resultingEvolutionStage: \"proto-social\";\n readonly consequenceCodes: readonly string[];\n}\n\nconst AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER: Readonly<\n Record<AiGamePointsLedgerId, AiGamePointsAuthorityBoundary>\n> = Object.freeze({\n pp: Object.freeze({\n ledgerId: \"pp\",\n authorityBand: \"self\",\n authoritySystem: \"player-system\",\n requiresWorldAuthority: false,\n combatSafeOnly: false,\n }),\n esp: Object.freeze({\n ledgerId: \"esp\",\n authorityBand: \"frontier\",\n authoritySystem: \"exploration-system\",\n requiresWorldAuthority: false,\n combatSafeOnly: true,\n }),\n tis: Object.freeze({\n ledgerId: \"tis\",\n authorityBand: \"civic\",\n authoritySystem: \"territorial-influence-system\",\n requiresWorldAuthority: true,\n combatSafeOnly: false,\n }),\n dis: Object.freeze({\n ledgerId: \"dis\",\n authorityBand: \"divine\",\n authoritySystem: \"divine-influence-system\",\n requiresWorldAuthority: true,\n combatSafeOnly: false,\n }),\n});\n\nconst AI_GAME_DEFAULT_POINTS_SPEND_POLICIES: readonly AiGamePointsSpendPolicy[] =\n Object.freeze([\n Object.freeze({\n policyId: \"pp-personal-respec\",\n ledgerId: \"pp\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"return-to-slime\",\n title: \"Return to slime\",\n cost: 12,\n prerequisiteCodes: Object.freeze([\"proto-social-window-open\", \"single-use-remaining\"]),\n consequenceCodes: Object.freeze([\"reset-social-form\", \"consume-pp-balance\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"esp-exploration-routing\",\n ledgerId: \"esp\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.esp,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"fast-travel-upgrade\",\n title: \"Unlock frontier fast travel\",\n cost: 8,\n prerequisiteCodes: Object.freeze([\"frontier-route-discovered\", \"out-of-combat-only\"]),\n consequenceCodes: Object.freeze([\"reduce-route-friction\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"tis-civic-investment\",\n ledgerId: \"tis\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.tis,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"district-favor\",\n title: \"Commit district influence favor\",\n cost: 5,\n prerequisiteCodes: Object.freeze([\"civic-authority-approval\"]),\n consequenceCodes: Object.freeze([\"alter-territorial-standing\"]),\n }),\n ]),\n }),\n Object.freeze({\n policyId: \"dis-divine-covenant\",\n ledgerId: \"dis\",\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.dis,\n actions: Object.freeze([\n Object.freeze({\n actionId: \"divine-oath\",\n title: \"Bind a divine covenant\",\n cost: 3,\n prerequisiteCodes: Object.freeze([\"divine-clearance-granted\"]),\n consequenceCodes: Object.freeze([\"alter-divine-standing\"]),\n }),\n ]),\n }),\n ]);\n\nconst AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY: AiGameProtoSocialDevolutionPolicy =\n Object.freeze({\n actionId: \"return-to-slime\",\n ledgerId: \"pp\",\n cost: 12,\n requiredEvolutionStage: \"proto-social\",\n closesAtEvolutionStage: \"social-lock\",\n singleUse: true,\n authorityBoundary: AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER.pp,\n prerequisiteCodes: Object.freeze([\"proto-social-window-open\", \"single-use-remaining\"]),\n consequenceCodes: Object.freeze([\"reset-social-form\", \"consume-pp-balance\"]),\n });\n\nfunction normalizeNonNegativeInteger(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n\n return Math.max(0, Math.trunc(value));\n}\n\nexport function isAiGamePointsLedgerId(value: string): value is AiGamePointsLedgerId {\n return (AI_GAME_POINTS_LEDGER_IDS as readonly string[]).includes(value);\n}\n\nexport function isAiGamePlayerEvolutionStage(\n value: string,\n): value is AiGamePlayerEvolutionStage {\n return (AI_GAME_PLAYER_EVOLUTION_STAGES as readonly string[]).includes(value);\n}\n\nexport function resolveAiGamePointsAuthorityBoundary(\n ledgerId: AiGamePointsLedgerId,\n): AiGamePointsAuthorityBoundary {\n return AI_GAME_POINTS_AUTHORITY_BOUNDARY_BY_LEDGER[ledgerId];\n}\n\nexport function createAiGamePointsLedgerSnapshot(\n input: AiGamePointsLedgerSnapshot,\n): AiGamePointsLedgerSnapshot {\n return Object.freeze({\n ledgerId: input.ledgerId,\n balance: normalizeNonNegativeInteger(input.balance),\n earnedTotal: normalizeNonNegativeInteger(input.earnedTotal),\n spentTotal: normalizeNonNegativeInteger(input.spentTotal),\n committedTotal: normalizeNonNegativeInteger(input.committedTotal),\n asOfEpochMs: input.asOfEpochMs,\n });\n}\n\nexport function getDefaultAiGamePointsSpendPolicies(): readonly AiGamePointsSpendPolicy[] {\n return AI_GAME_DEFAULT_POINTS_SPEND_POLICIES;\n}\n\nexport function getAiGameProtoSocialDevolutionPolicy(): AiGameProtoSocialDevolutionPolicy {\n return AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;\n}\n\n/**\n * Evaluate whether the one-time PP devolution action is still allowed.\n */\nexport function evaluateAiGameProtoSocialDevolutionEligibility(\n input: ResolveAiGameProtoSocialDevolutionEligibilityInput,\n): AiGameProtoSocialDevolutionEligibilityResult {\n const reasonCodes: string[] = [];\n const policy = AI_GAME_PROTO_SOCIAL_DEVOLUTION_POLICY;\n const currentBalance = normalizeNonNegativeInteger(input.currentBalance);\n\n if (input.evolutionStage !== policy.requiredEvolutionStage) {\n reasonCodes.push(\"devolution-window-closed\");\n }\n\n if (input.alreadyUsed) {\n reasonCodes.push(\"devolution-already-used\");\n }\n\n if (currentBalance < policy.cost) {\n reasonCodes.push(\"insufficient-pp-balance\");\n }\n\n if (reasonCodes.length === 0) {\n reasonCodes.push(\"devolution-allowed\");\n }\n\n return Object.freeze({\n available: reasonCodes.length === 1 && reasonCodes[0] === \"devolution-allowed\",\n reasonCodes: Object.freeze(reasonCodes),\n policy,\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","import { AI_GAME_POINTS_STORE_FEATURE_FLAG_ID } from \"./points-store.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 pointsStore: AI_GAME_POINTS_STORE_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 aiGameFeatureFlags.pointsStore,\n]);\n\nexport {\n createAiGamePointsLedgerSnapshot,\n evaluateAiGameProtoSocialDevolutionEligibility,\n getAiGameProtoSocialDevolutionPolicy,\n getDefaultAiGamePointsSpendPolicies,\n isAiGamePlayerEvolutionStage,\n isAiGamePointsLedgerId,\n resolveAiGamePointsAuthorityBoundary,\n} from \"./points-store.js\";\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 * from \"./points-store.js\";\nexport * from \"./world-events.js\";\nexport * from \"./gossip.js\";\n"],"mappings":";AAAO,IAAM,uCAAuC;AAE7C,IAAM,4BAA4B,CAAC,MAAM,OAAO,OAAO,KAAK;AAI5D,IAAM,kCAAkC,CAAC,gBAAgB,aAAa;AAKtE,IAAM,iCAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,mCAAmC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAuEA,IAAM,8CAEF,OAAO,OAAO;AAAA,EAChB,IAAI,OAAO,OAAO;AAAA,IAChB,UAAU;AAAA,IACV,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,wBAAwB;AAA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C;","names":[]}
@@ -0,0 +1,27 @@
1
+ # ADR-0002: Canonical world event envelope and classification
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ Downstream systems (ingestion, gossip, analytics, and gameplay systems) require a stable event envelope shared across producers and consumers.
12
+
13
+ ## Decision
14
+
15
+ - Define a canonical `GameWorldEventCandidate` / `GameWorldEventCanonical` envelope split.
16
+ - Explicitly include identity, causation, timestamps, location, visibility, participants, and schema version metadata.
17
+ - Keep event payloads typed by event family (`monster.*`, `dungeon.*`, `war.*`, `famine.*`, `surplus.*`) with a required severity/tone summary pattern.
18
+
19
+ ## Alternatives Considered
20
+
21
+ - Unstructured JSON payload contracts: rejected because of weak typing and weak replay semantics.
22
+ - Reusing generic graph envelopes: rejected because gameplay semantics require richer visibility and actor metadata.
23
+
24
+ ## Consequences
25
+
26
+ - Consumers can filter by event family, actor role, and visibility class.
27
+ - Canonical storage and downstream projections stay deterministic and testable.
@@ -0,0 +1,29 @@
1
+ # ADR-0002: Game AI Task Contracts and Speech Cache Safety
2
+
3
+ - Date: 2026-05-14
4
+ - Status: Accepted
5
+
6
+ ## Context
7
+
8
+ The `@plasius/ai-game` package began as a package boundary scaffold while `#266` and `#273` were still open. The implementation needed concrete, testable contracts for:
9
+
10
+ - player-action validation intents
11
+ - NPC action/dialogue/gossip/governance task types
12
+ - gameplay authority boundaries for high-impact outcomes
13
+ - player-address text handling before speech render to control cache reuse
14
+
15
+ ## Decision
16
+
17
+ The package now exports stable contracts for:
18
+
19
+ - deterministic task classification from free text (`classifyAiGameTask`)
20
+ - batched task resolution for actor-role-aware workflow gating (`resolveAiGameTaskBatch`)
21
+ - player-address redaction + TTS cache decisioning (`resolveAiGamePlayerAddressText`)
22
+
23
+ `ai.game-agentic-workloads.enabled` is the primary feature gate for all task resolution decisions. Existing speech-feature flags are surfaced for cache behavior alignment but do not change the package boundary contract.
24
+
25
+ ## Consequences
26
+
27
+ - Consumers receive a single point of contract for gameplay task risk classes and fallback paths.
28
+ - High-impact gameplay decisions are represented as deterministic/operator-review/blocked outcomes, enabling explicit human fallback.
29
+ - Default speech payloads remove player/account identifiers before cache reuse decisions.
@@ -0,0 +1,28 @@
1
+ # ADR-0003: Authoritative ingestion, append-only ledger, and projector interfaces
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ Candidate submissions and canonical events must remain authoritative and replay-safe for downstream consumers.
12
+
13
+ ## Decision
14
+
15
+ - Split contract into candidate and canonical forms.
16
+ - Add validation receipt and commit interfaces for candidate flow.
17
+ - Add projector-facing checkpoint interfaces to represent deterministic replay progress independent of domain-specific storage.
18
+ - Require downstream consumers to use explicit checkpoint stores instead of implicit idempotency assumptions.
19
+
20
+ ## Alternatives Considered
21
+
22
+ - Immediate-upsert-only persistence: rejected because it cannot support strict replay/validation guarantees.
23
+ - No explicit checkpoint contracts: rejected due auditability and restart safety needs.
24
+
25
+ ## Consequences
26
+
27
+ - Ingestion paths can clearly distinguish accepted vs pending candidate events.
28
+ - Replay behavior is explicit and can be shared via generic graph primitives.
@@ -0,0 +1,27 @@
1
+ # ADR-0004: Incident lifecycle, resolution, and world impact vectors
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ Long-lived world effects (war, famine, supply disruptions) need stable lifecycle and impact modeling.
12
+
13
+ ## Decision
14
+
15
+ - Represent incidents with explicit lifecycle states and resolution metadata.
16
+ - Define a bounded numeric impact vector with clamped values and scope.
17
+ - Include source event references and optional superseding links to preserve causality.
18
+
19
+ ## Alternatives Considered
20
+
21
+ - Event-only logging without explicit incidents: rejected because downstream analytics and gameplay effects need stateful summaries.
22
+ - Ad-hoc numeric metadata maps: rejected in favor of constrained impact vectors.
23
+
24
+ ## Consequences
25
+
26
+ - Incident queries can identify active/resolved/superseded/expired state consistently.
27
+ - Impact ordering and deterministic ranking can be implemented from a shared contract.
@@ -0,0 +1,26 @@
1
+ # ADR-0005: Structured gossip topics as output boundary
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ NPC dialogue must be driven from structured content, not pre-rendered prose.
12
+
13
+ ## Decision
14
+
15
+ - Define gossip topics with source references, certainty, salience, certainty and speech hints.
16
+ - Model source lineage and expiry explicitly so downstream generators can choose rendering shape.
17
+
18
+ ## Alternatives Considered
19
+
20
+ - Pre-generated dialogue strings as contract: rejected to avoid localization and moderation lock-in.
21
+ - Domain-agnostic freeform payload: rejected because moderation and projection rules become inconsistent.
22
+
23
+ ## Consequences
24
+
25
+ - Dialogue/NPC rendering can generate language locally and safely from structured facts.
26
+ - Source/event linkage remains stable across systems.
@@ -0,0 +1,27 @@
1
+ # ADR-0006: Perspective-gated relative knowledge projection
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ Gossip needs to be constrained by locality, faction, and witness confidence.
12
+
13
+ ## Decision
14
+
15
+ - Add projection envelopes for segment and NPC modes.
16
+ - Require witness channels, locality, faction, and relationship context as first-class fields.
17
+ - Require confidence and audience segment controls before topic becomes visible in an NPC projection.
18
+
19
+ ## Alternatives Considered
20
+
21
+ - Global visibility model: rejected to prevent omniscience and data leakage.
22
+ - Ad-hoc projection filtering in consumers: rejected because this logic belongs in a shared contract boundary.
23
+
24
+ ## Consequences
25
+
26
+ - Projection rules are testable and centrally documented.
27
+ - Consumers can enforce “secret/non-public” states without duplicating domain-specific checks.
@@ -0,0 +1,27 @@
1
+ # ADR-0007: Gossip spread, decay, correction, and resolution
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ Rumors should decay, be corrected, and resolve with preserved lineage.
12
+
13
+ ## Decision
14
+
15
+ - Add explicit topic statuses for active, corrected, resolved, and stale topics.
16
+ - Preserve lineage through replacement/supersession references.
17
+ - Expose expiration windows and projection status to allow deterministic age-based behavior.
18
+
19
+ ## Alternatives Considered
20
+
21
+ - Blind overwrite of prior topics: rejected because it loses correction/audit trace.
22
+ - Hard delete on correction: rejected because consumers need traceability and rollbacks.
23
+
24
+ ## Consequences
25
+
26
+ - Gossip pipelines can model correction and resolution without ambiguity.
27
+ - Consumers can report or render rumor lineage and freshness metadata.
@@ -0,0 +1,36 @@
1
+ # ADR-0008: Quiet Measure public contracts and hidden runtime boundary
2
+
3
+ ## Status
4
+
5
+ - Accepted
6
+ - Date: 2026-05-14
7
+ - Version: 1.0
8
+
9
+ ## Context
10
+
11
+ The Isekai Player System needs a hidden character-inference layer that can shape missions, social reactions, and explicit Judgment rituals.
12
+
13
+ That layer must be discoverable through the public `@plasius/ai-*` package family for developers, evaluators, and deep players, but runtime hosts must not be forced into exposing raw hidden metrics as an ordinary UI feature.
14
+
15
+ ## Decision
16
+
17
+ - Reserve `@plasius/ai-game` as the public contract boundary for Quiet Measure concepts, including hidden axes, evidence summaries, mission-probe archetypes, Judgment request/response models, and caste-title descriptors.
18
+ - Keep raw per-player scores, private inference weights, evidence retention strategy, and host-specific disclosure policy outside the public contract package.
19
+ - Model the difference between System-scoped truth and NPC/faction-scoped observed reputation explicitly so hosts do not collapse omniscient judgment into every consumer.
20
+ - Prefer structured verdicts and reason codes over freeform alignment prose in public contracts.
21
+ - Keep evaluation fixtures and regression datasets for hero-villain-mask classification in `@plasius/ai-evals` rather than embedding them into `@plasius/ai-game`.
22
+
23
+ ## Alternatives Considered
24
+
25
+ - Keep Quiet Measure entirely private with no public contracts:
26
+ - rejected because cross-package integration, public discoverability, and downstream tooling become inconsistent.
27
+ - Publish raw runtime score storage models:
28
+ - rejected because hosts need freedom to keep player-specific hidden data private and nondisplayed.
29
+ - Put the feature primarily in `@plasius/ai` instead of `@plasius/ai-game`:
30
+ - rejected because the domain concepts are game-specific rather than generic capability contracts.
31
+
32
+ ## Consequences
33
+
34
+ - Deep technical consumers can discover that the hidden system exists without receiving a turnkey visible morality meter.
35
+ - Host applications can implement different storage, privacy, and disclosure policies while sharing one canonical contract vocabulary.
36
+ - `@plasius/ai-evals` becomes the natural home for regression fixtures that test fake heroes, fake villains, tyrants, protectors, and redemption arcs.
@@ -0,0 +1,57 @@
1
+ # ADR 0009: Protected-main releases use release-prep PRs and reconciled version state
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-06-13
5
+
6
+ ## Context
7
+
8
+ `@plasius/ai-game` publishes from `.github/workflows/cd.yml`, but the original workflow mutated `package.json`, created tags, and pushed release metadata directly back to protected `main`.
9
+
10
+ That path failed under branch protection, and the repository also drifted behind already-published release state:
11
+
12
+ - `package.json` on `main` remained at `0.1.2`,
13
+ - npm latest and the published GitHub release were already `0.1.3`,
14
+ - origin still carried the `v0.1.3` release tag.
15
+
16
+ Without reconciling package, tag, and npm state first, future release attempts can either fail on protected-branch writes or try to reuse a version that is already published.
17
+
18
+ ## Decision
19
+
20
+ Protected `main` releases will use a two-phase workflow:
21
+
22
+ 1. `workflow_dispatch` prepares a `release/vX.Y.Z` branch and PR from `main`.
23
+ 2. Merging that PR back to `main` makes the unpublished versioned metadata available on `main`, where the publish job can tag, draft the GitHub release, publish to npm, and then publish the GitHub release.
24
+
25
+ Release preparation must derive its base version from the highest known semantic version across:
26
+
27
+ - `package.json`,
28
+ - the latest published npm version, and
29
+ - existing `v*` Git tags on origin.
30
+
31
+ The workflow will then apply the requested bump on top of that reconciled base so lagging `package.json` values cannot reuse or collide with an already-published release number.
32
+
33
+ When repository settings prevent GitHub Actions from creating pull requests, the workflow will still push the release-preparation branch and emit the manual PR URL instead of failing the run.
34
+
35
+ When a release version is already present on `main`, operators may run the workflow with `bump: none` to publish that prepared version directly without opening another release-preparation branch.
36
+
37
+ Release preparation must create the `release/vX.Y.Z` branch from the currently checked out commit before committing version and changelog edits so those metadata changes are preserved on the release branch instead of being discarded by a reset to `origin/main`.
38
+
39
+ Release preparation must promote the `## [Unreleased]` section through a tested helper instead of fragile inline shell text processing so the versioned release section is actually written into the release-preparation commit.
40
+
41
+ ## Consequences
42
+
43
+ - Release metadata now flows through an approved pull-request path instead of an unauthorized direct push to protected `main`.
44
+ - Existing published/tagged versions remain authoritative when repository version metadata lags.
45
+ - The release-preparation commit always carries the versioned changelog section that the publish gate requires on `main`.
46
+ - Publish no longer depends on merge-commit text matching a release prefix; it keys off unpublished versioned metadata on `main` instead.
47
+ - Changelog promotion now runs through a tested helper, preventing silent release-prep commits that only bump `package.json`.
48
+ - The version-selection logic is isolated in a helper with regression tests so future release-drift bugs are easier to catch locally.
49
+
50
+ ## Alternatives considered
51
+
52
+ - Keeping direct workflow pushes to `main`.
53
+ Rejected because branch protection forbids that path and it already failed in production.
54
+ - Using `package.json` as the sole release source of truth.
55
+ Rejected because it can lag behind already-published npm and GitHub release state.
56
+ - Manually bumping repository version metadata after every release drift incident.
57
+ Rejected because it is error-prone and does not prevent recurrence.
@@ -1,3 +1,11 @@
1
1
  # Architecture Decision Records
2
2
 
3
3
  - [ADR-0001: @plasius/ai-game Package Boundary](./adr-0001-package-boundary.md)
4
+ - [ADR-0002: Canonical world event envelope and classification](./adr-0002-canonical-world-event-envelope-and-classification.md)
5
+ - [ADR-0003: Authoritative ingestion, append-only ledger, and projector interfaces](./adr-0003-authoritative-ingestion-append-only-ledger-and-projections.md)
6
+ - [ADR-0004: Incident lifecycle, resolution, and world impact vectors](./adr-0004-incident-lifecycle-resolution-and-world-impact.md)
7
+ - [ADR-0005: Structured gossip topics as the output boundary](./adr-0005-structured-gossip-topics-as-the-output-boundary.md)
8
+ - [ADR-0006: Perspective-gated relative knowledge projection](./adr-0006-perspective-gated-relative-knowledge-projection.md)
9
+ - [ADR-0007: Gossip spread, decay, correction, and resolution](./adr-0007-gossip-spread-decay-correction-and-resolution.md)
10
+ - [ADR-0008: Quiet Measure public contracts and hidden runtime boundary](./adr-0008-quiet-measure-public-contracts-and-hidden-runtime-boundary.md)
11
+ - [ADR-0009: Protected-main releases use release-prep PRs and reconciled version state](./adr-0009-protected-main-release-preparation-and-version-reconciliation.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasius/ai-game",
3
- "version": "0.1.2",
3
+ "version": "0.1.6",
4
4
  "description": "Game-domain AI contracts for player action validation, NPC actions, gossip, and feedback.",
5
5
  "type": "module",
6
6
  "sideEffects": false,