Skip to content

test: enforce tool_dispatch predicate ordering invariants#98

Merged
wpak-ai merged 2 commits into
masterfrom
test/tool-dispatch-ordering-invariants
Jun 25, 2026
Merged

test: enforce tool_dispatch predicate ordering invariants#98
wpak-ai merged 2 commits into
masterfrom
test/tool-dispatch-ordering-invariants

Conversation

@clean6378-max-it

@clean6378-max-it clean6378-max-it commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #95

Summary

  • Add tests/test_tool_dispatch_ordering.py with declarative (before, after, reason) ordering invariants for _TOOL_RESULT_DISPATCH
  • Assert is_plan before is_file_write and is_task_message before narrower task predicates (is_task_retrieval, is_task_completed, is_task_async)
  • Cross-reference the test from utils/tool_dispatch.py module docstring

Test plan

  • pytest tests/test_tool_dispatch_ordering.py -v — 4 passed
  • pytest — 413 passed, 13 skipped
  • Misorder a predicate locally — confirm test fails with constraint message, then revert

Sprint item #2 (Thursday, 3 pt).

Summary by CodeRabbit

  • Documentation

    • Added clearer guidance on maintaining consistent tool-result predicate ordering when extending tool-result dispatch behavior.
  • Tests

    • Added coverage that verifies declared tool-result dispatch ordering invariants and reports detailed failures if the expected “before”/“after” sequence changes.

Add declarative (before, after, reason) ordering checks so misordered
predicates in _TOOL_RESULT_DISPATCH fail immediately with a clear message.
@clean6378-max-it clean6378-max-it self-assigned this Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 11f420fb-f725-49eb-b74e-98e713e75f04

📥 Commits

Reviewing files that changed from the base of the PR and between b83bce5 and e351ee7.

📒 Files selected for processing (1)
  • tests/test_tool_dispatch_ordering.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_tool_dispatch_ordering.py

📝 Walkthrough

Walkthrough

Adds a dedicated pytest module that asserts _TOOL_RESULT_DISPATCH ordering constraints by index, and updates the tool dispatch docstring to reference that test.

Changes

Tool dispatch ordering enforcement

Layer / File(s) Summary
Ordering invariant test and docstring note
tests/test_tool_dispatch_ordering.py, utils/tool_dispatch.py
Adds explicit before/after index assertions for dispatch predicates and a docstring cross-reference to the ordering test.

Estimated review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • timon0305
  • wpak-ai

Poem

A rabbit hopped through dispatch with glee,
Counting predicate steps one-two-three.
The tests said, “Stay in line!”
And the docstring shone fine,
So the ordering purrs happily. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the new ordering-invariant test and docstring update.
Linked Issues check ✅ Passed The PR adds declarative index-based ordering tests and a docstring cross-reference, matching #95's scope and constraints.
Out of Scope Changes check ✅ Passed The changes stay within scope: only a new test and a docstring note were added, with no dispatch logic changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/tool-dispatch-ordering-invariants

Comment @coderabbitai help to get the list of available commands.

Comment thread tests/test_tool_dispatch_ordering.py Outdated
Comment thread tests/test_tool_dispatch_ordering.py
@clean6378-max-it clean6378-max-it requested a review from wpak-ai June 25, 2026 18:24
@wpak-ai wpak-ai merged commit bddbda3 into master Jun 25, 2026
16 checks passed
@wpak-ai wpak-ai deleted the test/tool-dispatch-ordering-invariants branch June 25, 2026 18:28
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.

claude-code-chat-browser: Predicate ordering structural enforcement

3 participants