fix(kernel): cron dedupe + next_run + token_length annotation#3109
Merged
Conversation
…rrent activation duplicates If two registry entries share the same `hand_tag` and `hand_role` (a race between concurrent `activate_hand` calls or a stale cleanup), the loop would collect the same CronJob twice from list_jobs and replay both via add_job — leaving duplicate jobs that fire in lockstep. Track seen CronJobIds per role bucket so each saved job is added at most once.
…avoid immediate refire Previously the restore path set `next_run = None` and relied on the implicit recompute inside `add_job`. That coupling is fragile: a future change to `add_job` semantics could let restored jobs fire on the very next scheduler tick. Compute the next fire time explicitly from the saved schedule at the call site so the intent — "resume on the natural next future fire" — is visible and locally enforced.
…tokens) `MessageContent::text_length` is sometimes used as a proxy for LLM token count, but it returns UTF-8 byte length — not Unicode chars and not real tokens. Document the upper-bound semantics, the ~4 bytes ≈ 1 token rule of thumb, and that exact counts should swap to a real tokenizer rather than mutate this function.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Follow-up review concerns from #3090 (already merged).
saved_cronsduring restore so concurrent hand-reactivation paths cannot end up activating the same cron twice.next_runfrom the cron expression on hand reactivation instead of restoring a stale fire time, preventing an immediate spurious refire just after restart.text_lengthtoken estimation as an upper-bound heuristic (char ≈ 4 tokens) so callers don't treat it as exact.Cherry-picks: 3dc39d4, b64a24c, 9203a83
Test plan