1
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
import type { SimulationRunResult } from '../../types';
|
||||
|
||||
export interface NarrativeReplaySeed {
|
||||
id: string;
|
||||
seed: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function recordReplaySeed(params: {
|
||||
seed: string;
|
||||
label: string;
|
||||
}) {
|
||||
return {
|
||||
id: `replay-seed:${params.seed}`,
|
||||
seed: params.seed,
|
||||
label: params.label,
|
||||
} satisfies NarrativeReplaySeed;
|
||||
}
|
||||
|
||||
export function replayNarrativeRun(params: {
|
||||
recordedSeed: NarrativeReplaySeed;
|
||||
result: SimulationRunResult;
|
||||
}) {
|
||||
return {
|
||||
replayId: `replay:${params.recordedSeed.id}`,
|
||||
seed: params.recordedSeed.seed,
|
||||
summary: `${params.recordedSeed.label} 回放结果:${params.result.summary}`,
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { recordReplaySeed, replayNarrativeRun } from './narrativeRegressionReplay';
|
||||
import { recordRerunSeed, rerunNarrativeSimulation } from './narrativeRegressionRerun';
|
||||
|
||||
describe('narrativeRegressionReplay', () => {
|
||||
it('records and replays a narrative seed summary', () => {
|
||||
const seed = recordReplaySeed({
|
||||
describe('narrativeRegressionRerun', () => {
|
||||
it('records and reruns a narrative seed summary', () => {
|
||||
const seed = recordRerunSeed({
|
||||
seed: 'baseline',
|
||||
label: 'Baseline',
|
||||
});
|
||||
const replay = replayNarrativeRun({
|
||||
const rerun = rerunNarrativeSimulation({
|
||||
recordedSeed: seed,
|
||||
result: {
|
||||
id: 'simulation-1',
|
||||
@@ -23,6 +23,6 @@ describe('narrativeRegressionReplay', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(replay.summary).toContain('Baseline');
|
||||
expect(rerun.summary).toContain('Baseline');
|
||||
});
|
||||
});
|
||||
29
src/services/storyEngine/narrativeRegressionRerun.ts
Normal file
29
src/services/storyEngine/narrativeRegressionRerun.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { SimulationRunResult } from '../../types';
|
||||
|
||||
export interface NarrativeRerunSeed {
|
||||
id: string;
|
||||
seed: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function recordRerunSeed(params: {
|
||||
seed: string;
|
||||
label: string;
|
||||
}) {
|
||||
return {
|
||||
id: `rerun-seed:${params.seed}`,
|
||||
seed: params.seed,
|
||||
label: params.label,
|
||||
} satisfies NarrativeRerunSeed;
|
||||
}
|
||||
|
||||
export function rerunNarrativeSimulation(params: {
|
||||
recordedSeed: NarrativeRerunSeed;
|
||||
result: SimulationRunResult;
|
||||
}) {
|
||||
return {
|
||||
rerunId: `rerun:${params.recordedSeed.id}`,
|
||||
seed: params.recordedSeed.seed,
|
||||
summary: `${params.recordedSeed.label} 复测结果:${params.result.summary}`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user