Originally created by: fu351
Originally owned by: slegarraga
doberman log --last 0 (and policy-history --last 0, tune --last 0) prints the whole table. The CLI passes limit=max(0, last) through (src/doberman/cli/main.py:1311, :1627, :1200), and read_decisions builds its query with (f" LIMIT {int(limit)}" if limit else "") (src/doberman/storage/log.py:287). limit=0 is falsy, so the LIMIT clause is dropped and "show me zero rows" becomes "show me everything". The signature already says what was meant: limit: int | None = None, where None means unlimited.
Reproduce: seed with doberman demo --fast --path <tmp>, then doberman log --last 0 --path <tmp> prints all eight rows.
What to do
if limit is not None at log.py:287 and the same shape in read_decisions_since (:310). Check read_policy_changes in the same module for the same pattern and fix it too if it has it.read_decisions tests: with N rows stored, limit=0 returns [], limit=None returns all N, limit=1 returns one. Then one CLI-level test beside tests/unit/test_cli_log_jsonl.py: log --last 0 prints no rows.pytest tests/unit -k "log or decisions" green.One-token fix at the root, so all three callers are fixed at once. Don't patch it in the CLI instead; the storage helper is where the meaning lives.
Originally posted by: slegarraga
Claiming this one. Reproduced first on a clean tree:
doberman demo --fast --path <tmp>seeds 8 decisions, anddoberman log --last 0printed all of them, identical to--last 100.Root cause is exactly where you pointed: the truthiness guard on the LIMIT clause (
if limit) treatslimit=0as "no limit". Since the signature already documentsNoneas unlimited, the fix is the one-token change tolimit is not Nonein all three readers:read_decisions(storage/log.py)read_decisions_since(storage/log.py)read_policy_changes(policy/drift.py, same pattern, sopolicy-history --last 0was affected too)All three
--lastcallers go through these helpers, so nothing needed patching at the CLI layer.Verification on my machine:
limit=0->[],limit=None-> all N,limit=1-> one.test_cli_log_jsonl.py:log --jsonl --last 0prints no rows.test_hosthook_codex.py/test_hosthook_taint_floor.pywhich abort natively on this Mac even on clean main; CI arbitrates those.ruff checkandruff format --checkclean on touched files.PR incoming.
Ticket changed by: fu351