Skip to content

semantic/codegen: a Sharpy type's import clone (alias or re-export) is not its declaration at every consumer — nested type SPY0909, alias-vs-direct type identity SPY0220, warm-incremental interface materialization SPY0909 #2402

Open

Description

@antonsynd

Contract

An import of a Sharpy type, whether aliased (from core import Box as B) or through a re-exporter (from lib1 import Box where lib1 did from core import Box), binds a clone TypeSymbol. Since b7f365060 (P21i F1, #2389) that clone carries OriginSymbol back to its declaration. But the consumers below still treat the clone as a separate type with its own (missing) facts. Every consumer should resolve the clone to the declaration it names: its layout facts, its type identity and its materialized interfaces.

Cells (found by the P21i final refutation pass, verified by the lead with the HEAD binary @ 60bd27738 unless noted)

# Consumer Program Observed Expected
1 nested type through an import clone core.spy: class Box: / class Inner: v: int = 11; main.spy: from core import Box as B + print(B.Inner().v). Also from lib1 import Box; Box.Inner() (re-exporter, only when the entry sorts before lib1), import lib1; lib1.Box.Inner(), and the annotation i: Box.Inner SPY0909 TypeSyntaxMapper "layout fact missing (#2102, Rule 2): no namespace recorded for type 'Box' (TypeSymbol, hasCodeGenInfo=False …)" prints 11
2 type identity of an alias next to the direct import from core import Box as B + from core import Box + c: Box = B(); also f(B()) where f(b: Box), and c: core.Box = B() SPY0220 "Cannot assign type 'B' to variable of type 'Box'", in both orders prints 8: B and Box name one declaration
3 warm incremental build, interface + implementer re-exported entry aa.spy: from lib1 import Box, Impl, where lib1 re-exports an interface and its implementer from core. Cold build is OK, and so is the warm build after touching lib1. The next build (no-op, or touch the entry) fails SPY0909 "TypeSymbol 'Impl' has 2 interface(s) but SemanticBinding.GetInterfaces() holds 1 (materialization inconsistency)", i.e. cache poisoning. The zz-order and direct-only controls stay green. Measured by the verification pass (scratchpad/verify2 O4); not re-run by the lead. every build is green

Related, already tracked: emission of an aliased type in isinstance, a match pattern, or a @static member access is #1928 (cell posted there).

The one cell that moved because of b7f365060: the dual import from lib1 import Box + from core import Box + Box.Inner() with the entry sorting first was SPY0204 before, and is now cell 1's ICE. The defect exists without the dual import.

Activity

  1. added
    lane:iceInternal compiler error: SPY0908/SPY0909, a CSxxxx leak, a crash
    reach:programAn ordinary program a Python programmer would write hits it
    class-trackerThe one issue per class: carries the contract and the cell table
    on Oct 30, 2026
  2. antonsynd commented on Oct 31, 2026

    @antonsynd
    OwnerAuthor

    Batching 2026-10-31 @ 2c42408 — charter .claude/plans/remediation-round-2026-09-20-batching.md §3.20i, P21k — one name, one meaning at every consumer: residue (order 6c⁹, directly after P21j, before P69; full (b, c, d)). This issue is the class tracker and lands FIRST. Ruling R-JY (owner, 2026-10-31): (a) new group P21k {#2402 FIRST · #1928 · #2403 · #2408}.

    Contract: a module binding's RECORDED identity is what every consumer reads — a type's import clone (alias, re-exporter, aliasing re-exporter, two-hop) resolves to its declaration for layout facts (nested types), type identity (assignability, argument passing) and materialized interfaces (warm builds), and is emitted under the declaration's qualified name (#1928's cells). Lane / reach: ice · program. Generator: REQUIRED FIRST — clone kind {alias, re-exporter, aliasing re-exporter, two-hop} × consumer {nested-type access, annotation, identity compare, isinstance, match head, static member, warm incremental} × route {run, project}, emit-and-run against the direct-import twin, allowlist ratchet. The warm cell (cell 3) stays here; P28's harness replays the result later. The fact the cure reads exists since P21i (Symbol.DeclarationRoot, OriginSymbol, the defining-module identity R-JK). Rejected: (b) scatter — #2402 + #1928 to P16 (row 33), #2403 to P26 (row 24), #2408 alone (months out for program-reach ICEs whose cure facts were just built). Two-way: P16's and P26's generators later gain the arm P21k drains. No seam hypothesis — the plan measures the seam.

  3. antonsynd commented on Nov 13, 2026

    @antonsynd
    OwnerAuthor

    Batching 2026-11-13 @ dbb17ee — charter docs/process/rounds/remediation-round-2026-09-20-batching.md §3.20i, P21k — one name, one meaning at every consumer: residue (order 6c⁹).

    Cell moved here from #2680 (enum comparison residue): the failing part is the import alias, not the comparison. Measured by the reviewer of PR #2679 with run @ 2d3b05b, the same at the base 428cb7b.

    Cell Program Observed Expected Lane Reach Found by Notes
    alias clone × identity compare, enum from lib import Color as C
    c: C = C.GREEN
    print(c == C.GREEN)
    SPY0908 (CS0234) @ 2d3b05b True (CPython 3.15.2) ice program PR #2679 / reviewer This class's clause (i): an alias clone is emitted under the declaration's qualified name in every position. The consumer axis gains an enum member read under ==.

    Generated by Claude Code

  4. antonsynd commented on Nov 19, 2026

    @antonsynd
    OwnerAuthor

    New spellings of cells 1 and 2, from P77 (#2742) review 7. Measured at the #2742 tip 9e39086; the reviewer reports the same at that PR's previous tip, 985b5e3.

    • Cell 1 (nested type through an alias), through a @static. In lib: class LC: / class N: / @static / t: int = 3. In main: from lib import LC as CC and then print(CC.N.t). Observed SPY0909 TypeSyntaxMapper "layout fact missing (tests: LayoutFactConsumerScan roster guard is vacuous; P14c residue (stale fixture comment, 5 unwritten fixtures) #2102) … no namespace recorded for type 'LC'". The annotation form fails the same way: from lib import Outer as O2 with x: O2.Inner = ….
    • Cell 2 (alias next to the direct import), through a subclass of the alias. In lib: class Shape with a @virtual name. In main: from lib import Shape as LShape + import lib + class Plain(LShape). Then a: lib.Shape = Plain() is SPY0220 "Cannot assign type 'Plain' to variable of type 'Shape'", at main.spy:16. With only the alias import (no import lib), a: LShape = Plain() runs.

    What #2742 moves, for reference: ProjectCompiler.Phases now points an aliased Sharpy type's OriginSymbol at this compilation's own declaration. This is the rule P21i D5 applies to aliased variables. The static-value resolver then binds the declaration's field, and the emitter spells the owner by its OriginalImportName. As a result CC.s read, store, +=, out and CC.q.append(…) run, in sync code and across await. On dev 20909f7, print(CC.s) is SPY0908 CS0234 (measured). The change reaches only the static-value binding: the layout-fact and type-identity consumers in cells 1–2 still see the clone.


    Generated by Claude Code

  5. antonsynd commented on Nov 19, 2026

    @antonsynd
    OwnerAuthor

    Reproduction sweep, 2026-11-16: PARTIAL (at least one cell is right today and at least one is not).

    Re-measured against dev @ d81425f with a Debug sharpyc, about eight cells per issue; CPython 3.15.2 where python is the standard. Copied at batching call 46 (2026-11-19) from docs/process/rounds/sweep-2026-11-16.md. Not re-run since: P77 merged after the sweep, so a plan re-measures before relying on a row.

    Today: Nested type through an alias or a re-exporter 'from' import is still SPY0909 (TypeSyntaxMapper: no namespace recorded for type 'Box'); alias-vs-direct identity is still SPY0220; the enum alias cell is still SPY0908 CS0234. One sub-variant now works: 'import lib1; lib1.Box.Inner()' prints 11. The warm-incremental cell did not reproduce with my reconstruction (inconclusive).

    Cells (controls left out):


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    class-trackerThe one issue per class: carries the contract and the cell tablelane:iceInternal compiler error: SPY0908/SPY0909, a CSxxxx leak, a crashreach:programAn ordinary program a Python programmer would write hits it

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions