← Back to Pull requests

Implement descriptors with suspension and dump support #1110

Open
jaheba opened this pull request with 3129 lines diff across 39 files
View on GitHub
jaheba jaheba commented on Oct 22, 2026 16:59 UTC
Author

Implement Python descriptors for sandbox classes, including property, classmethod, and staticmethod. Attribute reads honor data descriptor precedence, and writes/deletes dispatch descriptor hooks. Class creation calls __set_name__ in namespace order.

Descriptor hooks run through ordinary VM frames so external calls and OS calls can suspend and resume. This also covers getattr, hasattr, and class patterns with descriptor-backed __match_args__, including dump/restore during metadata lookup and subsequent attribute reads.

New dumps use version 14; version 13 dumps remain supported, with a regression test loading and resuming the existing version 13 fixture. Legacy CallAttr opcodes remain unchanged. This branch starts from upstream main and is independent of #1089 and the method-call implementation.

Validation:

  • 948 Rust tests with memory-model-checks.

  • 704 Monty fixtures with memory-model-checks and ref-count-return.

  • Rust formatting, Rust lint, and Python lint checks.
  • <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Implements Python descriptors — property, classmethod, and staticmethod — for sandbox classes. Attribute reads honor data descriptor precedence, writes and deletes dispatch descriptor hooks, class creation calls __set_name__ in namespace order, and del now works on attributes instead of raising NotImplementedError. Descriptor-free classes keep their fast attribute paths, and class patterns without descriptor-backed __match_args__ keep their fast path.

  • Descriptor hooks suspend through ordinary VM frames, covering external calls, OS calls, awaits, getattr, hasattr, match patterns with descriptor-backed __match_args__, and the new delattr builtin.

  • Dump format bumps to version 14; version 13 dumps remain readable, and a per-class flag restores fast-path lookup on resume.

  • Data-descriptor setters in the synthesized dataclass initializer run synchronously and cannot suspend, and dataclass defaults are read from the class namespace directly.
  • <sup>Written for commit 50bce6ed84384155a3812c0bfcbf55ed8428855e. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/pydantic/monty/pull/1110?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 3129 lines (+2920 / -209) across 39 files Reviewer: jaheba Review duration: 13067m
    All Vouch review confidence checks passed
    Residual risk 0.12 = Change Risk (0.86) × (1 − Review Confidence (0.86)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 3129 lines diff across 39 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.96 · 5 substantive comment(s)
    0.96
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    86%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    36 items
    github-actions[bot] github-actions[bot] commented on Oct 22, 2026 16:59 UTC
    Bot

    <!-- branch-diff -->

    Branch diff: descriptor-protocol

    | Commit | Message | Production | Test | Docs | Other |
    | --- | --- | --: | --: | --: | --: |
    | df2672def | Implement descriptors with su… | +1264 -181 | +702 -11 | +25 -17 | +0 -0 |
    | 1bd27e525 | Fix descriptor review finding… | +42 -29 | +164 -0 | +12 -12 | +0 -0 |
    | bd3000155 | Restore fast paths for ordina… | +309 -60 | +115 -0 | +0 -0 | +0 -0 |
    | a79f4d059 | Optimize attribute lookup and… | +257 -48 | +167 -0 | +0 -0 | +0 -0 |
    | 35d1fa164 | Clarify descriptor lookup nam… | +110 -96 | +0 -0 | +0 -0 | +0 -0 |
    | 50bce6ed8 | Address descriptor lookup rev… | +37 -39 | +0 -0 | +6 -6 | +0 -0 |
    | | TOTAL | +1739 -173 | +1148 -11 | +33 -25 | +0 -0 |

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/modules/dataclasses/mod.rs:1
    @@ -817,14 +825,27 @@ fn run_post_init<'h>(instance_id: HeapId, class: &HeapRead<'h, Class>, vm: &mut
     /// guard; the caller owns the instance.
     fn store_bound_fields<'h>(
         instance: &HeapReadMut<'h, Instance>,
    +    instance_id: HeapId,
         fields: &[(StringId, bool)],
         values: Vec<Value>,
         vm: &mut VM<'h>,
     ) -> Result<(), RunError> {
         defer_drop_mut!(values, vm);
         for i in 0..values.len() {
    -        let value = mem::replace(&mut values[i], Value::None);
             let name = Value::InternString(fields[i].0);
    +        if let Some(member) = class_member(instance.get(vm.heap).class(), vm.interns.get_str(fields[i].0), vm) {
    +            defer_drop!(member, vm);
    +            if descriptor::is_data(member, vm) {
    +                let value = mem::replace(&mut values[i], Value::None);
    +                vm.heap.inc_ref(instance_id);
    +                let object = Value::Ref(instance_id);
    +                defer_drop!(object, vm);
    +                let result = descriptor::mutate(member, object, Some(value), vm)?.require_synchronous(vm)?;

    <!-- cubic:v=b0fab775-9177-4aa5-b349-0558f9ea4cac -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":9} -->
    P1: Dataclass construction rejects a data-descriptor setter as soon as it suspends. Run the initializer's descriptor setter through a resumable continuation, or document and consistently enforce this unsupported case.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/modules/dataclasses/mod.rs, line 843:
    
    <comment>Dataclass construction rejects a data-descriptor setter as soon as it suspends. Run the initializer's descriptor setter through a resumable continuation, or document and consistently enforce this unsupported case.</comment>
    
    <file context>
    @@ -817,14 +825,27 @@ fn run_post_init<'h>(instance_id: HeapId, class: &HeapRead<'h, Class>, vm: &mut
    +                vm.heap.inc_ref(instance_id);
    +                let object = Value::Ref(instance_id);
    +                defer_drop!(object, vm);
    +                let result = descriptor::mutate(member, object, Some(value), vm)?.require_synchronous(vm)?;
    +                result.drop_with(vm);
    +                continue;
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    docs/limitations/index.md:1
    @@ -31,6 +31,7 @@ They exist for development and for agents debugging code that runs on Monty; mos
     - List, dict and set comprehensions
     - `try` / `except` / `else` / `finally`, `raise ... from ...`
     - `for`, `while`, `if` / `elif` / `else`, `break`, `continue`, `pass`, `assert`, `global`, `nonlocal`, `return`
    +- Descriptors, `property`, `classmethod`, `staticmethod`, and decorators on methods

    <!-- cubic:v=cf0bbb23-dbd5-4b41-9474-e989d2195758 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P2: This supported-feature entry leaves docs/limitations/language.md saying that decorators do not work on methods. Update that stale limitation in the same PR so users are not given contradictory subset documentation.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/limitations/index.md, line 34:
    
    <comment>This supported-feature entry leaves `docs/limitations/language.md` saying that decorators do not work on methods. Update that stale limitation in the same PR so users are not given contradictory subset documentation.</comment>
    
    <file context>
    @@ -31,6 +31,7 @@ They exist for development and for agents debugging code that runs on Monty; mos
     - List, dict and set comprehensions
     - `try` / `except` / `else` / `finally`, `raise ... from ...`
     - `for`, `while`, `if` / `elif` / `else`, `break`, `continue`, `pass`, `assert`, `global`, `nonlocal`, `return`
    +- Descriptors, `property`, `classmethod`, `staticmethod`, and decorators on methods
     - `with` statements, for files and for classes implementing `__enter__` / `__exit__`
     - `match` statements with every PEP 634 pattern kind and guards, see [match.md](match.md)
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/class.rs:1
    @@ -184,6 +188,16 @@ impl<'h> PyTrait<'h> for HeapObjectRead<'h, Class> {
         }
     
         fn py_call_attr(&mut self, vm: &mut VM<'h>, attr: &EitherStr, args: ArgValues) -> RunResult<CallResult> {
    +        let member = super::instance::class_member(self.id(), attr.as_str(vm.interns), vm);

    <!-- cubic:v=0bb2e4e1-f607-4b79-baa3-1d182669c642 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":7} -->
    P2: Check the synthesized __name__ case before descriptor dispatch. Otherwise a class-dict descriptor named __name__ sends calls through descriptor::call_attr, whose argument packing can reject duplicate keywords before the metaclass-like synthesized string is handled.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/class.rs, line 191:
    
    <comment>Check the synthesized `__name__` case before descriptor dispatch. Otherwise a class-dict descriptor named `__name__` sends calls through `descriptor::call_attr`, whose argument packing can reject duplicate keywords before the metaclass-like synthesized string is handled.</comment>
    
    <file context>
    @@ -184,6 +188,16 @@ impl<'h> PyTrait<'h> for HeapObjectRead<'h, Class> {
         }
     
         fn py_call_attr(&mut self, vm: &mut VM<'h>, attr: &EitherStr, args: ArgValues) -> RunResult<CallResult> {
    +        let member = super::instance::class_member(self.id(), attr.as_str(vm.interns), vm);
    +        defer_drop!(member, vm);
    +        if member
    </file context>
    

    </details>

            let member = (attr.as_str(vm.interns) != "__name__")
                .then(|| super::instance::class_member(self.id(), attr.as_str(vm.interns), vm))
                .flatten();
    

    ✅ Addressed in bd30001

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    docs/limitations/builtins.md:1
    @@ -25,10 +25,9 @@ These raise `NameError`:
     - **Code objects and imports**: `compile`, `__import__`.
     - **Namespace introspection**: `globals`, `vars`, `dir`.
     - **Interactive**: `input`, `breakpoint`, `help`.
    -- **Decorators / descriptors**: `classmethod`, `staticmethod`, `property`,
    -    `super`. (`@property` on functions is not recognized; use a method.)
    +- **Inheritance**: `super`.
     - **Construction / coercion**: `bytearray`, `memoryview`, `object`, `ascii`.
    -- **Other**: `callable`, `delattr`, `issubclass`, `aiter`, `anext`.
    +- **Other**: `callable`, `issubclass`, `aiter`, `anext`.

    <!-- cubic:v=77b00d6c-032a-4ea6-a482-2ae0f99d82bb -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P2: This change removes delattr, property, classmethod, and staticmethod from the unimplemented list without adding them to an implemented list, contradicting this page’s promise that every unlisted builtin raises NameError. Add delattr to the implemented builtin functions and the three descriptor constructors to the implemented type constructors (or another explicit implemented section).

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/limitations/builtins.md, line 30:
    
    <comment>This change removes `delattr`, `property`, `classmethod`, and `staticmethod` from the unimplemented list without adding them to an implemented list, contradicting this page’s promise that every unlisted builtin raises `NameError`. Add `delattr` to the implemented builtin functions and the three descriptor constructors to the implemented type constructors (or another explicit implemented section).</comment>
    
    <file context>
    @@ -25,10 +25,9 @@ These raise `NameError`:
    +- **Inheritance**: `super`.
     - **Construction / coercion**: `bytearray`, `memoryview`, `object`, `ascii`.
    -- **Other**: `callable`, `delattr`, `issubclass`, `aiter`, `anext`.
    +- **Other**: `callable`, `issubclass`, `aiter`, `anext`.
     
     `super()` is the biggest practical omission: with no class inheritance either
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/builtins/delattr.rs:1
    @@ -0,0 +1,67 @@
    +//! Attribute deletion, including suspendable descriptor deleters.
    +
    +use crate::{
    +    args::ArgValues,
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    heap::{HeapData, HeapReadOutput},
    +    modules::dataclasses,
    +    types::{attribute_name_value, descriptor, instance::class_member},
    +    value::Value,
    +};
    +
    +pub(crate) fn builtin_delattr(vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +    let args = args.into_pos_only("delattr", vm.heap)?;
    +    defer_drop!(args, vm);
    +    let [object, name] = args.as_slice() else {
    +        return Err(ExcType::type_error_arg_count("delattr", 2, args.len()));
    +    };
    +    let Some(attr) = name.as_either_str(vm.heap).map(|s| s.resolve_interned(vm.interns)) else {
    +        return Err(ExcType::type_error("attribute name must be string"));
    +    };
    +    if let Some(class) = descriptor::descriptor_class(object, vm)
    +        && let Some(error) = dataclasses::frozen_deletion_error(class, name, vm)
    +    {
    +        return Err(error);
    +    }
    +    if let Some(class) = descriptor::descriptor_class(object, vm)
    +        && let Some(member) = class_member(class, attr.as_str(vm.interns), vm)
    +    {
    +        defer_drop!(member, vm);
    +        if descriptor::is_data(member, vm) {
    +            return descriptor::mutate(member, object, None, vm);
    +        }
    +    }
    +    let key = attribute_name_value(&attr, vm);
    +    defer_drop!(key, vm);
    +    let removed = match object {
    +        Value::Ref(id) => match vm.heap.read(*id) {
    +            HeapReadOutput::Instance(instance) => instance.attrs_mut().pop(key, vm)?.map(|(key, value)| {
    +                key.drop_with(vm);
    +                value
    +            }),
    +            HeapReadOutput::Class(class) => class.pop_attr(key, vm)?,
    +            _ => None,
    +        },
    +        _ => None,
    +    };
    +    if let Some(value) = removed {
    +        value.drop_with(vm);
    +        Ok(CallResult::Value(Value::None))
    +    } else {
    +        let class = if let Value::Ref(id) = object {
    +            matches!(vm.heap.get(*id), HeapData::Class(_))
    +        } else {
    +            false
    +        };
    +        if class {
    +            Err(ExcType::attribute_error_type("type", attr.as_str(vm.interns)))

    <!-- cubic:v=606feca7-7d6a-4eb8-8488-566dfc9a5a0d -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":9} -->
    P2: Deleting a missing attribute from a user-defined class reports the wrong class name because this passes the literal "type" to attribute_error_type. Pass the class object's actual name, as Class::py_getattr does, so delattr(C, 'missing') identifies C.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/builtins/delattr.rs, line 59:
    
    <comment>Deleting a missing attribute from a user-defined class reports the wrong class name because this passes the literal `"type"` to `attribute_error_type`. Pass the class object's actual name, as `Class::py_getattr` does, so `delattr(C, 'missing')` identifies `C`.</comment>
    
    <file context>
    @@ -0,0 +1,67 @@
    +            false
    +        };
    +        if class {
    +            Err(ExcType::attribute_error_type("type", attr.as_str(vm.interns)))
    +        } else {
    +            Err(ExcType::attribute_error(
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on Oct 22, 2026 17:07 UTC
    Reviewer

    <!-- cubic:review-summary:start -->
    All reported issues were addressed across 39 files
    <!-- cubic:review-summary:end -->

    <sub>Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.<br /><br />View guided diff | Re-trigger cubic</sub>

    <!-- cubic:review-post:ai_pr_review_github_delivery_a2b85eb0e22f7dbe946cecc80166e1c2d19062218a261935293c0bd4d4311758:df2672def42b1dbc8a77fe767bc233da03695705:e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/instance.rs:1
    @@ -631,64 +652,43 @@ impl HeapItem for BoundMethod {
         }
     }
     
    -/// Reads an instance attribute for `obj.attr` (the `LoadAttr` path).
    -///
    -/// Mirrors Python's lookup order: the instance `__dict__` first, then the class
    -/// namespace, then the `__class__` special case. A class method becomes a
    -/// [`BoundMethod`] (binding `self`); a class variable is returned as-is. A missing
    -/// attribute raises `AttributeError` with the real class name. Takes `self_id`
    -/// (available at the `Value` level) because binding a method needs the instance's
    -/// `HeapId`.
    +/// Reads data descriptors before instance storage, then other class members.
    +/// Descriptor code uses ordinary VM frames and may suspend.
     pub(crate) fn instance_getattr(self_id: HeapId, attr: &EitherStr, vm: &mut VM<'_>) -> RunResult<CallResult> {
    -    let attr_str = attr.as_str(vm.interns);
    -    if let Some(value) = instance_attr(self_id, attr_str, vm) {
    -        Ok(CallResult::Value(value))
    -    } else {
    -        let class_id = instance_class(self_id, vm);
    -        Err(ExcType::attribute_error(
    -            class_name(class_id, vm.heap, vm.interns),
    -            attr_str,
    -        ))
    +    let name = attr.as_str(vm.interns).to_owned();
    +    let class = instance_class(self_id, vm);
    +    let member = class_member(class, &name, vm);
    +    defer_drop!(member, vm);
    +    if let Some(member) = member
    +        && super::descriptor::is_data(member, vm)
    +        && super::descriptor::has_get(member, vm)
    +    {
    +        return super::descriptor::get(member, Some(self_id), class, vm);
    +    }
    +    let HeapData::Instance(instance) = vm.heap.get(self_id) else {
    +        unreachable!()
    +    };
    +    if let Some(value) = instance.attrs().get_by_str(&name, vm.heap, vm.interns) {
    +        return Ok(CallResult::Value(value.clone_with_heap(vm.heap)));
    +    }
    +    if let Some(member) = member {
    +        return super::descriptor::get(member, Some(self_id), class, vm);
         }
    +    if name == "__class__" {
    +        vm.heap.inc_ref(class);
    +        return Ok(CallResult::Value(Value::Ref(class)));
    +    }
    +    Err(ExcType::attribute_error(class_name(class, vm.heap, vm.interns), &name))
     }
     
    -/// The lookup half of [`instance_getattr`]: the instance `__dict__`, then the
    -/// class namespace, then the `__class__` special case; `None` when nothing binds
    -/// `attr`, leaving the `AttributeError` to the caller.
    -///
    -/// Split out so the synthesized dataclass `__repr__`/`__eq__` read their fields
    -/// exactly as `self.field` does, binding a function-valued class member as a
    -/// [`BoundMethod`].
    -pub(crate) fn instance_attr(self_id: HeapId, attr: &str, vm: &VM<'_>) -> Option<Value> {
    -    if let HeapReadOutput::Instance(inst) = vm.heap.read(self_id)
    -        && let Some(value) = inst
    -            .get(vm.heap)
    -            .attrs
    -            .get_by_str(attr, vm.heap, vm.interns)
    -            .map(|v| v.clone_with_heap(vm.heap))
    -    {
    -        return Some(value);
    -    }
    -    let class_id = instance_class(self_id, vm);
    -    match class_member(class_id, attr, vm) {
    -        // A class variable is returned as-is; a function binds `self`.
    -        Some(member) if is_method_value(&member, vm) => {
    -            vm.heap.inc_ref(self_id);
    -            let bound = BoundMethod {
    -                instance: Value::Ref(self_id),
    -                func: member,
    -            };
    -            Some(Value::Ref(vm.heap.allocate(HeapData::BoundMethod(bound))))
    -        }
    -        Some(member) => Some(member),
    -        // `obj.__class__` returns the class object itself (`obj.__class__ is Foo`).
    -        // Last, so an explicit member of the same name wins, mirroring the
    -        // `__name__` handling on class objects.
    -        None if attr == "__class__" => {
    -            vm.heap.inc_ref(class_id);
    -            Some(Value::Ref(class_id))
    -        }
    -        None => None,
    +/// Attribute lookup for native operations that require synchronous completion.
    +/// Dataclass repr, comparison and hash use the same descriptor precedence as `obj.attr`.
    +pub(crate) fn instance_attr(self_id: HeapId, attr: &str, vm: &mut VM<'_>) -> RunResult<Option<Value>> {
    +    let attr = EitherStr::Heap(attr.to_owned());
    +    match instance_getattr(self_id, &attr, vm) {
    +        Ok(result) => result.require_synchronous(vm).map(Some),
    +        Err(RunError::Exc(exc)) if exc.exc.exc_type() == ExcType::AttributeError => Ok(None),

    <!-- cubic:v=6e9584ab-e856-4e10-8066-66457b8bb2c4 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":9} -->
    P2: Do not treat an AttributeError raised by a descriptor getter as lookup absence. Distinguish a missing class/instance member before invoking its getter, or propagate getter exceptions and return None only for a genuinely absent attribute.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/instance.rs, line 690:
    
    <comment>Do not treat an `AttributeError` raised by a descriptor getter as lookup absence. Distinguish a missing class/instance member before invoking its getter, or propagate getter exceptions and return `None` only for a genuinely absent attribute.</comment>
    
    <file context>
    @@ -631,64 +652,43 @@ impl HeapItem for BoundMethod {
    +    let attr = EitherStr::Heap(attr.to_owned());
    +    match instance_getattr(self_id, &attr, vm) {
    +        Ok(result) => result.require_synchronous(vm).map(Some),
    +        Err(RunError::Exc(exc)) if exc.exc.exc_type() == ExcType::AttributeError => Ok(None),
    +        Err(error) => Err(error),
         }
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn classmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let ClassMethodArgs { function } = ClassMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::ClassMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn staticmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let StaticMethodArgs { function } = StaticMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::StaticMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +fn allocate(descriptor: BuiltinDescriptor, vm: &mut VM<'_>) -> Value {
    +    Value::Ref(vm.heap.allocate(HeapData::BuiltinDescriptor(Box::new(descriptor))))
    +}
    +
    +pub(crate) fn get(id: HeapId, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let instance = instance.map_or(Value::None, |id| {
    +        vm.heap.inc_ref(id);
    +        Value::Ref(id)
    +    });
    +    defer_drop!(instance, vm);
    +    vm.heap.inc_ref(owner);
    +    let owner = Value::Ref(owner);
    +    defer_drop!(owner, vm);
    +    protocol_get(id, instance, Some(owner), vm)
    +}
    +
    +fn protocol_get(id: HeapId, instance: &Value, owner: Option<&Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {
    +        Type::StaticMethod => Ok(CallResult::Value(descriptor.values[0].clone_with_heap(vm))),
    +        Type::ClassMethod => {
    +            let func = descriptor.values[0].clone_with_heap(vm.heap);
    +            let instance = match owner {
    +                Some(owner) if !matches!(owner, Value::None) => owner.clone_with_heap(vm.heap),
    +                _ => type_of_ref(vm, instance),
    +            };
    +            Ok(CallResult::Value(Value::Ref(vm.heap.allocate(HeapData::BoundMethod(
    +                super::BoundMethod { instance, func },
    +            )))))
    +        }
    +        Type::Property => {
    +            if matches!(instance, Value::None) {
    +                if owner.is_none_or(|v| matches!(v, Value::None)) {
    +                    return Err(ExcType::type_error("__get__(None, None) is invalid"));
    +                }
    +                vm.heap.inc_ref(id);
    +                return Ok(CallResult::Value(Value::Ref(id)));
    +            }
    +            let function = descriptor.values[0].clone_with_heap(vm);
    +            defer_drop!(function, vm);
    +            if matches!(function, Value::None) {
    +                return Err(missing_accessor("getter"));
    +            }
    +            vm.call_function(function, ArgValues::One(instance.clone_with_heap(vm.heap)))
    +        }
    +        _ => unreachable!("descriptor constructor selects its kind"),
    +    }
    +}
    +
    +pub(crate) fn mutate(id: HeapId, object: &Value, value: Option<Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    defer_drop!(value, vm);
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    let index = if value.is_some() { 1 } else { 2 };
    +    let function = descriptor.values[index].clone_with_heap(vm.heap);
    +    if matches!(function, Value::None) {
    +        return Err(missing_accessor(if index == 1 { "setter" } else { "deleter" }));
    +    }
    +    let mut args = vec![object.clone_with_heap(vm.heap)];
    +    args.extend(value.as_ref().map(|v| v.clone_with_heap(vm.heap)));
    +    super::descriptor::discard_call(function, args, vm)
    +}
    +
    +fn missing_accessor(accessor: &str) -> RunError {
    +    SimpleException::new_msg(ExcType::AttributeError, format!("property has no {accessor}")).into()
    +}
    +
    +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
    +pub(crate) enum DescriptorMethod {
    +    Getter,
    +    Setter,
    +    Deleter,
    +    Get,
    +    Set,
    +    Delete,
    +    SetName,
    +}
    +
    +impl fmt::Display for DescriptorMethod {
    +    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    +        f.write_str(match self {
    +            Self::Getter => "property.getter",
    +            Self::Setter => "property.setter",
    +            Self::Deleter => "property.deleter",
    +            Self::Get => "descriptor.__get__",
    +            Self::Set => "descriptor.__set__",
    +            Self::Delete => "descriptor.__delete__",
    +            Self::SetName => "property.__set_name__",
    +        })
    +    }
    +}
    +
    +impl DescriptorMethod {
    +    pub(crate) fn call(self, vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +        if matches!(self, Self::Get | Self::Set | Self::Delete | Self::SetName) {
    +            return self.protocol_call(vm, args);
    +        }
    +        let AccessorArgs { receiver, function } = AccessorArgs::from_args(args, vm)?;
    +        let mut guard = DropGuard::new((receiver, function), vm);
    +        let ((receiver, _), vm) = guard.as_parts_mut();
    +        let mut values = if let Value::Ref(id) = receiver
    +            && let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(*id)
    +            && descriptor.kind == Type::Property
    +        {
    +            descriptor.values.each_ref().map(|v| v.clone_with_heap(vm))
    +        } else {
    +            return Err(ExcType::type_error("property accessor requires a property"));
    +        };
    +        let name = if let Value::Ref(id) = receiver {
    +            let HeapData::BuiltinDescriptor(d) = vm.heap.get(*id) else {
    +                unreachable!()
    +            };
    +            d.name.clone()
    +        } else {
    +            unreachable!()
    +        };
    +        let ((receiver, function), vm) = guard.into_parts();
    +        receiver.drop_with(vm);
    +        let index = match self {
    +            Self::Getter => 0,
    +            Self::Setter => 1,
    +            Self::Deleter => 2,
    +            _ => unreachable!(),
    +        };
    +        mem::replace(&mut values[index], function).drop_with(vm);
    +        Ok(CallResult::Value(Value::Ref(vm.heap.allocate(
    +            HeapData::BuiltinDescriptor(Box::new(BuiltinDescriptor {
    +                kind: Type::Property,
    +                values,
    +                name,
    +            })),
    +        ))))
    +    }
    +}
    +
    +impl DescriptorMethod {
    +    fn protocol_call(self, vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +        let args = args.into_pos_only("descriptor", vm.heap)?;
    +        defer_drop!(args, vm);
    +        let Some(Value::Ref(id)) = args.as_slice().first() else {
    +            return Err(ExcType::type_error("descriptor receiver required"));
    +        };
    +        match (self, args.as_slice()) {
    +            (Self::Get, [_, instance, owner]) => protocol_get(*id, instance, Some(owner), vm),
    +            (Self::Get, [_, instance]) => protocol_get(*id, instance, None, vm),
    +            (Self::Set, [_, object, value]) => mutate(*id, object, Some(value.clone_with_heap(vm.heap)), vm),
    +            (Self::Delete, [_, object]) => mutate(*id, object, None, vm),
    +            (Self::SetName, [_, _, name]) => {
    +                set_name(*id, name, vm)?;
    +                Ok(CallResult::Value(Value::None))
    +            }
    +            _ => Err(ExcType::type_error("invalid descriptor arguments")),
    +        }
    +    }
    +}
    +
    +impl HeapItem for BuiltinDescriptor {
    +    fn py_dec_ref_ids(&mut self, stack: &mut Vec<HeapId>) {
    +        for value in &mut self.values {
    +            value.py_dec_ref_ids(stack);
    +        }
    +    }
    +}
    +
    +impl<'h> PyTrait<'h> for HeapObjectRead<'h, BuiltinDescriptor> {
    +    fn py_type(&self, vm: &VM<'h>) -> Type {
    +        self.get(vm.heap).kind
    +    }
    +
    +    fn py_len(&self, _: &VM<'h>) -> Option<usize> {
    +        None
    +    }
    +
    +    fn py_eq_impl(&self, _: &Value, _: &mut VM<'h>) -> RunResult<Option<bool>> {
    +        Ok(None)
    +    }
    +
    +    fn py_hash(&self, _: &mut VM<'h>) -> RunResult<Option<HashValue>> {
    +        Ok(Some(identity_hash(self.id())))
    +    }
    +
    +    fn py_repr_fmt(&self, f: &mut impl Write, vm: &mut VM<'h>, _: &mut LazyHeapSet) -> RunResult<()> {
    +        Ok(write!(f, "<{} object>", self.get(vm.heap).kind)?)
    +    }
    +
    +    fn py_getattr(&self, attr: &EitherStr, vm: &mut VM<'h>) -> RunResult<Option<CallResult>> {
    +        let descriptor = self.get(vm.heap);
    +        let name = attr.as_str(vm.interns);
    +        if name == "__name__" {
    +            return Ok(descriptor
    +                .name
    +                .as_ref()
    +                .map(|name| CallResult::Value(super::str::allocate_string(name.clone(), vm.heap))));
    +        }
    +        let value = if descriptor.kind == Type::Property {
    +            let index = match name {
    +                "fget" => Some(0),
    +                "fset" => Some(1),
    +                "fdel" => Some(2),
    +                "__doc__" => Some(3),
    +                _ => None,
    +            };
    +            if let Some(index) = index {
    +                descriptor.values[index].clone_with_heap(vm)
    +            } else {
    +                let method = match name {
    +                    "getter" => DescriptorMethod::Getter,
    +                    "setter" => DescriptorMethod::Setter,
    +                    "deleter" => DescriptorMethod::Deleter,
    +                    "__get__" => DescriptorMethod::Get,
    +                    "__set__" => DescriptorMethod::Set,
    +                    "__delete__" => DescriptorMethod::Delete,
    +                    "__set_name__" => DescriptorMethod::SetName,
    +                    _ => return Ok(None),
    +                };
    +                bind_method(
    +                    &Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::Descriptor(method))),
    +                    self.id(),
    +                    vm,
    +                )
    +            }
    +        } else if name == "__get__" {
    +            bind_method(
    +                &Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::Descriptor(
    +                    DescriptorMethod::Get,
    +                ))),
    +                self.id(),
    +                vm,
    +            )
    +        } else if matches!(name, "__func__" | "__wrapped__") {

    <!-- cubic:v=fdae301a-fbb1-4058-b2d5-c810d27be9a8 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":9} -->
    P2: classmethod and staticmethod wrappers raise AttributeError for __doc__ instead of exposing the wrapped function's documentation. Preserve and return the wrapped function's __doc__ for these descriptor kinds.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/builtin_descriptor.rs, line 340:
    
    <comment>`classmethod` and `staticmethod` wrappers raise `AttributeError` for `__doc__` instead of exposing the wrapped function's documentation. Preserve and return the wrapped function's `__doc__` for these descriptor kinds.</comment>
    
    <file context>
    @@ -0,0 +1,401 @@
    +                self.id(),
    +                vm,
    +            )
    +        } else if matches!(name, "__func__" | "__wrapped__") {
    +            descriptor.values[0].clone_with_heap(vm)
    +        } else {
    </file context>
    

    </details>

    <a href="https://www.cubic.dev/action/fix/violation/fdae301a-fbb1-4058-b2d5-c810d27be9a8" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true">
    <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/fix-with-cubic-light.svg">
    <img alt="Fix with cubic" src="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    </picture>
    </a>

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),

    <!-- cubic:v=abca51ff-0ee8-4e95-ba6d-b4900423329f -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P2: An omitted property docstring is incorrectly stored as None; derive __doc__ from fget.__doc__ when the explicit doc argument is absent.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/builtin_descriptor.rs, line 77:
    
    <comment>An omitted `property` docstring is incorrectly stored as `None`; derive `__doc__` from `fget.__doc__` when the explicit `doc` argument is absent.</comment>
    
    <file context>
    @@ -0,0 +1,401 @@
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    </file context>
    

    </details>

    <a href="https://www.cubic.dev/action/fix/violation/abca51ff-0ee8-4e95-ba6d-b4900423329f" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true">
    <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/fix-with-cubic-light.svg">
    <img alt="Fix with cubic" src="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    </picture>
    </a>

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn classmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let ClassMethodArgs { function } = ClassMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::ClassMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn staticmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let StaticMethodArgs { function } = StaticMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::StaticMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +fn allocate(descriptor: BuiltinDescriptor, vm: &mut VM<'_>) -> Value {
    +    Value::Ref(vm.heap.allocate(HeapData::BuiltinDescriptor(Box::new(descriptor))))
    +}
    +
    +pub(crate) fn get(id: HeapId, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let instance = instance.map_or(Value::None, |id| {
    +        vm.heap.inc_ref(id);
    +        Value::Ref(id)
    +    });
    +    defer_drop!(instance, vm);
    +    vm.heap.inc_ref(owner);
    +    let owner = Value::Ref(owner);
    +    defer_drop!(owner, vm);
    +    protocol_get(id, instance, Some(owner), vm)
    +}
    +
    +fn protocol_get(id: HeapId, instance: &Value, owner: Option<&Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {

    <!-- cubic:v=541a6834-9b34-41a2-a36d-29352f4c50d6 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P2: classmethod.__get__(None) and staticmethod.__get__(None) incorrectly succeed because the invalid (None, None) receiver check is limited to properties. Reject that receiver pair before dispatching all builtin descriptor kinds.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/builtin_descriptor.rs, line 128:
    
    <comment>`classmethod.__get__(None)` and `staticmethod.__get__(None)` incorrectly succeed because the invalid `(None, None)` receiver check is limited to properties. Reject that receiver pair before dispatching all builtin descriptor kinds.</comment>
    
    <file context>
    @@ -0,0 +1,401 @@
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {
    +        Type::StaticMethod => Ok(CallResult::Value(descriptor.values[0].clone_with_heap(vm))),
    +        Type::ClassMethod => {
    </file context>
    

    </details>

        if matches!(instance, Value::None) && owner.is_none_or(|v| matches!(v, Value::None)) {
            return Err(ExcType::type_error("__get__(None, None) is invalid"));
        }
        match descriptor.kind {
    

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/types/descriptor.rs:1
    @@ -0,0 +1,356 @@
    +//! Descriptor lookup and suspendable continuations for sandbox classes.
    +
    +use super::{
    +    Dict,
    +    builtin_descriptor::DescriptorMethod,
    +    instance::{bind_method, class_defines, class_member, is_method_value},
    +    tuple::allocate_tuple,
    +};
    +use crate::{
    +    args::{ArgValues, KwargsValues},
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    frozen::{FrozenFunction, FrozenFunctions},
    +    heap::{DropGuard, HeapData, HeapId},
    +    modules::{ModuleFunctions, dataclasses},
    +    value::{EitherStr, Value},
    +};
    +
    +pub(crate) const CALL_SOURCE: &str = r"
    +def _call(get, obj, name, args, kwargs):
    +    return get(obj, name)(*args, **kwargs)
    +";
    +pub(crate) const BIND_CALL_SOURCE: &str = r"
    +def _bind_call(bind, member, instance, owner, args, kwargs):
    +    return bind(member, instance, owner)(*args, **kwargs)
    +";
    +pub(crate) const DISCARD_SOURCE: &str = r"
    +def _discard(function, args):
    +    function(*args)
    +    return None
    +";
    +pub(crate) const NAMES_SOURCE: &str = r"
    +def _names(cls, members, lookup):
    +    missing = []
    +    for descriptor, name in members:
    +        function = lookup(descriptor, missing)
    +        if function is not missing:
    +            function(cls, name)
    +    return cls
    +";
    +pub(crate) const MUTATION_SOURCE: &str = r"
    +def _mutate(bind, function, descriptor, owner, obj, value, setting):
    +    bound = bind(function, descriptor, owner)
    +    if setting:
    +        bound(obj, value)
    +    else:
    +        bound(obj)
    +    return None
    +";
    +pub(crate) const GETATTR_SOURCE: &str = r"
    +def _getattr(get, obj, name, default, attribute_error):
    +    try:
    +        return get(obj, name)
    +    except attribute_error:
    +        return default
    +";
    +pub(crate) const MATCH_SOURCE: &str = r"
    +def _match(get, obj, name, attribute_error):
    +    try:
    +        return (get(obj, name), True)
    +    except attribute_error:
    +        return (None, False)
    +";
    +pub(crate) const MATCH_CLASS_SOURCE: &str = r"
    +def _match_class(get, finish, cls, keywords, nargs, attribute_error):
    +    try:
    +        names = get(cls, '__match_args__')
    +    except attribute_error:
    +        names = ()
    +    return (finish(cls, keywords, nargs, names), True)
    +";
    +pub(crate) const HASATTR_SOURCE: &str = r"
    +def _hasattr(get, obj, name, attribute_error):
    +    try:
    +        get(obj, name)
    +        return True
    +    except attribute_error:
    +        return False
    +";
    +
    +pub(crate) fn attribute_helper() -> Value {
    +    Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::GetAttribute))
    +}
    +
    +pub(crate) fn descriptor_class(value: &Value, vm: &VM<'_>) -> Option<HeapId> {
    +    match value {
    +        Value::Ref(id) => match vm.heap.get(*id) {
    +            HeapData::Instance(instance) => Some(instance.class()),
    +            _ => None,
    +        },
    +        _ => None,
    +    }
    +}
    +
    +/// The setter/deleter is looked up on the descriptor's type, never its instance.
    +pub(crate) fn is_data(value: &Value, vm: &VM<'_>) -> bool {
    +    if let Value::Ref(id) = value
    +        && let HeapData::BuiltinDescriptor(d) = vm.heap.get(*id)
    +    {
    +        return d.kind == super::Type::Property;
    +    }
    +    descriptor_class(value, vm)
    +        .is_some_and(|class| class_defines(class, "__set__", vm) || class_defines(class, "__delete__", vm))
    +}
    +
    +pub(crate) fn has_get(value: &Value, vm: &VM<'_>) -> bool {
    +    matches!(value, Value::Ref(id) if matches!(vm.heap.get(*id), HeapData::BuiltinDescriptor(_)))
    +        || descriptor_class(value, vm).is_some_and(|class| class_defines(class, "__get__", vm))
    +}
    +
    +/// A plain function binds an instance; arbitrary descriptors may install a Python frame.
    +pub(crate) fn get(value: &Value, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    if let Value::Ref(id) = value
    +        && matches!(vm.heap.get(*id), HeapData::BuiltinDescriptor(_))
    +    {
    +        return super::builtin_descriptor::get(*id, instance, owner, vm);
    +    }
    +    if let Some(class) = descriptor_class(value, vm)
    +        && let Some(getter) = class_member(class, "__get__", vm)
    +    {
    +        defer_drop!(getter, vm);
    +        let receiver = instance.map_or(Value::None, |id| {
    +            vm.heap.inc_ref(id);
    +            Value::Ref(id)
    +        });
    +        vm.heap.inc_ref(owner);
    +        let args = ArgValues::ArgsKargs {
    +            args: vec![value.clone_with_heap(vm.heap), receiver, Value::Ref(owner)],
    +            kwargs: KwargsValues::Empty,
    +        };
    +        return vm.call_function(getter, args);

    <!-- cubic:v=bd18b0dc-120e-4a2a-a84a-dd8c31402c0c -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":8} -->
    P2: Custom descriptor hooks do not honor descriptor binding for __get__ itself. Route the hook through the same suspendable binding path used by __set__, otherwise staticmethod/classmethod __get__ implementations receive incorrect arguments or fail.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/types/descriptor.rs, line 132:
    
    <comment>Custom descriptor hooks do not honor descriptor binding for `__get__` itself. Route the hook through the same suspendable binding path used by `__set__`, otherwise staticmethod/classmethod `__get__` implementations receive incorrect arguments or fail.</comment>
    
    <file context>
    @@ -0,0 +1,356 @@
    +            args: vec![value.clone_with_heap(vm.heap), receiver, Value::Ref(owner)],
    +            kwargs: KwargsValues::Empty,
    +        };
    +        return vm.call_function(getter, args);
    +    }
    +    Ok(CallResult::Value(match instance {
    </file context>
    

    </details>

    <a href="https://www.cubic.dev/action/fix/violation/bd18b0dc-120e-4a2a-a84a-dd8c31402c0c" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true">
    <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://cubic.dev/buttons/fix-with-cubic-light.svg">
    <img alt="Fix with cubic" src="https://cubic.dev/buttons/fix-with-cubic-dark.svg">
    </picture>
    </a>

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/intern.rs:1
    @@ -923,6 +923,9 @@ pub enum StaticStrings {
         Dklen,
         /// `field(doc=...)`, CPython's per-field docstring.
         Doc,
    +    Fget,
    +    Fset,

    <!-- cubic:v=5dac36e4-3f97-4277-92bb-32162e563e64 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P3: Keep the new StaticStrings variants alphabetized as documented; Fset currently precedes Fdel. Reorder them to Fdel, Fget, Fset to preserve the enum’s maintenance invariant.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/intern.rs, line 927:
    
    <comment>Keep the new `StaticStrings` variants alphabetized as documented; `Fset` currently precedes `Fdel`. Reorder them to `Fdel`, `Fget`, `Fset` to preserve the enum’s maintenance invariant.</comment>
    
    <file context>
    @@ -923,6 +923,9 @@ pub enum StaticStrings {
         /// `field(doc=...)`, CPython's per-field docstring.
         Doc,
    +    Fget,
    +    Fset,
    +    Fdel,
         /// `sys.dont_write_bytecode` attribute.
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    docs/limitations/dataclasses.md:1
    @@ -97,7 +99,7 @@ field after a defaulted one
         Monty's own `repr` for those differs (see [classes.md](classes.md)). Only the
         text differs; the value and its equality match CPython.
     - **A class-body `__setattr__` never runs for the synthesized `__init__`**,
    -    which writes fields straight into the instance `__dict__`. This is the
    +    which honors descriptors but otherwise writes to the instance `__dict__`. This is the

    <!-- cubic:v=98bbd5f1-7b56-4e7f-904f-a305c70f498d -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P3: The synthesized initializer does not invoke arbitrary descriptors and cannot suspend through a data-descriptor setter. Describe this as synchronous data-descriptor dispatch; otherwise the limitation overstates descriptor support and omits a user-visible suspension divergence.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/limitations/dataclasses.md, line 102:
    
    <comment>The synthesized initializer does not invoke arbitrary descriptors and cannot suspend through a data-descriptor setter. Describe this as synchronous data-descriptor dispatch; otherwise the limitation overstates descriptor support and omits a user-visible suspension divergence.</comment>
    
    <file context>
    @@ -97,7 +99,7 @@ field after a defaulted one
         text differs; the value and its equality match CPython.
     - **A class-body `__setattr__` never runs for the synthesized `__init__`**,
    -    which writes fields straight into the instance `__dict__`. This is the
    +    which honors descriptors but otherwise writes to the instance `__dict__`. This is the
         never-dispatched attribute hook described in [classes.md](classes.md) rather than
         something dataclass-specific, so `@dataclass` does not reject it.
    </file context>
    

    </details>

        which synchronously dispatches data descriptors but otherwise writes to the instance `__dict__`. This is the
    

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    docs/limitations/language.md:1
    @@ -13,17 +13,12 @@ any code runs.
         class-body statements other than `def`, a simple `name [: T] = <expr>`
         assignment, `pass`, or a docstring. There is no inheritance and no general
         dunder protocol. See [classes.md](classes.md).
    -- **Decorators** (`@deco`) — supported on classes and on top-level or nested
    -    `def`/`async def`, taking any callable in scope, evaluated in the enclosing
    -    scope and applied bottom-up. Rejected at parse time on **methods**, so
    -    `@classmethod`, `@staticmethod`, `@property` and any decorator on a `def`
    -    inside a class body are unavailable. See [classes.md](classes.md).
     - **`async with` statements** — not yet supported.
     - **`yield` / `yield from` expressions** — no generator functions. Generator
         *expressions* (`(x for x in ...)`) parse but currently materialize to a
         `list` rather than a lazy iterator, a known temporary divergence; see
         `iter__generator_expr_type.py`.
    -- **`del` statements** — neither `del x` nor `del d[k]` parse.
    +- **`del` statements** — `del x`, `del d[k]`, and multiple targets are unsupported; `del obj.attr` is supported.

    <!-- cubic:v=8a989883-d9a9-4203-bdc8-40ee35fc0ff8 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P3: This bullet now documents a supported del obj.attr form inside a section whose introduction says every listed statement is rejected at compile time. Qualify the bullet as unsupported forms, or move the supported form out of this section.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At docs/limitations/language.md, line 21:
    
    <comment>This bullet now documents a supported `del obj.attr` form inside a section whose introduction says every listed statement is rejected at compile time. Qualify the bullet as unsupported forms, or move the supported form out of this section.</comment>
    
    <file context>
    @@ -13,17 +13,12 @@ any code runs.
         `list` rather than a lazy iterator, a known temporary divergence; see
         `iter__generator_expr_type.py`.
    -- **`del` statements** — neither `del x` nor `del d[k]` parse.
    +- **`del` statements** — `del x`, `del d[k]`, and multiple targets are unsupported; `del obj.attr` is supported.
     - **`try*` / `except*` exception groups** — PEP 654 syntax rejected.
     - **`type` aliases** (PEP 695 `type Foo = int`).
    </file context>
    

    </details>

    - **Unsupported `del` forms** — `del x`, `del d[k]`, and multiple targets are rejected at parse time; `del obj.attr` is supported.
    

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/builtins/delattr.rs:1
    @@ -0,0 +1,67 @@
    +//! Attribute deletion, including suspendable descriptor deleters.
    +
    +use crate::{
    +    args::ArgValues,
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    heap::{HeapData, HeapReadOutput},
    +    modules::dataclasses,
    +    types::{attribute_name_value, descriptor, instance::class_member},
    +    value::Value,
    +};
    +
    +pub(crate) fn builtin_delattr(vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +    let args = args.into_pos_only("delattr", vm.heap)?;
    +    defer_drop!(args, vm);
    +    let [object, name] = args.as_slice() else {
    +        return Err(ExcType::type_error_arg_count("delattr", 2, args.len()));
    +    };
    +    let Some(attr) = name.as_either_str(vm.heap).map(|s| s.resolve_interned(vm.interns)) else {
    +        return Err(ExcType::type_error("attribute name must be string"));

    <!-- cubic:v=0fc68930-dd5b-496a-8ef6-e48c1427ecc2 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P3: delattr(obj, 1) drops the offending type from its TypeError, unlike the other attribute builtins and Python's error contract. Include name.py_type_name(vm) in this message.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/builtins/delattr.rs, line 21:
    
    <comment>`delattr(obj, 1)` drops the offending type from its TypeError, unlike the other attribute builtins and Python's error contract. Include `name.py_type_name(vm)` in this message.</comment>
    
    <file context>
    @@ -0,0 +1,67 @@
    +        return Err(ExcType::type_error_arg_count("delattr", 2, args.len()));
    +    };
    +    let Some(attr) = name.as_either_str(vm.heap).map(|s| s.resolve_interned(vm.interns)) else {
    +        return Err(ExcType::type_error("attribute name must be string"));
    +    };
    +    if let Some(class) = descriptor::descriptor_class(object, vm)
    </file context>
    

    </details>

            return Err(ExcType::type_error(format!("attribute name must be string, not '{}'", name.py_type_name(vm))));
    

    ✅ Addressed in 1bd27e5

    cubic-dev-ai[bot] cubic-dev-ai[bot] commented on code on Oct 22, 2026 17:07 UTC
    Code Review
    crates/monty/src/parse.rs:1
    @@ -1113,26 +1132,15 @@ impl<'a, 'i> Parser<'a, 'i> {
             for (i, stmt) in class.body.into_iter().enumerate() {
                 match stmt {
                     Stmt::FunctionDef(function) => {
    -                    if !function.decorator_list.is_empty() {
    -                        return Err(ParseError::not_implemented(
    -                            "method decorators (classmethod/staticmethod/property)",
    -                            self.convert_range(function.range),
    -                        ));
    -                    }
    -                    // Parameter defaults evaluate in the class-body scope, so a
    -                    // walrus target there would become a class member (see
    -                    // `reject_class_body_walrus`); walrus in the method *body*
    -                    // binds in the method scope and is fine.
                         for param in function.parameters.iter_non_variadic_params() {
                             if let Some(default) = &param.default {
                                 self.reject_class_body_walrus(default)?;
                             }
                         }
    +                    for decorator in &function.decorator_list {

    <!-- cubic:v=ff94b4ef-43bd-4513-bd25-efd06e305a03 -->
    <!-- cubic:review-run=e8aed5c7-e941-5df3-9bbb-f25c372b00c7 -->
    <!-- metadata:{"confidence":10} -->
    P3: Update the parser documentation: class methods now accept and apply decorators, but parse_function_def and parse_class_def still say method decorators are rejected. Stale scope documentation can cause later changes to preserve the old behavior accidentally.

    <details>
    <summary>Prompt for AI agents</summary>

    Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At crates/monty/src/parse.rs, line 1140:
    
    <comment>Update the parser documentation: class methods now accept and apply decorators, but `parse_function_def` and `parse_class_def` still say method decorators are rejected. Stale scope documentation can cause later changes to preserve the old behavior accidentally.</comment>
    
    <file context>
    @@ -1113,26 +1132,15 @@ impl<'a, 'i> Parser<'a, 'i> {
                                 self.reject_class_body_walrus(default)?;
                             }
                         }
    +                    for decorator in &function.decorator_list {
    +                        self.reject_class_body_walrus(&decorator.expression)?;
    +                    }
    </file context>
    

    </details>

    ✅ Addressed in 1bd27e5

    veria-ai[bot] veria-ai[bot] commented on code on Oct 22, 2026 17:09 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn classmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let ClassMethodArgs { function } = ClassMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::ClassMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn staticmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let StaticMethodArgs { function } = StaticMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::StaticMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +fn allocate(descriptor: BuiltinDescriptor, vm: &mut VM<'_>) -> Value {
    +    Value::Ref(vm.heap.allocate(HeapData::BuiltinDescriptor(Box::new(descriptor))))
    +}
    +
    +pub(crate) fn get(id: HeapId, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let instance = instance.map_or(Value::None, |id| {
    +        vm.heap.inc_ref(id);
    +        Value::Ref(id)
    +    });
    +    defer_drop!(instance, vm);
    +    vm.heap.inc_ref(owner);
    +    let owner = Value::Ref(owner);
    +    defer_drop!(owner, vm);
    +    protocol_get(id, instance, Some(owner), vm)
    +}
    +
    +fn protocol_get(id: HeapId, instance: &Value, owner: Option<&Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {
    +        Type::StaticMethod => Ok(CallResult::Value(descriptor.values[0].clone_with_heap(vm))),
    +        Type::ClassMethod => {
    +            let func = descriptor.values[0].clone_with_heap(vm.heap);
    +            let instance = match owner {
    +                Some(owner) if !matches!(owner, Value::None) => owner.clone_with_heap(vm.heap),
    +                _ => type_of_ref(vm, instance),
    +            };
    +            Ok(CallResult::Value(Value::Ref(vm.heap.allocate(HeapData::BoundMethod(
    +                super::BoundMethod { instance, func },
    +            )))))
    +        }
    +        Type::Property => {
    +            if matches!(instance, Value::None) {
    +                if owner.is_none_or(|v| matches!(v, Value::None)) {
    +                    return Err(ExcType::type_error("__get__(None, None) is invalid"));
    +                }
    +                vm.heap.inc_ref(id);
    +                return Ok(CallResult::Value(Value::Ref(id)));
    +            }
    +            let function = descriptor.values[0].clone_with_heap(vm);
    +            defer_drop!(function, vm);
    +            if matches!(function, Value::None) {
    +                return Err(missing_accessor("getter"));
    +            }
    +            vm.call_function(function, ArgValues::One(instance.clone_with_heap(vm.heap)))

    Medium: Property getter chains bypass recursion limits

    An untrusted script can build the chain below and trigger a native stack overflow, aborting the worker—or the host process when embedding the Rust interpreter—despite configured recursion limits. Each getter re-enters protocol_get through call_function, BoundMethod::py_call, and protocol_call without pushing a VM frame or reserving native re-entry. Guard this dispatch with enter_run_reentry/RunReentryGuard, or use a continuation.

    p = property(len)
    for _ in range(10000):
        p = property(p.__get__)
    p.__get__([])
    

    veria-ai[bot] veria-ai[bot] commented on Oct 22, 2026 17:09 UTC
    Bot

    PR overview

    All previously flagged issues have been addressed. No open security concerns remain on this pull request.

    Security review

    No open security issues remain on this pull request.

    Fixed/addressed: 1 · PR risk: 0/10

    jaheba jaheba commented on code on Oct 22, 2026 17:21 UTC
    Code Review
    crates/monty/src/types/class.rs:1
    @@ -184,6 +188,16 @@ impl<'h> PyTrait<'h> for HeapObjectRead<'h, Class> {
         }
     
         fn py_call_attr(&mut self, vm: &mut VM<'h>, attr: &EitherStr, args: ArgValues) -> RunResult<CallResult> {
    +        let member = super::instance::class_member(self.id(), attr.as_str(vm.interns), vm);

    _Auto response from AI running Codex fix-pr-comments:_

    I checked this against CPython 3.14: with a property stored under __name__, Named.__name__(x=1, **{'x': 2}) raises the duplicate-keyword TypeError before testing whether the synthesized string is callable. Monty does the same (its callable label differs). Moving the special case ahead of argument handling would change this to a not-callable error, so I am retaining the current order.

    jaheba jaheba commented on code on Oct 22, 2026 17:21 UTC
    Code Review
    crates/monty/src/types/descriptor.rs:1
    @@ -0,0 +1,356 @@
    +//! Descriptor lookup and suspendable continuations for sandbox classes.
    +
    +use super::{
    +    Dict,
    +    builtin_descriptor::DescriptorMethod,
    +    instance::{bind_method, class_defines, class_member, is_method_value},
    +    tuple::allocate_tuple,
    +};
    +use crate::{
    +    args::{ArgValues, KwargsValues},
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    frozen::{FrozenFunction, FrozenFunctions},
    +    heap::{DropGuard, HeapData, HeapId},
    +    modules::{ModuleFunctions, dataclasses},
    +    value::{EitherStr, Value},
    +};
    +
    +pub(crate) const CALL_SOURCE: &str = r"
    +def _call(get, obj, name, args, kwargs):
    +    return get(obj, name)(*args, **kwargs)
    +";
    +pub(crate) const BIND_CALL_SOURCE: &str = r"
    +def _bind_call(bind, member, instance, owner, args, kwargs):
    +    return bind(member, instance, owner)(*args, **kwargs)
    +";
    +pub(crate) const DISCARD_SOURCE: &str = r"
    +def _discard(function, args):
    +    function(*args)
    +    return None
    +";
    +pub(crate) const NAMES_SOURCE: &str = r"
    +def _names(cls, members, lookup):
    +    missing = []
    +    for descriptor, name in members:
    +        function = lookup(descriptor, missing)
    +        if function is not missing:
    +            function(cls, name)
    +    return cls
    +";
    +pub(crate) const MUTATION_SOURCE: &str = r"
    +def _mutate(bind, function, descriptor, owner, obj, value, setting):
    +    bound = bind(function, descriptor, owner)
    +    if setting:
    +        bound(obj, value)
    +    else:
    +        bound(obj)
    +    return None
    +";
    +pub(crate) const GETATTR_SOURCE: &str = r"
    +def _getattr(get, obj, name, default, attribute_error):
    +    try:
    +        return get(obj, name)
    +    except attribute_error:
    +        return default
    +";
    +pub(crate) const MATCH_SOURCE: &str = r"
    +def _match(get, obj, name, attribute_error):
    +    try:
    +        return (get(obj, name), True)
    +    except attribute_error:
    +        return (None, False)
    +";
    +pub(crate) const MATCH_CLASS_SOURCE: &str = r"
    +def _match_class(get, finish, cls, keywords, nargs, attribute_error):
    +    try:
    +        names = get(cls, '__match_args__')
    +    except attribute_error:
    +        names = ()
    +    return (finish(cls, keywords, nargs, names), True)
    +";
    +pub(crate) const HASATTR_SOURCE: &str = r"
    +def _hasattr(get, obj, name, attribute_error):
    +    try:
    +        get(obj, name)
    +        return True
    +    except attribute_error:
    +        return False
    +";
    +
    +pub(crate) fn attribute_helper() -> Value {
    +    Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::GetAttribute))
    +}
    +
    +pub(crate) fn descriptor_class(value: &Value, vm: &VM<'_>) -> Option<HeapId> {
    +    match value {
    +        Value::Ref(id) => match vm.heap.get(*id) {
    +            HeapData::Instance(instance) => Some(instance.class()),
    +            _ => None,
    +        },
    +        _ => None,
    +    }
    +}
    +
    +/// The setter/deleter is looked up on the descriptor's type, never its instance.
    +pub(crate) fn is_data(value: &Value, vm: &VM<'_>) -> bool {
    +    if let Value::Ref(id) = value
    +        && let HeapData::BuiltinDescriptor(d) = vm.heap.get(*id)
    +    {
    +        return d.kind == super::Type::Property;
    +    }
    +    descriptor_class(value, vm)
    +        .is_some_and(|class| class_defines(class, "__set__", vm) || class_defines(class, "__delete__", vm))
    +}
    +
    +pub(crate) fn has_get(value: &Value, vm: &VM<'_>) -> bool {
    +    matches!(value, Value::Ref(id) if matches!(vm.heap.get(*id), HeapData::BuiltinDescriptor(_)))
    +        || descriptor_class(value, vm).is_some_and(|class| class_defines(class, "__get__", vm))
    +}
    +
    +/// A plain function binds an instance; arbitrary descriptors may install a Python frame.
    +pub(crate) fn get(value: &Value, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    if let Value::Ref(id) = value
    +        && matches!(vm.heap.get(*id), HeapData::BuiltinDescriptor(_))
    +    {
    +        return super::builtin_descriptor::get(*id, instance, owner, vm);
    +    }
    +    if let Some(class) = descriptor_class(value, vm)
    +        && let Some(getter) = class_member(class, "__get__", vm)
    +    {
    +        defer_drop!(getter, vm);
    +        let receiver = instance.map_or(Value::None, |id| {
    +            vm.heap.inc_ref(id);
    +            Value::Ref(id)
    +        });
    +        vm.heap.inc_ref(owner);
    +        let args = ArgValues::ArgsKargs {
    +            args: vec![value.clone_with_heap(vm.heap), receiver, Value::Ref(owner)],
    +            kwargs: KwargsValues::Empty,
    +        };
    +        return vm.call_function(getter, args);

    _Auto response from AI running Codex fix-pr-comments:_

    CPython 3.14 also invokes the type's raw __get__ hook: a staticmethod hook receives (descriptor, instance, owner), while a classmethod hook raises TypeError: 'classmethod' object is not callable. I verified both cases against Monty. Binding __get__ like __set__ would introduce a CPython divergence, so no change is needed here.

    jaheba jaheba commented on code on Oct 22, 2026 17:21 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),

    _Auto response from AI running Codex fix-pr-comments:_

    Getter docstring inference is an intentional, already documented subset limitation in docs/limitations/classes.md under Descriptor limitations: pass doc= explicitly. Function objects themselves do not expose __doc__ in Monty (documented in language.md), and this PR does not add function metadata support. I am retaining that documented limitation in this PR.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/modules/dataclasses/mod.rs:1
    @@ -817,14 +825,27 @@ fn run_post_init<'h>(instance_id: HeapId, class: &HeapRead<'h, Class>, vm: &mut
     /// guard; the caller owns the instance.
     fn store_bound_fields<'h>(
         instance: &HeapReadMut<'h, Instance>,
    +    instance_id: HeapId,
         fields: &[(StringId, bool)],
         values: Vec<Value>,
         vm: &mut VM<'h>,
     ) -> Result<(), RunError> {
         defer_drop_mut!(values, vm);
         for i in 0..values.len() {
    -        let value = mem::replace(&mut values[i], Value::None);
             let name = Value::InternString(fields[i].0);
    +        if let Some(member) = class_member(instance.get(vm.heap).class(), vm.interns.get_str(fields[i].0), vm) {
    +            defer_drop!(member, vm);
    +            if descriptor::is_data(member, vm) {
    +                let value = mem::replace(&mut values[i], Value::None);
    +                vm.heap.inc_ref(instance_id);
    +                let object = Value::Ref(instance_id);
    +                defer_drop!(object, vm);
    +                let result = descriptor::mutate(member, object, Some(value), vm)?.require_synchronous(vm)?;

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Kept the synthesized dataclass initializer synchronous, consistent with its existing default-factory and post-init restrictions. The limitation now explicitly covers data-descriptor setters. Added regression coverage for native properties and custom descriptors that attempt external/OS calls, repeat the rejection, then successfully construct another instance and continue the REPL. Ordinary attribute assignment still supports suspension and dump/restore.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    docs/limitations/index.md:1
    @@ -31,6 +31,7 @@ They exist for development and for agents debugging code that runs on Monty; mos
     - List, dict and set comprehensions
     - `try` / `except` / `else` / `finally`, `raise ... from ...`
     - `for`, `while`, `if` / `elif` / `else`, `break`, `continue`, `pass`, `assert`, `global`, `nonlocal`, `return`
    +- Descriptors, `property`, `classmethod`, `staticmethod`, and decorators on methods

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Removed the stale but not on methods wording from the language page's supported-functions list; it now includes decorators on functions and methods.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    docs/limitations/builtins.md:1
    @@ -25,10 +25,9 @@ These raise `NameError`:
     - **Code objects and imports**: `compile`, `__import__`.
     - **Namespace introspection**: `globals`, `vars`, `dir`.
     - **Interactive**: `input`, `breakpoint`, `help`.
    -- **Decorators / descriptors**: `classmethod`, `staticmethod`, `property`,
    -    `super`. (`@property` on functions is not recognized; use a method.)
    +- **Inheritance**: `super`.
     - **Construction / coercion**: `bytearray`, `memoryview`, `object`, `ascii`.
    -- **Other**: `callable`, `delattr`, `issubclass`, `aiter`, `anext`.
    +- **Other**: `callable`, `issubclass`, `aiter`, `anext`.

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Added delattr to the implemented functions and property, classmethod, and staticmethod to the implemented type constructors.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/builtins/delattr.rs:1
    @@ -0,0 +1,67 @@
    +//! Attribute deletion, including suspendable descriptor deleters.
    +
    +use crate::{
    +    args::ArgValues,
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    heap::{HeapData, HeapReadOutput},
    +    modules::dataclasses,
    +    types::{attribute_name_value, descriptor, instance::class_member},
    +    value::Value,
    +};
    +
    +pub(crate) fn builtin_delattr(vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +    let args = args.into_pos_only("delattr", vm.heap)?;
    +    defer_drop!(args, vm);
    +    let [object, name] = args.as_slice() else {
    +        return Err(ExcType::type_error_arg_count("delattr", 2, args.len()));
    +    };
    +    let Some(attr) = name.as_either_str(vm.heap).map(|s| s.resolve_interned(vm.interns)) else {
    +        return Err(ExcType::type_error("attribute name must be string"));
    +    };
    +    if let Some(class) = descriptor::descriptor_class(object, vm)
    +        && let Some(error) = dataclasses::frozen_deletion_error(class, name, vm)
    +    {
    +        return Err(error);
    +    }
    +    if let Some(class) = descriptor::descriptor_class(object, vm)
    +        && let Some(member) = class_member(class, attr.as_str(vm.interns), vm)
    +    {
    +        defer_drop!(member, vm);
    +        if descriptor::is_data(member, vm) {
    +            return descriptor::mutate(member, object, None, vm);
    +        }
    +    }
    +    let key = attribute_name_value(&attr, vm);
    +    defer_drop!(key, vm);
    +    let removed = match object {
    +        Value::Ref(id) => match vm.heap.read(*id) {
    +            HeapReadOutput::Instance(instance) => instance.attrs_mut().pop(key, vm)?.map(|(key, value)| {
    +                key.drop_with(vm);
    +                value
    +            }),
    +            HeapReadOutput::Class(class) => class.pop_attr(key, vm)?,
    +            _ => None,
    +        },
    +        _ => None,
    +    };
    +    if let Some(value) = removed {
    +        value.drop_with(vm);
    +        Ok(CallResult::Value(Value::None))
    +    } else {
    +        let class = if let Value::Ref(id) = object {
    +            matches!(vm.heap.get(*id), HeapData::Class(_))
    +        } else {
    +            false
    +        };
    +        if class {
    +            Err(ExcType::attribute_error_type("type", attr.as_str(vm.interns)))

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Missing class-attribute deletion now uses the class object's actual name. Added a regression asserting type object 'Record' has no attribute 'missing'.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/types/instance.rs:1
    @@ -631,64 +652,43 @@ impl HeapItem for BoundMethod {
         }
     }
     
    -/// Reads an instance attribute for `obj.attr` (the `LoadAttr` path).
    -///
    -/// Mirrors Python's lookup order: the instance `__dict__` first, then the class
    -/// namespace, then the `__class__` special case. A class method becomes a
    -/// [`BoundMethod`] (binding `self`); a class variable is returned as-is. A missing
    -/// attribute raises `AttributeError` with the real class name. Takes `self_id`
    -/// (available at the `Value` level) because binding a method needs the instance's
    -/// `HeapId`.
    +/// Reads data descriptors before instance storage, then other class members.
    +/// Descriptor code uses ordinary VM frames and may suspend.
     pub(crate) fn instance_getattr(self_id: HeapId, attr: &EitherStr, vm: &mut VM<'_>) -> RunResult<CallResult> {
    -    let attr_str = attr.as_str(vm.interns);
    -    if let Some(value) = instance_attr(self_id, attr_str, vm) {
    -        Ok(CallResult::Value(value))
    -    } else {
    -        let class_id = instance_class(self_id, vm);
    -        Err(ExcType::attribute_error(
    -            class_name(class_id, vm.heap, vm.interns),
    -            attr_str,
    -        ))
    +    let name = attr.as_str(vm.interns).to_owned();
    +    let class = instance_class(self_id, vm);
    +    let member = class_member(class, &name, vm);
    +    defer_drop!(member, vm);
    +    if let Some(member) = member
    +        && super::descriptor::is_data(member, vm)
    +        && super::descriptor::has_get(member, vm)
    +    {
    +        return super::descriptor::get(member, Some(self_id), class, vm);
    +    }
    +    let HeapData::Instance(instance) = vm.heap.get(self_id) else {
    +        unreachable!()
    +    };
    +    if let Some(value) = instance.attrs().get_by_str(&name, vm.heap, vm.interns) {
    +        return Ok(CallResult::Value(value.clone_with_heap(vm.heap)));
    +    }
    +    if let Some(member) = member {
    +        return super::descriptor::get(member, Some(self_id), class, vm);
         }
    +    if name == "__class__" {
    +        vm.heap.inc_ref(class);
    +        return Ok(CallResult::Value(Value::Ref(class)));
    +    }
    +    Err(ExcType::attribute_error(class_name(class, vm.heap, vm.interns), &name))
     }
     
    -/// The lookup half of [`instance_getattr`]: the instance `__dict__`, then the
    -/// class namespace, then the `__class__` special case; `None` when nothing binds
    -/// `attr`, leaving the `AttributeError` to the caller.
    -///
    -/// Split out so the synthesized dataclass `__repr__`/`__eq__` read their fields
    -/// exactly as `self.field` does, binding a function-valued class member as a
    -/// [`BoundMethod`].
    -pub(crate) fn instance_attr(self_id: HeapId, attr: &str, vm: &VM<'_>) -> Option<Value> {
    -    if let HeapReadOutput::Instance(inst) = vm.heap.read(self_id)
    -        && let Some(value) = inst
    -            .get(vm.heap)
    -            .attrs
    -            .get_by_str(attr, vm.heap, vm.interns)
    -            .map(|v| v.clone_with_heap(vm.heap))
    -    {
    -        return Some(value);
    -    }
    -    let class_id = instance_class(self_id, vm);
    -    match class_member(class_id, attr, vm) {
    -        // A class variable is returned as-is; a function binds `self`.
    -        Some(member) if is_method_value(&member, vm) => {
    -            vm.heap.inc_ref(self_id);
    -            let bound = BoundMethod {
    -                instance: Value::Ref(self_id),
    -                func: member,
    -            };
    -            Some(Value::Ref(vm.heap.allocate(HeapData::BoundMethod(bound))))
    -        }
    -        Some(member) => Some(member),
    -        // `obj.__class__` returns the class object itself (`obj.__class__ is Foo`).
    -        // Last, so an explicit member of the same name wins, mirroring the
    -        // `__name__` handling on class objects.
    -        None if attr == "__class__" => {
    -            vm.heap.inc_ref(class_id);
    -            Some(Value::Ref(class_id))
    -        }
    -        None => None,
    +/// Attribute lookup for native operations that require synchronous completion.
    +/// Dataclass repr, comparison and hash use the same descriptor precedence as `obj.attr`.
    +pub(crate) fn instance_attr(self_id: HeapId, attr: &str, vm: &mut VM<'_>) -> RunResult<Option<Value>> {
    +    let attr = EitherStr::Heap(attr.to_owned());
    +    match instance_getattr(self_id, &attr, vm) {
    +        Ok(result) => result.require_synchronous(vm).map(Some),
    +        Err(RunError::Exc(exc)) if exc.exc.exc_type() == ExcType::AttributeError => Ok(None),

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    The synchronous lookup now checks whether the member exists before invoking its descriptor. Exceptions raised by a present descriptor propagate, including immediate AttributeError from a property without a getter. Added repr and equality regressions for that case.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn classmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let ClassMethodArgs { function } = ClassMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::ClassMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn staticmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let StaticMethodArgs { function } = StaticMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::StaticMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +fn allocate(descriptor: BuiltinDescriptor, vm: &mut VM<'_>) -> Value {
    +    Value::Ref(vm.heap.allocate(HeapData::BuiltinDescriptor(Box::new(descriptor))))
    +}
    +
    +pub(crate) fn get(id: HeapId, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let instance = instance.map_or(Value::None, |id| {
    +        vm.heap.inc_ref(id);
    +        Value::Ref(id)
    +    });
    +    defer_drop!(instance, vm);
    +    vm.heap.inc_ref(owner);
    +    let owner = Value::Ref(owner);
    +    defer_drop!(owner, vm);
    +    protocol_get(id, instance, Some(owner), vm)
    +}
    +
    +fn protocol_get(id: HeapId, instance: &Value, owner: Option<&Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {
    +        Type::StaticMethod => Ok(CallResult::Value(descriptor.values[0].clone_with_heap(vm))),
    +        Type::ClassMethod => {
    +            let func = descriptor.values[0].clone_with_heap(vm.heap);
    +            let instance = match owner {
    +                Some(owner) if !matches!(owner, Value::None) => owner.clone_with_heap(vm.heap),
    +                _ => type_of_ref(vm, instance),
    +            };
    +            Ok(CallResult::Value(Value::Ref(vm.heap.allocate(HeapData::BoundMethod(
    +                super::BoundMethod { instance, func },
    +            )))))
    +        }
    +        Type::Property => {
    +            if matches!(instance, Value::None) {
    +                if owner.is_none_or(|v| matches!(v, Value::None)) {
    +                    return Err(ExcType::type_error("__get__(None, None) is invalid"));
    +                }
    +                vm.heap.inc_ref(id);
    +                return Ok(CallResult::Value(Value::Ref(id)));
    +            }
    +            let function = descriptor.values[0].clone_with_heap(vm);
    +            defer_drop!(function, vm);
    +            if matches!(function, Value::None) {
    +                return Err(missing_accessor("getter"));
    +            }
    +            vm.call_function(function, ArgValues::One(instance.clone_with_heap(vm.heap)))
    +        }
    +        _ => unreachable!("descriptor constructor selects its kind"),
    +    }
    +}
    +
    +pub(crate) fn mutate(id: HeapId, object: &Value, value: Option<Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    defer_drop!(value, vm);
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    let index = if value.is_some() { 1 } else { 2 };
    +    let function = descriptor.values[index].clone_with_heap(vm.heap);
    +    if matches!(function, Value::None) {
    +        return Err(missing_accessor(if index == 1 { "setter" } else { "deleter" }));
    +    }
    +    let mut args = vec![object.clone_with_heap(vm.heap)];
    +    args.extend(value.as_ref().map(|v| v.clone_with_heap(vm.heap)));
    +    super::descriptor::discard_call(function, args, vm)
    +}
    +
    +fn missing_accessor(accessor: &str) -> RunError {
    +    SimpleException::new_msg(ExcType::AttributeError, format!("property has no {accessor}")).into()
    +}
    +
    +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
    +pub(crate) enum DescriptorMethod {
    +    Getter,
    +    Setter,
    +    Deleter,
    +    Get,
    +    Set,
    +    Delete,
    +    SetName,
    +}
    +
    +impl fmt::Display for DescriptorMethod {
    +    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
    +        f.write_str(match self {
    +            Self::Getter => "property.getter",
    +            Self::Setter => "property.setter",
    +            Self::Deleter => "property.deleter",
    +            Self::Get => "descriptor.__get__",
    +            Self::Set => "descriptor.__set__",
    +            Self::Delete => "descriptor.__delete__",
    +            Self::SetName => "property.__set_name__",
    +        })
    +    }
    +}
    +
    +impl DescriptorMethod {
    +    pub(crate) fn call(self, vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +        if matches!(self, Self::Get | Self::Set | Self::Delete | Self::SetName) {
    +            return self.protocol_call(vm, args);
    +        }
    +        let AccessorArgs { receiver, function } = AccessorArgs::from_args(args, vm)?;
    +        let mut guard = DropGuard::new((receiver, function), vm);
    +        let ((receiver, _), vm) = guard.as_parts_mut();
    +        let mut values = if let Value::Ref(id) = receiver
    +            && let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(*id)
    +            && descriptor.kind == Type::Property
    +        {
    +            descriptor.values.each_ref().map(|v| v.clone_with_heap(vm))
    +        } else {
    +            return Err(ExcType::type_error("property accessor requires a property"));
    +        };
    +        let name = if let Value::Ref(id) = receiver {
    +            let HeapData::BuiltinDescriptor(d) = vm.heap.get(*id) else {
    +                unreachable!()
    +            };
    +            d.name.clone()
    +        } else {
    +            unreachable!()
    +        };
    +        let ((receiver, function), vm) = guard.into_parts();
    +        receiver.drop_with(vm);
    +        let index = match self {
    +            Self::Getter => 0,
    +            Self::Setter => 1,
    +            Self::Deleter => 2,
    +            _ => unreachable!(),
    +        };
    +        mem::replace(&mut values[index], function).drop_with(vm);
    +        Ok(CallResult::Value(Value::Ref(vm.heap.allocate(
    +            HeapData::BuiltinDescriptor(Box::new(BuiltinDescriptor {
    +                kind: Type::Property,
    +                values,
    +                name,
    +            })),
    +        ))))
    +    }
    +}
    +
    +impl DescriptorMethod {
    +    fn protocol_call(self, vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +        let args = args.into_pos_only("descriptor", vm.heap)?;
    +        defer_drop!(args, vm);
    +        let Some(Value::Ref(id)) = args.as_slice().first() else {
    +            return Err(ExcType::type_error("descriptor receiver required"));
    +        };
    +        match (self, args.as_slice()) {
    +            (Self::Get, [_, instance, owner]) => protocol_get(*id, instance, Some(owner), vm),
    +            (Self::Get, [_, instance]) => protocol_get(*id, instance, None, vm),
    +            (Self::Set, [_, object, value]) => mutate(*id, object, Some(value.clone_with_heap(vm.heap)), vm),
    +            (Self::Delete, [_, object]) => mutate(*id, object, None, vm),
    +            (Self::SetName, [_, _, name]) => {
    +                set_name(*id, name, vm)?;
    +                Ok(CallResult::Value(Value::None))
    +            }
    +            _ => Err(ExcType::type_error("invalid descriptor arguments")),
    +        }
    +    }
    +}
    +
    +impl HeapItem for BuiltinDescriptor {
    +    fn py_dec_ref_ids(&mut self, stack: &mut Vec<HeapId>) {
    +        for value in &mut self.values {
    +            value.py_dec_ref_ids(stack);
    +        }
    +    }
    +}
    +
    +impl<'h> PyTrait<'h> for HeapObjectRead<'h, BuiltinDescriptor> {
    +    fn py_type(&self, vm: &VM<'h>) -> Type {
    +        self.get(vm.heap).kind
    +    }
    +
    +    fn py_len(&self, _: &VM<'h>) -> Option<usize> {
    +        None
    +    }
    +
    +    fn py_eq_impl(&self, _: &Value, _: &mut VM<'h>) -> RunResult<Option<bool>> {
    +        Ok(None)
    +    }
    +
    +    fn py_hash(&self, _: &mut VM<'h>) -> RunResult<Option<HashValue>> {
    +        Ok(Some(identity_hash(self.id())))
    +    }
    +
    +    fn py_repr_fmt(&self, f: &mut impl Write, vm: &mut VM<'h>, _: &mut LazyHeapSet) -> RunResult<()> {
    +        Ok(write!(f, "<{} object>", self.get(vm.heap).kind)?)
    +    }
    +
    +    fn py_getattr(&self, attr: &EitherStr, vm: &mut VM<'h>) -> RunResult<Option<CallResult>> {
    +        let descriptor = self.get(vm.heap);
    +        let name = attr.as_str(vm.interns);
    +        if name == "__name__" {
    +            return Ok(descriptor
    +                .name
    +                .as_ref()
    +                .map(|name| CallResult::Value(super::str::allocate_string(name.clone(), vm.heap))));
    +        }
    +        let value = if descriptor.kind == Type::Property {
    +            let index = match name {
    +                "fget" => Some(0),
    +                "fset" => Some(1),
    +                "fdel" => Some(2),
    +                "__doc__" => Some(3),
    +                _ => None,
    +            };
    +            if let Some(index) = index {
    +                descriptor.values[index].clone_with_heap(vm)
    +            } else {
    +                let method = match name {
    +                    "getter" => DescriptorMethod::Getter,
    +                    "setter" => DescriptorMethod::Setter,
    +                    "deleter" => DescriptorMethod::Deleter,
    +                    "__get__" => DescriptorMethod::Get,
    +                    "__set__" => DescriptorMethod::Set,
    +                    "__delete__" => DescriptorMethod::Delete,
    +                    "__set_name__" => DescriptorMethod::SetName,
    +                    _ => return Ok(None),
    +                };
    +                bind_method(
    +                    &Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::Descriptor(method))),
    +                    self.id(),
    +                    vm,
    +                )
    +            }
    +        } else if name == "__get__" {
    +            bind_method(
    +                &Value::ModuleFunction(ModuleFunctions::Frozen(FrozenFunctions::Descriptor(
    +                    DescriptorMethod::Get,
    +                ))),
    +                self.id(),
    +                vm,
    +            )
    +        } else if matches!(name, "__func__" | "__wrapped__") {

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Wrapper metadata copying remains an intentional subset limitation, consistent with function objects not exposing __doc__. The descriptor limitations already said other function metadata is not copied; I made __doc__ explicit there to remove ambiguity. Full function metadata support is outside this PR.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/types/builtin_descriptor.rs:1
    @@ -0,0 +1,401 @@
    +//! The builtin property, classmethod and staticmethod wrappers.
    +
    +use std::{
    +    fmt::{self, Write},
    +    mem,
    +};
    +
    +use super::{LazyHeapSet, PyTrait, Type, instance::bind_method};
    +use crate::{
    +    args::{ArgValues, FromArgs},
    +    builtins::type_of_ref,
    +    bytecode::{CallResult, RunReentryGuard, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunError, RunResult, SimpleException},
    +    frozen::FrozenFunctions,
    +    hash::{HashValue, identity_hash},
    +    heap::{DropGuard, DropWithContext, HeapData, HeapId, HeapItem, HeapObjectRead, HeapReadOutput},
    +    modules::ModuleFunctions,
    +    value::{EitherStr, Value},
    +};
    +
    +#[derive(Debug, serde::Serialize, serde::Deserialize)]
    +pub(crate) struct BuiltinDescriptor {
    +    pub kind: Type,
    +    // Property: fget, fset, fdel, doc. Other wrappers use only the first slot.
    +    pub values: [Value; 4],
    +    #[serde(default)]
    +    pub name: Option<String>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property")]
    +struct PropertyArgs {
    +    #[from_args(default)]
    +    fget: Option<Value>,
    +    #[from_args(default)]
    +    fset: Option<Value>,
    +    #[from_args(default)]
    +    fdel: Option<Value>,
    +    #[from_args(default)]
    +    doc: Option<Value>,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "classmethod")]
    +struct ClassMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "staticmethod")]
    +struct StaticMethodArgs {
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +#[derive(FromArgs)]
    +#[from_args(name = "property accessor")]
    +struct AccessorArgs {
    +    #[from_args(pos_only)]
    +    receiver: Value,
    +    #[from_args(pos_only)]
    +    function: Value,
    +}
    +
    +pub(crate) fn property_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let PropertyArgs { fget, fset, fdel, doc } = PropertyArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::Property,
    +            name: fget.as_ref().and_then(|f| function_name(f, vm)),
    +            values: [
    +                fget.unwrap_or(Value::None),
    +                fset.unwrap_or(Value::None),
    +                fdel.unwrap_or(Value::None),
    +                doc.unwrap_or(Value::None),
    +            ],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn classmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let ClassMethodArgs { function } = ClassMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::ClassMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +pub(crate) fn staticmethod_init(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    +    let StaticMethodArgs { function } = StaticMethodArgs::from_args(args, vm)?;
    +    Ok(allocate(
    +        BuiltinDescriptor {
    +            kind: Type::StaticMethod,
    +            name: function_name(&function, vm),
    +            values: [function, Value::None, Value::None, Value::None],
    +        },
    +        vm,
    +    ))
    +}
    +
    +fn allocate(descriptor: BuiltinDescriptor, vm: &mut VM<'_>) -> Value {
    +    Value::Ref(vm.heap.allocate(HeapData::BuiltinDescriptor(Box::new(descriptor))))
    +}
    +
    +pub(crate) fn get(id: HeapId, instance: Option<HeapId>, owner: HeapId, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let instance = instance.map_or(Value::None, |id| {
    +        vm.heap.inc_ref(id);
    +        Value::Ref(id)
    +    });
    +    defer_drop!(instance, vm);
    +    vm.heap.inc_ref(owner);
    +    let owner = Value::Ref(owner);
    +    defer_drop!(owner, vm);
    +    protocol_get(id, instance, Some(owner), vm)
    +}
    +
    +fn protocol_get(id: HeapId, instance: &Value, owner: Option<&Value>, vm: &mut VM<'_>) -> RunResult<CallResult> {
    +    let HeapData::BuiltinDescriptor(descriptor) = vm.heap.get(id) else {
    +        unreachable!()
    +    };
    +    match descriptor.kind {

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Moved the (None, None) validation before dispatching by descriptor kind. Regression coverage checks both omitted and explicit None owners for all three constructors, plus valid class-only access.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/intern.rs:1
    @@ -923,6 +923,9 @@ pub enum StaticStrings {
         Dklen,
         /// `field(doc=...)`, CPython's per-field docstring.
         Doc,
    +    Fget,
    +    Fset,

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Placed Fdel/Fget in alphabetical order after Fanout, and Fset after FrozenSet. Static-string entries persist as text, so this preserves existing dumps; the version 13 fixture still loads and resumes.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    docs/limitations/dataclasses.md:1
    @@ -97,7 +99,7 @@ field after a defaulted one
         Monty's own `repr` for those differs (see [classes.md](classes.md)). Only the
         text differs; the value and its equality match CPython.
     - **A class-body `__setattr__` never runs for the synthesized `__init__`**,
    -    which writes fields straight into the instance `__dict__`. This is the
    +    which honors descriptors but otherwise writes to the instance `__dict__`. This is the

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    The dataclass limitation now specifically describes synchronous data-descriptor setter dispatch and explicitly lists suspension as unsupported in the synthesized initializer. Added coverage for rejected external/OS calls and successful use after the rejection.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    docs/limitations/language.md:1
    @@ -13,17 +13,12 @@ any code runs.
         class-body statements other than `def`, a simple `name [: T] = <expr>`
         assignment, `pass`, or a docstring. There is no inheritance and no general
         dunder protocol. See [classes.md](classes.md).
    -- **Decorators** (`@deco`) — supported on classes and on top-level or nested
    -    `def`/`async def`, taking any callable in scope, evaluated in the enclosing
    -    scope and applied bottom-up. Rejected at parse time on **methods**, so
    -    `@classmethod`, `@staticmethod`, `@property` and any decorator on a `def`
    -    inside a class body are unavailable. See [classes.md](classes.md).
     - **`async with` statements** — not yet supported.
     - **`yield` / `yield from` expressions** — no generator functions. Generator
         *expressions* (`(x for x in ...)`) parse but currently materialize to a
         `list` rather than a lazy iterator, a known temporary divergence; see
         `iter__generator_expr_type.py`.
    -- **`del` statements** — neither `del x` nor `del d[k]` parse.
    +- **`del` statements** — `del x`, `del d[k]`, and multiple targets are unsupported; `del obj.attr` is supported.

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    Narrowed this bullet to unsupported del forms only: name deletion, subscription deletion, and multiple targets.

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    jaheba jaheba commented on code on Oct 22, 2026 17:23 UTC
    Code Review
    crates/monty/src/builtins/delattr.rs:1
    @@ -0,0 +1,67 @@
    +//! Attribute deletion, including suspendable descriptor deleters.
    +
    +use crate::{
    +    args::ArgValues,
    +    bytecode::{CallResult, VM},
    +    defer_drop,
    +    exception_private::{ExcType, ExcTypeExt, RunResult},
    +    heap::{HeapData, HeapReadOutput},
    +    modules::dataclasses,
    +    types::{attribute_name_value, descriptor, instance::class_member},
    +    value::Value,
    +};
    +
    +pub(crate) fn builtin_delattr(vm: &mut VM<'_>, args: ArgValues) -> RunResult<CallResult> {
    +    let args = args.into_pos_only("delattr", vm.heap)?;
    +    defer_drop!(args, vm);
    +    let [object, name] = args.as_slice() else {
    +        return Err(ExcType::type_error_arg_count("delattr", 2, args.len()));
    +    };
    +    let Some(attr) = name.as_either_str(vm.heap).map(|s| s.resolve_interned(vm.interns)) else {
    +        return Err(ExcType::type_error("attribute name must be string"));

    _Auto response from AI running Codex fix-pr-comments:_

    Prepared locally; changes have not been pushed yet.

    The error now includes the offending Python type, matching the other attribute builtins. Added a regression for delattr(Record(), 1).

    Validation: 953 Rust tests and 704 fixtures passed, including version 13 dump compatibility; Rust and Python lint passed.

    codspeed[bot] codspeed[bot] commented on Oct 22, 2026 17:38 UTC
    Bot

    <!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->

    Merging this PR will not alter performance

    ✅ 116 untouched benchmarks
    ⏩ 78 skipped benchmarks[^skipped]

    ---

    <sub>Comparing <code>jaheba:descriptor-protocol</code> (50bce6e) with <code>main</code> (d45587e)</sub>

    <a href="https://app.codspeed.io/pydantic/monty/branches/jaheba%3Adescriptor-protocol?utm_source=github&utm_medium=comment-v2&utm_content=button">
    <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
    <img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
    </picture>
    </a>

    [^skipped]: 78 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

    Reviewers
    Assignees
    jaheba jaheba
    Labels
    risk: low confidence: 86.1% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 86.1% · Lower = rushed or shallow review
    86.1%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 11.9% · Safe to merge
    11.9%
    Repository