Skip to content

fix(homeostatic): the fold UPDATE runs in each backend's own dialect (#736) - #761

Merged
cdeust merged 2 commits into
mainfrom
fix/736-sqlite-fold
Oct 16, 2026
Merged

cdeust merged 2 commits into
mainfrom
fix/736-sqlite-fold

Conversation

@cdeust

@cdeust cdeust commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Fixes #736

Cause

_apply_fold (handlers/consolidation/homeostatic_apply.py) issued LEAST/GREATEST in handler code. SQLite has neither, so every fold cycle raised sqlite3.OperationalError: no such function: LEAST on the SQLite backend.

Fix

The UPDATE moves into fold_heat_base(domain, write_class, factor) on each store, as the other heat writers already are. PostgreSQL keeps the same statement; SQLite uses scalar MIN/MAX and CURRENT_TIMESTAMP. No skip, no fallback. The I2 allow-list tracks the two new writer sites.

Evidence

  • tests_py/infrastructure/test_sqlite_homeostatic_fold_736.py runs the fold on a real SqliteMemoryStore: fails on main with no such function: LEAST, passes here.
  • Homeostatic, I2 and SQLite parity tests pass; ruff check, ruff format --check and the craftsmanship gate are clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VH9JM8qvKiJysP16BmAxAU

@cdeust

cdeust commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

ZETETIC-REVIEW: APPROVE
head: 08be5d9

MIN/MAX scalaires équivalents à LEAST/GREATEST (heat_base est REAL NOT NULL dans les deux schémas). CURRENT_TIMESTAMP suit bump_heat_raw. Le SQL PG est déplacé sans changement. L'allow-list I2 reste exacte, sans relâchement de l'invariant. Couches améliorées : le handler ne fait plus de SQL brut.
Nits non bloquants : le docstring de test_I2 cite encore _apply_fold ; COALESCE(is_protected/is_stale, 0) replie une ligne NULL explicite, alors que PG l'exclut ; no_decay n'est pas couvert par le nouveau test.
Merge après CI verte.

cdeust and others added 2 commits October 16, 2026 09:21
…736)

_apply_fold issued LEAST/GREATEST in handler code, which SQLite lacks, so
every fold cycle raised OperationalError on the SQLite backend. The UPDATE
moves into fold_heat_base on each store (PostgreSQL keeps LEAST/GREATEST/
NOW(); SQLite uses scalar MIN/MAX and CURRENT_TIMESTAMP), like the other
heat writers.

Fixes #736

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n test stubs fold_heat_base (#736)

The fold UPDATE moved from the handler into PgHeatMixin.fold_heat_base,
which borrows the batch pool through self.acquire_batch(). PgStoreHost,
the typing surface every pg mixin inherits, declared acquire_interactive
but not acquire_batch, so pyright's zero-diagnostic gate failed on
pg_store_heat.py:63. The host now declares acquire_batch next to
acquire_interactive (implementation unchanged in pg_store_schema.py).

test_homeostatic_stratification stubbed the old handler path
(store.acquire_batch -> conn.execute) and asserted on conn.execute. It
now stubs store.fold_heat_base and asserts one call, for the auto class
only, which is what the test protects (deliberate is never folded).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VH9JM8qvKiJysP16BmAxAU
@cdeust
cdeust force-pushed the fix/736-sqlite-fold branch from 08be5d9 to d3a0743 Compare October 16, 2026 07:29
@cdeust

cdeust commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

ZETETIC-REVIEW: APPROVE
head: d3a0743

Delta depuis 08be5d9 (relu par range-diff) : rebase sans changement, plus d3a0743. Le stub acquire_batch sous TYPE_CHECKING correspond à pg_store_schema.py:115. Le test de stratification stub maintenant fold_heat_base et vérifie un seul repli, classe AUTO, jamais DELIBERATE. CI entièrement verte.

@cdeust
cdeust merged commit 28bd507 into main Oct 16, 2026
31 checks passed
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.

SQLite: the homeostatic fold UPDATE uses LEAST/GREATEST, fails on every cycle once triggered, and freezes the heat factor

1 participant