@gridlock/orchestrator 0.1.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/LICENSE +21 -0
- package/dist/AgentRoute.d.ts +44 -0
- package/dist/AgentRoute.d.ts.map +1 -0
- package/dist/AgentRoute.js +54 -0
- package/dist/AgentRoute.js.map +1 -0
- package/dist/CommandRegistry.d.ts +68 -0
- package/dist/CommandRegistry.d.ts.map +1 -0
- package/dist/CommandRegistry.js +87 -0
- package/dist/CommandRegistry.js.map +1 -0
- package/dist/ContextFactory.d.ts +62 -0
- package/dist/ContextFactory.d.ts.map +1 -0
- package/dist/ContextFactory.js +59 -0
- package/dist/ContextFactory.js.map +1 -0
- package/dist/DialogueGate.d.ts +117 -0
- package/dist/DialogueGate.d.ts.map +1 -0
- package/dist/DialogueGate.js +101 -0
- package/dist/DialogueGate.js.map +1 -0
- package/dist/DisclosureEngine.d.ts +160 -0
- package/dist/DisclosureEngine.d.ts.map +1 -0
- package/dist/DisclosureEngine.js +241 -0
- package/dist/DisclosureEngine.js.map +1 -0
- package/dist/EvidenceGraph.d.ts +71 -0
- package/dist/EvidenceGraph.d.ts.map +1 -0
- package/dist/EvidenceGraph.js +177 -0
- package/dist/EvidenceGraph.js.map +1 -0
- package/dist/InteractionEvaluator.d.ts +50 -0
- package/dist/InteractionEvaluator.d.ts.map +1 -0
- package/dist/InteractionEvaluator.js +205 -0
- package/dist/InteractionEvaluator.js.map +1 -0
- package/dist/KnowledgeBoundary.d.ts +74 -0
- package/dist/KnowledgeBoundary.d.ts.map +1 -0
- package/dist/KnowledgeBoundary.js +76 -0
- package/dist/KnowledgeBoundary.js.map +1 -0
- package/dist/evaluation/EscalationClock.d.ts +65 -0
- package/dist/evaluation/EscalationClock.d.ts.map +1 -0
- package/dist/evaluation/EscalationClock.js +106 -0
- package/dist/evaluation/EscalationClock.js.map +1 -0
- package/dist/evaluation/PerformanceEvaluator.d.ts +54 -0
- package/dist/evaluation/PerformanceEvaluator.d.ts.map +1 -0
- package/dist/evaluation/PerformanceEvaluator.js +161 -0
- package/dist/evaluation/PerformanceEvaluator.js.map +1 -0
- package/dist/evaluation/WorldState.d.ts +30 -0
- package/dist/evaluation/WorldState.d.ts.map +1 -0
- package/dist/evaluation/WorldState.js +43 -0
- package/dist/evaluation/WorldState.js.map +1 -0
- package/dist/evaluation/index.d.ts +8 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +4 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/evaluation/types.d.ts +26 -0
- package/dist/evaluation/types.d.ts.map +1 -0
- package/dist/evaluation/types.js +9 -0
- package/dist/evaluation/types.js.map +1 -0
- package/dist/handlers/AssistantCommandRegistry.d.ts +55 -0
- package/dist/handlers/AssistantCommandRegistry.d.ts.map +1 -0
- package/dist/handlers/AssistantCommandRegistry.js +59 -0
- package/dist/handlers/AssistantCommandRegistry.js.map +1 -0
- package/dist/handlers/EvidenceIngestion.d.ts +64 -0
- package/dist/handlers/EvidenceIngestion.d.ts.map +1 -0
- package/dist/handlers/EvidenceIngestion.js +114 -0
- package/dist/handlers/EvidenceIngestion.js.map +1 -0
- package/dist/handlers/GameLifecycle.d.ts +71 -0
- package/dist/handlers/GameLifecycle.d.ts.map +1 -0
- package/dist/handlers/GameLifecycle.js +100 -0
- package/dist/handlers/GameLifecycle.js.map +1 -0
- package/dist/handlers/GraphPopulation.d.ts +24 -0
- package/dist/handlers/GraphPopulation.d.ts.map +1 -0
- package/dist/handlers/GraphPopulation.js +21 -0
- package/dist/handlers/GraphPopulation.js.map +1 -0
- package/dist/handlers/ResolutionGate.d.ts +60 -0
- package/dist/handlers/ResolutionGate.d.ts.map +1 -0
- package/dist/handlers/ResolutionGate.js +49 -0
- package/dist/handlers/ResolutionGate.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/investigation/Analyst.d.ts +80 -0
- package/dist/investigation/Analyst.d.ts.map +1 -0
- package/dist/investigation/Analyst.js +514 -0
- package/dist/investigation/Analyst.js.map +1 -0
- package/dist/investigation/AnalystWorkspace.d.ts +182 -0
- package/dist/investigation/AnalystWorkspace.d.ts.map +1 -0
- package/dist/investigation/AnalystWorkspace.js +405 -0
- package/dist/investigation/AnalystWorkspace.js.map +1 -0
- package/dist/investigation/CaseFile.d.ts +92 -0
- package/dist/investigation/CaseFile.d.ts.map +1 -0
- package/dist/investigation/CaseFile.js +117 -0
- package/dist/investigation/CaseFile.js.map +1 -0
- package/dist/investigation/DiscoveryLayer.d.ts +133 -0
- package/dist/investigation/DiscoveryLayer.d.ts.map +1 -0
- package/dist/investigation/DiscoveryLayer.js +176 -0
- package/dist/investigation/DiscoveryLayer.js.map +1 -0
- package/dist/investigation/FactLedger.d.ts +91 -0
- package/dist/investigation/FactLedger.d.ts.map +1 -0
- package/dist/investigation/FactLedger.js +185 -0
- package/dist/investigation/FactLedger.js.map +1 -0
- package/dist/investigation/InvestigationTimeline.d.ts +98 -0
- package/dist/investigation/InvestigationTimeline.d.ts.map +1 -0
- package/dist/investigation/InvestigationTimeline.js +178 -0
- package/dist/investigation/InvestigationTimeline.js.map +1 -0
- package/dist/investigation/ProfileEngine.d.ts +84 -0
- package/dist/investigation/ProfileEngine.d.ts.map +1 -0
- package/dist/investigation/ProfileEngine.js +170 -0
- package/dist/investigation/ProfileEngine.js.map +1 -0
- package/dist/investigation/WorkspaceProjections.d.ts +94 -0
- package/dist/investigation/WorkspaceProjections.d.ts.map +1 -0
- package/dist/investigation/WorkspaceProjections.js +92 -0
- package/dist/investigation/WorkspaceProjections.js.map +1 -0
- package/dist/investigation/index.d.ts +18 -0
- package/dist/investigation/index.d.ts.map +1 -0
- package/dist/investigation/index.js +10 -0
- package/dist/investigation/index.js.map +1 -0
- package/dist/investigation/types.d.ts +206 -0
- package/dist/investigation/types.d.ts.map +1 -0
- package/dist/investigation/types.js +20 -0
- package/dist/investigation/types.js.map +1 -0
- package/dist/types.d.ts +283 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +70 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvidenceGraph.js","sourceRoot":"","sources":["../src/EvidenceGraph.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IAChB,KAAK,GAA2B,IAAI,GAAG,EAAE,CAAC;IAC1C,KAAK,GAAgB,EAAE,CAAC;IAEhC,YAAY,WAA+B;QACzC,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;YACjE,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,IAAe;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,IAAe,EAAE,iBAAiB,GAAG,IAAI;QACtD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhD,IAAI,CAAC,iBAAiB,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,EAAE,CAAC;YACnD,0BAA0B;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAA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ACI,SAAS;QACd,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACtC,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { DomainInteractionState, RiceProgress, InteractionSignal } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Character RICE profile passed to the evaluator.
|
|
4
|
+
* All values 1-10. Defaults to 5 (neutral) when absent.
|
|
5
|
+
*/
|
|
6
|
+
export interface CharacterRiceProfile {
|
|
7
|
+
rapport: number;
|
|
8
|
+
incentive: number;
|
|
9
|
+
coercion: number;
|
|
10
|
+
ego: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Result metadata returned alongside the new state.
|
|
14
|
+
* Used by SAGE to provide qualitative feedback.
|
|
15
|
+
*/
|
|
16
|
+
export interface InteractionResult {
|
|
17
|
+
state: DomainInteractionState;
|
|
18
|
+
/** Which RICE dimension the action targeted */
|
|
19
|
+
riceDimension: keyof RiceProgress | null;
|
|
20
|
+
/** How effective the action was: 'backfire' | 'weak' | 'neutral' | 'effective' | 'highly_effective' */
|
|
21
|
+
effectiveness: 'backfire' | 'weak' | 'neutral' | 'effective' | 'highly_effective' | 'none';
|
|
22
|
+
}
|
|
23
|
+
export declare function getSensitivityMultiplier(riceScore: number): number;
|
|
24
|
+
export declare const UNBLOCK_BASELINE = 5;
|
|
25
|
+
export declare const MAX_PER_ACTION_GAIN = 4;
|
|
26
|
+
/**
|
|
27
|
+
* Base gain per RICE action type (before sensitivity multiplier).
|
|
28
|
+
* Maps the best action for each dimension to its base gain value.
|
|
29
|
+
* Used by evaluateInteraction() and SolvabilityChecker for RICE reachability.
|
|
30
|
+
*/
|
|
31
|
+
export declare const RICE_BASE_GAINS: Record<string, number>;
|
|
32
|
+
/**
|
|
33
|
+
* Evaluate a player interaction signal against a character's RICE profile.
|
|
34
|
+
* Returns the updated state and effectiveness metadata.
|
|
35
|
+
*
|
|
36
|
+
* When no RICE profile is provided, defaults to neutral (5) for all dimensions,
|
|
37
|
+
* preserving backward compatibility with the pre-RICE behavior.
|
|
38
|
+
*/
|
|
39
|
+
export declare function evaluateInteraction(signal: InteractionSignal, state: DomainInteractionState, riceProfile?: CharacterRiceProfile): InteractionResult;
|
|
40
|
+
/** Build a CharacterRiceProfile from raw schema data. */
|
|
41
|
+
export declare function buildRiceProfile(rice?: {
|
|
42
|
+
reward?: number;
|
|
43
|
+
coercion?: number;
|
|
44
|
+
ego?: number;
|
|
45
|
+
ideology?: number;
|
|
46
|
+
}, ocean?: {
|
|
47
|
+
agreeableness?: number;
|
|
48
|
+
extraversion?: number;
|
|
49
|
+
}): CharacterRiceProfile;
|
|
50
|
+
//# sourceMappingURL=InteractionEvaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionEvaluator.d.ts","sourceRoot":"","sources":["../src/InteractionEvaluator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,sBAAsB,CAAC;IAC9B,+CAA+C;IAC/C,aAAa,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC;IACzC,uGAAuG;IACvG,aAAa,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,GAAG,MAAM,CAAC;CAC5F;AAOD,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAMlE;AAcD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKlD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,sBAAsB,EAC7B,WAAW,CAAC,EAAE,oBAAoB,GACjC,iBAAiB,CAiHnB;AA2CD,yDAAyD;AACzD,wBAAgB,gBAAgB,CAC9B,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAC9E,KAAK,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD,oBAAoB,CAWtB"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Sensitivity multiplier table
|
|
3
|
+
// Shared with SolvabilityChecker for static RICE reachability analysis.
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export function getSensitivityMultiplier(riceScore) {
|
|
6
|
+
if (riceScore <= 2)
|
|
7
|
+
return 0.0; // Immune
|
|
8
|
+
if (riceScore <= 4)
|
|
9
|
+
return 0.5; // Resistant
|
|
10
|
+
if (riceScore <= 6)
|
|
11
|
+
return 1.0; // Neutral
|
|
12
|
+
if (riceScore <= 8)
|
|
13
|
+
return 1.5; // Susceptible
|
|
14
|
+
return 2.0; // Highly susceptible (9-10)
|
|
15
|
+
}
|
|
16
|
+
function getEffectivenessLabel(riceScore) {
|
|
17
|
+
if (riceScore <= 2)
|
|
18
|
+
return 'backfire';
|
|
19
|
+
if (riceScore <= 4)
|
|
20
|
+
return 'weak';
|
|
21
|
+
if (riceScore <= 6)
|
|
22
|
+
return 'neutral';
|
|
23
|
+
if (riceScore <= 8)
|
|
24
|
+
return 'effective';
|
|
25
|
+
return 'highly_effective';
|
|
26
|
+
}
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Core evaluator
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
export const UNBLOCK_BASELINE = 5;
|
|
31
|
+
export const MAX_PER_ACTION_GAIN = 4;
|
|
32
|
+
/**
|
|
33
|
+
* Base gain per RICE action type (before sensitivity multiplier).
|
|
34
|
+
* Maps the best action for each dimension to its base gain value.
|
|
35
|
+
* Used by evaluateInteraction() and SolvabilityChecker for RICE reachability.
|
|
36
|
+
*/
|
|
37
|
+
export const RICE_BASE_GAINS = {
|
|
38
|
+
rapport: 1.0, // empathize
|
|
39
|
+
incentive: 2.5, // gift_high
|
|
40
|
+
coercion: 1.5, // threaten
|
|
41
|
+
ego: 2.0, // challenge
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Evaluate a player interaction signal against a character's RICE profile.
|
|
45
|
+
* Returns the updated state and effectiveness metadata.
|
|
46
|
+
*
|
|
47
|
+
* When no RICE profile is provided, defaults to neutral (5) for all dimensions,
|
|
48
|
+
* preserving backward compatibility with the pre-RICE behavior.
|
|
49
|
+
*/
|
|
50
|
+
export function evaluateInteraction(signal, state, riceProfile) {
|
|
51
|
+
const profile = riceProfile ?? {
|
|
52
|
+
rapport: 5, incentive: 5, coercion: 5, ego: 5,
|
|
53
|
+
};
|
|
54
|
+
const newState = { ...state };
|
|
55
|
+
newState.riceProgress = { ...state.riceProgress };
|
|
56
|
+
newState.recentSignals = [...(state.recentSignals || []), signal].slice(-10);
|
|
57
|
+
let riceDimension = null;
|
|
58
|
+
let effectiveness = 'none';
|
|
59
|
+
if (signal.type === 'dialogue') {
|
|
60
|
+
if (signal.subtype === 'accuse_no_evidence') {
|
|
61
|
+
// Accusation without evidence — not RICE-scaled, always penalizes
|
|
62
|
+
newState.hostility = Math.min(10, newState.hostility + 2);
|
|
63
|
+
// Reduce best progress dimension by 2
|
|
64
|
+
_reduceBestProgress(newState.riceProgress, 2);
|
|
65
|
+
}
|
|
66
|
+
else if (signal.subtype === 'accuse_with_evidence') {
|
|
67
|
+
// Evidence-backed accusation — not RICE-scaled, always rewards
|
|
68
|
+
// Boost best progress dimension by 2
|
|
69
|
+
_boostBestProgress(newState.riceProgress, 2);
|
|
70
|
+
newState.trust = Math.min(10, newState.trust + 1);
|
|
71
|
+
}
|
|
72
|
+
else if (signal.subtype === 'empathize') {
|
|
73
|
+
riceDimension = 'rapport';
|
|
74
|
+
const multiplier = getSensitivityMultiplier(profile.rapport);
|
|
75
|
+
effectiveness = getEffectivenessLabel(profile.rapport);
|
|
76
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(1.0 * multiplier));
|
|
77
|
+
newState.riceProgress.rapport = Math.min(10, newState.riceProgress.rapport + gain);
|
|
78
|
+
newState.rapport = Math.min(10, newState.rapport + Math.max(1, gain));
|
|
79
|
+
newState.hostility = Math.max(1, newState.hostility - 1);
|
|
80
|
+
// Empathy never backfires
|
|
81
|
+
}
|
|
82
|
+
else if (signal.subtype === 'threaten') {
|
|
83
|
+
riceDimension = 'coercion';
|
|
84
|
+
const multiplier = getSensitivityMultiplier(profile.coercion);
|
|
85
|
+
effectiveness = getEffectivenessLabel(profile.coercion);
|
|
86
|
+
if (multiplier === 0.0) {
|
|
87
|
+
// Backfire: immune to coercion
|
|
88
|
+
_reduceBestProgress(newState.riceProgress, 1);
|
|
89
|
+
newState.hostility = Math.min(10, newState.hostility + 2);
|
|
90
|
+
}
|
|
91
|
+
else if (newState.hostility >= 5 && multiplier < 1.5) {
|
|
92
|
+
// High hostility + not susceptible = backfire (preserves old behavior)
|
|
93
|
+
_reduceBestProgress(newState.riceProgress, 1);
|
|
94
|
+
newState.hostility = Math.min(10, newState.hostility + 2);
|
|
95
|
+
effectiveness = 'backfire';
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(1.5 * multiplier));
|
|
99
|
+
newState.riceProgress.coercion = Math.min(10, newState.riceProgress.coercion + gain);
|
|
100
|
+
newState.hostility = Math.min(10, newState.hostility + 1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (signal.subtype === 'flatter') {
|
|
104
|
+
riceDimension = 'ego';
|
|
105
|
+
const multiplier = getSensitivityMultiplier(profile.ego);
|
|
106
|
+
effectiveness = getEffectivenessLabel(profile.ego);
|
|
107
|
+
if (multiplier === 0.0) {
|
|
108
|
+
// Backfire: immune to flattery — feels patronized
|
|
109
|
+
newState.hostility = Math.min(10, newState.hostility + 1);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(1.0 * multiplier));
|
|
113
|
+
newState.riceProgress.ego = Math.min(10, newState.riceProgress.ego + gain);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (signal.subtype === 'challenge') {
|
|
117
|
+
riceDimension = 'ego';
|
|
118
|
+
const multiplier = getSensitivityMultiplier(profile.ego);
|
|
119
|
+
effectiveness = getEffectivenessLabel(profile.ego);
|
|
120
|
+
if (multiplier === 0.0) {
|
|
121
|
+
// Backfire: challenged but not ego-driven — hostility
|
|
122
|
+
newState.hostility = Math.min(10, newState.hostility + 2);
|
|
123
|
+
_reduceBestProgress(newState.riceProgress, 1);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(2.0 * multiplier));
|
|
127
|
+
newState.riceProgress.ego = Math.min(10, newState.riceProgress.ego + gain);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
else if (signal.type === 'gift') {
|
|
132
|
+
riceDimension = 'incentive';
|
|
133
|
+
const multiplier = getSensitivityMultiplier(profile.incentive);
|
|
134
|
+
effectiveness = getEffectivenessLabel(profile.incentive);
|
|
135
|
+
if (signal.subtype === 'gift_high') {
|
|
136
|
+
if (multiplier === 0.0) {
|
|
137
|
+
// Backfire: perceived as bribe
|
|
138
|
+
newState.trust = Math.max(1, newState.trust - 1);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(2.5 * multiplier));
|
|
142
|
+
newState.riceProgress.incentive = Math.min(10, newState.riceProgress.incentive + gain);
|
|
143
|
+
newState.rapport = Math.min(10, newState.rapport + 1); // minor social side-effect
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else if (signal.subtype === 'gift_low') {
|
|
147
|
+
if (multiplier === 0.0) {
|
|
148
|
+
newState.trust = Math.max(1, newState.trust - 1);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const gain = Math.min(MAX_PER_ACTION_GAIN, Math.round(1.0 * multiplier));
|
|
152
|
+
newState.riceProgress.incentive = Math.min(10, newState.riceProgress.incentive + gain);
|
|
153
|
+
newState.rapport = Math.min(10, newState.rapport + 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Derive unblockScore from baseline + best RICE progress
|
|
158
|
+
newState.unblockScore = _deriveUnblockScore(newState.riceProgress);
|
|
159
|
+
return { state: newState, riceDimension, effectiveness };
|
|
160
|
+
}
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// Helpers
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
function _deriveUnblockScore(progress) {
|
|
165
|
+
const best = Math.max(progress.rapport, progress.incentive, progress.coercion, progress.ego);
|
|
166
|
+
return Math.min(10, UNBLOCK_BASELINE + best);
|
|
167
|
+
}
|
|
168
|
+
function _reduceBestProgress(progress, amount) {
|
|
169
|
+
// Find the dimension with the highest progress and reduce it
|
|
170
|
+
const dims = ['rapport', 'incentive', 'coercion', 'ego'];
|
|
171
|
+
let bestDim = 'rapport';
|
|
172
|
+
let bestVal = 0;
|
|
173
|
+
for (const dim of dims) {
|
|
174
|
+
if (progress[dim] > bestVal) {
|
|
175
|
+
bestVal = progress[dim];
|
|
176
|
+
bestDim = dim;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
progress[bestDim] = Math.max(0, progress[bestDim] - amount);
|
|
180
|
+
}
|
|
181
|
+
function _boostBestProgress(progress, amount) {
|
|
182
|
+
const dims = ['rapport', 'incentive', 'coercion', 'ego'];
|
|
183
|
+
let bestDim = 'rapport';
|
|
184
|
+
let bestVal = 0;
|
|
185
|
+
for (const dim of dims) {
|
|
186
|
+
if (progress[dim] > bestVal) {
|
|
187
|
+
bestVal = progress[dim];
|
|
188
|
+
bestDim = dim;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
progress[bestDim] = Math.min(10, progress[bestDim] + amount);
|
|
192
|
+
}
|
|
193
|
+
/** Build a CharacterRiceProfile from raw schema data. */
|
|
194
|
+
export function buildRiceProfile(rice, ocean) {
|
|
195
|
+
const rapportFromOcean = (ocean?.agreeableness != null && ocean?.extraversion != null)
|
|
196
|
+
? Math.round((ocean.agreeableness + ocean.extraversion) / 2)
|
|
197
|
+
: 5;
|
|
198
|
+
return {
|
|
199
|
+
rapport: rapportFromOcean,
|
|
200
|
+
incentive: rice?.reward ?? 5,
|
|
201
|
+
coercion: rice?.coercion ?? 5,
|
|
202
|
+
ego: rice?.ego ?? 5,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=InteractionEvaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionEvaluator.js","sourceRoot":"","sources":["../src/InteractionEvaluator.ts"],"names":[],"mappings":"AAyBA,8EAA8E;AAC9E,+BAA+B;AAC/B,wEAAwE;AACxE,8EAA8E;AAE9E,MAAM,UAAU,wBAAwB,CAAC,SAAiB;IACxD,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,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Q,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,gBAAgB,CAC9B,IAA8E,EAC9E,KAAyD;IAEzD,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,aAAa,IAAI,IAAI,IAAI,KAAK,EAAE,YAAY,IAAI,IAAI,CAAC;QACpF,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC,CAAC;IAEN,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,SAAS,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;QAC5B,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,CAAC;QAC7B,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Boundary — entity-scoped knowledge projection.
|
|
3
|
+
*
|
|
4
|
+
* Engine-generic: computes the set of facts, entities, and artifacts
|
|
5
|
+
* that a specific entity is aware of at a given moment. This is a
|
|
6
|
+
* reusable engine primitive — no TIC vocabulary.
|
|
7
|
+
*
|
|
8
|
+
* Computed deterministically from:
|
|
9
|
+
* 1. Authored knowledge (declarative knowledge field on entity definition)
|
|
10
|
+
* 2. Entity's own facts
|
|
11
|
+
* 3. Graph-derived knowledge (BFS traversal filtered by visibility score)
|
|
12
|
+
* 4. Disclosed knowledge (facts shared during interactions)
|
|
13
|
+
*
|
|
14
|
+
* See docs/architecture/character-knowledge-model.md for full design.
|
|
15
|
+
*/
|
|
16
|
+
import type { EvidenceGraph } from './EvidenceGraph.js';
|
|
17
|
+
import type { Finding } from '@gridlock/validators';
|
|
18
|
+
/** Entity-scoped knowledge view — what an entity knows at a point in time. */
|
|
19
|
+
export interface EntityKnowledgeView {
|
|
20
|
+
/** The entity this view belongs to. */
|
|
21
|
+
entityId: string;
|
|
22
|
+
/** All fact IDs the entity knows. */
|
|
23
|
+
knownFactIds: Set<string>;
|
|
24
|
+
/** All peer entity IDs the entity is aware of. */
|
|
25
|
+
knownEntityIds: Set<string>;
|
|
26
|
+
/** All artifact IDs the entity is aware of. */
|
|
27
|
+
knownArtifactIds: Set<string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Authored knowledge declaration on an entity definition.
|
|
31
|
+
* Mirrors the case-schema knowledge field shape.
|
|
32
|
+
*/
|
|
33
|
+
export interface AuthoredKnowledge {
|
|
34
|
+
factIds: string[];
|
|
35
|
+
characterIds: string[];
|
|
36
|
+
artifactIds: string[];
|
|
37
|
+
}
|
|
38
|
+
/** A fact owned by an entity (id + subject). */
|
|
39
|
+
export interface EntityFact {
|
|
40
|
+
id: string;
|
|
41
|
+
subject: string;
|
|
42
|
+
}
|
|
43
|
+
/** A disclosure record — a fact shared with an entity during interaction. */
|
|
44
|
+
export interface KnowledgeDisclosure {
|
|
45
|
+
entityId: string;
|
|
46
|
+
factId: string;
|
|
47
|
+
}
|
|
48
|
+
/** Input for computing an entity's knowledge view. */
|
|
49
|
+
export interface KnowledgeBoundaryInput {
|
|
50
|
+
/** The entity to compute the view for. */
|
|
51
|
+
entityId: string;
|
|
52
|
+
/** Authored knowledge declarations (from entity definition). */
|
|
53
|
+
authoredKnowledge?: AuthoredKnowledge;
|
|
54
|
+
/** Facts owned by this entity. */
|
|
55
|
+
ownFacts: EntityFact[];
|
|
56
|
+
/** The discovered evidence graph. */
|
|
57
|
+
graph: EvidenceGraph;
|
|
58
|
+
/** Visibility score controlling graph traversal depth. */
|
|
59
|
+
visibilityScore: number;
|
|
60
|
+
/** All findings in the current state. */
|
|
61
|
+
findings: Finding[];
|
|
62
|
+
/** All disclosures made to entities. */
|
|
63
|
+
disclosures: KnowledgeDisclosure[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Computes the entity-scoped knowledge view.
|
|
67
|
+
*
|
|
68
|
+
* This is the engine-generic extraction of what was formerly
|
|
69
|
+
* `Orchestrator.getCharacterKnowledgeView()`. It takes explicit
|
|
70
|
+
* inputs rather than reading from game state, making it testable
|
|
71
|
+
* in isolation and reusable outside TIC.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getEntityKnowledgeView(input: KnowledgeBoundaryInput): EntityKnowledgeView;
|
|
74
|
+
//# sourceMappingURL=KnowledgeBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBoundary.d.ts","sourceRoot":"","sources":["../src/KnowledgeBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAMpD,8EAA8E;AAC9E,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,kDAAkD;IAClD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,+CAA+C;IAC/C,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACrC,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,kCAAkC;IAClC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,qCAAqC;IACrC,KAAK,EAAE,aAAa,CAAC;IACrB,0DAA0D;IAC1D,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,wCAAwC;IACxC,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAMD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,mBAAmB,CAyDzF"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge Boundary — entity-scoped knowledge projection.
|
|
3
|
+
*
|
|
4
|
+
* Engine-generic: computes the set of facts, entities, and artifacts
|
|
5
|
+
* that a specific entity is aware of at a given moment. This is a
|
|
6
|
+
* reusable engine primitive — no TIC vocabulary.
|
|
7
|
+
*
|
|
8
|
+
* Computed deterministically from:
|
|
9
|
+
* 1. Authored knowledge (declarative knowledge field on entity definition)
|
|
10
|
+
* 2. Entity's own facts
|
|
11
|
+
* 3. Graph-derived knowledge (BFS traversal filtered by visibility score)
|
|
12
|
+
* 4. Disclosed knowledge (facts shared during interactions)
|
|
13
|
+
*
|
|
14
|
+
* See docs/architecture/character-knowledge-model.md for full design.
|
|
15
|
+
*/
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Core function
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Computes the entity-scoped knowledge view.
|
|
21
|
+
*
|
|
22
|
+
* This is the engine-generic extraction of what was formerly
|
|
23
|
+
* `Orchestrator.getCharacterKnowledgeView()`. It takes explicit
|
|
24
|
+
* inputs rather than reading from game state, making it testable
|
|
25
|
+
* in isolation and reusable outside TIC.
|
|
26
|
+
*/
|
|
27
|
+
export function getEntityKnowledgeView(input) {
|
|
28
|
+
const { entityId, authoredKnowledge, ownFacts, graph, visibilityScore, findings, disclosures, } = input;
|
|
29
|
+
const knownFactIds = new Set();
|
|
30
|
+
const knownEntityIds = new Set();
|
|
31
|
+
const knownArtifactIds = new Set();
|
|
32
|
+
// 1. Seed with authored knowledge (from definition)
|
|
33
|
+
if (authoredKnowledge) {
|
|
34
|
+
for (const id of authoredKnowledge.factIds)
|
|
35
|
+
knownFactIds.add(id);
|
|
36
|
+
for (const id of authoredKnowledge.characterIds)
|
|
37
|
+
knownEntityIds.add(id);
|
|
38
|
+
for (const id of authoredKnowledge.artifactIds)
|
|
39
|
+
knownArtifactIds.add(id);
|
|
40
|
+
}
|
|
41
|
+
// 2. Add entity's own fact IDs
|
|
42
|
+
for (const fact of ownFacts) {
|
|
43
|
+
knownFactIds.add(fact.id);
|
|
44
|
+
}
|
|
45
|
+
// 3. Graph-derived knowledge — filtered by visibilityScore
|
|
46
|
+
const visibleGraph = graph.getVisibleSubgraph(entityId, visibilityScore);
|
|
47
|
+
for (const node of visibleGraph.getAllNodes()) {
|
|
48
|
+
if (node.id === entityId)
|
|
49
|
+
continue; // skip self (added below)
|
|
50
|
+
if (node.type === 'fact')
|
|
51
|
+
knownFactIds.add(node.id);
|
|
52
|
+
else if (node.type === 'character')
|
|
53
|
+
knownEntityIds.add(node.id);
|
|
54
|
+
else if (node.type === 'artifact')
|
|
55
|
+
knownArtifactIds.add(node.id);
|
|
56
|
+
else if (node.type === 'finding') {
|
|
57
|
+
// Finding in visible subgraph — entity becomes aware of related entities
|
|
58
|
+
const finding = findings.find(f => f.id === node.id);
|
|
59
|
+
if (finding) {
|
|
60
|
+
for (const ref of finding.relatedEntities.filter(e => e.type === 'character')) {
|
|
61
|
+
knownEntityIds.add(ref.id);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// 4. Disclosed knowledge (facts shared during interactions)
|
|
67
|
+
for (const disclosure of disclosures) {
|
|
68
|
+
if (disclosure.entityId === entityId) {
|
|
69
|
+
knownFactIds.add(disclosure.factId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Entity always knows about itself
|
|
73
|
+
knownEntityIds.add(entityId);
|
|
74
|
+
return { entityId, knownFactIds, knownEntityIds, knownArtifactIds };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=KnowledgeBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnowledgeBoundary.js","sourceRoot":"","sources":["../src/KnowledgeBoundary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6DH,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAA6B;IAClE,MAAM,EACJ,QAAQ,EACR,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,eAAe,EACf,QAAQ,EACR,WAAW,GACZ,GAAG,KAAK,CAAC;IAEV,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IACzC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;IAE3C,oDAAoD;IACpD,IAAI,iBAAiB,EAAE,CAAC;QACtB,KAAK,MAAM,EAAE,IAAI,iBAAiB,CAAC,OAAO;YAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjE,KAAK,MAAM,EAAE,IAAI,iBAAiB,CAAC,YAAY;YAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxE,KAAK,MAAM,EAAE,IAAI,iBAAiB,CAAC,WAAW;YAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,+BAA+B;IAC/B,KAAK,MAA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QAAQ,EAAE,CAAC;YACrC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE7B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluation Layer — Operational Escalation Clock
|
|
3
|
+
*
|
|
4
|
+
* Generic time-pressure mechanic: actions cost time, phases escalate,
|
|
5
|
+
* messages fire at thresholds. Engine-level primitive.
|
|
6
|
+
*
|
|
7
|
+
* Core-Configure pattern:
|
|
8
|
+
* - Engine provides: clock mechanics, phase transitions, action cost lookup
|
|
9
|
+
* - Product provides: phase definitions, messages, action cost table, status labels
|
|
10
|
+
*
|
|
11
|
+
* The clock exists above the Evidence Engine — it never modifies
|
|
12
|
+
* validator truth, findings, or resolution gating. It creates pressure
|
|
13
|
+
* through narrative events and minor gameplay effects.
|
|
14
|
+
*/
|
|
15
|
+
/** A single phase in the escalation sequence. */
|
|
16
|
+
export interface PhaseDefinition {
|
|
17
|
+
/** Unique phase identifier. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Threshold as a fraction of max time (0.0 to 1.0). */
|
|
20
|
+
threshold: number;
|
|
21
|
+
/** Message displayed when this phase is entered. Empty string = silent. */
|
|
22
|
+
message: string;
|
|
23
|
+
/** Qualitative label for status display (e.g. "on track", "critical"). */
|
|
24
|
+
statusLabel: string;
|
|
25
|
+
}
|
|
26
|
+
/** Full clock configuration injected by the product layer. */
|
|
27
|
+
export interface ClockConfig {
|
|
28
|
+
/** Ordered list of phases (must be sorted by threshold ascending). */
|
|
29
|
+
phases: PhaseDefinition[];
|
|
30
|
+
/** Action costs by verb. Unknown verbs default to 0. */
|
|
31
|
+
actionCosts: Record<string, number>;
|
|
32
|
+
}
|
|
33
|
+
/** TIC's default clock configuration. */
|
|
34
|
+
export declare const TIC_CLOCK_CONFIG: ClockConfig;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use PhaseDefinition.id (string) instead.
|
|
37
|
+
* Kept for backward compatibility with GameState.clock.phase typing.
|
|
38
|
+
*/
|
|
39
|
+
export type EscalationPhase = 'initial_lead' | 'internal_suspicion' | 'security_review' | 'hq_pressure' | 'operational_deadline';
|
|
40
|
+
export interface GameClock {
|
|
41
|
+
/** Time units elapsed. */
|
|
42
|
+
current: number;
|
|
43
|
+
/** Maximum time units for this case. */
|
|
44
|
+
max: number;
|
|
45
|
+
/** Current phase identifier. */
|
|
46
|
+
phase: string;
|
|
47
|
+
/** Phases already announced (to prevent repeats). */
|
|
48
|
+
announcedPhases: Set<string>;
|
|
49
|
+
/** Clock configuration (phases, action costs). */
|
|
50
|
+
config: ClockConfig;
|
|
51
|
+
}
|
|
52
|
+
/** Create a new clock for a case. Accepts optional config; defaults to TIC. */
|
|
53
|
+
export declare function createClock(maxTime?: number, config?: ClockConfig): GameClock;
|
|
54
|
+
/** Get the time cost of a command verb from the clock's config. */
|
|
55
|
+
export declare function getActionCost(verb: string, clock?: GameClock): number;
|
|
56
|
+
/**
|
|
57
|
+
* Advance the clock and return any phase transition message.
|
|
58
|
+
* Returns empty string if no phase transition occurred.
|
|
59
|
+
*/
|
|
60
|
+
export declare function advanceClock(clock: GameClock, cost: number): string;
|
|
61
|
+
/** Get a qualitative label for status display. */
|
|
62
|
+
export declare function getClockStatusLabel(clock: GameClock): string;
|
|
63
|
+
/** Check if the clock has exceeded max time. */
|
|
64
|
+
export declare function isOverrun(clock: GameClock): boolean;
|
|
65
|
+
//# sourceMappingURL=EscalationClock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EscalationClock.d.ts","sourceRoot":"","sources":["../../src/evaluation/EscalationClock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,iDAA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ChD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEnD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluation Layer — Operational Escalation Clock
|
|
3
|
+
*
|
|
4
|
+
* Generic time-pressure mechanic: actions cost time, phases escalate,
|
|
5
|
+
* messages fire at thresholds. Engine-level primitive.
|
|
6
|
+
*
|
|
7
|
+
* Core-Configure pattern:
|
|
8
|
+
* - Engine provides: clock mechanics, phase transitions, action cost lookup
|
|
9
|
+
* - Product provides: phase definitions, messages, action cost table, status labels
|
|
10
|
+
*
|
|
11
|
+
* The clock exists above the Evidence Engine — it never modifies
|
|
12
|
+
* validator truth, findings, or resolution gating. It creates pressure
|
|
13
|
+
* through narrative events and minor gameplay effects.
|
|
14
|
+
*/
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// TIC default configuration
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/** TIC's default escalation phases. Product layers override via ClockConfig. */
|
|
19
|
+
const TIC_DEFAULT_PHASES = [
|
|
20
|
+
{ id: 'initial_lead', threshold: 0.0, message: '', statusLabel: 'on track' },
|
|
21
|
+
{ id: 'internal_suspicion', threshold: 0.3, message: 'C: The organisation is becoming aware something is wrong. Work efficiently.', statusLabel: 'active — organisation alerted' },
|
|
22
|
+
{ id: 'security_review', threshold: 0.55, message: 'C: Security has started reviewing access logs. Some sources may become less cooperative.', statusLabel: 'elevated — security review underway' },
|
|
23
|
+
{ id: 'hq_pressure', threshold: 0.8, message: 'C: HQ is demanding progress. You are running out of time to build your case.', statusLabel: 'critical — HQ demanding progress' },
|
|
24
|
+
{ id: 'operational_deadline', threshold: 1.0, message: 'C: This is your final window. Submit your conclusion or the operation will be recorded as a failure.', statusLabel: 'final window — submit conclusion' },
|
|
25
|
+
];
|
|
26
|
+
/** TIC's default action costs. Product layers override via ClockConfig. */
|
|
27
|
+
const TIC_DEFAULT_ACTION_COSTS = {
|
|
28
|
+
talk: 2,
|
|
29
|
+
examine: 1,
|
|
30
|
+
solve: 1,
|
|
31
|
+
empathize: 1,
|
|
32
|
+
threaten: 1,
|
|
33
|
+
gift: 1,
|
|
34
|
+
flatter: 1,
|
|
35
|
+
challenge: 1,
|
|
36
|
+
accuse: 0, // conclusion — not penalized
|
|
37
|
+
// Read-only / analysis — no cost
|
|
38
|
+
notes: 0,
|
|
39
|
+
timeline: 0,
|
|
40
|
+
findings: 0,
|
|
41
|
+
graph: 0,
|
|
42
|
+
sage: 0,
|
|
43
|
+
logbook: 0,
|
|
44
|
+
help: 0,
|
|
45
|
+
};
|
|
46
|
+
/** TIC's default clock configuration. */
|
|
47
|
+
export const TIC_CLOCK_CONFIG = {
|
|
48
|
+
phases: TIC_DEFAULT_PHASES,
|
|
49
|
+
actionCosts: TIC_DEFAULT_ACTION_COSTS,
|
|
50
|
+
};
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Functions
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
/** Create a new clock for a case. Accepts optional config; defaults to TIC. */
|
|
55
|
+
export function createClock(maxTime = 20, config = TIC_CLOCK_CONFIG) {
|
|
56
|
+
const initialPhase = config.phases.length > 0 ? config.phases[0].id : 'default';
|
|
57
|
+
return {
|
|
58
|
+
current: 0,
|
|
59
|
+
max: maxTime,
|
|
60
|
+
phase: initialPhase,
|
|
61
|
+
announcedPhases: new Set([initialPhase]),
|
|
62
|
+
config,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Get the time cost of a command verb from the clock's config. */
|
|
66
|
+
export function getActionCost(verb, clock) {
|
|
67
|
+
const costs = clock?.config.actionCosts ?? TIC_DEFAULT_ACTION_COSTS;
|
|
68
|
+
return costs[verb] ?? 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Advance the clock and return any phase transition message.
|
|
72
|
+
* Returns empty string if no phase transition occurred.
|
|
73
|
+
*/
|
|
74
|
+
export function advanceClock(clock, cost) {
|
|
75
|
+
if (cost <= 0)
|
|
76
|
+
return '';
|
|
77
|
+
clock.current += cost;
|
|
78
|
+
// Determine current phase based on progress
|
|
79
|
+
const progress = clock.current / clock.max;
|
|
80
|
+
let newPhaseId = clock.phase;
|
|
81
|
+
for (const phaseDef of clock.config.phases) {
|
|
82
|
+
if (progress >= phaseDef.threshold) {
|
|
83
|
+
newPhaseId = phaseDef.id;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Check for phase transition
|
|
87
|
+
if (newPhaseId !== clock.phase && !clock.announcedPhases.has(newPhaseId)) {
|
|
88
|
+
clock.phase = newPhaseId;
|
|
89
|
+
clock.announcedPhases.add(newPhaseId);
|
|
90
|
+
const phaseDef = clock.config.phases.find(p => p.id === newPhaseId);
|
|
91
|
+
return phaseDef?.message ?? '';
|
|
92
|
+
}
|
|
93
|
+
// Update phase even if already announced
|
|
94
|
+
clock.phase = newPhaseId;
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
/** Get a qualitative label for status display. */
|
|
98
|
+
export function getClockStatusLabel(clock) {
|
|
99
|
+
const phaseDef = clock.config.phases.find(p => p.id === clock.phase);
|
|
100
|
+
return phaseDef?.statusLabel ?? clock.phase;
|
|
101
|
+
}
|
|
102
|
+
/** Check if the clock has exceeded max time. */
|
|
103
|
+
export function isOverrun(clock) {
|
|
104
|
+
return clock.current > clock.max;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=EscalationClock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EscalationClock.js","sourceRoot":"","sources":["../../src/evaluation/EscalationClock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA0BH,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE9E,gFAAgF;AAChF,MAAM,kBAAkB,GAAsB;IAC5C,EAAE,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,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