Skip to content

Type-4 semantic clones: provable canonicalization phase over the semantic IR #59

Description

@orenlab

Context

The empirical benchmark closure phase (39Y) fixed every unconditional defect surfaced by the pyscn-vs-codeclone comparison and deliberately recorded Type-4 semantic equivalence as an explicit refusal (EMP-CC-003c): CodeClone does not currently claim detection of semantically equivalent but syntactically different clones, and will not ship it as pattern-matching.

Position

Any general semantic-clone claim requires canonicalization proofs over the semantic IR, not heuristics:

  • Candidate provable rewrites: accumulation-loop ↔ fold, clamp-chain ↔ min/max.
  • Shipping this as pattern-matching would embed exactly the hidden non-deterministic judgment the project's determinism mandate forbids. A Type-4 verdict must be a proof artifact, not a similarity score.

Scope sketch

  • Feature phase over codeclone/semantics/ (IR + canonicalizer), post-39R candidate.
  • Acceptance fixtures: PAIR-T4-01 / PAIR-T4-02 (validation corpus), with the 39Y fixture discipline — rename-invariance plus negative twins, goldens frozen before implementation.
  • No actionability scoring rides along (EMP-CC-004 stays refused: declared facts only).

Interactions to resolve up front

From the flow-resolver precision research, three contact points with the resolver route:

  1. Expression canonicalizer is shared machinery — resolver composite-leaf traceability (R5) and Type-4 equivalence both decide "this expression is a pure function of these leaves". One canonicalizer, two consumers; do not build it twice.
  2. Call-output fact identity is the main collision risk (resolver R3): both routes need call results as identified facts. Whichever phase lands first owns that fact's identity and its place in the IR wire; the other consumes it.
  3. Destructuring binding (R6) is a cheap prerequisite — accumulation loops over tuple unpacking are invisible without it.

Non-goals

  • No similarity scores, no ML ranking, no "likely duplicate" verdicts.
  • No relaxation of determinism: two runs over the same tree must produce byte-identical Type-4 facts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions