Repository navigation
Fix #2370: [Bug] meta.rewardDirty is re-set on episode reopen and never cleared when the ep - #2578
Open
syzsunshine219 wants to merge 2 commits into
Open
syzsunshine219 wants to merge 2 commits into
syzsunshine219 wants to merge 2 commits into
Conversation
added 2 commits
September 16, 2026 06:16
…MemTensor#2370) When an episode is terminal-skipped (meta.reward.skipped=true) and then reopened, episode-manager.ts correctly sets rewardDirty but leaves reward.skipped untouched. episodeRewardIsDirty() in memory-core.ts calls rewardWasSkipped() before hasRewardDirtyMarker(), short-circuiting to false and making the episode permanently invisible to every rescore scan. Fix: in reopen(), when setting rewardDirty, also clear reward.skipped so the marker is evaluated and the episode is queued for rescoring. The collectDirtyClosedEpisodes bounded-page cleanup already handles existing persisted rows with the contradictory marker pair; this fix closes the write-path gap so new reopens don't produce the stale state in the first place. Regression test: reopen clears reward.skipped when setting rewardDirty (MemTensor#2370)
…emTensor#2370) reopen() re-sets meta.rewardDirty, but EpisodeManager.finalize() and abandon() passed snap.meta through to the repo without clearing it. Any terminal path that did not happen to run the reward write — e.g. the episode resumed with rTask != null, so the reward fallback was skipped — left the marker on a fully resolved episode. episodeRewardIsDirty() and consistency checks built on json_type(meta_json,'$.rewardDirty') then reported the row as dirty indefinitely (reporter saw 17 days), which is the durable half of MemTensor#2370 that clearing reward.skipped on reopen does not address on its own. Overwrite the key with `undefined` rather than dropping it or setting `null`: the repo merges the patch into the existing meta_json (so an omitted key would leave the stale value), and toJsonText uses JSON.stringify, which omits undefined-valued keys — leaving the key absent instead of present-and-null, which would still satisfy `IS NOT NULL`. Regression tests cover both terminal paths and assert on the JSON-round-tripped meta, i.e. the shape the reporter's watchdog reads.
syzsunshine219
marked this pull request as ready for review
November 9, 2026 15:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restores the change proposed in #2371 for review against
mainafter its former base branch,dev-v2.0.34, was deleted. The source commits and authors are preserved.Source head:
78c784798f20219d89139e5115e66252b80e7bdeThis PR is open for review. Review and CI against the current base are pending; validation claims in the original description below refer to the earlier snapshot. The original discussion and evidence remain in #2371.
Original change description
Description
Fixed a permanent
meta.rewardDirtymarker on episodes that were terminal-skipped and then reopened (issue #2370).Root cause:
episode-manager.ts reopen()correctly setsrewardDirty: {reason:"episode_reopened",...}on the episode meta, but leftmeta.reward.skipped: trueuntouched from the earlier heuristic-skip scoring pass.episodeRewardIsDirty()inmemory-core.tsevaluatesrewardWasSkipped()beforehasRewardDirtyMarker(), so the skip flag permanently short-circuited the function tofalse, making the episode invisible to every rescore scan path (init recovery loop, periodic dirty-closed scan, backoff filter). The marker was therefore never cleared.Fix: In
episode-manager.ts reopen(), when settingrewardDirty, also spreadreward.skipped: undefinedinto the reward object if the episode had previously been terminal-skipped. This is a targeted one-shot patch to the object written tometa; it does not change any other reward fields. The existingcollectDirtyClosedEpisodesbounded-page cleanup already handles any persisted rows that have the contradictory marker pair from before this fix.Tests: Added two regression tests to
tests/unit/session/episode-manager.test.ts: one asserting thatreward.skippedis cleared andrewardDirtyis set correctly after reopen on a previously-skipped episode, and one asserting thatrewardDirtyis not set when the episode was never scored. All 176 tests across 13 files pass.Related Issue (Required): Fixes #2370
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Not run; documentation-only change.
Checklist
@whipser030,@hijzyplease review this PR.Reviewer Checklist