Skip to content

Report attribute probes that never succeed - #475

Merged
trissim merged 1 commit into
mainfrom
s-nra/absent-attribute-probe
Nov 18, 2026
Merged

trissim merged 1 commit into
mainfrom
s-nra/absent-attribute-probe

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This adds absent_attribute_probe (pattern 57). It reports a getattr or hasattr whose literal name is bound or stored by no class the receiver is declared as, and by none of its scanned subclasses, according to member_in_mro and the stores on each class's own object. Such a probe always gives the same answer, so the branch it guards is dead.

A probe is never reported when:

  • the name is a dunder;
  • the name is stored on any other receiver;
  • the MRO is open, including a base outside the scan;
  • a class defines __getattr__ or __getattribute__;
  • a class stores attributes on itself by a computed name;
  • the receiver is not declared as an instance of scanned classes.

named_attribute hands these sites over, so each site belongs to one detector.

This is only the detector part of the pre-amend commit e0be993, rebased on main. The named_attribute exemptions from that commit are not included; they are separate precision work.

Evidence

  • Fixtures use toad's real shapes, with DeclaredFamily members created by FamilyMeta, whose order Detectors and refactors read one creation proof: a family's order is closed #471 proved:

    • The turn owner's hasattr(owner, 'describe') (from composer_surround) is reported, and named_attribute no longer reports it.
    • On the line-link probe getattr(link, 'url', None) or getattr(link, 'href', None), href is not reported because ProjectLink declares it, and it stays a named_attribute site; url is reported.
  • Every site found on fresh archives of agent-comms 106007daa, toad 9b203dad + agent-comms, and textual f5ec9e757:

    • agent-comms: 0
    • toad + agent-comms: 1, toad/qt/composer_surround.py:68, owner.describe. None of TurnOwner, ActivityTurn, AgentTurn, ClientTurn, ManagedTurn or NoTurn binds or stores describe.
    • textual: 0

    The real window.py url probe is not reported: some module stores .url on another receiver, so the name is held conservatively.

  • named_attribute goes from 37 to 36 on toad + agent-comms because the describe site moved; it is unchanged on agent-comms (5) and textual (40).

  • Tests: tests/test_restated_fact_detectors.py, tests/test_pattern_semantic_authority.py and tests/test_class_mro.py passed 158. pytest tests -k test_repository_ passed 72.


Generated by Claude Code

absent_attribute_probe (pattern 57) reports a getattr or hasattr whose
literal name no class the receiver is declared as, nor any scanned
subclass, binds through its MRO (member_in_mro) or stores on itself; such
a probe has a fixed answer and the branch it guards is dead. A dunder, a
name stored on any other receiver, an open MRO, a lookup hook and a class
storing by a computed name all keep a probe off it. named_attribute
leaves those sites to it, so each site is one detector's.

Fixtures are toad's own shapes: the turn owner's `describe` probe
(composer_surround) is reported; the line link's `href` probe is not,
since ProjectLink declares it, while its `url` probe is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016gZLduhisRHdamZ5LNK72Z
@trissim
trissim merged commit 46636fb into main Nov 18, 2026
1 of 10 checks passed
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.

2 participants