mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix: guard luker panel graph load retries
This commit is contained in:
4
index.js
4
index.js
@@ -8989,6 +8989,10 @@ function shouldSyncGraphLoadFromLiveContext(
|
||||
|
||||
function syncGraphLoadFromLiveContext(options = {}) {
|
||||
const { source = "live-context-sync", force = false } = options;
|
||||
const attemptIndex = Math.max(
|
||||
0,
|
||||
Math.floor(Number(options?.attemptIndex) || 0),
|
||||
);
|
||||
const context = getContext();
|
||||
syncCommitMarkerToPersistenceState(context);
|
||||
if (!shouldSyncGraphLoadFromLiveContext(context, { force })) {
|
||||
|
||||
@@ -1848,6 +1848,47 @@ result = {
|
||||
assert.equal(result.reason, "no-sync-needed");
|
||||
}
|
||||
|
||||
{
|
||||
const harness = await createGraphPersistenceHarness({
|
||||
chatId: "chat-luker-panel-open",
|
||||
globalChatId: "chat-luker-panel-open",
|
||||
characterId: "char-luker-panel-open",
|
||||
chatMetadata: {
|
||||
integrity: "chat-luker-panel-open-integrity",
|
||||
},
|
||||
});
|
||||
harness.runtimeContext.Luker = {
|
||||
getContext() {
|
||||
return harness.runtimeContext.__chatContext;
|
||||
},
|
||||
};
|
||||
harness.api.setGraphPersistenceState({
|
||||
loadState: "idle",
|
||||
chatId: "chat-luker-panel-open",
|
||||
reason: "cold-start",
|
||||
revision: 0,
|
||||
lastPersistedRevision: 0,
|
||||
dbReady: false,
|
||||
writesBlocked: false,
|
||||
});
|
||||
|
||||
const result = harness.api.syncGraphLoadFromLiveContext({
|
||||
source: "panel-open-sync",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
result.reason,
|
||||
"luker-chat-state-probe-pending",
|
||||
"Luker 面板打开时应进入 chat-state probe,而不是抛出未定义变量异常",
|
||||
);
|
||||
assert.equal(result.attemptIndex, 0);
|
||||
assert.equal(harness.api.getGraphPersistenceState().loadState, "loading");
|
||||
assert.equal(
|
||||
harness.api.getGraphPersistenceState().primaryStorageTier,
|
||||
"luker-chat-state",
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const metadataGraph = stampPersistedGraph(
|
||||
createMeaningfulGraph("chat-stale-metadata", "metadata-older"),
|
||||
|
||||
Reference in New Issue
Block a user