@modern-fireman-99755 this message is relevant to your phased PR plan for the AST refactor issue
#2721, posted here because others likely have opinions:
In the parse-once-query-thrice architecture (your 2c plan), each detector class needs direct AST access. I think the ideal implementation would be: parse() returns a ParseResult dataclass exposing root_node as a public, read-only field alongside the convenience iterators (iter_simple_commands, iter_pipelines, etc.). Detector classes can then live outside shell_parser.py without needing private accessors.
If root_node is public, an AST-to-CSV exporter (externally maintained, not in the SDK) can feed parsed ASTs into a graph-theoretic analyzer for structural analysis of agent action traces. I've been building out the graph-theory side of this for a while (
navi-fractal). Long agentic sessions may produce graphs with measurable structure that distinguishes benign from anomalous behavior.
So, with your thumbs up, I'm asking for read-only root_node on ParseResult. No export, no analyzer, no new behavior, no new dep. A future graph-theoretic analyzer would be a separate opt-in PR or stay external, purely the maintainers' call when that time comes.
Edit: theory grounding from recent research here:
https://arxiv.org/pdf/2603.22868