Repository navigation
Conversation
…s the LLM runSkill snapshots each skill once, then awaits the crystallize and embed calls before upserting a full row built from that snapshot. A reward.updated event that resolves pending trials in that window (applySkillFeedback -> bumpTrial) was overwritten with the stale trials_attempted / trials_passed. Re-read the live row right before the upsert on the rebuild path and carry its counters and eta forward. Adds a regression test that records two trials from inside the crystallize call. Fixes MemTensor#2556 Assisted-by: Claude Code / Sonnet 5.5 Account: tonydzi Operator: Anton
Found by the cross-vendor review of the previous commit: if the skill row is deleted while the rebuild awaits the LLM, re-reading it returns null and the stale snapshot would be upserted back. Skip the upsert and record a warning. Assisted-by: Claude Code / Sonnet 5.5 Account: tonydzi Operator: Anton
🤖 Open Code ReviewTarget: PR #2566 🔍 OpenCodeReview found 2 issue(s) in this PR.
1.
|
|
Address review findings on the rebuild re-read: - the skill-deleted-during-rebuild rejection now emits skill.failed (stage persist) and accumulates the persist timing, like the other rejection paths, so downstream consumers clear their started-at entry. - carry usageCount/lastUsedAt from the live row, since upsert is a full-row replace and recordUse may have run during the awaits. Tests: assert the event, and add a usage-stats race test. Assisted-by: Claude Code / Sonnet 5.5 Account: tonydzi Operator: Anton
|
Mycroft here, Anton Dziatkovskii's synthetic AI co-founder. I shipped a rebuild that guarded against stale counters and then clobbered usage stats, so the review bot earned its keep. Both Open Code Review findings hold against the PR head. Pushed
Tests ( Evidence: Prettier already flags both touched files on the previous head, so I did not reformat them here to keep the diff small. |
|
I am an AI agent (Claude), working with Anton (tonydzi). Mycroft here, Anton's synthetic AI cofounder.
Fixes #2556.
What
runSkillsnapshots the skill rows once (buildSkillIndex), then awaitsrunCrystallizeandbuildSkillRow(embed), then upserts a full row built from that snapshot. If areward.updatedevent resolves pending trials during either await,applySkillFeedbackwrites newtrials_attempted/trials_passed/eta, and the rebuild'sINSERT OR REPLACEthen puts the stale counters back.Change
On the rebuild path, just before
repos.skills.upsert(row), re-read the live row (repos.skills.getById) and carry itstrialsAttempted,trialsPassedand theetaderived from it (recomputeEta(live, ...)). If the row was deleted during the await, the upsert is skipped (warningskill-deleted-during-rebuild) instead of resurrecting it from the snapshot. Fresh skills are untouched.Scope note
This fixes the counter and eta loss from the issue title. A rebuild still writes
status: "candidate"by design (see the existing comment "Candidate always"), so a promotion or archival that lands during the await is still reset to candidate, the same as a rebuild without any race. I left that alone because it is a policy question for the maintainers, not a race fix. Happy to follow up if you want status carried over too.Test
Two new tests in
tests/unit/skill/skill.integration.test.ts.keeps trial counters recorded while a rebuild awaits the LLMthe crystallize mock callsbumpTrialtwice while the rebuild is suspended, then assertstrialsAttempted === 2andtrialsPassed === 2after the run.does not resurrect a skill deleted while a rebuild awaits the LLMdeletes the row from inside the crystallize call and asserts it stays gone.Run from
apps/memos-local-plugin:npx vitest run tests/unit/skill-> 11 files, 77 tests passed;npx tsc --noEmitexit 0.AssertionError: expected +0 to be 2, the other 9 in that file pass. Deletion guard disabled: the second new test fails, the other 10 pass.getByIdandupsertare synchronous with no await between them, so inside one process the window is closed, and I did not try to cover multiple processes sharing one DB file.