Commit ca40ed2
authored
impr(cli + core + hql): ordered return values, helix restart, hql fixes, api verification (#841)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR implements several major improvements across the CLI, core
database, and HQL compiler components.
**Key Changes:**
- **CLI Output System**: introduced a new structured output module
(`output.rs`) with verbosity control (quiet/normal/verbose), modern
spinner UI, and operation tracking - significantly improves developer
experience
- **Restart Command**: added `helix restart` command supporting both
local Docker instances and cloud deployments (Fly.io)
- **Ordered Return Values**: implemented ordered return values in HQL
queries using a struct-based approach instead of json! macros,
preserving field order as defined in queries
- **Variable Binding Fix**: fixed bug where variable bindings and map
variables weren't appearing in inline RETURN objects - now properly
handles scope variables vs schema properties
- **Test Infrastructure**: added comprehensive test utilities with
isolated temp directories and extensive lifecycle tests for
build/start/stop/restart workflows
- **API Key Verification**: added conditional API key verification for
schema introspection endpoint with feature flag support
**Technical Improvements:**
- Switched from `HashMap` to `IndexMap` in object validation to preserve
field ordering
- Enhanced return value generation to distinguish primitive types
(Count/Boolean/Scalar) from complex types (Nodes/Edges/Objects)
- Improved nested traversal handling with variable reference detection
- Updated all CLI commands to use new `Output`/`Step` helpers for
consistent UX
**Critical Issues:**
The test utilities use `unsafe` blocks to modify environment variables,
claiming safety based on isolation. However, environment variables are
process-global and this creates actual data races when tests run in
parallel. The `unsafe` blocks should be removed - the operations aren't
actually unsafe in Rust's memory safety sense, but the concurrency issue
remains.
<details><summary><h3>Important Files Changed</h3></summary>
| Filename | Overview |
|----------|----------|
| helix-cli/src/tests/test_utils.rs | new test utilities with isolated
temp directories and env variable management |
| helix-db/src/helixc/generator/queries.rs | implemented ordered return
values with struct-based approach and variable reference handling |
| helix-db/src/helixc/analyzer/methods/query_validation.rs | fixed
variable binding and map variable handling in return objects, added
primitive type detection |
| helix-db/src/helixc/analyzer/methods/object_validation.rs | improved
scope variable handling in property access, switched HashMap to IndexMap
for ordering |
</details>
</details>
<details><summary><h3>Sequence Diagram</h3></summary>
```mermaid
sequenceDiagram
participant User
participant CLI
participant Output
participant Docker
participant Compiler
participant Generator
participant Gateway
User->>CLI: helix restart dev
CLI->>Output: Operation::new("Restarting", "dev")
Output-->>User: Display operation header
CLI->>Docker: restart_instance()
Docker->>Docker: check_runtime_available()
Docker->>Docker: verify docker-compose.yml exists
Docker->>Output: Step::start("Restarting container")
Docker->>Docker: run_compose_command(["restart"])
Docker->>Output: Step::done()
Output-->>User: Display success
Note over User,Gateway: Ordered Return Values Flow
User->>CLI: helix build dev
CLI->>Compiler: compile HQL queries
Compiler->>Compiler: analyze_return_expr()
Compiler->>Compiler: build_return_fields()
Compiler->>Compiler: detect primitive vs struct types
alt Primitive Type (Count/Boolean/Scalar)
Compiler->>Generator: create primitive ReturnValueStruct
Generator->>Generator: emit variable directly (no struct def)
else Complex Type (Nodes/Edges/Objects)
Compiler->>Generator: create nested ReturnValueStruct
Generator->>Generator: generate struct definitions
Generator->>Generator: handle variable references
Generator->>Generator: map closure parameters
end
Generator->>Generator: format ordered return JSON
Generator-->>CLI: compiled Rust code
CLI->>Docker: build_instance()
Docker-->>User: Built instance
Note over User,Gateway: API Key Verification
User->>Gateway: introspect_schema request
Gateway->>Gateway: check API key feature flag
alt API Key Enabled
Gateway->>Gateway: validate API key
alt Valid Key
Gateway-->>User: return schema
else Invalid Key
Gateway-->>User: 401 Unauthorized
end
else API Key Disabled
Gateway-->>User: return schema
end
```
</details>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->File tree
83 files changed
+3909
-1338
lines changed- .github/workflows
- helix-cli
- src
- commands
- integrations
- logs
- tests
- helix-container/src
- helix-db
- src
- helix_engine
- tests/traversal_tests
- traversal_core/ops/source
- helix_gateway
- tests
- worker_pool
- helixc
- analyzer
- methods
- generator
- parser
- protocol
- helix-macros
- tests
- hql-tests/tests/user_test_11
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
83 files changed
+3909
-1338
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | | - | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | 14 | | |
| |||
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
36 | | - | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | | - | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
| 88 | + | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
| |||
115 | 113 | | |
116 | 114 | | |
117 | 115 | | |
118 | | - | |
| 116 | + | |
119 | 117 | | |
120 | 118 | | |
121 | 119 | | |
| |||
140 | 138 | | |
141 | 139 | | |
142 | 140 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 141 | + | |
146 | 142 | | |
147 | 143 | | |
148 | 144 | | |
| |||
159 | 155 | | |
160 | 156 | | |
161 | 157 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
169 | 162 | | |
170 | 163 | | |
171 | 164 | | |
| |||
196 | 189 | | |
197 | 190 | | |
198 | 191 | | |
199 | | - | |
| 192 | + | |
200 | 193 | | |
201 | 194 | | |
202 | 195 | | |
| |||
246 | 239 | | |
247 | 240 | | |
248 | 241 | | |
249 | | - | |
| 242 | + | |
250 | 243 | | |
251 | 244 | | |
252 | 245 | | |
253 | 246 | | |
254 | 247 | | |
255 | 248 | | |
256 | 249 | | |
257 | | - | |
258 | | - | |
259 | | - | |
| 250 | + | |
260 | 251 | | |
261 | 252 | | |
262 | 253 | | |
| |||
0 commit comments