Skip to content

Refactor: introduce shared tree-sitter traversal helpers (A / with sview) - #9

Closed
jolestar wants to merge 1 commit into
mainfrom
ab-sview-issue-2-a
Closed

Refactor: introduce shared tree-sitter traversal helpers (A / with sview)#9
jolestar wants to merge 1 commit into
mainfrom
ab-sview-issue-2-a

Conversation

@jolestar

@jolestar jolestar commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

A/B analysis report — issue #2

Task: refactor sview to introduce shared tree-sitter traversal helpers for the Rust and JavaScript/TypeScript analyzers.

Candidates

Side PR Skill setup Runtime tokens Model rounds Tool calls Elapsed Verification
A #9 WITH sview skill 69,388 total (50,884 input / 18,504 output) 44 ~15 self-counted ~8 min cargo fmt --check, cargo test passed
B #8 WITHOUT sview skill 48,780 total (38,331 input / 10,449 output) 24 ~15 self-counted ~4 min 8 sec cargo fmt --check, cargo test passed

Implementation comparison

  • A adds a new src/traverse.rs module with a NodeClassifier trait and mutable sibling-observation hook, then wires Rust and JavaScript analyzers through it. This is flexible, but adds a second tree-related module next to the existing src/tree.rs and more abstraction surface.
  • B extends the existing src/tree.rs module with parse(), collect_items(), and ast_preview(), then keeps language-specific classification local to src/rust.rs and src/javascript.rs. This is smaller and aligns with the shared tree-building helper introduced by the previous refactor.
  • Both keep language-specific naming/classification logic local and both pass the test suite.

sview observations

A reports that sview provided a compact structural map and helped identify duplicated parser/traversal/preview boundaries. However, issue #2 still involves small source files, so the sview overview did not translate into lower runtime cost: A used ~42% more tokens and 20 more model rounds than B, with similar self-counted tool-call volume.

Decision

Recommendation: merge B (#8) and close/supersede A (#9).

Rationale: B achieves the same behavior with fewer files changed, less new abstraction, lower token cost, fewer model rounds, and about half the elapsed time. A is a useful experiment sample showing that sview helped orientation, but this task size still did not produce a measurable efficiency win.

Extract the duplicated parser setup, recursive AST walk, and preview
generation from rust.rs and javascript.rs into a new traverse.rs module.

The shared layer provides:
- NodeClassifier trait: language-specific node classification with
  an observe_sibling hook for sibling-level state (e.g. Rust #[test]
  attribute tracking)
- analyze_tree_sitter: parse + traverse + build_tree in one call
- ast_preview: shared first-line preview extraction
- collect_items: recursive named-children walk with FlatItem collection

Language-specific logic (node kind matching, naming, impl signature
extraction) remains local to each language module.

Closes #2
jolestar added a commit that referenced this pull request Jun 21, 2026
Merge the B/control implementation from the issue #2 A/B test.\n\nChosen over #9 because it keeps the shared helpers in existing src/tree.rs, changes fewer files, passes the same verification, and used fewer runtime tokens/model rounds.\n\nCloses #2.
@jolestar

Copy link
Copy Markdown
Contributor Author

Superseded by #8, which was selected as the A/B winner: same passing behavior with fewer files changed, lower abstraction overhead, lower token usage, fewer model rounds, and shorter elapsed time. Closing this experimental candidate.

@jolestar jolestar closed this Jun 21, 2026
@jolestar
jolestar deleted the ab-sview-issue-2-a branch June 21, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant