wip: preserve local engine and agent workflow changes before ganjihong refactor integration
This commit is contained in:
@@ -15,6 +15,18 @@ class QueryInfo:
|
||||
source_entity: str | None = None
|
||||
is_start: bool | None = None
|
||||
calls: list[str] = field(default_factory=list)
|
||||
# The AST is intentionally lossless for the parser's value model. Query
|
||||
# aliases may be resolved for lowering, but their nested query semantics
|
||||
# must remain auditable and cannot be collapsed into a geometry hint.
|
||||
ast: dict[str, Any] | list[Any] | str | float | bool | None = None
|
||||
query_combinators: list[str] = field(default_factory=list)
|
||||
filters: list[str] = field(default_factory=list)
|
||||
body_scope: list[str] = field(default_factory=list)
|
||||
disambiguation: list[str] = field(default_factory=list)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.ast is None:
|
||||
self.ast = {}
|
||||
|
||||
def as_dict(self) -> dict[str, Any]: return asdict(self)
|
||||
|
||||
@@ -29,10 +41,31 @@ def walk_calls(value: Any):
|
||||
for item in value.values(): yield from walk_calls(item)
|
||||
|
||||
|
||||
def query_ast(value: Any) -> dict[str, Any] | list[Any] | str | float | bool | None:
|
||||
"""Serialize parsed FeatureScript query syntax without evaluating it."""
|
||||
if isinstance(value, Call):
|
||||
return {"call": value.name, "args": [query_ast(arg) for arg in value.args], "line": value.line}
|
||||
if isinstance(value, list):
|
||||
return [query_ast(item) for item in value]
|
||||
if isinstance(value, dict):
|
||||
return {str(key): query_ast(item) for key, item in value.items()}
|
||||
if value is None or isinstance(value, (str, float, bool, int)):
|
||||
return value
|
||||
return str(value)
|
||||
|
||||
|
||||
def parse_query(value: Any) -> QueryInfo:
|
||||
info = QueryInfo()
|
||||
info = QueryInfo(ast=query_ast(value))
|
||||
for call in walk_calls(value):
|
||||
info.calls.append(call.name)
|
||||
if call.name in {"qUnion", "qIntersection", "qSubtraction", "qAdjacent"}:
|
||||
info.query_combinators.append(call.name)
|
||||
if call.name in {"qBodyType", "qOwnerBody"}:
|
||||
info.body_scope.append(call.name)
|
||||
if call.name in {"TDD", "trueDependencyDisambiguation"}:
|
||||
info.disambiguation.append(call.name)
|
||||
if call.name in {"qBodyType", "qOwnerBody", "qAdjacent"}:
|
||||
info.filters.append(call.name)
|
||||
if call.name in {"makeQuery", "qCreatedBy"} and call.args:
|
||||
owner = symbolic_string(call.args[0])
|
||||
if "F" in owner:
|
||||
|
||||
Reference in New Issue
Block a user