Skip to content

fix(sleep): avoid mutating tasks while grouping - #196

Merged
Yif-Yang merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/group-task-copy-normalization
Aug 2, 2026
Merged

fix(sleep): avoid mutating tasks while grouping#196
Yif-Yang merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/group-task-copy-normalization

Conversation

@Yif-Yang

@Yif-Yang Yif-Yang commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up hardening for #184.

The existing dedup_tasks helper merges records in place. group_tasks_by_skill_hint now operates on copied records so grouping cannot mutate caller-owned TaskRecord instances, and it keeps each returned record skill_hint aligned with the normalized evidence used for routing.

Validation:

  • pytest tests/test_sleep_engine.py -q: 95 passed, 1 skipped
  • pytest tests/ -q: 614 passed, 6 skipped, 130 subtests passed
  • Claude Code + Opus 5.0 independent review: safe; no blocking findings

Copilot AI review requested due to automatic review settings August 2, 2026 17:57
@Yif-Yang
Yif-Yang merged commit 07d5d42 into microsoft:main Aug 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens the sleep miner’s task-grouping helper so it remains side-effect-free with respect to caller-owned TaskRecord instances, while ensuring each returned grouped record’s skill_hint matches the normalized evidence used for routing.

Changes:

  • Update group_tasks_by_skill_hint to deduplicate/merge using copied TaskRecord instances to avoid mutating inputs.
  • Normalize/align returned TaskRecord.skill_hint to the computed routing hint (including blank/ambiguous cases).
  • Expand tests to assert no input mutation occurs and that returned skill_hint values are normalized/blank as expected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
skillopt_sleep/mine.py Copies TaskRecord inputs before dedup_tasks() and aligns returned skill_hint with normalized routing evidence.
tests/test_sleep_engine.py Adds assertions covering non-mutation of inputs and skill_hint normalization behavior in grouped outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants