Skip to content

Larens94/codedna-challenge-codedna

CodeDNA Challenge — CodeDNA Version

django__django-13495 · Django with CodeDNA v0.8 annotations

This is the CodeDNA version of the CodeDNA Challenge — the same Django bug, but every Python file has CodeDNA v0.8 annotations (exports:, used_by:, rules:, agent:).

The goal: open this repo in your AI coding agent, paste the prompt below, and see how it navigates compared to the control version — same bug, same model, same prompt, but without annotations.


What's Different Here

Every Python file in django/ starts with a module docstring:

"""datetime.py — date/time database functions (Trunc, Extract) with timezone support.

exports: TruncBase, TruncYear, TruncMonth, TruncDay, ExtractYear, ...
used_by: django/db/models/__init__.py → ORM query layer
rules:   TimezoneMixin.get_tzname() is the single source of timezone resolution
         for all Trunc/Extract SQL generation — every backend calls this
agent:   claude-sonnet-4-6 | anthropic | 2026-03-21 | Annotated with AST skeleton
"""

A CLAUDE.md at the root teaches Claude Code (and other agents) to read these annotations before writing code.


The Bug

Trunc() ignores tzinfo param when output_field=DateField()

TruncDay('created_at', output_field=DateField(), tzinfo=tz_kyiv)

generates:
  DATE_TRUNC('day', "storage_transaction"."created_at")

instead of:
  DATE_TRUNC('day', "storage_transaction"."created_at" AT TIME ZONE 'Europe/Kiev')

The timezone conversion is silently ignored.

Prompt to use

Paste this exactly into your agent session:

Bug: Trunc() ignores tzinfo param when output_field=DateField()

I'm trying to use TruncDay() function like this:
  TruncDay('created_at', output_field=DateField(), tzinfo=tz_kyiv)

but for PostgreSQL the SQL generated is:
  (DATE_TRUNC('day', "storage_transaction"."created_at"))

So timezone conversion like AT TIME ZONE 'Europe/Kiev' was totally ignored.

Find the root cause and fix it.

---

Session logging (mandatory):
As you work, continuously append every step to session_log.md in the project root:

## [EXPLORE] <what you opened/searched and why>
## [FOUND] <what you discovered>
## [DECISION] <what you decided to do and why>
## [ACTION] <what you changed and where>
## [VERIFY] <how you checked the fix is correct>

Write each entry immediately when it happens. Do not batch at the end.

Ground Truth

The official Django patch for this bug touches 7 files:

django/db/models/functions/datetime.py
django/db/backends/base/operations.py
django/db/backends/postgresql/operations.py
django/db/backends/mysql/operations.py
django/db/backends/oracle/operations.py
django/db/backends/sqlite3/operations.py
django/db/backends/sqlite3/base.py          ← easy to miss

Score your session: how many of the 7 files did your agent touch?


How to run

git clone https://github.com/Larens94/codedna-challenge-codedna
cd codedna-challenge-codedna

# Open in your AI agent
claude    # Claude Code
cursor .  # Cursor
# etc.

# Paste the prompt above

Compare with Control

Run the same session on the unannotated version:

git clone https://github.com/Larens94/codedna-challenge-control
cd codedna-challenge-control
# same prompt, same model

Reference results

Control CodeDNA
Session time ~10–11 min ~8 min
Files matching official patch 6 / 7 7 / 7
time_trunc_sql fixed
sqlite3/base.py updated
Failed edits 5 0

Model: claude-sonnet-4-6 · Full report: BENCHMARK_RESULTS.md


Share your results

Open an issue or PR in github.com/Larens94/codedna with:

  • Model used
  • Files touched (out of 7)
  • Session time
  • session_log.md

Every data point helps validate the protocol.


Part of CodeDNA v0.8 — an in-source communication protocol for AI coding agents.

About

CodeDNA Challenge — CodeDNA version: Django annotated with CodeDNA v0.8. Fix the Trunc() tzinfo bug and compare with the control.

Resources

License

BSD-3-Clause, Unknown licenses found

Licenses found

BSD-3-Clause
LICENSE
Unknown
LICENSE.python

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors