Skip to content

Bring the name contract to btclib's walks, with validate_ and async (closes #490) - #491

Merged
fametrano merged 1 commit into
mainfrom
iss-490-name-contract
Nov 8, 2026
Merged

fametrano merged 1 commit into
mainfrom
iss-490-name-contract

Conversation

@fametrano

Copy link
Copy Markdown
Member

ecc's name contract test is the source btclib's copy is ported from, and btclib's had moved ahead: validate_ in the vocabulary (btclib-org/btclib#2960), every definition of a name held to its prefix instead of the last one only, async def read, and class members keyed by their dotted path (btclib-org/btclib#2963). This brings ecc's tests/name_contract_test.py to those walks, adds validate_ to _PROMISED and _NOT_A_READ, and adds the rule decided in btclib-org/btclib#2964: an async def carries none of the prefixes, since a call without await answers a coroutine, which is true for is_, check_ and verify and refuses nothing for assert_ and validate_. CONTRIBUTING.md's vocabulary says so.

Nothing in src/ecc changes verdict: ecc.frost.validate_threshold_info is now held to validate_'s promise and keeps it, no name is defined twice, and there is no async def. What still differs from btclib's file is btclib's own: its exemption lists, the op-code and English-predicate entries, and the argument-less bool walk ecc never had.

Evidence

What Result
The controls can fail each of: validate_ dropped from _PROMISED or _NOT_A_READ; one definition per name; FunctionDef only; no coroutine wrap; wrap only bool or only None answers; wrap only is_/validate_ names; flat keys for nested classes; judging the last definition only — fails a control (the one equivalent mutant, async read in _public_bools_in, is dead once the wrap applies)
The library _PUBLIC_BOOLS and _CLASS_MEMBERS hold the same keys before and after; _NAMED gains ecc.frost.validate_threshold_info only
Gates on 8c16031, under the gate lock pytest whole suite 0 (coverage 100%); pre-commit run --all-files 0; sphinx-build -n -W 0 on c4b2529e, the round before two that changed only the test file
Rebase case one commit on main e5260d4, no rebase
Local review dedicated reviewer CLEARED 8c16031a, after three rounds (a docstring restating CONTRIBUTING's reason; a false sentence on _answer's argument; a control with an async def under two prefixes only; a comment claiming every prefix)
Fresh review in the other client missing: Codex refused the run with ERROR: Your workspace is out of credits. Add credits to continue. (2026-11-07)

Closes #490

🤖 Generated with Claude Code

…loses #490)

tests/name_contract_test.py takes the walks of btclib's port at
btclib-org/btclib@96f3b68a (PR btclib-org/btclib#2960 and
PR btclib-org/btclib#2963), adapted to this tree's exemptions:

- `validate_` promises None, matched at the front with its underscore,
  and a self-only `validate_` member is not a read. This holds
  `frost.validate_threshold_info`, which already returns None.
- each definition of a name is kept, in a list per name, so a second
  definition hides no first.
- the name walks read `async def`, and class members are keyed by their
  full dotted path, so two nested classes of one name are two keys.

It adds the rule of ISS btclib-org/btclib#2964: an `async def` whose
name carries a `_PROMISED` prefix breaks the promise, whatever its
annotation, because a call without `await` answers a coroutine. The
walk records such a definition as `Coroutine[<annotation>]`, so an
async bool is neither a kept promise nor a public bool.

Control sources hold each case the tree does not: a `validate_`
answering a bool or a coroutine, a name defined twice, nested classes of
one name, and an `async def` under each prefix. CONTRIBUTING.md's
vocabulary states `validate_*` and the async rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net>
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Documentation
    • Clarified naming guidance for validation functions, asynchronous functions, and properties.
  • Tests
    • Expanded naming-contract checks to cover validation names, asynchronous functions, nested classes, and additional class-member cases.

The naming guidance and AST-based name contract now include validate_*. The census retains duplicate definitions, accounts for async return types, and expands class-member and public-bool discovery. Tests cover these rules.

Changes: Naming contract and census

Layer / File(s) Summary
Document and encode naming rules
CONTRIBUTING.md, tests/name_contract_test.py
The guidance and test vocabulary define validate_* as a refusal prefix that promises None. The property guidance exempts validate_*, and the read check treats it as a non-read prefix.
Expand definition census
tests/name_contract_test.py
The census retains all matching public definitions, represents async functions as coroutines, and reports a broken promise when any definition differs from the promised type. Class-member and public-bool discovery now handle the described nested and async cases.
Test naming and member rules
tests/name_contract_test.py
Tests cover validate_* return promises, duplicate and async definitions, nested discovery, and member read classification.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to 8c160

This PR extends the naming-contract test and contributor guidance to cover validate_* functions. It changes no production behavior, and no merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: bringing the name contract test in btclib's walks up to date, and it covers the validate_ prefix and async handling. It also cites issue #490. It follows the title for…
Description check Passed The description states that it ports ecc's tests/name_contract_test.py to btclib's walks, adds validate_ to _PROMISED and _NOT_A_READ, and adds the async def rule. It also lists the controls, gate res…
Linked Issues check Passed Directly linked issue #490 requires that tests/name_contract_test.py hold validate_* to a None answer and that validate_ be exempt from the property rule. At the reviewed head 8c16031, _PROMISED maps…
Out of Scope Changes check Passed The reviewed change set, from merge base e5260d4 to head 8c16031, touches only CONTRIBUTING.md and tests/name_contract_test.py. No file under src/ecc changes. The CONTRIBUTING.md edits add validate_…
Full details: Title check

Explanation

The title names the main change: bringing the name contract test in btclib's walks up to date, and it covers the validate_ prefix and async handling. It also cites issue #490. It follows the title format in the referenced organization standard, which the reviewer has not checked in detail.

Full details: Description check

Explanation

The description states that it ports ecc's tests/name_contract_test.py to btclib's walks, adds validate_ to _PROMISED and _NOT_A_READ, and adds the async def rule. It also lists the controls, gate results, and the missing fresh review. It matches the changeset closely.

Full details: Linked Issues check

Explanation

Directly linked issue #490 requires that tests/name_contract_test.py hold validate_* to a None answer and that validate_ be exempt from the property rule. At the reviewed head 8c16031, PROMISED maps "validate" to "None", matched at the front with its underscore. NOT_A_READ is ("assert", "to_", "validate_"). Both changes are present in the code. The walk test test_the_walk_reaches_what_it_claims asserts ecc.frost.validate_threshold_info == ["None"], and the control test_a_validate_answering_a_bool_breaks_its_promise fails if validate_ is dropped from _PROMISED, because validate_answer would no longer break its promise. The control for the NOT_A_READ change lies beyond the 16000-byte read limit, so I could not view it directly. The PR reports that control exists, and the visible code shows the change. CONTRIBUTING.md adds the validate* line the issue cites. The issue's convergence goal is met for the two changes it names. No coding requirement is unmet in the evidence I could read.

Full details: Out of Scope Changes check

Explanation

The reviewed change set, from merge base e5260d4 to head 8c16031, touches only CONTRIBUTING.md and tests/name_contract_test.py. No file under src/ecc changes. The CONTRIBUTING.md edits add validate_* to the prefix vocabulary and state the no-async-prefix rule, which matches the test changes and the #490 vocabulary point. The test-file changes beyond the two named additions cover the walk rules the PR cites from btclib-org/btclib#2963 and #2964: every definition checked, async def read as a coroutine, dotted class keys, and the async-method exclusion. These extend the same name contract that #490 asks to converge with btclib's port, so they are not demonstrated to be unrelated. The added controls are supporting tests for these rules. I found no change that lacks a connection to the linked issue or to the name contract.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e5260d4 and 8c16031.

Files selected for processing: 2

  • CONTRIBUTING.md
  • tests/name_contract_test.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 ecc | 🛠️ Build #35728384 | 📁 Comparing 8c16031 against latest (e5260d4)

  🔍 Preview build  

1 file changed
± contributing_link.html

@claude claude 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.

ACK 8c16031

Not checked: the new walks and controls in tests/name_contract_test.py, and the mutants the description's "The controls can fail" row reports, were not run, because there is no interpreter here. A grep of src/ finds no async def, which matches the description's claim that the tree has none.

@fametrano
fametrano merged commit 980b2c6 into main Nov 8, 2026
22 checks passed
@fametrano
fametrano deleted the iss-490-name-contract branch November 8, 2026 05:04
fametrano added a commit to btclib-org/btclib that referenced this pull request Nov 8, 2026
tests/name_contract_test.py read an `async def`'s annotation as its answer, so `async def is_ready(self) -> bool` kept the `is_` promise, while a call without `await` answers a coroutine, which is true, and an unawaited `validate_x()` refuses nothing. `_named_in` now records an `async def` as `Coroutine[<annotation>]`, which breaks the promise of every prefix in `_PROMISED`; an `_OTHER_CONTRACT` exception excuses an answer, never a coroutine; and an `async def -> bool` is no longer a public bool. Controls hold an `async def` under each prefix and an excepted name made async, as ecc's copy does (btclib-org/ecc#491). CONTRIBUTING.md's vocabulary states the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ferdinando Ametrano <ferdinando@ametrano.net>
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.

The name contract lacks validate_, which frost.validate_threshold_info uses

1 participant