@plasius/ai-game 0.1.3 → 0.1.7
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 +6 -8
- package/README.md +18 -3
- package/dist/index.cjs +355 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -1
- package/dist/index.d.ts +121 -1
- package/dist/index.js +337 -0
- package/dist/index.js.map +1 -1
- package/docs/adrs/adr-0009-protected-main-release-preparation-and-version-reconciliation.md +57 -0
- package/docs/adrs/index.md +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
5
|
The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/)**, and this project adheres to **[Semantic Versioning](https://semver.org/spec/v2.0.0.html)**.
|
|
6
|
-
|
|
7
6
|
## [Unreleased]
|
|
8
|
-
|
|
9
7
|
- **Added**
|
|
10
8
|
- (placeholder)
|
|
11
9
|
|
|
@@ -17,21 +15,21 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
17
15
|
|
|
18
16
|
- **Security**
|
|
19
17
|
- (placeholder)
|
|
20
|
-
|
|
21
|
-
## [0.1.3] - 2026-06-01
|
|
18
|
+
## [0.1.7] - 2026-06-14
|
|
22
19
|
|
|
23
20
|
- **Added**
|
|
24
21
|
- Implemented canonical world event contracts with candidate and canonical envelopes, taxonomy, payload typing, and visibility classes.
|
|
25
22
|
- Added authoritative ingestion interfaces and replay-safe projection/checkpoint contracts.
|
|
26
23
|
- Added incident lifecycle, resolution link, and impact vector models.
|
|
27
24
|
- Added structured gossip topic contracts with lifecycle, confidence, and perspective projection projections.
|
|
28
|
-
-
|
|
25
|
+
- Added Quiet Measure public contracts for hidden-axis summaries, derived reads, mission probe metadata, and Judgment eligibility or verdict responses under `isekai.player-system.quiet-measure.enabled`.
|
|
26
|
+
- Documented the Quiet Measure hidden-runtime boundary so hosts can expose title-plus-verdict outputs without publishing raw per-player score storage.
|
|
29
27
|
|
|
30
28
|
- **Changed**
|
|
31
|
-
- Extended public package surface to include
|
|
29
|
+
- Extended the public package surface to include the Quiet Measure contract family alongside world-event and gossip exports while keeping host-private runtime weights out of the package API.
|
|
32
30
|
|
|
33
31
|
- **Fixed**
|
|
34
|
-
-
|
|
32
|
+
- Hardened Quiet Measure runtime validation and defensive copying for public Judgment request, title, dominant-read, and reason-code payloads.
|
|
35
33
|
|
|
36
34
|
- **Security**
|
|
37
35
|
- (placeholder)
|
|
@@ -58,4 +56,4 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
|
|
|
58
56
|
|
|
59
57
|
[0.1.1]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.1
|
|
60
58
|
[0.1.2]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.2
|
|
61
|
-
[0.1.
|
|
59
|
+
[0.1.7]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.7
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @plasius/ai-game
|
|
2
2
|
|
|
3
|
-
Game-domain AI contracts for player action validation, NPC actions, gossip, and
|
|
3
|
+
Game-domain AI contracts for player action validation, NPC actions, gossip, Quiet Measure mission probes, and Judgment disclosure surfaces.
|
|
4
4
|
|
|
5
5
|
## Scope
|
|
6
6
|
|
|
7
|
-
This package is part of the layered `@plasius/ai-*` package family. It exports canonical public contracts for world events, world-event ingestion, incident impact state,
|
|
7
|
+
This package is part of the layered `@plasius/ai-*` package family. It exports canonical public contracts for world events, world-event ingestion, incident impact state, gossip topic projection, and Quiet Measure hidden-runtime integration surfaces.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -20,14 +20,28 @@ import {
|
|
|
20
20
|
AI_GAME_FEATURE_FLAG_ID,
|
|
21
21
|
aiGameFeatureFlags,
|
|
22
22
|
packageDescriptor,
|
|
23
|
+
AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
|
|
23
24
|
type GameWorldEvent,
|
|
24
25
|
type WorldEventIngestionPort,
|
|
25
26
|
type WorldIncidentThread,
|
|
26
27
|
type GossipTopic,
|
|
27
|
-
type GossipPerspectiveProjection
|
|
28
|
+
type GossipPerspectiveProjection,
|
|
29
|
+
type QuietMeasureAxisSummary,
|
|
30
|
+
type QuietMeasureMissionProbe,
|
|
31
|
+
type QuietMeasureJudgmentResponse
|
|
28
32
|
} from "@plasius/ai-game";
|
|
29
33
|
```
|
|
30
34
|
|
|
35
|
+
## Quiet Measure contracts
|
|
36
|
+
|
|
37
|
+
The Quiet Measure surface is intentionally structured as a hidden-runtime contract, not a turnkey morality meter.
|
|
38
|
+
|
|
39
|
+
- Axis and derived-read contracts expose bounded summaries, confidence bands, evidence windows, and perspective scope without publishing host-specific raw score storage.
|
|
40
|
+
- Mission probe contracts model `Clarify`, `Tempt`, and `Reinforce` modes plus `Restorative`, `Dominant`, `Detached`, and optional `Performative` resolution shapes.
|
|
41
|
+
- Judgment contracts model request, eligibility, insufficient-evidence, and verdict responses with `title-and-verdict-only` disclosure as the default public output.
|
|
42
|
+
- Runtime helpers validate and defensively copy public Quiet Measure request, title, dominant-read, and reason-code payloads so malformed host input fails closed without leaking hidden-score internals.
|
|
43
|
+
- Evaluation fixtures for hero, villain, counterfeit, tyrant, and redemption regression cases belong in `@plasius/ai-evals`, not this package.
|
|
44
|
+
|
|
31
45
|
## Development
|
|
32
46
|
|
|
33
47
|
```bash
|
|
@@ -46,6 +60,7 @@ npm run pack:check
|
|
|
46
60
|
- `ai.game.npc-gossip.topics.enabled`
|
|
47
61
|
- `ai.game.npc-gossip.perspective.enabled`
|
|
48
62
|
- `ai.game.npc-gossip.lifecycle.enabled`
|
|
63
|
+
- `isekai.player-system.quiet-measure.enabled`
|
|
49
64
|
|
|
50
65
|
## Governance
|
|
51
66
|
|
package/dist/index.cjs
CHANGED
|
@@ -31,20 +31,38 @@ __export(index_exports, {
|
|
|
31
31
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID: () => AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
32
32
|
AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
|
|
33
33
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
34
|
+
AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID: () => AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
|
|
34
35
|
AI_GAME_TASK_AUTHORITY_BOUNDARIES: () => AI_GAME_TASK_AUTHORITY_BOUNDARIES,
|
|
35
36
|
AI_GAME_TASK_DECISIONS: () => AI_GAME_TASK_DECISIONS,
|
|
36
37
|
AI_GAME_TASK_KINDS: () => AI_GAME_TASK_KINDS,
|
|
37
38
|
AI_GAME_TASK_RESULTS: () => AI_GAME_TASK_RESULTS,
|
|
38
39
|
AI_GAME_TASK_RISK_CLASSES: () => AI_GAME_TASK_RISK_CLASSES,
|
|
39
40
|
AI_GAME_TTS_CACHE_POLICIES: () => AI_GAME_TTS_CACHE_POLICIES,
|
|
41
|
+
QUIET_MEASURE_AXES: () => QUIET_MEASURE_AXES,
|
|
42
|
+
QUIET_MEASURE_CONFIDENCE_BANDS: () => QUIET_MEASURE_CONFIDENCE_BANDS,
|
|
43
|
+
QUIET_MEASURE_DERIVED_READS: () => QUIET_MEASURE_DERIVED_READS,
|
|
44
|
+
QUIET_MEASURE_EVIDENCE_CLASSES: () => QUIET_MEASURE_EVIDENCE_CLASSES,
|
|
45
|
+
QUIET_MEASURE_JUDGMENT_DISCLOSURES: () => QUIET_MEASURE_JUDGMENT_DISCLOSURES,
|
|
46
|
+
QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE: () => QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE,
|
|
47
|
+
QUIET_MEASURE_JUDGMENT_REQUESTERS: () => QUIET_MEASURE_JUDGMENT_REQUESTERS,
|
|
48
|
+
QUIET_MEASURE_MISSION_PROBE_MODES: () => QUIET_MEASURE_MISSION_PROBE_MODES,
|
|
49
|
+
QUIET_MEASURE_MISSION_RESOLUTION_SHAPES: () => QUIET_MEASURE_MISSION_RESOLUTION_SHAPES,
|
|
50
|
+
QUIET_MEASURE_PERSPECTIVES: () => QUIET_MEASURE_PERSPECTIVES,
|
|
51
|
+
QUIET_MEASURE_SIGNAL_BANDS: () => QUIET_MEASURE_SIGNAL_BANDS,
|
|
40
52
|
aiGameFeatureFlags: () => aiGameFeatureFlags,
|
|
41
53
|
classifyAiGameTask: () => classifyAiGameTask,
|
|
54
|
+
createQuietMeasureJudgmentEligibility: () => createQuietMeasureJudgmentEligibility,
|
|
55
|
+
createQuietMeasureJudgmentResponse: () => createQuietMeasureJudgmentResponse,
|
|
42
56
|
gameEventFeatureFlags: () => gameEventFeatureFlags,
|
|
43
57
|
isCandidateWorldEvent: () => isCandidateWorldEvent,
|
|
44
58
|
isCanonicalWorldEvent: () => isCanonicalWorldEvent,
|
|
45
59
|
isGossipTopicActive: () => isGossipTopicActive,
|
|
46
60
|
isGossipTopicCorrected: () => isGossipTopicCorrected,
|
|
47
61
|
isIncidentResolved: () => isIncidentResolved,
|
|
62
|
+
isQuietMeasureAxis: () => isQuietMeasureAxis,
|
|
63
|
+
isQuietMeasureMissionProbeMode: () => isQuietMeasureMissionProbeMode,
|
|
64
|
+
isQuietMeasureMissionResolutionShape: () => isQuietMeasureMissionResolutionShape,
|
|
65
|
+
listQuietMeasureMissingEvidence: () => listQuietMeasureMissingEvidence,
|
|
48
66
|
normalizeIncidentImpactVector: () => normalizeIncidentImpactVector,
|
|
49
67
|
packageDescriptor: () => packageDescriptor,
|
|
50
68
|
projectTopicForAudience: () => projectTopicForAudience,
|
|
@@ -144,6 +162,325 @@ function projectTopicForAudience(topic, projection, nowEpochMs = Date.now()) {
|
|
|
144
162
|
};
|
|
145
163
|
}
|
|
146
164
|
|
|
165
|
+
// src/quiet-measure.ts
|
|
166
|
+
var AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID = "isekai.player-system.quiet-measure.enabled";
|
|
167
|
+
var QUIET_MEASURE_AXES = [
|
|
168
|
+
"selflessness",
|
|
169
|
+
"give",
|
|
170
|
+
"mercy",
|
|
171
|
+
"duty",
|
|
172
|
+
"principle",
|
|
173
|
+
"courtesy"
|
|
174
|
+
];
|
|
175
|
+
var QUIET_MEASURE_CONFIDENCE_BANDS = ["low", "medium", "high"];
|
|
176
|
+
var QUIET_MEASURE_SIGNAL_BANDS = [
|
|
177
|
+
"suppressed",
|
|
178
|
+
"latent",
|
|
179
|
+
"present",
|
|
180
|
+
"dominant"
|
|
181
|
+
];
|
|
182
|
+
var QUIET_MEASURE_PERSPECTIVES = [
|
|
183
|
+
"system-truth",
|
|
184
|
+
"observed-reputation"
|
|
185
|
+
];
|
|
186
|
+
var QUIET_MEASURE_EVIDENCE_CLASSES = [
|
|
187
|
+
"declared-intent",
|
|
188
|
+
"costly-choice",
|
|
189
|
+
"private-conduct",
|
|
190
|
+
"repair-after-harm",
|
|
191
|
+
"weak-party-treatment",
|
|
192
|
+
"observed-pattern",
|
|
193
|
+
"social-mask"
|
|
194
|
+
];
|
|
195
|
+
var QUIET_MEASURE_DERIVED_READS = [
|
|
196
|
+
"nature",
|
|
197
|
+
"mask",
|
|
198
|
+
"veil-gap",
|
|
199
|
+
"restitution"
|
|
200
|
+
];
|
|
201
|
+
var QUIET_MEASURE_MISSION_PROBE_MODES = [
|
|
202
|
+
"clarify",
|
|
203
|
+
"tempt",
|
|
204
|
+
"reinforce"
|
|
205
|
+
];
|
|
206
|
+
var QUIET_MEASURE_MISSION_RESOLUTION_SHAPES = [
|
|
207
|
+
"restorative",
|
|
208
|
+
"dominant",
|
|
209
|
+
"detached",
|
|
210
|
+
"performative"
|
|
211
|
+
];
|
|
212
|
+
var QUIET_MEASURE_JUDGMENT_DISCLOSURES = [
|
|
213
|
+
"title-and-verdict-only"
|
|
214
|
+
];
|
|
215
|
+
var QUIET_MEASURE_JUDGMENT_REQUESTERS = [
|
|
216
|
+
"player",
|
|
217
|
+
"system",
|
|
218
|
+
"operator"
|
|
219
|
+
];
|
|
220
|
+
var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
|
|
221
|
+
"repeated-meaningful-evidence",
|
|
222
|
+
"private-or-low-witness-evidence",
|
|
223
|
+
"costly-pressure-event"
|
|
224
|
+
];
|
|
225
|
+
function isMember(value, members) {
|
|
226
|
+
return members.includes(value);
|
|
227
|
+
}
|
|
228
|
+
function assertRecord(value, label) {
|
|
229
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
230
|
+
throw new TypeError(`${label} must be an object.`);
|
|
231
|
+
}
|
|
232
|
+
return value;
|
|
233
|
+
}
|
|
234
|
+
function normalizeNonEmptyString(value, label) {
|
|
235
|
+
if (typeof value !== "string") {
|
|
236
|
+
throw new TypeError(`${label} must be a non-empty string.`);
|
|
237
|
+
}
|
|
238
|
+
const normalized = value.trim();
|
|
239
|
+
if (normalized.length === 0) {
|
|
240
|
+
throw new TypeError(`${label} must be a non-empty string.`);
|
|
241
|
+
}
|
|
242
|
+
return normalized;
|
|
243
|
+
}
|
|
244
|
+
function normalizeBoolean(value, label) {
|
|
245
|
+
if (typeof value !== "boolean") {
|
|
246
|
+
throw new TypeError(`${label} must be a boolean.`);
|
|
247
|
+
}
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
function normalizeOptionalBoolean(value, fallback, label) {
|
|
251
|
+
if (value === void 0) {
|
|
252
|
+
return fallback;
|
|
253
|
+
}
|
|
254
|
+
return normalizeBoolean(value, label);
|
|
255
|
+
}
|
|
256
|
+
function normalizeTimestamp(value, label) {
|
|
257
|
+
const normalized = normalizeNonEmptyString(value, label);
|
|
258
|
+
const parsed = Date.parse(normalized);
|
|
259
|
+
if (Number.isNaN(parsed)) {
|
|
260
|
+
throw new TypeError(`${label} must be a valid ISO-8601 timestamp.`);
|
|
261
|
+
}
|
|
262
|
+
return normalized;
|
|
263
|
+
}
|
|
264
|
+
function normalizeMember(value, members, label) {
|
|
265
|
+
const normalized = normalizeNonEmptyString(value, label);
|
|
266
|
+
if (!isMember(normalized, members)) {
|
|
267
|
+
throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
|
|
268
|
+
}
|
|
269
|
+
return normalized;
|
|
270
|
+
}
|
|
271
|
+
function normalizeReasonCodes(value, label) {
|
|
272
|
+
if (value === void 0) {
|
|
273
|
+
return Object.freeze([]);
|
|
274
|
+
}
|
|
275
|
+
if (!Array.isArray(value)) {
|
|
276
|
+
throw new TypeError(`${label} must be an array of strings.`);
|
|
277
|
+
}
|
|
278
|
+
for (const [index, entry] of value.entries()) {
|
|
279
|
+
if (typeof entry !== "string") {
|
|
280
|
+
throw new TypeError(`${label}[${index}] must be a string.`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const normalized = value.map((entry) => entry.trim());
|
|
284
|
+
if (normalized.some((entry) => entry.length === 0)) {
|
|
285
|
+
throw new TypeError(`${label} must not contain blank strings.`);
|
|
286
|
+
}
|
|
287
|
+
return Object.freeze(Array.from(new Set(normalized)));
|
|
288
|
+
}
|
|
289
|
+
function normalizeJudgmentRequest(input) {
|
|
290
|
+
const request = assertRecord(input, "Quiet Measure judgment request");
|
|
291
|
+
return Object.freeze({
|
|
292
|
+
subjectId: normalizeNonEmptyString(
|
|
293
|
+
request.subjectId,
|
|
294
|
+
"Quiet Measure judgment request subjectId"
|
|
295
|
+
),
|
|
296
|
+
requestedAtUtc: normalizeTimestamp(
|
|
297
|
+
request.requestedAtUtc,
|
|
298
|
+
"Quiet Measure judgment request requestedAtUtc"
|
|
299
|
+
),
|
|
300
|
+
requestedBy: normalizeMember(
|
|
301
|
+
request.requestedBy,
|
|
302
|
+
QUIET_MEASURE_JUDGMENT_REQUESTERS,
|
|
303
|
+
"Quiet Measure judgment request requestedBy"
|
|
304
|
+
),
|
|
305
|
+
disclosure: normalizeMember(
|
|
306
|
+
request.disclosure,
|
|
307
|
+
QUIET_MEASURE_JUDGMENT_DISCLOSURES,
|
|
308
|
+
"Quiet Measure judgment request disclosure"
|
|
309
|
+
)
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function normalizeJudgmentEligibility(input) {
|
|
313
|
+
const eligibility = assertRecord(input, "Quiet Measure judgment eligibility");
|
|
314
|
+
const repeatedMeaningfulEvidence = normalizeBoolean(
|
|
315
|
+
eligibility.repeatedMeaningfulEvidence,
|
|
316
|
+
"Quiet Measure judgment eligibility repeatedMeaningfulEvidence"
|
|
317
|
+
);
|
|
318
|
+
const includesPrivateOrLowWitnessEvidence = normalizeBoolean(
|
|
319
|
+
eligibility.includesPrivateOrLowWitnessEvidence,
|
|
320
|
+
"Quiet Measure judgment eligibility includesPrivateOrLowWitnessEvidence"
|
|
321
|
+
);
|
|
322
|
+
const includesCostlyPressureEvent = normalizeBoolean(
|
|
323
|
+
eligibility.includesCostlyPressureEvent,
|
|
324
|
+
"Quiet Measure judgment eligibility includesCostlyPressureEvent"
|
|
325
|
+
);
|
|
326
|
+
return Object.freeze({
|
|
327
|
+
eligible: repeatedMeaningfulEvidence && includesPrivateOrLowWitnessEvidence && includesCostlyPressureEvent,
|
|
328
|
+
repeatedMeaningfulEvidence,
|
|
329
|
+
includesPrivateOrLowWitnessEvidence,
|
|
330
|
+
includesCostlyPressureEvent,
|
|
331
|
+
reasonCodes: normalizeReasonCodes(
|
|
332
|
+
eligibility.reasonCodes,
|
|
333
|
+
"Quiet Measure eligibility reasonCodes"
|
|
334
|
+
)
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function normalizeTitleDescriptor(input) {
|
|
338
|
+
const title = assertRecord(input, "Quiet Measure title");
|
|
339
|
+
return Object.freeze({
|
|
340
|
+
titleId: normalizeNonEmptyString(title.titleId, "Quiet Measure title titleId"),
|
|
341
|
+
title: normalizeNonEmptyString(title.title, "Quiet Measure title title"),
|
|
342
|
+
verdictLabel: normalizeNonEmptyString(
|
|
343
|
+
title.verdictLabel,
|
|
344
|
+
"Quiet Measure title verdictLabel"
|
|
345
|
+
),
|
|
346
|
+
perspective: normalizeMember(
|
|
347
|
+
title.perspective,
|
|
348
|
+
QUIET_MEASURE_PERSPECTIVES,
|
|
349
|
+
"Quiet Measure title perspective"
|
|
350
|
+
),
|
|
351
|
+
disclosure: normalizeMember(
|
|
352
|
+
title.disclosure,
|
|
353
|
+
QUIET_MEASURE_JUDGMENT_DISCLOSURES,
|
|
354
|
+
"Quiet Measure title disclosure"
|
|
355
|
+
),
|
|
356
|
+
reasonCodes: normalizeReasonCodes(title.reasonCodes, "Quiet Measure title reasonCodes")
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function normalizeDerivedReadSummary(input, index) {
|
|
360
|
+
const prefix = `Quiet Measure dominantReads[${index}]`;
|
|
361
|
+
const dominantRead = assertRecord(input, prefix);
|
|
362
|
+
return Object.freeze({
|
|
363
|
+
read: normalizeMember(
|
|
364
|
+
dominantRead.read,
|
|
365
|
+
QUIET_MEASURE_DERIVED_READS,
|
|
366
|
+
`${prefix} read`
|
|
367
|
+
),
|
|
368
|
+
perspective: normalizeMember(
|
|
369
|
+
dominantRead.perspective,
|
|
370
|
+
QUIET_MEASURE_PERSPECTIVES,
|
|
371
|
+
`${prefix} perspective`
|
|
372
|
+
),
|
|
373
|
+
signalBand: normalizeMember(
|
|
374
|
+
dominantRead.signalBand,
|
|
375
|
+
QUIET_MEASURE_SIGNAL_BANDS,
|
|
376
|
+
`${prefix} signalBand`
|
|
377
|
+
),
|
|
378
|
+
confidenceBand: normalizeMember(
|
|
379
|
+
dominantRead.confidenceBand,
|
|
380
|
+
QUIET_MEASURE_CONFIDENCE_BANDS,
|
|
381
|
+
`${prefix} confidenceBand`
|
|
382
|
+
),
|
|
383
|
+
reasonCodes: normalizeReasonCodes(
|
|
384
|
+
dominantRead.reasonCodes,
|
|
385
|
+
`${prefix} reasonCodes`
|
|
386
|
+
)
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function normalizeDominantReads(value) {
|
|
390
|
+
if (value === void 0) {
|
|
391
|
+
return Object.freeze([]);
|
|
392
|
+
}
|
|
393
|
+
if (!Array.isArray(value)) {
|
|
394
|
+
throw new TypeError("Quiet Measure dominantReads must be an array.");
|
|
395
|
+
}
|
|
396
|
+
return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
|
|
397
|
+
}
|
|
398
|
+
function isQuietMeasureAxis(value) {
|
|
399
|
+
return isMember(value, QUIET_MEASURE_AXES);
|
|
400
|
+
}
|
|
401
|
+
function isQuietMeasureMissionProbeMode(value) {
|
|
402
|
+
return isMember(value, QUIET_MEASURE_MISSION_PROBE_MODES);
|
|
403
|
+
}
|
|
404
|
+
function isQuietMeasureMissionResolutionShape(value) {
|
|
405
|
+
return isMember(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
|
|
406
|
+
}
|
|
407
|
+
function createQuietMeasureJudgmentEligibility(input = {}) {
|
|
408
|
+
const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
|
|
409
|
+
input.repeatedMeaningfulEvidence,
|
|
410
|
+
false,
|
|
411
|
+
"Quiet Measure eligibility repeatedMeaningfulEvidence"
|
|
412
|
+
);
|
|
413
|
+
const includesPrivateOrLowWitnessEvidence = normalizeOptionalBoolean(
|
|
414
|
+
input.includesPrivateOrLowWitnessEvidence,
|
|
415
|
+
false,
|
|
416
|
+
"Quiet Measure eligibility includesPrivateOrLowWitnessEvidence"
|
|
417
|
+
);
|
|
418
|
+
const includesCostlyPressureEvent = normalizeOptionalBoolean(
|
|
419
|
+
input.includesCostlyPressureEvent,
|
|
420
|
+
false,
|
|
421
|
+
"Quiet Measure eligibility includesCostlyPressureEvent"
|
|
422
|
+
);
|
|
423
|
+
return Object.freeze({
|
|
424
|
+
eligible: repeatedMeaningfulEvidence && includesPrivateOrLowWitnessEvidence && includesCostlyPressureEvent,
|
|
425
|
+
repeatedMeaningfulEvidence,
|
|
426
|
+
includesPrivateOrLowWitnessEvidence,
|
|
427
|
+
includesCostlyPressureEvent,
|
|
428
|
+
reasonCodes: normalizeReasonCodes(input.reasonCodes, "Quiet Measure eligibility reasonCodes")
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function listQuietMeasureMissingEvidence(eligibility) {
|
|
432
|
+
const normalizedEligibility = normalizeJudgmentEligibility(eligibility);
|
|
433
|
+
const missing = [];
|
|
434
|
+
if (!normalizedEligibility.repeatedMeaningfulEvidence) {
|
|
435
|
+
missing.push("repeated-meaningful-evidence");
|
|
436
|
+
}
|
|
437
|
+
if (!normalizedEligibility.includesPrivateOrLowWitnessEvidence) {
|
|
438
|
+
missing.push("private-or-low-witness-evidence");
|
|
439
|
+
}
|
|
440
|
+
if (!normalizedEligibility.includesCostlyPressureEvent) {
|
|
441
|
+
missing.push("costly-pressure-event");
|
|
442
|
+
}
|
|
443
|
+
return Object.freeze(missing);
|
|
444
|
+
}
|
|
445
|
+
function createQuietMeasureJudgmentResponse(input) {
|
|
446
|
+
const request = normalizeJudgmentRequest(input.request);
|
|
447
|
+
const eligibility = normalizeJudgmentEligibility(input.eligibility);
|
|
448
|
+
const missingEvidence = listQuietMeasureMissingEvidence(eligibility);
|
|
449
|
+
const reasonCodes = normalizeReasonCodes(
|
|
450
|
+
input.reasonCodes,
|
|
451
|
+
"Quiet Measure judgment response reasonCodes"
|
|
452
|
+
);
|
|
453
|
+
const hasRequiredEvidence = missingEvidence.length === 0;
|
|
454
|
+
if (!hasRequiredEvidence) {
|
|
455
|
+
return Object.freeze({
|
|
456
|
+
kind: "insufficient-evidence",
|
|
457
|
+
request,
|
|
458
|
+
eligibility: Object.freeze({
|
|
459
|
+
...eligibility,
|
|
460
|
+
eligible: false
|
|
461
|
+
}),
|
|
462
|
+
missingEvidence,
|
|
463
|
+
reasonCodes
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (!input.title) {
|
|
467
|
+
throw new TypeError(
|
|
468
|
+
"Quiet Measure verdict responses require a title descriptor when eligibility is met."
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
return Object.freeze({
|
|
472
|
+
kind: "verdict",
|
|
473
|
+
request,
|
|
474
|
+
eligibility: Object.freeze({
|
|
475
|
+
...eligibility,
|
|
476
|
+
eligible: true
|
|
477
|
+
}),
|
|
478
|
+
title: normalizeTitleDescriptor(input.title),
|
|
479
|
+
dominantReads: normalizeDominantReads(input.dominantReads),
|
|
480
|
+
reasonCodes
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
|
|
147
484
|
// src/index.ts
|
|
148
485
|
var AI_GAME_PACKAGE = "@plasius/ai-game";
|
|
149
486
|
var AI_GAME_ENV_PREFIX = "AI_GAME";
|
|
@@ -574,20 +911,38 @@ var gameEventFeatureFlags = Object.freeze([
|
|
|
574
911
|
AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
|
|
575
912
|
AI_GAME_PACKAGE,
|
|
576
913
|
AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
|
|
914
|
+
AI_GAME_QUIET_MEASURE_FEATURE_FLAG_ID,
|
|
577
915
|
AI_GAME_TASK_AUTHORITY_BOUNDARIES,
|
|
578
916
|
AI_GAME_TASK_DECISIONS,
|
|
579
917
|
AI_GAME_TASK_KINDS,
|
|
580
918
|
AI_GAME_TASK_RESULTS,
|
|
581
919
|
AI_GAME_TASK_RISK_CLASSES,
|
|
582
920
|
AI_GAME_TTS_CACHE_POLICIES,
|
|
921
|
+
QUIET_MEASURE_AXES,
|
|
922
|
+
QUIET_MEASURE_CONFIDENCE_BANDS,
|
|
923
|
+
QUIET_MEASURE_DERIVED_READS,
|
|
924
|
+
QUIET_MEASURE_EVIDENCE_CLASSES,
|
|
925
|
+
QUIET_MEASURE_JUDGMENT_DISCLOSURES,
|
|
926
|
+
QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE,
|
|
927
|
+
QUIET_MEASURE_JUDGMENT_REQUESTERS,
|
|
928
|
+
QUIET_MEASURE_MISSION_PROBE_MODES,
|
|
929
|
+
QUIET_MEASURE_MISSION_RESOLUTION_SHAPES,
|
|
930
|
+
QUIET_MEASURE_PERSPECTIVES,
|
|
931
|
+
QUIET_MEASURE_SIGNAL_BANDS,
|
|
583
932
|
aiGameFeatureFlags,
|
|
584
933
|
classifyAiGameTask,
|
|
934
|
+
createQuietMeasureJudgmentEligibility,
|
|
935
|
+
createQuietMeasureJudgmentResponse,
|
|
585
936
|
gameEventFeatureFlags,
|
|
586
937
|
isCandidateWorldEvent,
|
|
587
938
|
isCanonicalWorldEvent,
|
|
588
939
|
isGossipTopicActive,
|
|
589
940
|
isGossipTopicCorrected,
|
|
590
941
|
isIncidentResolved,
|
|
942
|
+
isQuietMeasureAxis,
|
|
943
|
+
isQuietMeasureMissionProbeMode,
|
|
944
|
+
isQuietMeasureMissionResolutionShape,
|
|
945
|
+
listQuietMeasureMissingEvidence,
|
|
591
946
|
normalizeIncidentImpactVector,
|
|
592
947
|
packageDescriptor,
|
|
593
948
|
projectTopicForAudience,
|