Skip to content

feat(describegpt): inferred date format for Min/Max in JSON/TOON/JSONSchema#3922

Merged
jqnatividad merged 3 commits into
masterfrom
describegpt-structured-date-minmax
May 30, 2026
Merged

feat(describegpt): inferred date format for Min/Max in JSON/TOON/JSONSchema#3922
jqnatividad merged 3 commits into
masterfrom
describegpt-structured-date-minmax

Conversation

@jqnatividad
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to the markdown dictionary date-formatting feature (already on master). The markdown dictionary renders Date/DateTime Min/Max in the LLM-inferred strftime format (e.g. 01/01/2010, 06/17/2021 04:34:13 PM) via the datefmt template filter, but the structured outputs still serialized them raw (RFC 3339). This makes them consistent.

Changes

  • New helpers in src/cmd/describegpt/dictionary.rs:
    • content_type_date_format() — extracts the validated strftime suffix from a date:/datetime: content type.
    • format_date_value() — Rust mirror of the markdown template's datefmt logic (parse via qsv-dateparser, reformat; unchanged on empty/no-format/parse-failure).
  • JSON / TOON (format_dictionary_json): Min/Max reformatted for date fields with an inferred format. Bare date/datetime tokens and non-date fields are unchanged.
  • JSONSchema: date Min/Max aren't expressible as JSON Schema minimum/maximum (those stay numeric-only), so the formatted range is surfaced in the per-property x-qsv annotation (x-qsv.min / x-qsv.max) for date fields with an inferred format. This is new info in the schema (previously dates had no Min/Max anywhere in the schema output).

Scope / non-goals

  • The markdown path is untouched (stays template-driven; its feature + regenerated examples remain on master).
  • Without --infer-content-type, or for fields with no inferred date format, output is unchanged.

Testing

  • New formatters unit tests: JSON (date %m/%d/%Y, datetime-with-colons, bare-token unchanged, non-date unchanged) and JSONSchema x-qsv (formatted min/max present for inferred-format dates, absent for bare tokens).
  • Full describegpt suite passes: 84 unit + 74 integration, no regressions (existing byte-identical JSON/TSV/JSONSchema tests still pass).
  • cargo clippy -F all_features clean; cargo +nightly fmt applied.
  • Regenerated the JSON/TOON/JSONSchema NYC 311 examples (openai/gpt-oss-20b on LM Studio) — they now show formatted Min/Max (e.g. JSON Created Date 01/01/201012/23/2020; schema x-qsv.min/max likewise).

🤖 Generated with Claude Code

…/JSONSchema

The markdown dictionary already renders Date/DateTime Min/Max in the LLM-
inferred strftime format (via the datefmt template filter), but the structured
outputs serialized them raw (RFC3339). Make them consistent:

- Add dictionary::content_type_date_format() + format_date_value() helpers
  (Rust mirror of the markdown template's datefmt logic).
- JSON/TOON (format_dictionary_json): reformat Min/Max for date/datetime fields
  carrying an inferred format; bare tokens and non-date fields unchanged.
- JSONSchema: Date/DateTime Min/Max aren't expressible as JSON Schema
  minimum/maximum (those stay numeric-only), so surface the formatted range in
  the per-property x-qsv annotation (x-qsv.min / x-qsv.max) for date fields with
  an inferred format.

Add formatters unit tests for JSON (date, datetime-with-colons, bare-token,
non-date) and JSONSchema x-qsv. Regenerate the JSON/TOON/JSONSchema NYC 311
examples (openai/gpt-oss-20b on LM Studio).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread docs/describegpt/nyc311-describegpt-schema.json Dismissed
Comment thread docs/describegpt/nyc311-describegpt-schema.json Dismissed
Comment thread docs/describegpt/nyc311-describegpt.json Dismissed
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 30, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…prose)

The prior TOON example reused the JSON run's cache; regenerate with --fresh so
its Label/Description/Tags prose is independently generated. Date Min/Max are
shown in the inferred format (e.g. Created Date 01/01/2010, Due Date
01/02/1900 12:00:00 AM) as in the other formats.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes describegpt structured dictionary outputs align with markdown output by formatting inferred date/datetime min/max values using their inferred strftime format.

Changes:

  • Adds helpers to extract date/datetime format suffixes and reformat min/max values.
  • Applies formatted date min/max to JSON/TOON output and JSONSchema x-qsv annotations.
  • Adds formatter unit tests and regenerates NYC 311 example artifacts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/cmd/describegpt/dictionary.rs Adds date-format extraction and date-value formatting helpers.
src/cmd/describegpt/formatters.rs Uses formatted min/max values in JSON and JSONSchema outputs; adds tests.
docs/describegpt/nyc311-describegpt.json Regenerated JSON example showing formatted date min/max.
docs/describegpt/nyc311-describegpt.toon Regenerated TOON example showing formatted date min/max.
docs/describegpt/nyc311-describegpt-schema.json Regenerated JSONSchema example with formatted date min/max in x-qsv.

Comment thread src/cmd/describegpt/formatters.rs Outdated
…type

Per Copilot review: format_dictionary_json reformatted Min/Max based on
e.content_type alone, so a flag-off entry carrying a date content_type would
change the legacy (byte-identical) JSON output while omitting content_type.
Gate the reformatting on infer_content_type so the flag-off path is unchanged.
Add a flag-off regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jqnatividad jqnatividad merged commit 274213e into master May 30, 2026
16 of 18 checks passed
@jqnatividad jqnatividad deleted the describegpt-structured-date-minmax branch May 30, 2026 01:28
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.

3 participants