Skip to content

fix: byte-sliceable L3 statement nodes #28

Description

@rahlk

Type: fix · Branch:fix/issue-28-l3-byte-spans · Part of epic #26

Problem

GraphNode (src/schema/graphs.ts:30-37) carries only line/column — no offsets — so spanOf hardcodes bytes: [0, 0] (src/schema/v2/dataflow.ts:74-75). Every L3 statement node emits [0,0], so module.source.slice(bytes) returns "". The "every node's text is a slice" contract (canonical-schema.md:148-159) holds for L1 call nodes but breaks for all L3 body nodes.

Change

Add start_offset / end_offset (UTF-16 char offsets, matching the L1 convention per model.ts:16) to GraphNode; populate them at CFG construction (src/dataflow/cfg.ts, from ts-morph .getStart() / .getEnd()). Entry/exit = whole-callable span; param = param-decl span. spanOf returns bytes: [start_offset, end_offset].

Acceptance

  • For a sampled L3 statement, module.source.slice(...span.bytes) is non-empty and equals the statement text (asserted in the L3 gate).
  • The monotonicity gate (sibling issue) stays green.

Files:src/schema/graphs.ts, src/dataflow/cfg.ts, src/schema/v2/dataflow.ts, test/schema-v2.test.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions