Merge pull request #2785 from pikasTech/fix/embdagentbench-launch-context-jsonb
fix: 修正 CaseRun jsonb 身份比较
This commit is contained in:
@@ -48,7 +48,7 @@ test("API restart preserves PostgreSQL-shaped registry read model", async () =>
|
||||
|
||||
test("Workbench launch context is frozen and conflicting run replay is rejected", async () => {
|
||||
const fixture = await softwareSmokeFixture();
|
||||
const registry = new MemoryRegistry();
|
||||
const registry = new JsonbMemoryRegistry();
|
||||
const service = createHarnessRLService({ registry, temporal: new FakeTemporal(), cwd: fixture.root, caseRepo: fixture.root, stateRoot: fixture.stateRoot, caseAuthority: fixture.caseAuthority });
|
||||
const launchContext = {
|
||||
workbenchSessionRef: { sessionId: "ses_caserun_arm2d", actorId: "usr_arm2d" },
|
||||
@@ -376,3 +376,22 @@ class MemoryRegistry implements HarnessRLRegistry {
|
||||
async health() { return { ok: true as const }; }
|
||||
async close() {}
|
||||
}
|
||||
|
||||
class JsonbMemoryRegistry extends MemoryRegistry {
|
||||
async createRun(input: StartCaseRunInput) {
|
||||
const record = await super.createRun(input);
|
||||
if (!record.launchContext) return record;
|
||||
const context = record.launchContext;
|
||||
return {
|
||||
...record,
|
||||
launchContext: {
|
||||
hwpodId: context.hwpodId,
|
||||
...(context.subjectRef ? { subjectRef: context.subjectRef } : {}),
|
||||
workbenchSessionRef: {
|
||||
actorId: context.workbenchSessionRef.actorId,
|
||||
sessionId: context.workbenchSessionRef.sessionId,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,11 @@ function requiredLaunchText(value: unknown, field: string) {
|
||||
}
|
||||
|
||||
function sameLaunchContext(left: CaseRunLaunchContext | null, right: CaseRunLaunchContext | null) {
|
||||
return JSON.stringify(left) === JSON.stringify(right);
|
||||
if (left === null || right === null) return left === right;
|
||||
return left.workbenchSessionRef.sessionId === right.workbenchSessionRef.sessionId
|
||||
&& left.workbenchSessionRef.actorId === right.workbenchSessionRef.actorId
|
||||
&& left.hwpodId === right.hwpodId
|
||||
&& (left.subjectRef ?? "") === (right.subjectRef ?? "");
|
||||
}
|
||||
|
||||
function finiteNumber(value: unknown): number | null {
|
||||
|
||||
Reference in New Issue
Block a user