@plasius/ai-game 0.2.0 → 0.3.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 CHANGED
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
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
6
  ## [Unreleased]
7
7
 
8
+ - **Added**
9
+ - (placeholder)
10
+
11
+ - **Changed**
12
+ - (placeholder)
13
+
14
+ - **Fixed**
15
+ - (placeholder)
16
+
17
+ - **Security**
18
+ - (placeholder)
19
+
20
+ ## [0.3.0] - 2026-07-10
21
+
8
22
  - **Added**
9
23
  - (placeholder)
10
24
 
@@ -21,6 +35,7 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
21
35
 
22
36
  - **Added**
23
37
  - Added versioned Player System session, focus-mode, module, alert-priority, and preference-learning contracts under `isekai.player-system.core.enabled`.
38
+ - Added identity projection and target-classification contracts under `isekai.player-system.identity.enabled`, with self/full, knowledge-gated partial, and line-of-sight-safe target payloads.
24
39
 
25
40
  - **Changed**
26
41
  - (placeholder)
@@ -165,3 +180,4 @@ The format is based on **[Keep a Changelog](https://keepachangelog.com/en/1.1.0/
165
180
  [0.1.12]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.12
166
181
  [0.1.13]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.1.13
167
182
  [0.2.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.2.0
183
+ [0.3.0]: https://github.com/Plasius-LTD/ai-game/releases/tag/v0.3.0
package/README.md CHANGED
@@ -96,6 +96,24 @@ The Quiet Measure surface is intentionally structured as a hidden-runtime contra
96
96
  - 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.
97
97
  - Evaluation fixtures for hero, villain, counterfeit, tyrant, and redemption regression cases belong in `@plasius/ai-evals`, not this package.
98
98
 
99
+ ## Identity projection contracts
100
+
101
+ Identity projections are versioned, projection-only payloads under
102
+ `isekai.player-system.identity.enabled`. The identity-card boundary remains the
103
+ authority of record; `@plasius/ai-game` only defines portable consumer
104
+ contracts.
105
+
106
+ - Self projections are full reads.
107
+ - Visible targets are full only when both line of sight and full knowledge are
108
+ present; otherwise fields are redacted into a partial read.
109
+ - Occluded targets always become partial reads with `Withheld` field values.
110
+ - Target categories are `allied`, `neutral`, `unknown`, and `unfriendly`.
111
+
112
+ Use `createAiGameIdentityProjectionContract()` to build an immutable payload
113
+ and `selectAiGameVisibleIdentityTargets()` before rendering line-of-sight
114
+ surfaces. The contract does not carry hidden truth or authority-owned mutation
115
+ data.
116
+
99
117
  ## Development
100
118
 
101
119
  ```bash
@@ -116,6 +134,7 @@ npm run pack:check
116
134
  - `ai.game.npc-gossip.lifecycle.enabled`
117
135
  - `isekai.player-system.quiet-measure.enabled`
118
136
  - `isekai.player-system.core.enabled`
137
+ - `isekai.player-system.identity.enabled`
119
138
  - `isekai.training.institutions.enabled`
120
139
  - `isekai.training.academies.enabled`
121
140
  - `isekai.training.martial.enabled`
package/dist/index.cjs CHANGED
@@ -28,6 +28,13 @@ __export(index_exports, {
28
28
  AI_GAME_FEATURE_FLAG_ID: () => AI_GAME_FEATURE_FLAG_ID,
29
29
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
30
30
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID: () => AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
31
+ AI_GAME_IDENTITY_CONTRACT_VERSION: () => AI_GAME_IDENTITY_CONTRACT_VERSION,
32
+ AI_GAME_IDENTITY_DISCLOSURE_POLICY: () => AI_GAME_IDENTITY_DISCLOSURE_POLICY,
33
+ AI_GAME_IDENTITY_FEATURE_FLAG_ID: () => AI_GAME_IDENTITY_FEATURE_FLAG_ID,
34
+ AI_GAME_IDENTITY_KNOWLEDGE_STATES: () => AI_GAME_IDENTITY_KNOWLEDGE_STATES,
35
+ AI_GAME_IDENTITY_PROJECTION_READS: () => AI_GAME_IDENTITY_PROJECTION_READS,
36
+ AI_GAME_IDENTITY_TARGET_CATEGORIES: () => AI_GAME_IDENTITY_TARGET_CATEGORIES,
37
+ AI_GAME_IDENTITY_VISIBILITY_STATES: () => AI_GAME_IDENTITY_VISIBILITY_STATES,
31
38
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID: () => AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
32
39
  AI_GAME_PACKAGE: () => AI_GAME_PACKAGE,
33
40
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID: () => AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
@@ -77,8 +84,12 @@ __export(index_exports, {
77
84
  QUIET_MEASURE_PERSPECTIVES: () => QUIET_MEASURE_PERSPECTIVES,
78
85
  QUIET_MEASURE_SIGNAL_BANDS: () => QUIET_MEASURE_SIGNAL_BANDS,
79
86
  aiGameFeatureFlags: () => aiGameFeatureFlags,
87
+ assertAiGameIdentityProjectionContractVersion: () => assertAiGameIdentityProjectionContractVersion,
80
88
  classifyAiGameTask: () => classifyAiGameTask,
81
89
  createAiGameAcademicTrainingSnapshot: () => createAiGameAcademicTrainingSnapshot,
90
+ createAiGameIdentityProjectionContract: () => createAiGameIdentityProjectionContract,
91
+ createAiGameIdentitySelfProjection: () => createAiGameIdentitySelfProjection,
92
+ createAiGameIdentityTargetProjection: () => createAiGameIdentityTargetProjection,
82
93
  createAiGameInstitutionEligibility: () => createAiGameInstitutionEligibility,
83
94
  createAiGameMartialTrainingSnapshot: () => createAiGameMartialTrainingSnapshot,
84
95
  createAiGamePlayerSystemAlert: () => createAiGamePlayerSystemAlert,
@@ -98,6 +109,10 @@ __export(index_exports, {
98
109
  gameEventFeatureFlags: () => gameEventFeatureFlags,
99
110
  getAiGamePlayerSystemFocusModeContract: () => getAiGamePlayerSystemFocusModeContract,
100
111
  getAiGamePlayerSystemModuleContract: () => getAiGamePlayerSystemModuleContract,
112
+ isAiGameIdentityKnowledgeState: () => isAiGameIdentityKnowledgeState,
113
+ isAiGameIdentityProjectionRead: () => isAiGameIdentityProjectionRead,
114
+ isAiGameIdentityTargetCategory: () => isAiGameIdentityTargetCategory,
115
+ isAiGameIdentityVisibilityState: () => isAiGameIdentityVisibilityState,
101
116
  isAiGamePlayerSystemAlertDeliverable: () => isAiGamePlayerSystemAlertDeliverable,
102
117
  isAiGamePlayerSystemAlertPriority: () => isAiGamePlayerSystemAlertPriority,
103
118
  isAiGamePlayerSystemConfidenceBand: () => isAiGamePlayerSystemConfidenceBand,
@@ -133,10 +148,12 @@ __export(index_exports, {
133
148
  normalizeIncidentImpactVector: () => normalizeIncidentImpactVector,
134
149
  packageDescriptor: () => packageDescriptor,
135
150
  projectTopicForAudience: () => projectTopicForAudience,
151
+ resolveAiGameIdentityProjectionRead: () => resolveAiGameIdentityProjectionRead,
136
152
  resolveAiGamePlayerAddressText: () => resolveAiGamePlayerAddressText,
137
153
  resolveAiGamePlayerSystemConfidenceBand: () => resolveAiGamePlayerSystemConfidenceBand,
138
154
  resolveAiGameTaskBatch: () => resolveAiGameTaskBatch,
139
- selectAiGamePlayerSystemAlertsForFocusMode: () => selectAiGamePlayerSystemAlertsForFocusMode
155
+ selectAiGamePlayerSystemAlertsForFocusMode: () => selectAiGamePlayerSystemAlertsForFocusMode,
156
+ selectAiGameVisibleIdentityTargets: () => selectAiGameVisibleIdentityTargets
140
157
  });
141
158
  module.exports = __toCommonJS(index_exports);
142
159
 
@@ -656,6 +673,146 @@ function createAiGamePlayerSystemSession(input) {
656
673
  });
657
674
  }
658
675
 
676
+ // src/identity.ts
677
+ var AI_GAME_IDENTITY_FEATURE_FLAG_ID = "isekai.player-system.identity.enabled";
678
+ var AI_GAME_IDENTITY_CONTRACT_VERSION = "1.0";
679
+ var AI_GAME_IDENTITY_PROJECTION_READS = [
680
+ "self",
681
+ "partial",
682
+ "full"
683
+ ];
684
+ var AI_GAME_IDENTITY_TARGET_CATEGORIES = [
685
+ "allied",
686
+ "neutral",
687
+ "unknown",
688
+ "unfriendly"
689
+ ];
690
+ var AI_GAME_IDENTITY_KNOWLEDGE_STATES = [
691
+ "unknown",
692
+ "partial",
693
+ "full"
694
+ ];
695
+ var AI_GAME_IDENTITY_VISIBILITY_STATES = ["visible", "occluded"];
696
+ var AI_GAME_IDENTITY_DISCLOSURE_POLICY = Object.freeze({
697
+ self: "full",
698
+ visibleTargets: "partial-or-full-by-knowledge",
699
+ occludedTargets: "partial-redacted"
700
+ });
701
+ function freezeReadonlyArray3(items) {
702
+ return Object.freeze([...items]);
703
+ }
704
+ function assertNonEmptyString3(value, label) {
705
+ if (value.trim().length === 0) {
706
+ throw new Error(`${label} must be a non-empty string`);
707
+ }
708
+ }
709
+ function assertContractVersion2(value, label = "contractVersion") {
710
+ if (value !== AI_GAME_IDENTITY_CONTRACT_VERSION) {
711
+ throw new Error(`${label} must be ${AI_GAME_IDENTITY_CONTRACT_VERSION}`);
712
+ }
713
+ }
714
+ function isMember2(value, members) {
715
+ return members.includes(value);
716
+ }
717
+ function createField(field) {
718
+ assertNonEmptyString3(field.label, "field.label");
719
+ assertNonEmptyString3(field.value, "field.value");
720
+ return Object.freeze({
721
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
722
+ label: field.label,
723
+ value: field.value,
724
+ redacted: field.redacted ?? false
725
+ });
726
+ }
727
+ function redactField(field, value) {
728
+ return createField({
729
+ label: field.label,
730
+ value,
731
+ redacted: true
732
+ });
733
+ }
734
+ function isAiGameIdentityProjectionRead(value) {
735
+ return isMember2(value, AI_GAME_IDENTITY_PROJECTION_READS);
736
+ }
737
+ function isAiGameIdentityTargetCategory(value) {
738
+ return isMember2(value, AI_GAME_IDENTITY_TARGET_CATEGORIES);
739
+ }
740
+ function isAiGameIdentityKnowledgeState(value) {
741
+ return isMember2(value, AI_GAME_IDENTITY_KNOWLEDGE_STATES);
742
+ }
743
+ function isAiGameIdentityVisibilityState(value) {
744
+ return isMember2(value, AI_GAME_IDENTITY_VISIBILITY_STATES);
745
+ }
746
+ function resolveAiGameIdentityProjectionRead(input) {
747
+ return input.lineOfSight && input.knowledgeState === "full" ? "full" : "partial";
748
+ }
749
+ function createAiGameIdentitySelfProjection(input) {
750
+ assertNonEmptyString3(input.entityId, "entityId");
751
+ assertNonEmptyString3(input.label, "label");
752
+ assertNonEmptyString3(input.summary, "summary");
753
+ return Object.freeze({
754
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
755
+ entityId: input.entityId,
756
+ label: input.label,
757
+ projectionRead: "self",
758
+ summary: input.summary,
759
+ fields: freezeReadonlyArray3(input.fields.map((field) => createField(field)))
760
+ });
761
+ }
762
+ function createAiGameIdentityTargetProjection(input) {
763
+ assertNonEmptyString3(input.targetId, "targetId");
764
+ assertNonEmptyString3(input.label, "label");
765
+ assertNonEmptyString3(input.summary, "summary");
766
+ assertNonEmptyString3(input.combatSummary, "combatSummary");
767
+ if (!isAiGameIdentityTargetCategory(input.category)) {
768
+ throw new Error("category must be a supported identity target category");
769
+ }
770
+ if (!isAiGameIdentityKnowledgeState(input.knowledgeState)) {
771
+ throw new Error("knowledgeState must be a supported identity knowledge state");
772
+ }
773
+ const projectionRead = resolveAiGameIdentityProjectionRead(input);
774
+ const visibility = input.lineOfSight ? "visible" : "occluded";
775
+ const fields = input.fields.map(
776
+ (field) => projectionRead === "full" ? createField(field) : redactField(field, input.lineOfSight ? "Unknown" : "Withheld")
777
+ );
778
+ return Object.freeze({
779
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
780
+ targetId: input.targetId,
781
+ label: input.label,
782
+ category: input.category,
783
+ knowledgeState: input.knowledgeState,
784
+ visibility,
785
+ lineOfSight: input.lineOfSight,
786
+ projectionRead,
787
+ summary: input.summary,
788
+ combatSummary: input.combatSummary,
789
+ fields: freezeReadonlyArray3(fields)
790
+ });
791
+ }
792
+ function selectAiGameVisibleIdentityTargets(targets) {
793
+ return freezeReadonlyArray3(
794
+ targets.filter((target) => target.visibility === "visible" && target.lineOfSight)
795
+ );
796
+ }
797
+ function createAiGameIdentityProjectionContract(input) {
798
+ const self = createAiGameIdentitySelfProjection(input.self);
799
+ const targets = freezeReadonlyArray3(
800
+ (input.targets ?? []).map((target) => createAiGameIdentityTargetProjection(target))
801
+ );
802
+ return Object.freeze({
803
+ contractVersion: AI_GAME_IDENTITY_CONTRACT_VERSION,
804
+ featureFlagId: AI_GAME_IDENTITY_FEATURE_FLAG_ID,
805
+ authorityOwner: "identity-card",
806
+ authorityMode: "projection-only",
807
+ disclosurePolicy: AI_GAME_IDENTITY_DISCLOSURE_POLICY,
808
+ self,
809
+ targets
810
+ });
811
+ }
812
+ function assertAiGameIdentityProjectionContractVersion(value) {
813
+ assertContractVersion2(value);
814
+ }
815
+
659
816
  // src/world-events.ts
660
817
  function isCanonicalWorldEvent(event) {
661
818
  return event.recordType === "canonical";
@@ -807,7 +964,7 @@ var QUIET_MEASURE_JUDGMENT_MISSING_EVIDENCE = [
807
964
  "private-or-low-witness-evidence",
808
965
  "costly-pressure-event"
809
966
  ];
810
- function isMember2(value, members) {
967
+ function isMember3(value, members) {
811
968
  return members.includes(value);
812
969
  }
813
970
  function assertRecord(value, label) {
@@ -848,7 +1005,7 @@ function normalizeTimestamp(value, label) {
848
1005
  }
849
1006
  function normalizeMember(value, members, label) {
850
1007
  const normalized = normalizeNonEmptyString(value, label);
851
- if (!isMember2(normalized, members)) {
1008
+ if (!isMember3(normalized, members)) {
852
1009
  throw new TypeError(`${label} must be one of: ${members.join(", ")}.`);
853
1010
  }
854
1011
  return normalized;
@@ -981,13 +1138,13 @@ function normalizeDominantReads(value) {
981
1138
  return Object.freeze(value.map((entry, index) => normalizeDerivedReadSummary(entry, index)));
982
1139
  }
983
1140
  function isQuietMeasureAxis(value) {
984
- return isMember2(value, QUIET_MEASURE_AXES);
1141
+ return isMember3(value, QUIET_MEASURE_AXES);
985
1142
  }
986
1143
  function isQuietMeasureMissionProbeMode(value) {
987
- return isMember2(value, QUIET_MEASURE_MISSION_PROBE_MODES);
1144
+ return isMember3(value, QUIET_MEASURE_MISSION_PROBE_MODES);
988
1145
  }
989
1146
  function isQuietMeasureMissionResolutionShape(value) {
990
- return isMember2(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
1147
+ return isMember3(value, QUIET_MEASURE_MISSION_RESOLUTION_SHAPES);
991
1148
  }
992
1149
  function createQuietMeasureJudgmentEligibility(input = {}) {
993
1150
  const repeatedMeaningfulEvidence = normalizeOptionalBoolean(
@@ -1493,6 +1650,13 @@ var gameEventFeatureFlags = Object.freeze([
1493
1650
  AI_GAME_FEATURE_FLAG_ID,
1494
1651
  AI_GAME_GOSSIP_LIFECYCLE_FEATURE_FLAG_ID,
1495
1652
  AI_GAME_GOSSIP_TOPICS_FEATURE_FLAG_ID,
1653
+ AI_GAME_IDENTITY_CONTRACT_VERSION,
1654
+ AI_GAME_IDENTITY_DISCLOSURE_POLICY,
1655
+ AI_GAME_IDENTITY_FEATURE_FLAG_ID,
1656
+ AI_GAME_IDENTITY_KNOWLEDGE_STATES,
1657
+ AI_GAME_IDENTITY_PROJECTION_READS,
1658
+ AI_GAME_IDENTITY_TARGET_CATEGORIES,
1659
+ AI_GAME_IDENTITY_VISIBILITY_STATES,
1496
1660
  AI_GAME_INCIDENT_IMPACT_FEATURE_FLAG_ID,
1497
1661
  AI_GAME_PACKAGE,
1498
1662
  AI_GAME_PERSPECTIVE_FEATURE_FLAG_ID,
@@ -1542,8 +1706,12 @@ var gameEventFeatureFlags = Object.freeze([
1542
1706
  QUIET_MEASURE_PERSPECTIVES,
1543
1707
  QUIET_MEASURE_SIGNAL_BANDS,
1544
1708
  aiGameFeatureFlags,
1709
+ assertAiGameIdentityProjectionContractVersion,
1545
1710
  classifyAiGameTask,
1546
1711
  createAiGameAcademicTrainingSnapshot,
1712
+ createAiGameIdentityProjectionContract,
1713
+ createAiGameIdentitySelfProjection,
1714
+ createAiGameIdentityTargetProjection,
1547
1715
  createAiGameInstitutionEligibility,
1548
1716
  createAiGameMartialTrainingSnapshot,
1549
1717
  createAiGamePlayerSystemAlert,
@@ -1563,6 +1731,10 @@ var gameEventFeatureFlags = Object.freeze([
1563
1731
  gameEventFeatureFlags,
1564
1732
  getAiGamePlayerSystemFocusModeContract,
1565
1733
  getAiGamePlayerSystemModuleContract,
1734
+ isAiGameIdentityKnowledgeState,
1735
+ isAiGameIdentityProjectionRead,
1736
+ isAiGameIdentityTargetCategory,
1737
+ isAiGameIdentityVisibilityState,
1566
1738
  isAiGamePlayerSystemAlertDeliverable,
1567
1739
  isAiGamePlayerSystemAlertPriority,
1568
1740
  isAiGamePlayerSystemConfidenceBand,
@@ -1598,9 +1770,11 @@ var gameEventFeatureFlags = Object.freeze([
1598
1770
  normalizeIncidentImpactVector,
1599
1771
  packageDescriptor,
1600
1772
  projectTopicForAudience,
1773
+ resolveAiGameIdentityProjectionRead,
1601
1774
  resolveAiGamePlayerAddressText,
1602
1775
  resolveAiGamePlayerSystemConfidenceBand,
1603
1776
  resolveAiGameTaskBatch,
1604
- selectAiGamePlayerSystemAlertsForFocusMode
1777
+ selectAiGamePlayerSystemAlertsForFocusMode,
1778
+ selectAiGameVisibleIdentityTargets
1605
1779
  });
1606
1780
  //# sourceMappingURL=index.cjs.map