Skip to content

Replace deprecated datetime.utcnow() with timezone-aware alternative - #64

Merged
pgalko merged 1 commit into
pgalko:mainfrom
TejasLamba2006:fix-utcnow-deprecation
Nov 13, 2026
Merged

pgalko merged 1 commit into
pgalko:mainfrom
TejasLamba2006:fix-utcnow-deprecation

Conversation

@TejasLamba2006

Copy link
Copy Markdown
Contributor

datetime.utcnow() was deprecated in Python 3.12 and is removed in 3.14. Replaced 4 call sites with datetime.now(datetime.UTC). The supabase_client.py call that used .replace(tzinfo=...) no longer needs it since the result is already timezone-aware.

pgalko pushed a commit that referenced this pull request Nov 13, 2026
Found while evaluating the public PR #64: the battery is red from 11 November 2026 UTC on every tree, the 2.7.2
release included. One check in tests/analyst/test_routines.js ("the manager body with a fill running carries the
line under the Runs heading") built the weekly view on `new Date()`; the fixture's first week - the picked
athlete's only run - left the one-year view that day, so no table followed the bar. It is given the fixture's own
day now ({today: fri, horizon: 365}), as every other check of the table by unit is. Run with the clock set to
10 November it passed, from the 11th it failed; with the fix it passes at every date tried through 2028.

And the stack walk's Usage Overview check expected exactly one filled day: a walk started at 23:58 UTC ran past
midnight and filled two. It counts the days the route itself counted calls on (one, or two past midnight).

Tests only; no count changes (test_routines.js 139, the stack walk 141, the battery 1,830).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015JZ4FUwJKDFyNc9zsiCgPf
@pgalko pgalko closed this Nov 13, 2026
@pgalko pgalko reopened this Nov 13, 2026
@pgalko
pgalko merged commit 9c9a004 into pgalko:main Nov 13, 2026
3 of 4 checks passed
@pgalko

pgalko commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Thanks for this - merged ;-)

pgalko pushed a commit that referenced this pull request Nov 13, 2026
Palo, on a refusal that named three sessions in cells 2, 3 and 4 of a power-curve chain, six of its seven cells
kept: "this issue keeps bugging us ... is there really nothing we can do to address this properly in a more robust
way?" Whether a row named by its identifier feeds a result line is a fact of the code. The pruning of 0283 read it
too coarsely: it took or left whole cells, and it kept a cell when a later kept cell read any name it bound - every
cell of a real chain loads df again, so on the chain it was written for it dropped nothing. docs/ROUTINES_DESIGN.md
§19.5.

analyst/routines.py: _pruning takes the chain by top-level statement. From the last to the first, a statement stays
when something rests on it - a RESULT call, a figure (every statement of a figure cell; a show, save or write call),
an assert or a raise, a bare call on a module, the only read of an input - or when a later kept statement reads a
name it defines or changes; a statement that binds a name whole ends the reading of what the name held before it.
Everything else goes, with the comment lines standing on it; a cell left with nothing but imports and capture
switches goes, marker included. _Facts (was _CellFacts) reads what the code does not spell: a call does what the
function's body does (a RESULT line, a name changed outside it, a parameter changed in place), and so does a call
the function is handed to; a bare call changes the object it is called on and those it is handed; a draw reads its
generator's state and moves it on (the global generators, and one made by default_rng or RandomState); the names in
a query or eval string are read; globals(), locals() and vars() read the names whose strings the kept code holds, to
a fixed point; eval and exec keep everything before them. prune_cells(cells, figure_cells) returns (cells, the cells
dropped, the lines dropped, problem); keep_prints and prints_only are gone. held_out and put_back give the chain as
written the method's edits exactly: the dropped lines are held out while apply_edits runs, so a fragment the chain
repeats in a dropped line cannot take the edit.

bambooai/routines_host.py: propose condenses before the promoter (pruned_lines on the proposal). create builds the
chain as written with the same edits through held_out; zero falls back to it on the lines, as before. condense no
longer prunes: it runs the chain as written once beside a method that draws, and the method stands when the figures
are the same pictures, or when its own figures differ from one run to the next; else the chain as written is the
method and its run is run zero's record. 0283 had left the figures unchecked. settle_method writes the outcome; the
record is `condensed` alone (dropped.lines; elapsed: the chain as written's, the method's); the `pruned` record of
0283 and its row note are gone. consolidate takes the method's cells. A chain with no RESULT line and no figure is
left whole, prints included (the old pass dropped them).

The stack: the Condenser's stand-in drops comment lines (the dead stores it used to drop go before the promoter);
the field-trial promoter edits the method it was shown.

Measured on the seventeen real chains at hand (9,480 lines of code): 61% of the lines kept; every RESULT call there;
nothing kept reads a name only dropped code gave; pruning the pruned changes nothing; rows named by identifier in the
code 10 -> 3, the three a column of the method is built from. The chain of 8 November run as written and as
condensed, in separate processes, on stand-in data of its shape: the same 23 RESULT lines and both figures, 189
lines fewer.

Tests: test_routines.py 236 (the reading by statement: the re-loaded frame, the check inside the method's cell,
calls through functions, bare calls, asserts, draws, names in strings, globals; 400 random chains run as written and
as pruned, tests/analyst/_random_chains.py - 46,000 more while it was built, which found that a call reads what its
function reads at call time and that numpy's and the standard library's generators are two states; held_out and
put_back; the host: the
pass with nothing drawn, the figures the same, differing, differing run to run, the chain as written failing, the
fallback with and without the pass, the literal in its own cell and inside the method's, the edit on the chain as
written, behind the dialog), test_app_path.py 216 (a chain whose prints are its output), test_routines.js 139 (the
as-written note alone), the stack walk 141 (3 cells -> 2, twelve lines, the chain as written beside it, the figures
the same). Battery 1,839. HANDOVER: this patch, and the public PR #64 merged as 9c9a004.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015JZ4FUwJKDFyNc9zsiCgPf
pgalko pushed a commit that referenced this pull request Nov 13, 2026
pyproject.toml 2.7.2 -> 2.7.3; the handover's Published line and the design document's status line. Since 2.7.2:
custom instructions for the promoter (0281); a tool row's text and the Routines rail wrap (0282); the promoter reads
the chain without its exploration (0283, 0286); two checks that read the real clock (0285) and the public PR #64;
the manager names the athlete from the first run (0287); routines rebuilt - a run a statement at a time, a step that
stops costing its own lines and not the run, the trials at Save, with the condensing pass, the consolidation, the
Condenser seat and Fix it in the analysis (0284) gone (0288); the README rewritten (0289). The executor image stays
v74: no rebuild, no migration.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015JZ4FUwJKDFyNc9zsiCgPf
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.

2 participants