Skip to content

[codex] fix query safety and citation numbering - #1

Merged
sarthakagrawal927 merged 2 commits into
mainfrom
codex/query-safety-citation-fix
Jun 13, 2026
Merged

[codex] fix query safety and citation numbering#1
sarthakagrawal927 merged 2 commits into
mainfrom
codex/query-safety-citation-fix

Conversation

@sarthakagrawal927

Copy link
Copy Markdown
Member

What changed

  • Hardened structured-query filter handling by rejecting unsafe filter keys before SQL interpolation.
  • Allowed compare questions to use the structured entity-table path, not just aggregate questions.
  • Reworked query citations so graph-route sources and retrieval sources share one global numbering space.
  • Added tests for unsafe filter keys, compare-path coverage, and combined source numbering.

Why

  • The structured SQL path was interpolating LLM-derived filter keys directly into SQL.
  • Compare questions were being routed to a helper that immediately returned None.
  • Graph-route citations were numbered independently from retrieval citations, which made inline [n] markers ambiguous and the final citation list inconsistent with what the model saw.

Validation

  • uv run pytest -q tests/test_query_synthesis.py tests/test_duckdb_helpers.py
  • uv run ruff check src/kb/query/engine.py src/kb/query/structured.py tests/test_query_synthesis.py

@sarthakagrawal927
sarthakagrawal927 force-pushed the codex/query-safety-citation-fix branch from 8b4ab0f to 951fb04 Compare June 13, 2026 05:43
sarthakagrawal927 and others added 2 commits June 13, 2026 11:16
@sarthakagrawal927
sarthakagrawal927 force-pushed the codex/query-safety-citation-fix branch from 951fb04 to 5203be0 Compare June 13, 2026 05:46
@sarthakagrawal927
sarthakagrawal927 marked this pull request as ready for review June 13, 2026 05:47
@sarthakagrawal927
sarthakagrawal927 merged commit e46a6cc into main Jun 13, 2026
2 checks passed
@sarthakagrawal927
sarthakagrawal927 deleted the codex/query-safety-citation-fix branch June 13, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant