Skip to content

Callsite argument_types silently mixes AST node categories with inferred type names in one field (CLDK-007) #86

Description

@rahlk

Target: canonical schema v2 (epic #69) — representation is contract surface. From the external v0.3.0/Odoo quality audit, finding CLDK-007 (severity Medium).

Audit evidence (Odoo, native export)

Callsite argument_types mixes two unrelated vocabularies in one list with no discriminator: Python AST node class names (Name ×38,572, plus Constant, Attribute, Call) interleaved with Jedi-inferred type names (str ×28,422, …). A consumer cannot tell "this argument is a string" from "this argument was a Name node whose type is unknown" without undocumented conventions.

Root cause

symbol_table_builder.py (main @ 607-611):

argument_types = [
    self._infer_type(script, arg.lineno, arg.col_offset)
    or type(arg).__name__
    for arg in node.args
]

When Jedi inference fails, the code silently substitutes the AST node class name into the same field. Two adjacent weaknesses share the pattern of one field carrying mixed semantics:

Fix direction (v2)

Per the audit gate, consumers must be able to distinguish verbatim source, AST category, declared type, and inferred type without conventions. v2's source-span design (source stored once per module + byte offsets) already gives verbatim argument text; on top of that, keep AST category and inferred type as separate properties (either two parallel lists or a small per-argument object), and never let an inference failure masquerade as a type name — absent means absent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions