Skip to content

Compile calendar duration SQL with month-end and leap-year handling - #346

Draft
seyoung4503 wants to merge 2 commits into
experiment/mcp-astra-spider-backlogfrom
feat/calendar-interval-sql
Draft

seyoung4503 wants to merge 2 commits into
experiment/mcp-astra-spider-backlogfrom
feat/calendar-interval-sql

Conversation

@seyoung4503

@seyoung4503 seyoung4503 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Calendar spans generated by the model subtracted year/month/day fields independently, losing calendar borrowing. Add a deterministic SQLite calendar interval compiler exposed through the existing internal and MCP tool registries. It emits portable CTEs with explicit month-end clamping, leap-year, reversed-date and invalid-date behavior. Queries still execute through the existing guarded run_sql; no UDF, model prompt change, business-definition bypass or grader change.

The compiler requires calendar_input(row_id, start_date, end_date), reserves calendar_* CTE names, and implements absolute ordered calendar spans rather than signed AGE or boundary counts. SQLite is the only supported dialect. It chooses no fractional-year formula or aggregation.

Validation: 317 passed, 1 skipped, including actual MCP stdio compilation/execution and missing-receipt rejection. A separately executed 1,000-pair seeded synthetic comparison matched dateutil.relativedelta. Ruff and diff checks pass. A fresh original-input Astra/high retry of local007 is frozen in the protocol; official result 0 → 1 (one selected failure repaired). The model called the compiler and then wrote its own month-end-borrowing SQL, returning 4.82; this was not a verbatim CTE copy. Exact prompts/events/SQL/CSV, the unchanged official score, paired HTML/JSON comparison, synthetic check script and SHA-256 index are archived under bench/accuracy/mcp-review-results/calendar-interval. Single-failure repair is not full Spider accuracy. Stacked on #345; no merge requested.

Implementation principles verification:

# Principle Result Evidence
1 Reuse O Existing ToolSpec/ToolResult, registry, MCP logging/dispatch, run_sql and benchmark whitelist; one compiler concept with reused clamp expression; product/runtime +96 net lines, benchmark whitelist net 0
2 Cause/scope O Calendar borrowing only; wiring, tests and selected-failure protocol
3 Logging O Existing MCP start/done/failed call IDs; compiler has no external I/O
4 Errors O Unsupported dialect raises ValueError via existing error boundary; no silent fallback
5 Environment N/A No environment setting or read added
6 Issue comments O No issue-number comments
7 Checks O Root tests, Ruff, diff check; repository has no CODE MAP generator
8 Authority O Branch/PR only; no merge
9 Consumers O Internal runtime and MCP registry; actual stdio test and benchmark whitelist
10 Async O One pure compiler body, no blocking I/O or duplicate sync implementation
11 Constants O Calendar constants/ISO bounds only; no operational settings or deployment changes

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