You are GPT-5.3 Codex working inside the turso monorepo. Your task is to investigate (not implement yet) issue #5215 and build a clear mental model for an engineer.
Issue:
- tursodatabase/turso#5215
- Problem statement: In non-interactive CLI mode, query failures still return exit code 0; desired behavior is to return exit code 1 (SQLite-like behavior).
Goal: Produce a high-signal exploration report that explains exactly how non-interactive CLI execution works today, why exit code remains 0 on query failure, and what the safest implementation path is.
Scope:
- Focus on non-interactive CLI mode.
- Prioritize these likely files first:
cli/*testing/runner/src/backends/cli.rs
- Explore any additional files needed to trace control flow end-to-end.
What to do:
-
Reproduce and baseline behavior
- Run a failing multi-statement non-interactive query against
tursodband capture exit code. - Run equivalent
sqlite3command and capture exit code. - Note differences (e.g., whether execution stops after first error, output format, stderr/stdout split).
- Run a failing multi-statement non-interactive query against
-
Build the execution flow map
- Trace CLI startup path in non-interactive mode from argument parsing to query execution.
- Identify where errors are produced, transformed, logged, swallowed, or returned.
- Identify where process exit code is currently chosen (or defaults to success).
-
Build the error-propagation model
- For each relevant layer/function, document:
- input error type
- wrapping/conversion behavior
- return type/result handling
- whether it influences exit code
- Call out any “error observed but success returned” branches.
- For each relevant layer/function, document:
-
Test surface analysis
- Review existing tests related to non-interactive behavior and exit codes.
- Explain what is already covered vs missing.
- Identify best place(s) to add tests (unit/integration/runner) with rationale.
-
Design options (no code changes yet)
- Propose 2–3 implementation approaches to enforce exit code 1 on query failure.
- For each approach: touched files, complexity, regression risk, compatibility with current behavior, and recommendation.
- Recommend the smallest correct change consistent with SQLite behavior.
-
Edge cases checklist Analyze expected behavior for:
- Single failing statement
- Multi-statement input with middle failure
- Parse/prepare error vs runtime error
- Empty input / no-op input
- Interactive mode (note only; not primary target)
- Runner/fuzzer invocation paths
Output format (strict): A) “Current behavior” (short) B) “Control-flow map” (step-by-step with function names + file paths) C) “Error propagation table” (layer -> behavior -> impact on exit code) D) “Behavior matrix” (sqlite3 vs tursodb for key scenarios) E) “Gaps in tests” F) “Recommended implementation strategy” (with tradeoffs) G) “Open questions / assumptions” H) “Concrete implementation checklist” (ordered, small steps)
Quality bar:
- Be evidence-driven: cite exact file paths and function names for each claim.
- Keep it concise but complete enough that an engineer can start implementing immediately.
- Do not modify code in this run unless explicitly asked.