-
Notifications
You must be signed in to change notification settings - Fork 1
instrument(parser): establish strategy/work receipt foundation (#9444) #7332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: agent/6982-stored-lexer-checkpoints
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| use crate::incremental::checkpoint::{LexCheckpoint, ParseCheckpoint, ScopeSnapshot}; | ||
| use crate::incremental::lex::{StoredLexCheckpoint, lex_source_with_checkpoints}; | ||
| use crate::incremental::work::ParserInvocationReceipt; | ||
| use perl_lexer::Token; | ||
| use perl_line_index::LineIndex; | ||
| use perl_parser_core::ast::{Node, NodeKind}; | ||
|
|
@@ -166,13 +167,23 @@ impl IncrementalState { | |
| } | ||
|
|
||
| /// Refresh the authoritative parser output from the current source. | ||
| /// | ||
| /// The returned operation-local receipt is created at the same site that | ||
| /// invokes `parse_with_recovery`, so a caller cannot claim zero parser work | ||
| /// while this production entry point ran. | ||
| #[expect(deprecated, reason = "the compatibility AST field mirrors the native parse output")] | ||
| pub(crate) fn refresh_parse_output(&mut self) { | ||
| pub(crate) fn refresh_parse_output(&mut self) -> ParserInvocationReceipt { | ||
| let mut parser = Parser::new(self.source()); | ||
| let parse_output = parser.parse_with_recovery(); | ||
| let nodes_constructed = parse_output.ast.count_nodes(); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] |
||
| self.parse_checkpoints = Self::create_parse_checkpoints(&parse_output.ast); | ||
| self.ast = parse_output.ast.clone(); | ||
| self.parse_output = parse_output; | ||
| ParserInvocationReceipt { | ||
| full_parser_invocations: 1, | ||
| recovery_parser_invocations: 1, | ||
| nodes_constructed, | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn create_parse_checkpoints(ast: &Node) -> Vec<ParseCheckpoint> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] The
Unchangedpath walks the entire AST to computefinal_node_count, and then clonesParseOutputfor the returned result, yet the receipt says zero analysis/validation work and zero cloned nodes. A no-op edit should either reuse stored counts and return an identity-backed snapshot, or account for this traversal and clone. As written, the supposedly zero-work path can be O(AST size) while reporting no work.