Close by age what an incomplete board read did not list and what a filtered read spares, so no role stays open for good, as ADR 1.3 has it

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-10-06 14:27:09 +02:00
1 parent 136047023e
commit 849adb197d
4 files changed
+62 -16

No files matched your search

+21 -14
View File
@@ -37,7 +37,12 @@ not swept clears them.
A read narrowed by the agents' fetch terms (`ats:narrowed:<target>`) lists
the roles matching a word, which says nothing of the roles it did not list,
so it closes by list nothing: a role of such a board closes once the board
has not listed it for `STALE_DAYS`, the rule searches have.
has not listed it for `STALE_DAYS`, the rule searches have. The same age
rule is the floor under every board (ADR Fetch prep and score 1.3): an
incomplete read (a ceiling, a page cap without a sweep) and a filtered read,
which spares the roles acted on and the remote ones it could not ask for,
close by age what no read has listed for `STALE_DAYS` (`_close_aged`), so no
role stays open for good.
A search never closes by its list, even one stamped complete because it
read as many results as its provider stated: a search is never a company's
@@ -365,7 +370,10 @@ def close_boards(config: Config, store: Store, tally: Tally, *,
incomplete += 1
if not store.state.get(f"ats:sweep:{sub.target}"):
partial.append(sub.target)
continue
# An incomplete read closes nothing by its list; what no
# read has listed for STALE_DAYS still goes.
read = _close_aged(store, source, sub.id, json.loads(
store.state.get(f"{source}:ids:{sub.target}", "[]")), stale)
shut = read
closed += shut
before = open_before.get(sub.id, 0)
@@ -394,8 +402,9 @@ def _close_read(store: Store, source: str, sub: Any, stale: str) -> int | None:
clears that record and closes what it did not list, all of it unfiltered
(`Store.mark_closed`), filtered sparing the roles acted on
(`_close_unlisted`). A filtered read that could not ask for remote roles
(`remote_unasked`) spares the remote ones as well, and closes those by
age instead."""
(`remote_unasked`) spares the remote ones as well. What a filtered read
spares closes by age (`_close_aged`), as on an incomplete read
(`close_boards`)."""
state, target = store.state, sub.target
if not state.get(f"{source}:complete:{target}", ""):
return None
@@ -404,8 +413,7 @@ def _close_read(store: Store, source: str, sub: Any, stale: str) -> int | None:
return _close_aged(store, source, sub.id, seen_ids, stale)
is_filtered = bool(state.get(f"{source}:filtered:{target}", ""))
spare_remote = is_filtered and bool(state.get(f"{source}:remote_unasked:{target}", ""))
aged = (_close_aged(store, source, sub.id, seen_ids, stale, remote_only=True)
if spare_remote else 0)
aged = _close_aged(store, source, sub.id, seen_ids, stale) if is_filtered else 0
if state.get(f"{source}:swept:{target}", ""):
return aged + _close_swept(store, source, sub, seen_ids, is_filtered,
spare_remote=spare_remote)
@@ -484,20 +492,19 @@ def _close_unlisted(store: Store, source: str, seen_ids: list[str], subscription
def _close_aged(store: Store, source: str, subscription_id: int, seen_ids: list[str],
stale: str, *, remote_only: bool = False) -> int:
stale: str) -> int:
"""Close the open roles of one board that its read did not list and that
no read has listed since `stale` (`roles.last_seen`, which `upsert_role`
writes on every listing): the rule for what a read cannot speak for. A
read narrowed by terms closes all such roles, as a search does; with
`remote_only`, a filtered read that could not ask for remote closes only
its remote roles so, sparing those acted on as its list does."""
where = " AND remote = 'remote'" + _ACTED_ON if remote_only else ""
writes on every listing): the rule for what a read cannot speak for, a
read narrowed by terms, an incomplete one, or what a filtered read
spares. A role acted on is not spared here: three weeks unlisted is the
one evidence a filtered or incomplete read gives."""
with store.transaction() as conn:
return conn.execute(
f"""UPDATE roles SET closed_at = ?
"""UPDATE roles SET closed_at = ?
WHERE source = ? AND subscription_id = ? AND closed_at IS NULL
AND last_seen < ?
AND source_id NOT IN (SELECT value FROM json_each(?)){where}""",
AND source_id NOT IN (SELECT value FROM json_each(?))""",
(store.now(), source, subscription_id, stale,
json.dumps(list(seen_ids)))).rowcount