fix: apply --limit to the write, not to the selection #22
Reference in New Issue
Block a user
Delete Branch "fix/limit-bounds-the-write"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #18.
pull.py's docstring said "the limit is on the write, not on the selection" and the code did the opposite:_gitea.list_issuestruncated the payload list tolimit, andpull.pydropped the closed ones after that. A milestone whose first issues are closed answered--limit 20with twelve files, and the only statement about the behavior anywhere was the false one.What changed
--limitcounts what the run leaves in the store.list_issuestakes akeeppredicate; pages keep arriving untillimitpayloads satisfy it. Payloads that did not count are still returned, sopull.pycan keep reporting "N closed issue(s) enumerated, not stored". Whatkeepmeans stays the caller's business — the transport only counts.pull.lands_in_storeis the predicate, and it is the same test the walk itself applies: a closed issue counts only when the store already has it, because that one is refreshed rather than dropped. A--cachedskip counts too — the store holds it when the run ends.paginateis now a thin wrapper over a newpagesgenerator. The page after the one that fills the budget is never requested.keep-bounded read scans at most_gitea.PAGE_SLACK(4) times the pages the limit would need if nothing were dropped, then warns on stderr and returns short. Raising--limitraises that ceiling with it.--depsis outside the count: a dependency is followed because an issue named it, not because the filter selected it.remote.pykeeps the old meaning, now said out loud. It writes nothing, so there is no write for a limit to bound and its--limitcaps the listing, closed issues included. The divergence is documented in both scripts and in the/tea:synccommand table.--limit 0is refused instead of dividing by the page size and raisingZeroDivisionError.Acceptance criteria
pull.py --limit Nwrites N issues when at least N non-closed ones match the filterskills/sync/SKILL.mdand the behavior say the same thing; theremote.pydivergence is stated explicitly--limit NTests
tests/test_pull_limit.pystubs the transport at_gitea.apiwith a fake that servespage=/limit=itself, so the request pattern is observed rather than assumed. It covers exactly N files out of a half-closed selection, the second page being fetched and the third not, the scan stopping at the budget with a warning, a closed issue already on disk spending the budget, andremote.py's listing being unchanged. Stdlibunittest, a throwaway store per test, no network.Reverting
pull.pyand_gitea.pywhile keeping the new file fails 8 of its tests.🤖 Generated with Claude Code