Skip to content

rules: replacing a planned rule cannot grow its size; a rule may not rank itself - #11

Merged
MaxonT merged 2 commits into
mainfrom
port-enforcement-replace-size
Nov 12, 2026
Merged

MaxonT merged 2 commits into
mainfrom
port-enforcement-replace-size

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Follow-up to #10.

  • Addresses the review finding on rules: a rule with no enforcer keeps its planned check; rule enforce sets an existing rule #10: rule add --replaces on a planned rule kept its start day but accepted a larger size, which moved the due day with no reason on record. By ID the add is now refused and names the size to keep; when the old rule is matched by a piece of its text the size is clamped. Moving the due day stays possible afterwards with rule enforce --reason, which records it.
  • With require_enforcer off, replacing a planned rule while naming no enforcer raised an AttributeError; fixed, with a test.
  • rule_spec: a rule text that calls itself highest or TOP PRIORITY is refused (quoted words do not count).

436 tests pass locally; privacy scan 0 hits.

… not rank itself

- rule add --replaces on a planned rule: a larger --size is refused by ID (and clamped when the old rule is
  matched by a piece of its text), so a revision cannot postpone an outstanding check. Review finding on #10.
- with require_enforcer off, replacing a planned rule while naming no enforcer no longer raises
- rule_spec: a rule text that calls itself highest or TOP PRIORITY is refused (quoted words do not count)

Tests: 436 passed; privacy scan 0 hits.

Agent: claude-code
Co-authored-by: MaxonT <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T22:42:20.285105Z d0a1f25 Manual request
ℹ️ 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: af049571be

ℹ️ 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/rulespec.py Outdated
Comment on lines +88 to +89
if _SELF_RANK.search(_QUOTED.sub(" ", body)):
out.append("calls itself highest / TOP PRIORITY / 最高优先级 (R-358): say what it does; quoted words do not count")

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 Limit rejection to claims about the rule's own priority

With rule_spec = true, an ordinary operational rule such as When: selecting a release. Do: choose the highest compatible version. is now rejected by rule_add, even though it makes no claim about its own precedence. Searching the entire body for these words also marks such existing rules invalid in lint and prevents rewriting them. Restrict the check to self-ranking claims rather than rejecting unrelated uses of highest or top priority.

Useful? React with 👍 / 👎.

Comment thread ai_sync/rulespec.py Outdated
_META = re.compile(r"^Meta rule[.:]?\s+")
_FIELD = re.compile(r"(?:(?<=\s)|^)(When|Do|Not):\s*")
_SELF_RANK = re.compile(r"highest|top priority|最高优先级", re.I) # R-358: a rule does not rank itself
_QUOTED = re.compile(r"“[^”]*”|\"[^\"]*\"|「[^」]*」|‘[^’]*’|'[^']*'")

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 Distinguish apostrophes from quotation delimiters

When a rule contains two apostrophes in contractions or possessives, _QUOTED removes everything between them as though it were quoted text. For example, When: two rules conflict. Do: don't demote this highest rule's precedence. returns no problems because the self-ranking claim disappears between don't and rule's. Recognize actual quote boundaries so ordinary English punctuation cannot bypass the new enforcement.

Useful? React with 👍 / 👎.

…s own rank

Both review findings on this PR:
- an ordinary rule such as 'choose the highest compatible version' is no longer refused: the check wants a
  claim about the rule itself (the highest rule, this rule has top priority, the label TOP PRIORITY)
- apostrophes in don't ... rule's are no longer read as a pair of quotes
Also: the claim is read in When and Do; Not names what is forbidden, so a rule that forbids self-ranking
passes its own check.

Tests: 436 passed; privacy scan 0 hits.

Agent: claude-code
Co-authored-by: MaxonT <[email protected]>
@MaxonT

MaxonT commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Both findings addressed in the latest commit: the self-rank check now matches only a claim about the rule's own rank, read in When and Do, and a single quote opens only after a space or bracket. Tests cover the two examples from the review.

@MaxonT

MaxonT commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: d0a1f25d78

ℹ️ 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".

@MaxonT
MaxonT merged commit 2366cef into main Nov 12, 2026
6 checks passed
@MaxonT
MaxonT deleted the port-enforcement-replace-size branch November 12, 2026 22:42
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.

1 participant