Skip to content

fix(tidy): compare rules stored without topics - #43

Merged
MaxonT merged 1 commit into
MaxonT:mainfrom
sundaysebasidian-byte:fix/tidy-untopicked-rules
Nov 18, 2026
Merged

MaxonT merged 1 commit into
MaxonT:mainfrom
sundaysebasidian-byte:fix/tidy-untopicked-rules

Conversation

@sundaysebasidian-byte

Copy link
Copy Markdown
Collaborator

What does this change?

Fixes #24. Rules added in a hub without topic headings have a timestamp and author prefix, so tidy previously excluded them from duplicate comparison. Add a compatibility reader local to tidy that recognizes those stored bullets and excludes their Reason: metadata before comparing When/Do fields. Legacy rules can now be compared with each other and with topic rules. The skipped-rule notice describes both supported formats.

The change leaves the saved preferences, writing format, similarity threshold and interface-shape lint unchanged. Free-text and malformed rules remain explicitly listed as not compared.

Legacy-format boundary: this uses the same final Reason: separator convention as rulecheck.body. The legacy format has no escaping, so a rule whose body ends with a literal Reason: clause without appended metadata, or metadata that itself repeats the separator, remains ambiguous. This patch does not migrate or rewrite those stored rules.

How did you check it?

The three regression cases failed against main at c00344468fc504987c64f29d6d4c4c2a45b87fbe: all expected duplicate pairs were missing. One regression runs rule add twice without a topic and then runs JSON tidy, also checking preferences are unchanged. Other cases cover legacy/current comparisons, optional Not and Reason, numeric-offset time zones, metadata containing field labels and malformed rules.

Tested on macOS 27.2 arm64 with Python 3.14.6:

  • python -m pytest -q tests/test_tidy.py tests/test_rulespec.py tests/test_collab.py: 56 passed.
  • python -m pytest -q tests: 471 passed, 3 subtests passed (88.49 seconds).
  • python tools/privacy_scan.py --history: 213 files, 0 hits after the commit, including a freshly built wheel and sdist.
  • git diff --check: passed.

Linux, Python 3.11/3.13 and Docker installation checks have not been run locally.

AI assistance: Codex implemented the change and tests. A separate Codex reviewer found that using the first Reason separator could truncate an action containing that label. A regression reproduced the wrong duplicate pair, and the fix follows the existing final-separator convention. The reviewer independently reran all 12 tidy tests and an actual CLI counterexample and reported no remaining blocking code findings. This does not claim human review.

  • python3 -m pytest -q tests passes
  • python tools/privacy_scan.py finds nothing
  • If an AI tool helped, I said so above

MaxonT commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution! I'm considering this PR and reviewing how it fits with the other proposed changes.

@MaxonT
MaxonT marked this pull request as ready for review November 18, 2026 23:43
@MaxonT
MaxonT merged commit 11cc590 into MaxonT:main Nov 18, 2026
6 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T23:50:06.663872Z da499f7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da499f74bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ai_sync/tidy.py
reason = body.rfind(" Reason:")
if reason >= 0:
body = body[:reason]
return rulespec.parse(f"[{legacy.group(1)}] {body}" if legacy.group(1) else body)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve tag-like parentheses in legacy rule bodies

For timestamp-prefixed rules written by collab.rule_add whose final action is, for example, Do: notify (owner of the service) without a trailing full stop, rulespec.parse calls rulespec.split and strips (owner of the service) as though it were a current-format source tag. The resulting action is just notify: an equivalent topic-format rule is missed, while a plain Do: notify rule instead receives a 1.0 duplicate score. Parse the already-extracted legacy body without applying current-format source-tag stripping.

Useful? React with 👍 / 👎.

MaxonT added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: MaxonT <173550318+MaxonT@users.noreply.github.com>
Agent: codex
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.

tidy skips rules stored without a topic, so duplicates are not compared

2 participants