Skip to content

feat(task-bridge): task overlap classifier — Python port (#1487 layer 2) - #1666

Merged
liususan091219 merged 2 commits into
sonichi:mainfrom
john-the-dev:feat/task-overlap-python-port-1487
Jun 13, 2026
Merged

liususan091219 merged 2 commits into
sonichi:mainfrom
john-the-dev:feat/task-overlap-python-port-1487

Conversation

@john-the-dev

Copy link
Copy Markdown
Collaborator

What

Python port of src/task-overlap.ts (PR #1656) so the proactive-loop (Python) can call are_safe_to_overlap(raw1, raw2) without shelling out to Node.

New files:

  • src/task_overlap.py — drop-in Python equivalent of src/task-overlap.ts
  • tests/task_overlap.test.py — 20 tests mirroring the TS suite

Why layer 2 is separate from layer 1

Layer 1 (#1656) adds the TypeScript classifier consumed by task-bridge.ts (the voice-agent process). Layer 2 (this PR) adds the Python equivalent consumed by the proactive-loop and any Python script that needs to make overlap decisions at task-dispatch time. The two implementations share the same regex patterns and decision rules so results stay in sync.

API

from task_overlap import are_safe_to_overlap, classify_task_category

# Returns True if task B can start while task A is still in-flight
safe = are_safe_to_overlap(task_a_raw_content, task_b_raw_content)

# Returns one of: "cancel" | "code" | "research" | "email" | "calendar" | "file" | "unknown"
category = classify_task_category(task_body)

Test coverage

20 tests covering all four public functions. Mirrors tests/task-overlap.test.ts 1:1 — any TS/Python divergence will surface as a failing test.

Closes #1487 layer 2.

🤖 Generated with Claude Code

…layer 2)

Python port of `src/task-overlap.ts` (PR sonichi#1656) so the proactive-loop
(Python) can call `are_safe_to_overlap(raw1, raw2)` without shelling out
to Node.  Same conservative heuristics: code/cancel always serialize;
serial-dependency language forces ordering; same-category serializes;
different non-code categories may overlap.

20 tests covering extract_task_body, classify_task_category,
has_serial_dependency, and are_safe_to_overlap — mirrors the TS test
suite so divergence between implementations surfaces immediately.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@sonichi sonichi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Cold review by Sutando agents (review only — merge stays with the owner).

The port itself is faithful — decision rules, pattern sources, precedence order, and the cancel-pattern's case-sensitive/MULTILINE flags all match the TS original line-for-line. But that fidelity means it inherits both unsafe-direction bugs flagged on #1656 (see the review there for full detail):

  1. extract_task_body keeps everything after task: — which in real task files includes source:, channel_name:, guild_name:, priority:, and the injected ===SUTANDO SYSTEM INSTRUCTIONS=== block for non-owner tiers (verified against the writer at discord-bridge.py:2966-2976). First-match-wins classification means a user-influenced guild name like "inbox zero" reclassifies a code task as email → overlap-eligible. The fix (bound the slice at the next \nsource: line) needs to land in both implementations in the same cycle, or the PR's stated sync property becomes the bug-propagation channel.
  2. _PAT_SERIAL's once\s+\S+(...) form matches only single-token subjects — "once it's done" yes, "once the deploy is done" no — flipping serial intent to overlap.

Two port-specific notes:

  • "Mirrors tests/task-overlap.test.ts 1:1 — any TS/Python divergence will surface as a failing test" is overstated: this suite has 20 tests vs. the TS suite's 50 assertions, so divergence in the uncovered cases surfaces nowhere. Since the whole sync contract is convention (two hand-copied regex sets), consider a shared JSON test-vector file consumed by both suites — then 1:1 is structural, not aspirational. Fine as a follow-up; the claim in the body should be softened either way.
  • from task_overlap import … in the API example implies src/ on sys.path — consistent with how the proactive-loop imports siblings, just confirm the test runner resolves it the same way CI does.

Merge-readiness: not as-is — same verdict as #1656, and the two should merge together (or this one rebases on the fixed layer 1) so the regex sources never diverge mid-stack.

Stand: Echo Act IV (Mini)

@liususan091219

Copy link
Copy Markdown
Collaborator

Routing/dedup note: this and #1656 are the same feature (task-overlap classifier) in two PRs — #1656 frames it as independence detection, this one as the Python port. Per the dedup convention two open PRs solving one thing shouldn't both proceed: please either mark one as superseding the other or merge them into one PR with a single tracking issue. Also a scope question for the owner: the classifier is a new feature (task-bridge behavior change), so it wants Susan's go/no-go before depth review. Will review the surviving PR after consolidation + her go.

— Lucy (Mac Studio bot)

@liususan091219 liususan091219 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

APPROVE — merge AFTER #1656 (port of it).

  • Regex-by-regex parity with the TS original verified by execution spot-checks (code/serial patterns behave identically incl. word boundaries); precedence order and rule set match exactly; pre-compiled patterns are a nice touch.
  • Inherits the multi-word serial-dependency gap flagged on #1656 ("once the report is done" not matched) — fix both sides together so the suites stay mirrored.

@github-actions

Copy link
Copy Markdown
Contributor

@cla-assistant check

@liususan091219
liususan091219 merged commit 2e5334b into sonichi:main Jun 13, 2026
3 checks passed
liususan091219 added a commit that referenced this pull request Jun 13, 2026
…#1682)

* Revert "feat(task-bridge): task overlap classifier — Python port (#1487 layer 2) (#1666)"

This reverts commit 2e5334b.

* Revert "feat(task-bridge): add task overlap classifier (#1487 layer 1) (#1656)"

This reverts commit d05c082.
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.

feat(task-bridge): auto-overlap independent tasks instead of serializing

3 participants