@plasius/ai-game 0.5.0 → 0.6.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 +16 -0
- package/README.md +23 -1
- package/dist/index.cjs +334 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +313 -5
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0016-observed-event-log-and-gossip-export-contract-boundary.md +52 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,21 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
17
17
|
- **Security**
|
|
18
18
|
- (placeholder)
|
|
19
19
|
|
|
20
|
+
## [0.6.0] - 2026-07-11
|
|
21
|
+
|
|
22
|
+
- **Added**
|
|
23
|
+
- Added observed-event log, recency-window, highlight-summary, and gossip-export contracts under `isekai.player-system.logs.enabled`.
|
|
24
|
+
- Added defensive validation and immutable factories so gossip highlights can only reference the observed events in their source window.
|
|
25
|
+
|
|
26
|
+
- **Changed**
|
|
27
|
+
- (placeholder)
|
|
28
|
+
|
|
29
|
+
- **Fixed**
|
|
30
|
+
- (placeholder)
|
|
31
|
+
|
|
32
|
+
- **Security**
|
|
33
|
+
- (placeholder)
|
|
34
|
+
|
|
20
35
|
## [0.5.0] - 2026-07-11
|
|
21
36
|
|
|
22
37
|
- **Added**
|
|
@@ -214,3 +229,4 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
214
229
|
[0.3.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.3.0
|
|
215
230
|
[0.4.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.4.0
|
|
216
231
|
[0.5.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.5.0
|
|
232
|
+
[0.6.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.6.0
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @plasius/ai-game
|
|
2
2
|
|
|
3
|
-
Game-domain AI contracts for player action validation, adaptive System missions, NPC actions, gossip, Quiet Measure mission probes, Judgment disclosure surfaces, and Player System-readable training recommendations.
|
|
3
|
+
Game-domain AI contracts for player action validation, adaptive System missions, NPC actions, gossip, observed event logs, Quiet Measure mission probes, Judgment disclosure surfaces, and Player System-readable training recommendations.
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
@@ -156,6 +156,27 @@ and `selectAiGameVisibleIdentityTargets()` before rendering line-of-sight
|
|
|
156
156
|
surfaces. The contract does not carry hidden truth or authority-owned mutation
|
|
157
157
|
data.
|
|
158
158
|
|
|
159
|
+
## Observed event log and gossip export contracts
|
|
160
|
+
|
|
161
|
+
Observed event contracts provide a shared, privacy-safe basis for Player System
|
|
162
|
+
logs and gossip transport under `isekai.player-system.logs.enabled`:
|
|
163
|
+
|
|
164
|
+
- `AiGameObservedEvent` carries bounded domain references, summaries, visibility,
|
|
165
|
+
significance, and tags without raw player telemetry or account identifiers.
|
|
166
|
+
- `AiGameObservedEventRecencyWindow` validates that events fall inside a single
|
|
167
|
+
time-bounded window.
|
|
168
|
+
- `AiGameObservedEventHighlightSummary` references event IDs from its source
|
|
169
|
+
window rather than copying event truth.
|
|
170
|
+
- `AiGameGossipExport` packages one recency window and validated highlights for
|
|
171
|
+
a declared player, NPC, or public audience.
|
|
172
|
+
|
|
173
|
+
Use `createAiGameObservedEvent()`,
|
|
174
|
+
`createAiGameObservedEventRecencyWindow()`,
|
|
175
|
+
`createAiGameObservedEventHighlightSummary()`, and
|
|
176
|
+
`createAiGameGossipExport()` at package boundaries. Audience authorization,
|
|
177
|
+
feature-flag evaluation, persistence, and gossip generation remain the
|
|
178
|
+
responsibility of consuming services.
|
|
179
|
+
|
|
159
180
|
## Development
|
|
160
181
|
|
|
161
182
|
```bash
|
|
@@ -178,6 +199,7 @@ npm run pack:check
|
|
|
178
199
|
- `isekai.player-system.core.enabled`
|
|
179
200
|
- `isekai.player-system.guidance-nfr.enabled`
|
|
180
201
|
- `isekai.player-system.identity.enabled`
|
|
202
|
+
- `isekai.player-system.logs.enabled`
|
|
181
203
|
- `isekai.training.institutions.enabled`
|
|
182
204
|
- `isekai.training.academies.enabled`
|
|
183
205
|
- `isekai.training.martial.enabled`
|
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID: () => AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
27
27
|
AI_GAME_FEATURE_FLAGS: () => AI_GAME_FEATURE_FLAGS,
|
|
28
28
|
AI_GAME_FEATURE_FLAG_ID: () => AI_GAME_FEATURE_FLAG_ID,
|
|
29
|
+
AI_GAME_GOSSIP_EXPORT_AUDIENCES: () => AI_GAME_GOSSIP_EXPORT_AUDIENCES,
|
|
29
30
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
30
31
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
31
32
|
AI_GAME_IDENTITY_CONTRACT_VERSION: () => AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
@@ -49,6 +50,16 @@ __export(index_exports, {
|
|
|
49
50
|
AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING: () => AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
|
|
50
51
|
AI_GAME_MISSION_REWARD_CAP_SEMANTICS: () => AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
|
|
51
52
|
AI_GAME_MISSION_REWARD_KINDS: () => AI_GAME_MISSION_REWARD_KINDS,
|
|
53
|
+
AI_GAME_OBSERVED_EVENT_KINDS: () => AI_GAME_OBSERVED_EVENT_KINDS,
|
|
54
|
+
AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION: () => AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION,
|
|
55
|
+
AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID: () => AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID,
|
|
56
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH: () => AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH,
|
|
57
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAGS: () => AI_GAME_OBSERVED_EVENT_MAX_TAGS,
|
|
58
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH: () => AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH,
|
|
59
|
+
AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS: () => AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS,
|
|
60
|
+
AI_GAME_OBSERVED_EVENT_SIGNIFICANCE: () => AI_GAME_OBSERVED_EVENT_SIGNIFICANCE,
|
|
61
|
+
AI_GAME_OBSERVED_EVENT_SOURCES: () => AI_GAME_OBSERVED_EVENT_SOURCES,
|
|
62
|
+
AI_GAME_OBSERVED_EVENT_VISIBILITIES: () => AI_GAME_OBSERVED_EVENT_VISIBILITIES,
|
|
52
63
|
AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
|
|
53
64
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
54
65
|
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES: () => AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
@@ -106,8 +117,10 @@ __export(index_exports, {
|
|
|
106
117
|
aiGameFeatureFlags: () => aiGameFeatureFlags,
|
|
107
118
|
assertAiGameIdentityProjectionContractVersion: () => assertAiGameIdentityProjectionContractVersion,
|
|
108
119
|
assertAiGameMissionContractVersion: () => assertAiGameMissionContractVersion,
|
|
120
|
+
assertAiGameObservedEventLogContractVersion: () => assertAiGameObservedEventLogContractVersion,
|
|
109
121
|
classifyAiGameTask: () => classifyAiGameTask,
|
|
110
122
|
createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
|
|
123
|
+
createAiGameGossipExport: () => createAiGameGossipExport,
|
|
111
124
|
createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
|
|
112
125
|
createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
|
|
113
126
|
createAiGameIdentityTargetProjection: () => createAiGameIdentityTargetProjection,
|
|
@@ -123,6 +136,9 @@ __export(index_exports, {
|
|
|
123
136
|
createAiGameMissionRewardBound: () => createAiGameMissionRewardBound,
|
|
124
137
|
createAiGameMissionRewardEnvelope: () => createAiGameMissionRewardEnvelope,
|
|
125
138
|
createAiGameMissionRewardGrant: () => createAiGameMissionRewardGrant,
|
|
139
|
+
createAiGameObservedEvent: () => createAiGameObservedEvent,
|
|
140
|
+
createAiGameObservedEventHighlightSummary: () => createAiGameObservedEventHighlightSummary,
|
|
141
|
+
createAiGameObservedEventRecencyWindow: () => createAiGameObservedEventRecencyWindow,
|
|
126
142
|
createAiGamePlayerSystemAlert: () => createAiGamePlayerSystemAlert,
|
|
127
143
|
createAiGamePlayerSystemGuidanceCue: () => createAiGamePlayerSystemGuidanceCue,
|
|
128
144
|
createAiGamePlayerSystemPreferenceConfidenceState: () => createAiGamePlayerSystemPreferenceConfidenceState,
|
|
@@ -142,6 +158,7 @@ __export(index_exports, {
|
|
|
142
158
|
getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
|
|
143
159
|
getAiGamePlayerSystemGuidanceFallbackContract: () => getAiGamePlayerSystemGuidanceFallbackContract,
|
|
144
160
|
getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
|
|
161
|
+
isAiGameGossipExportAudience: () => isAiGameGossipExportAudience,
|
|
145
162
|
isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
|
|
146
163
|
isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
|
|
147
164
|
isAiGameIdentityTargetCategory: () => isAiGameIdentityTargetCategory,
|
|
@@ -157,6 +174,10 @@ __export(index_exports, {
|
|
|
157
174
|
isAiGameMissionRepeatedSignalHandling: () => isAiGameMissionRepeatedSignalHandling,
|
|
158
175
|
isAiGameMissionRewardCapSemantic: () => isAiGameMissionRewardCapSemantic,
|
|
159
176
|
isAiGameMissionRewardKind: () => isAiGameMissionRewardKind,
|
|
177
|
+
isAiGameObservedEventKind: () => isAiGameObservedEventKind,
|
|
178
|
+
isAiGameObservedEventSignificance: () => isAiGameObservedEventSignificance,
|
|
179
|
+
isAiGameObservedEventSource: () => isAiGameObservedEventSource,
|
|
180
|
+
isAiGameObservedEventVisibility: () => isAiGameObservedEventVisibility,
|
|
160
181
|
isAiGamePlayerSystemAlertDeliverable: () => isAiGamePlayerSystemAlertDeliverable,
|
|
161
182
|
isAiGamePlayerSystemAlertPriority: () => isAiGamePlayerSystemAlertPriority,
|
|
162
183
|
isAiGamePlayerSystemConfidenceBand: () => isAiGamePlayerSystemConfidenceBand,
|
|
@@ -1382,6 +1403,293 @@ function assertAiGameIdentityProjectionContractVersion(value) {
|
|
|
1382
1403
|
assertContractVersion3(value);
|
|
1383
1404
|
}
|
|
1384
1405
|
|
|
1406
|
+
// src/observed-events.ts
|
|
1407
|
+
var AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID = "isekai.player-system.logs.enabled";
|
|
1408
|
+
var AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION = "1.0";
|
|
1409
|
+
var AI_GAME_OBSERVED_EVENT_KINDS = [
|
|
1410
|
+
"combat",
|
|
1411
|
+
"crafting",
|
|
1412
|
+
"discovery",
|
|
1413
|
+
"mission",
|
|
1414
|
+
"social",
|
|
1415
|
+
"travel",
|
|
1416
|
+
"world"
|
|
1417
|
+
];
|
|
1418
|
+
var AI_GAME_OBSERVED_EVENT_SOURCES = [
|
|
1419
|
+
"player-action",
|
|
1420
|
+
"system-observation",
|
|
1421
|
+
"world-state"
|
|
1422
|
+
];
|
|
1423
|
+
var AI_GAME_OBSERVED_EVENT_VISIBILITIES = [
|
|
1424
|
+
"private",
|
|
1425
|
+
"party",
|
|
1426
|
+
"local",
|
|
1427
|
+
"public"
|
|
1428
|
+
];
|
|
1429
|
+
var AI_GAME_OBSERVED_EVENT_SIGNIFICANCE = [
|
|
1430
|
+
"routine",
|
|
1431
|
+
"notable",
|
|
1432
|
+
"critical"
|
|
1433
|
+
];
|
|
1434
|
+
var AI_GAME_GOSSIP_EXPORT_AUDIENCES = [
|
|
1435
|
+
"player",
|
|
1436
|
+
"npc",
|
|
1437
|
+
"public"
|
|
1438
|
+
];
|
|
1439
|
+
var AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH = 500;
|
|
1440
|
+
var AI_GAME_OBSERVED_EVENT_MAX_TAGS = 20;
|
|
1441
|
+
var AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH = 64;
|
|
1442
|
+
var AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS = 100;
|
|
1443
|
+
function freezeReadonlyArray5(items) {
|
|
1444
|
+
return Object.freeze([...items]);
|
|
1445
|
+
}
|
|
1446
|
+
function isMember4(value, members) {
|
|
1447
|
+
return members.includes(value);
|
|
1448
|
+
}
|
|
1449
|
+
function assertNonEmptyString5(value, label) {
|
|
1450
|
+
if (value.trim().length === 0) {
|
|
1451
|
+
throw new Error(`${label} must be a non-empty string`);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
function assertSafeText(value, label, maxLength) {
|
|
1455
|
+
assertNonEmptyString5(value, label);
|
|
1456
|
+
if (value.length > maxLength) {
|
|
1457
|
+
throw new Error(`${label} must be ${maxLength} characters or fewer`);
|
|
1458
|
+
}
|
|
1459
|
+
if ([...value].some((character) => {
|
|
1460
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
1461
|
+
return codePoint <= 31 || codePoint === 127;
|
|
1462
|
+
})) {
|
|
1463
|
+
throw new Error(`${label} must not contain control characters`);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function assertIsoTimestamp3(value, label) {
|
|
1467
|
+
assertNonEmptyString5(value, label);
|
|
1468
|
+
if (Number.isNaN(Date.parse(value))) {
|
|
1469
|
+
throw new Error(`${label} must be an ISO-8601 timestamp`);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
function assertContractVersion4(value) {
|
|
1473
|
+
if (value !== AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION) {
|
|
1474
|
+
throw new Error(
|
|
1475
|
+
`contractVersion must be ${AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION}`
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
function assertArrayLimit(value, label, maximum) {
|
|
1480
|
+
if (value.length > maximum) {
|
|
1481
|
+
throw new Error(`${label} must contain ${maximum} items or fewer`);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
function createStringArray2(values, label, maximum, itemMaximum) {
|
|
1485
|
+
assertArrayLimit(values, label, maximum);
|
|
1486
|
+
const result = values.map((value, index) => {
|
|
1487
|
+
assertSafeText(value, `${label}[${index}]`, itemMaximum);
|
|
1488
|
+
return value.trim();
|
|
1489
|
+
});
|
|
1490
|
+
if (new Set(result).size !== result.length) {
|
|
1491
|
+
throw new Error(`${label} must not contain duplicate values`);
|
|
1492
|
+
}
|
|
1493
|
+
return freezeReadonlyArray5(result);
|
|
1494
|
+
}
|
|
1495
|
+
function assertUniqueIds(values, label) {
|
|
1496
|
+
if (new Set(values).size !== values.length) {
|
|
1497
|
+
throw new Error(`${label} must not contain duplicate values`);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
function cloneObservedEvent(event) {
|
|
1501
|
+
return createAiGameObservedEvent(event);
|
|
1502
|
+
}
|
|
1503
|
+
function cloneRecencyWindow(window) {
|
|
1504
|
+
return createAiGameObservedEventRecencyWindow({
|
|
1505
|
+
contractVersion: window.contractVersion,
|
|
1506
|
+
windowId: window.windowId,
|
|
1507
|
+
startsAtIso: window.startsAtIso,
|
|
1508
|
+
endsAtIso: window.endsAtIso,
|
|
1509
|
+
events: window.events
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
function cloneHighlightSummary(summary) {
|
|
1513
|
+
return createAiGameObservedEventHighlightSummary({
|
|
1514
|
+
contractVersion: summary.contractVersion,
|
|
1515
|
+
summaryId: summary.summaryId,
|
|
1516
|
+
windowId: summary.windowId,
|
|
1517
|
+
title: summary.title,
|
|
1518
|
+
summary: summary.summary,
|
|
1519
|
+
significance: summary.significance,
|
|
1520
|
+
eventIds: summary.eventIds,
|
|
1521
|
+
reasonCodes: summary.reasonCodes
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
function isAiGameObservedEventKind(value) {
|
|
1525
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_KINDS);
|
|
1526
|
+
}
|
|
1527
|
+
function isAiGameObservedEventSource(value) {
|
|
1528
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_SOURCES);
|
|
1529
|
+
}
|
|
1530
|
+
function isAiGameObservedEventVisibility(value) {
|
|
1531
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_VISIBILITIES);
|
|
1532
|
+
}
|
|
1533
|
+
function isAiGameObservedEventSignificance(value) {
|
|
1534
|
+
return isMember4(value, AI_GAME_OBSERVED_EVENT_SIGNIFICANCE);
|
|
1535
|
+
}
|
|
1536
|
+
function isAiGameGossipExportAudience(value) {
|
|
1537
|
+
return isMember4(value, AI_GAME_GOSSIP_EXPORT_AUDIENCES);
|
|
1538
|
+
}
|
|
1539
|
+
function createAiGameObservedEvent(input) {
|
|
1540
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1541
|
+
assertContractVersion4(contractVersion);
|
|
1542
|
+
assertSafeText(input.eventId, "eventId", 200);
|
|
1543
|
+
assertIsoTimestamp3(input.occurredAtIso, "occurredAtIso");
|
|
1544
|
+
assertSafeText(input.subjectRef, "subjectRef", 200);
|
|
1545
|
+
assertSafeText(
|
|
1546
|
+
input.summary,
|
|
1547
|
+
"summary",
|
|
1548
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
|
|
1549
|
+
);
|
|
1550
|
+
if (!isAiGameObservedEventKind(input.kind)) {
|
|
1551
|
+
throw new Error(`kind must be one of: ${AI_GAME_OBSERVED_EVENT_KINDS.join(", ")}`);
|
|
1552
|
+
}
|
|
1553
|
+
if (!isAiGameObservedEventSource(input.source)) {
|
|
1554
|
+
throw new Error(
|
|
1555
|
+
`source must be one of: ${AI_GAME_OBSERVED_EVENT_SOURCES.join(", ")}`
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
if (!isAiGameObservedEventSignificance(input.significance)) {
|
|
1559
|
+
throw new Error(
|
|
1560
|
+
`significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
|
|
1561
|
+
);
|
|
1562
|
+
}
|
|
1563
|
+
if (!isAiGameObservedEventVisibility(input.visibility)) {
|
|
1564
|
+
throw new Error(
|
|
1565
|
+
`visibility must be one of: ${AI_GAME_OBSERVED_EVENT_VISIBILITIES.join(", ")}`
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
const tags = createStringArray2(
|
|
1569
|
+
input.tags ?? [],
|
|
1570
|
+
"tags",
|
|
1571
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAGS,
|
|
1572
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH
|
|
1573
|
+
);
|
|
1574
|
+
return Object.freeze({
|
|
1575
|
+
contractVersion,
|
|
1576
|
+
eventId: input.eventId.trim(),
|
|
1577
|
+
occurredAtIso: input.occurredAtIso,
|
|
1578
|
+
kind: input.kind,
|
|
1579
|
+
source: input.source,
|
|
1580
|
+
subjectRef: input.subjectRef.trim(),
|
|
1581
|
+
summary: input.summary.trim(),
|
|
1582
|
+
significance: input.significance,
|
|
1583
|
+
visibility: input.visibility,
|
|
1584
|
+
tags
|
|
1585
|
+
});
|
|
1586
|
+
}
|
|
1587
|
+
function createAiGameObservedEventRecencyWindow(input) {
|
|
1588
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1589
|
+
assertContractVersion4(contractVersion);
|
|
1590
|
+
assertSafeText(input.windowId, "windowId", 200);
|
|
1591
|
+
assertIsoTimestamp3(input.startsAtIso, "startsAtIso");
|
|
1592
|
+
assertIsoTimestamp3(input.endsAtIso, "endsAtIso");
|
|
1593
|
+
const startsAt = Date.parse(input.startsAtIso);
|
|
1594
|
+
const endsAt = Date.parse(input.endsAtIso);
|
|
1595
|
+
if (startsAt > endsAt) {
|
|
1596
|
+
throw new Error("startsAtIso must be before or equal to endsAtIso");
|
|
1597
|
+
}
|
|
1598
|
+
assertArrayLimit(
|
|
1599
|
+
input.events,
|
|
1600
|
+
"events",
|
|
1601
|
+
AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS
|
|
1602
|
+
);
|
|
1603
|
+
const events = input.events.map(cloneObservedEvent);
|
|
1604
|
+
const eventIds = events.map((event) => event.eventId);
|
|
1605
|
+
assertUniqueIds(eventIds, "events");
|
|
1606
|
+
for (const event of events) {
|
|
1607
|
+
const occurredAt = Date.parse(event.occurredAtIso);
|
|
1608
|
+
if (occurredAt < startsAt || occurredAt > endsAt) {
|
|
1609
|
+
throw new Error(`event ${event.eventId} must occur inside the recency window`);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
return Object.freeze({
|
|
1613
|
+
contractVersion,
|
|
1614
|
+
windowId: input.windowId.trim(),
|
|
1615
|
+
startsAtIso: input.startsAtIso,
|
|
1616
|
+
endsAtIso: input.endsAtIso,
|
|
1617
|
+
events: freezeReadonlyArray5(events)
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
function createAiGameObservedEventHighlightSummary(input) {
|
|
1621
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1622
|
+
assertContractVersion4(contractVersion);
|
|
1623
|
+
assertSafeText(input.summaryId, "summaryId", 200);
|
|
1624
|
+
assertSafeText(input.windowId, "windowId", 200);
|
|
1625
|
+
assertSafeText(input.title, "title", 200);
|
|
1626
|
+
assertSafeText(
|
|
1627
|
+
input.summary,
|
|
1628
|
+
"summary",
|
|
1629
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH
|
|
1630
|
+
);
|
|
1631
|
+
if (!isAiGameObservedEventSignificance(input.significance)) {
|
|
1632
|
+
throw new Error(
|
|
1633
|
+
`significance must be one of: ${AI_GAME_OBSERVED_EVENT_SIGNIFICANCE.join(", ")}`
|
|
1634
|
+
);
|
|
1635
|
+
}
|
|
1636
|
+
const eventIds = createStringArray2(input.eventIds, "eventIds", 100, 200);
|
|
1637
|
+
if (eventIds.length === 0) {
|
|
1638
|
+
throw new Error("eventIds must contain at least one event id");
|
|
1639
|
+
}
|
|
1640
|
+
const reasonCodes = createStringArray2(
|
|
1641
|
+
input.reasonCodes ?? [],
|
|
1642
|
+
"reasonCodes",
|
|
1643
|
+
20,
|
|
1644
|
+
100
|
|
1645
|
+
);
|
|
1646
|
+
return Object.freeze({
|
|
1647
|
+
contractVersion,
|
|
1648
|
+
summaryId: input.summaryId.trim(),
|
|
1649
|
+
windowId: input.windowId.trim(),
|
|
1650
|
+
title: input.title.trim(),
|
|
1651
|
+
summary: input.summary.trim(),
|
|
1652
|
+
significance: input.significance,
|
|
1653
|
+
eventIds,
|
|
1654
|
+
reasonCodes
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
function createAiGameGossipExport(input) {
|
|
1658
|
+
const contractVersion = input.contractVersion ?? AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION;
|
|
1659
|
+
assertContractVersion4(contractVersion);
|
|
1660
|
+
assertSafeText(input.exportId, "exportId", 200);
|
|
1661
|
+
assertIsoTimestamp3(input.exportedAtIso, "exportedAtIso");
|
|
1662
|
+
if (!isAiGameGossipExportAudience(input.audience)) {
|
|
1663
|
+
throw new Error(
|
|
1664
|
+
`audience must be one of: ${AI_GAME_GOSSIP_EXPORT_AUDIENCES.join(", ")}`
|
|
1665
|
+
);
|
|
1666
|
+
}
|
|
1667
|
+
const sourceWindow = cloneRecencyWindow(input.sourceWindow);
|
|
1668
|
+
const eventIds = new Set(sourceWindow.events.map((event) => event.eventId));
|
|
1669
|
+
const highlights = input.highlights.map(cloneHighlightSummary);
|
|
1670
|
+
const summaryIds = highlights.map((summary) => summary.summaryId);
|
|
1671
|
+
assertUniqueIds(summaryIds, "highlights");
|
|
1672
|
+
for (const highlight of highlights) {
|
|
1673
|
+
if (highlight.windowId !== sourceWindow.windowId) {
|
|
1674
|
+
throw new Error("highlight windowId must match sourceWindow windowId");
|
|
1675
|
+
}
|
|
1676
|
+
if (highlight.eventIds.some((eventId) => !eventIds.has(eventId))) {
|
|
1677
|
+
throw new Error("highlight eventIds must reference sourceWindow events");
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
return Object.freeze({
|
|
1681
|
+
contractVersion,
|
|
1682
|
+
exportId: input.exportId.trim(),
|
|
1683
|
+
exportedAtIso: input.exportedAtIso,
|
|
1684
|
+
audience: input.audience,
|
|
1685
|
+
sourceWindow,
|
|
1686
|
+
highlights: freezeReadonlyArray5(highlights)
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
function assertAiGameObservedEventLogContractVersion(value) {
|
|
1690
|
+
assertContractVersion4(value);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1385
1693
|
// src/world-events.ts
|
|
1386
1694
|
function isCanonicalWorldEvent(event) {
|
|
1387
1695
|
return event.recordType === "canonical";
|
|
@@ -1533,7 +1841,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
|
1533
1841
|
"private-or-low-witness-evidence",
|
|
1534
1842
|
"costly-pressure-event"
|
|
1535
1843
|
];
|
|
1536
|
-
function
|
|
1844
|
+
function isMember5(value, members) {
|
|
1537
1845
|
return members.includes(value);
|
|
1538
1846
|
}
|
|
1539
1847
|
function assertRecord(value, label) {
|
|
@@ -1574,7 +1882,7 @@ function normalizeTimestamp(value, label) {
|
|
|
1574
1882
|
}
|
|
1575
1883
|
function normalizeMember(value, members, label) {
|
|
1576
1884
|
const normalized = normalizeNonEmptyString(value, label);
|
|
1577
|
-
if (!
|
|
1885
|
+
if (!isMember5(normalized, members)) {
|
|
1578
1886
|
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
1579
1887
|
}
|
|
1580
1888
|
return normalized;
|
|
@@ -1707,13 +2015,13 @@ function normalizeDominantReads(value) {
|
|
|
1707
2015
|
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
1708
2016
|
}
|
|
1709
2017
|
function isQuietMeasureAxis(value) {
|
|
1710
|
-
return
|
|
2018
|
+
return isMember5(value, QUIET_MEASURE_AXES);
|
|
1711
2019
|
}
|
|
1712
2020
|
function isQuietMeasureMissionProbeMode(value) {
|
|
1713
|
-
return
|
|
2021
|
+
return isMember5(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
1714
2022
|
}
|
|
1715
2023
|
function isQuietMeasureMissionResolutionShape(value) {
|
|
1716
|
-
return
|
|
2024
|
+
return isMember5(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
1717
2025
|
}
|
|
1718
2026
|
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
1719
2027
|
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
@@ -2217,6 +2525,7 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2217
2525
|
AI_GAME_EVENT_INGESTION_FEATURE_FLAG_ID,
|
|
2218
2526
|
AI_GAME_FEATURE_FLAGS,
|
|
2219
2527
|
AI_GAME_FEATURE_FLAG_ID,
|
|
2528
|
+
AI_GAME_GOSSIP_EXPORT_AUDIENCES,
|
|
2220
2529
|
AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
|
|
2221
2530
|
AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
|
|
2222
2531
|
AI_GAME_IDENTITY_CONTRACT_VERSION,
|
|
@@ -2240,6 +2549,16 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2240
2549
|
AI_GAME_MISSION_REPEATED_SIGNAL_HANDLING,
|
|
2241
2550
|
AI_GAME_MISSION_REWARD_CAP_SEMANTICS,
|
|
2242
2551
|
AI_GAME_MISSION_REWARD_KINDS,
|
|
2552
|
+
AI_GAME_OBSERVED_EVENT_KINDS,
|
|
2553
|
+
AI_GAME_OBSERVED_EVENT_LOG_CONTRACT_VERSION,
|
|
2554
|
+
AI_GAME_OBSERVED_EVENT_LOG_FEATURE_FLAG_ID,
|
|
2555
|
+
AI_GAME_OBSERVED_EVENT_MAX_SUMMARY_LENGTH,
|
|
2556
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAGS,
|
|
2557
|
+
AI_GAME_OBSERVED_EVENT_MAX_TAG_LENGTH,
|
|
2558
|
+
AI_GAME_OBSERVED_EVENT_MAX_WINDOW_EVENTS,
|
|
2559
|
+
AI_GAME_OBSERVED_EVENT_SIGNIFICANCE,
|
|
2560
|
+
AI_GAME_OBSERVED_EVENT_SOURCES,
|
|
2561
|
+
AI_GAME_OBSERVED_EVENT_VISIBILITIES,
|
|
2243
2562
|
AI_GAME_PACKAGE,
|
|
2244
2563
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
2245
2564
|
AI_GAME_PLAYER_SYSTEM_ALERT_PRIORITIES,
|
|
@@ -2297,8 +2616,10 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2297
2616
|
aiGameFeatureFlags,
|
|
2298
2617
|
assertAiGameIdentityProjectionContractVersion,
|
|
2299
2618
|
assertAiGameMissionContractVersion,
|
|
2619
|
+
assertAiGameObservedEventLogContractVersion,
|
|
2300
2620
|
classifyAiGameTask,
|
|
2301
2621
|
createAiGameAcademicTrainingSnapshot,
|
|
2622
|
+
createAiGameGossipExport,
|
|
2302
2623
|
createAiGameIdentityProjectionContract,
|
|
2303
2624
|
createAiGameIdentitySelfProjection,
|
|
2304
2625
|
createAiGameIdentityTargetProjection,
|
|
@@ -2314,6 +2635,9 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2314
2635
|
createAiGameMissionRewardBound,
|
|
2315
2636
|
createAiGameMissionRewardEnvelope,
|
|
2316
2637
|
createAiGameMissionRewardGrant,
|
|
2638
|
+
createAiGameObservedEvent,
|
|
2639
|
+
createAiGameObservedEventHighlightSummary,
|
|
2640
|
+
createAiGameObservedEventRecencyWindow,
|
|
2317
2641
|
createAiGamePlayerSystemAlert,
|
|
2318
2642
|
createAiGamePlayerSystemGuidanceCue,
|
|
2319
2643
|
createAiGamePlayerSystemPreferenceConfidenceState,
|
|
@@ -2333,6 +2657,7 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2333
2657
|
getAiGamePlayerSystemFocusModeContract,
|
|
2334
2658
|
getAiGamePlayerSystemGuidanceFallbackContract,
|
|
2335
2659
|
getAiGamePlayerSystemModuleContract,
|
|
2660
|
+
isAiGameGossipExportAudience,
|
|
2336
2661
|
isAiGameIdentityKnowledgeState,
|
|
2337
2662
|
isAiGameIdentityProjectionRead,
|
|
2338
2663
|
isAiGameIdentityTargetCategory,
|
|
@@ -2348,6 +2673,10 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
2348
2673
|
isAiGameMissionRepeatedSignalHandling,
|
|
2349
2674
|
isAiGameMissionRewardCapSemantic,
|
|
2350
2675
|
isAiGameMissionRewardKind,
|
|
2676
|
+
isAiGameObservedEventKind,
|
|
2677
|
+
isAiGameObservedEventSignificance,
|
|
2678
|
+
isAiGameObservedEventSource,
|
|
2679
|
+
isAiGameObservedEventVisibility,
|
|
2351
2680
|
isAiGamePlayerSystemAlertDeliverable,
|
|
2352
2681
|
isAiGamePlayerSystemAlertPriority,
|
|
2353
2682
|
isAiGamePlayerSystemConfidenceBand,
|