vinothchandar commented on code in PR #19265:
URL: https://github.com/apache/hudi/pull/19265#discussion_r3567389828


##########
hudi-agent-gateway/src/hudi_agent_gateway/tools/registry.py:
##########
@@ -0,0 +1,148 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""The tool registry: define a lakehouse tool ONCE, expose it everywhere.

Review Comment:
   we will enhance this with more tools as we go



##########
hudi-agent-gateway/src/hudi_agent_gateway/tools/guardrails.py:
##########
@@ -0,0 +1,92 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""SQL guardrails for model-written queries.
+
+AST-level (sqlglot, Trino dialect) rather than regex: read-only enforcement
+survives comments, CTEs, and string literals; the row cap is injected as a
+real ``LIMIT``. Fail-closed: anything that does not parse is rejected.
+"""
+
+from __future__ import annotations
+
+import sqlglot
+from sqlglot import exp
+
+from hudi_agent_gateway.tools.registry import ToolInputError

Review Comment:
   even from my weekend testing, getting the tool calls to work reliably will 
be critical to making the intended experience successful. This is just some 
sanity checks. We need to go much deeper here



##########
.github/workflows/agent_gateway_ci.yml:
##########
@@ -0,0 +1,90 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Agent Gateway CI

Review Comment:
   This eventually needs to run on every commit, but for now, once it passes, 
I'm happy to turn this off until we stabilize the overall feature. 



##########
hudi-agent-gateway/src/hudi_agent_gateway/tools/trino_client.py:
##########
@@ -0,0 +1,96 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Async wrapper over the (synchronous) Trino DB-API client."""
+
+from __future__ import annotations
+
+import asyncio
+from dataclasses import dataclass, field
+from typing import Any
+
+import trino
+
+from hudi_agent_gateway.config import GatewaySettings
+
+
+class TrinoQueryError(Exception):
+    """A query failed on the Trino side; message is safe to surface to the 
model."""
+
+
+class TrinoTimeoutError(TrinoQueryError):
+    pass
+
+
+@dataclass
+class QueryResult:
+    columns: list[str]
+    rows: list[list[Any]]
+    row_count: int = field(init=False)
+
+    def __post_init__(self) -> None:
+        self.row_count = len(self.rows)
+
+
+class TrinoClient:
+    """Thin async facade: each query runs the sync client in a worker thread
+    under a hard timeout, and fetches at most ``max_rows`` from the cursor
+    regardless of what the SQL says (defense in depth behind the guardrails).
+    """
+
+    def __init__(self, settings: GatewaySettings) -> None:
+        self._settings = settings
+
+    def _connect(self) -> trino.dbapi.Connection:
+        s = self._settings
+        return trino.dbapi.connect(
+            host=s.trino_host,

Review Comment:
   eventually the chart install needs to cover authn completely. (I expect the 
catalog to cover authz) . This is a simple setup for now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to