refactor: keep runtime context in memory
This commit is contained in:
@@ -9,7 +9,10 @@ import { SessionLearningStateStore } from "./sessionStateStore.js";
|
||||
import { MemoryStore, type MemoryScope } from "../memory/store.js";
|
||||
import { type OpencodeRuntimeAdapter } from "../runtime/opencode.js";
|
||||
import { SkillStore } from "../skills/store.js";
|
||||
import { SessionRuntimeContextStore } from "../sessions/runtimeContextStore.js";
|
||||
import {
|
||||
removeRuntimeSessionContext,
|
||||
setRuntimeSessionContext,
|
||||
} from "../runtime/sessionContext.js";
|
||||
import {
|
||||
sanitizePersistentDocument,
|
||||
sanitizePersistentLine,
|
||||
@@ -76,7 +79,6 @@ export class LearningOrchestrator {
|
||||
private readonly activeReviews = new Set<string>();
|
||||
private readonly sessionLearningStateStore = new SessionLearningStateStore();
|
||||
private readonly skillStore = new SkillStore();
|
||||
private readonly sessionRuntimeContextStore = new SessionRuntimeContextStore();
|
||||
|
||||
constructor(
|
||||
private readonly runtime: OpencodeRuntimeAdapter,
|
||||
@@ -85,10 +87,7 @@ export class LearningOrchestrator {
|
||||
) {}
|
||||
|
||||
async initialize() {
|
||||
await Promise.all([
|
||||
this.sessionLearningStateStore.initialize(),
|
||||
this.sessionRuntimeContextStore.initialize(),
|
||||
]);
|
||||
await this.sessionLearningStateStore.initialize();
|
||||
}
|
||||
|
||||
async onTurnCompleted(input: TurnReviewInput) {
|
||||
@@ -147,7 +146,7 @@ export class LearningOrchestrator {
|
||||
`learning-gate-${input.requestContext.clientSessionId}`,
|
||||
);
|
||||
gateSessionId = gateSession.id;
|
||||
await this.sessionRuntimeContextStore.write({
|
||||
setRuntimeSessionContext({
|
||||
actorKey: input.requestContext.actorKey,
|
||||
allowLearningWrite: false,
|
||||
clientSessionId: `gate-${input.requestContext.clientSessionId}`,
|
||||
@@ -215,7 +214,7 @@ export class LearningOrchestrator {
|
||||
});
|
||||
} finally {
|
||||
if (gateSessionId) {
|
||||
await this.sessionRuntimeContextStore.remove(gateSessionId).catch(() => undefined);
|
||||
removeRuntimeSessionContext(gateSessionId);
|
||||
await this.runtime.abortSession(gateSessionId).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
@@ -235,7 +234,7 @@ export class LearningOrchestrator {
|
||||
const reviewSession = await this.runtime.createSession(
|
||||
`learning-review-${input.requestContext.clientSessionId}`,
|
||||
);
|
||||
await this.sessionRuntimeContextStore.write({
|
||||
setRuntimeSessionContext({
|
||||
actorKey: input.requestContext.actorKey,
|
||||
allowLearningWrite: false,
|
||||
clientSessionId: `review-${input.requestContext.clientSessionId}`,
|
||||
@@ -283,7 +282,7 @@ export class LearningOrchestrator {
|
||||
traceId: input.requestContext.traceId,
|
||||
});
|
||||
} finally {
|
||||
await this.sessionRuntimeContextStore.remove(reviewSession.id).catch(() => undefined);
|
||||
removeRuntimeSessionContext(reviewSession.id);
|
||||
await this.runtime.abortSession(reviewSession.id).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user