Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions arr-webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def from_remote_client(data):
# (/run-stalled-seeds, dry-run by default) still works regardless of this
# flag — this only gates the automatic weekly background removal.
STALL_AUTOMATION_ENABLED = os.environ.get('STALL_AUTOMATION_ENABLED', 'false').lower() in ('1', 'true', 'yes')
# Upgrade-lane cap. Penn, 2026-11-15: first "cap the backlog at 30 torrents",
# Upgrade-lane cap. The owner, 2026-11-15: first "cap the backlog at 30 torrents",
# then "remove the standing queue in deluge and just add an upgrade when one
# finishes". So the default is Deluge's 10 active-download slots: untouched
# upgrade torrents beyond it are dropped (anything with progress is always
Expand All @@ -647,7 +647,7 @@ def from_remote_client(data):
# torrents on these labels that have seeded SEED_RETIRE_DAYS, in a swarm with
# more than SEED_RETIRE_MIN_SWARM other seeds, stop seeding (download copy
# deleted only when the library verifiably holds every video). 0 days = off.
# 180 matches Penn's earlier six-month target for unseeding (STALL_SEED_MIN_DAYS).
# 180 matches the owner's earlier six-month target for unseeding (STALL_SEED_MIN_DAYS).
SEED_RETIRE_DAYS = int(os.environ.get('SEED_RETIRE_DAYS', '180'))
SEED_RETIRE_MIN_SWARM = int(os.environ.get('SEED_RETIRE_MIN_SWARM', str(STALL_MIN_SWARM_SEEDS)))
SEED_RETIRE_PER_RUN = int(os.environ.get('SEED_RETIRE_PER_RUN', '100'))
Expand All @@ -657,16 +657,16 @@ def from_remote_client(data):
# updates two hours apart retired two batches of 100).
SEED_RETIRE_STATE = os.environ.get('SEED_RETIRE_STATE', '/data/seed_retire_state.json')
SEED_RETIRE_FIRST_DELAY = 900
# Idle rule (Penn, 11-15: "can we do variable based on seeding activity?"): a
# Idle rule (the owner, 11-15: "can we do variable based on seeding activity?"): a
# managed torrent that has uploaded nothing for SEED_IDLE_DAYS retires once it
# has seeded SEED_IDLE_MIN_DAYS. One still uploading keeps seeding at any age
# (Penn, 11-15: "if its seeding actively i want to leave it"): with the idle
# (the owner, 11-15: "if its seeding actively i want to leave it"): with the idle
# rule on, SEED_RETIRE_DAYS only puts idle torrents past it first in line. The
# idle floor never drops below SEED_DAYS (remove_torrent would only defer it).
# 0 idle days = idle rule off (then SEED_RETIRE_DAYS alone retires by age).
SEED_IDLE_DAYS = int(os.environ.get('SEED_IDLE_DAYS', '14'))
SEED_IDLE_MIN_DAYS = max(int(os.environ.get('SEED_IDLE_MIN_DAYS', str(SEED_DAYS))), SEED_DAYS)
# Earner set (Penn, 11-21: keep the top earners seeding, yes). The labeled torrents
# Earner set (the owner, 11-21: keep the top earners seeding, yes). The labeled torrents
# with the most total_uploaded are never retired or unseeded as stalled. 0 = off.
SEED_KEEP_TOP_EARNERS = int(os.environ.get('SEED_KEEP_TOP_EARNERS', '30'))
UPGRADE_LANE_LABELS = (SONARR_UPG_LABEL, RADARR_UPG_LABEL, SONARR_UPG_PRIORITY_LABEL, RADARR_UPG_PRIORITY_LABEL)
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def _torrent_inflight_state(torrent_hash):

def release_inflight_superseded(torrent_hash, state, progress, resume=True):
"""A superseded torrent that has NOT finished must be allowed to finish,
never removed (Penn's policy: the label is `superseded`, lift the speed
never removed (the owner's policy: the label is `superseded`, lift the speed
limit, let it download to 100% and seed; cleanup_superseded reaps it after
SEED_DAYS). The radarr-upgrade/sonarr-upgrade lanes carry a per-torrent
max_download_speed that PERSISTS after relabel (the `superseded` label has
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def _arr_tracker_of(local_path, cache):


def rar_set_action(rset, cache=None, contents=None):
"""Unpack or delete one library RAR set (Penn, 2026-11-07).
"""Unpack or delete one library RAR set (the owner, 2026-11-07).
-> {'action': 'unpack'|'delete'|'skip'|'error', 'reason': str, 'arr': title}
delete: the owning Sonarr series has a file for every episode in the set,
or the owning Radarr movie has a file.
Expand Down Expand Up @@ -3564,7 +3564,7 @@ def cleanup_stalled_seeds(dry_run=False):
if prev is None:
continue
if h in earners:
continue # top earner: keeps seeding (Penn, 11-21)
continue # top earner: keeps seeding (the owner, 11-21)
if info.get('seeding_time', 0) < STALL_SEED_MIN_DAYS * 86400:
continue
gained = uploaded - prev.get('total_uploaded', 0)
Expand Down Expand Up @@ -6387,7 +6387,7 @@ def monthly_search_scheduler():
key so neither starves), and no pass starts once WEEKLY_UPGRADE_QUOTA
confirmed upgrades have been queued in the rolling 7-day window.

With the lane cap on, this is a refill, not a standing queue (Penn,
With the lane cap on, this is a refill, not a standing queue (the owner,
2026-11-15): a pass runs only while the lane has free slots, and it
searches at most that many items, so a finished upgrade frees a slot and
the next poll adds one. If Deluge can't report the lane, the poll is
Expand Down Expand Up @@ -6575,7 +6575,7 @@ def retire_old_seeds(dry_run=False):
(deluge_trim.seed_retire_picks): seeded SEED_RETIRE_DAYS ('age'), or seeded
SEED_IDLE_MIN_DAYS with no upload for SEED_IDLE_DAYS ('idle'). At most
SEED_RETIRE_PER_RUN per run, aged-out first. Files are always kept
(11-15, Penn: "we're linking them, so we need to keep them"): Sonarr and
(11-15, the owner: "we're linking them, so we need to keep them"): Sonarr and
Radarr import by hardlink (their logs show it), so deleting the download
copy frees no space and only loses the chance to seed it again. The link
count can't tell a hardlink from a copy here (shfs on /mnt/user always
Expand Down Expand Up @@ -6677,7 +6677,7 @@ def seed_retire_scheduler():
def refresh_metadata_on_grab(data, source):
"""Best-effort metadata refresh on Grab.

Penn hit this live: an episode downloaded but Sonarr refused to import
The owner hit this live: an episode downloaded but Sonarr refused to import
because the episode title in its DB was still 'TBA' (metadata never
refreshed after grab). Pulling fresh metadata at grab time via a
RefreshSeries/RefreshMovie command fixes it. Best-effort only — any
Expand Down Expand Up @@ -8315,7 +8315,7 @@ def _find_torrent_by_filepath(torrents, filepath):
return None, None


# Check before the duplicate cleanup removes a copy (Penn 11-15: have the model confirm correct matches).
# Check before the duplicate cleanup removes a copy (the owner 11-15: have the model confirm correct matches).
# Code guards (llm_decide.dupe_conflict: episodes, years, edition tags, running times) keep both files in every
# mode. Then the model (kind dupe_confirm, free layers only) is asked whether the two files are the same media:
# LLM_DUPE_CONFIRM = off | shadow (default: ask and log, change nothing) | enforce (remove a copy only on a
Expand Down Expand Up @@ -8354,7 +8354,7 @@ def _dupe_facts(entry, keeper, loser):
return facts


# Pairs a check kept, or (in shadow) the model doubted, listed in the report so Penn can look at each one
# Pairs a check kept, or (in shadow) the model doubted, listed in the report so the owner can look at each one
# ("never keeping dupes of the exact same media": a kept pair is not left quietly). Capped per run.
DUPE_REVIEW_MAX = 200

Expand Down Expand Up @@ -8527,7 +8527,7 @@ def plex_dupe_fix():
})
continue
media_list = present
# Score each Media: (HEVC, resolution_rank, size_gb). Higher wins. Penn always keeps HEVC over any
# Score each Media: (HEVC, resolution_rank, size_gb). Higher wins. The owner always keeps HEVC over any
# other codec, even a higher-resolution one.
res_rank = {'4k': 4, '2160': 4, '1080': 3, '720': 2, '576': 1, '480': 1, None: 0}
def score(m):
Expand Down
8 changes: 4 additions & 4 deletions deluge_trim.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
torrents, calls these, and does the removals through remove_torrent (which
keeps its own seed floor and library guards).

Upgrade-lane cap (added 2026-11-15 at Penn's request: "cap the backlog at 30
Upgrade-lane cap (added 2026-11-15 at the owner's request: "cap the backlog at 30
torrents"). The lane is every unfinished torrent carrying an upgrade label.
A torrent that has downloaded anything is never dropped: it may already be
announced with data, so dropping it could leave a partial on a tracker. Only
Expand All @@ -17,7 +17,7 @@
in a swarm that already has more than `min_swarm` other seeds, has paid its
dues (TorrentLeech's hit-and-run rule is 10 days or 1:1) and can stop seeding.

Idle rule (Penn, 11-15: "can we do variable based on seeding activity?"). A
Idle rule (the owner, 11-15: "can we do variable based on seeding activity?"). A
torrent nobody has downloaded from in `idle_days` retires as soon as it has
seeded `idle_min_days`, instead of waiting out `min_days`; a torrent that is
still uploading keeps seeding until `min_days`. Activity is Deluge's
Expand Down Expand Up @@ -94,7 +94,7 @@ def seed_retire_rule(t, labels, min_days, min_swarm, idle_days=0, idle_min_days=
the idle rule. Unknown seed time, swarm size or activity never qualifies.

With the idle rule on, a torrent still uploading is never retired, however
long it has seeded (Penn, 11-15: "if its seeding actively i want to leave
long it has seeded (the owner, 11-15: "if its seeding actively i want to leave
it, just torrents that aren't doing anything"): the age rule then only
puts idle torrents that are past min_days first in line."""
if (t.get('label') or '') not in labels:
Expand Down Expand Up @@ -122,7 +122,7 @@ def top_earners(torrents, n, labels=None):
0), ties broken by hash. labels=None means any non-empty label; unlabeled
torrents never count. n <= 0 gives none.

Penn, 11-21: keep the top earners seeding (ratio and bonus points), on top
The owner, 11-21: keep the top earners seeding (ratio and bonus points), on top
of the 21-day minimum that remove_torrent's SEED_DAYS floor enforces."""
if not n or n <= 0:
return frozenset()
Expand Down
6 changes: 3 additions & 3 deletions llm_advisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
# Per-kind answer lifetime in hours (LLM_ANSWER_TTL_H_<KIND> overrides). Two files' names don't change, so a
# dupe answer holds for a month; the rest use LLM_ANSWER_TTL_H.
ANSWER_TTL_H = {'dupe_confirm': 720.0, 'torrent_error': 24.0, 'unregistered_triage': 24.0, 'stuck_import': 24.0, 'stuck_upgrade_tag': 24.0, 'duplicate_folder': 24.0, 'audit_findings': 24.0, 'arr_health': 24.0}
# Kinds that never use a paid layer, in any mode (Penn 11-15: paid services only for time-sensitive work such as
# Kinds that never use a paid layer, in any mode (the owner 11-15: paid services only for time-sensitive work such as
# grab-time decisions and upgrades). They wait for the free layers, then fall back to the caller's rules action.
FREE_ONLY_KINDS = frozenset({'dupe_confirm', 'torrent_error', 'unregistered_triage', 'stuck_import', 'stuck_upgrade_tag', 'duplicate_folder', 'audit_findings', 'arr_health'})
UNRAID_MODEL = 'qwen3:14b'
Expand Down Expand Up @@ -842,7 +842,7 @@ def model_fn():

MODES = ('off', 'shadow', 'enforce')
# Kinds added after the first three: off unless LLM_MODE_<KIND> is set, so a deploy never starts them before
# their back-test (Penn 11-19: back-test first).
# their back-test (the owner 11-19: back-test first).
OPT_IN_KINDS = frozenset({'torrent_error', 'unregistered_triage', 'stuck_import', 'stuck_upgrade_tag', 'duplicate_folder', 'audit_findings', 'arr_health'})


Expand Down Expand Up @@ -1337,7 +1337,7 @@ def weak(dec):
return res
co = claude_only(env)
if local is None and unraid is None and not (co and 'claude' in layers):
# Paid layers are only a backup for the free ones (Penn, 2026-11-16). With no free layer configured,
# Paid layers are only a backup for the free ones (the owner, 2026-11-16). With no free layer configured,
# nothing is asked and the rules stand. The queue layer alone never opens the paid layers either.
if res['decision'] is None:
res['error'] = ('queue ' + str(res['queue'].get('pass') or 'failed')) if res['queue'] is not None \
Expand Down
26 changes: 13 additions & 13 deletions llm_decide.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
MIN_CONFIDENCE = 0.75
MIN_SEEDERS = 10

# Penn's standing preferences, shown to the model. Advisory only: apply_hard_rules() enforces the
# The owner's standing preferences, shown to the model. Advisory only: apply_hard_rules() enforces the
# non-negotiable ones in code. Edit here, not in the prompts.
POLICY = {
'upgrade_gate': (
Expand All @@ -41,18 +41,18 @@
'the candidate has 5.1 or more audio channels, the existing file has fewer, and hdr_surround_available is '
'false (no HDR release with 5.1 audio is available). '
'Also reject a candidate that is not x265 (x264, AV1 or any other codec) replacing an x265 file, even at a '
'higher resolution, a better source tier or with HDR: Penn always keeps HEVC over any other codec. '
'higher resolution, a better source tier or with HDR: the owner always keeps HEVC over any other codec. '
'2. Allow, even when the candidate is much bigger: a higher resolution; a better source tier (Bluray or '
'Remux over a WEB-DL, WEBRip or HDTV file); HDR10 or disc Dolby Vision (Bluray/Remux) over SDR; lossless '
'or Atmos audio over lossy; replacing an AV1 file (many Plex clients cannot play AV1 directly); a PROPER '
'or REPACK (it fixes a broken release); a replacement of a poor release group. '
'3. Allow: an x265 candidate replacing a file that is not x265, whatever its size, resolution or source '
'tier: Penn always prefers HEVC. A re-encode of a WEB-DL counts. '
'tier: the owner always prefers HEVC. A re-encode of a WEB-DL counts. '
'4. Allow at the same resolution and source tier: a candidate at least 1.4 times the existing size (a '
'higher-bitrate encode is better quality); or a smaller candidate with '
'the same codec (saves space). '
'5. Throttle: same resolution and source tier from a different release group when no rule above '
'applies. Sonarr and Radarr rank release groups by Penn\'s preferences, which these facts do not show. '
'applies. Sonarr and Radarr rank release groups by the owner\'s preferences, which these facts do not show. '
'6. Anything else is a sidegrade (for example the same group at about the same size): reject it. '
'Private-tracker ratio matters: prefer freeleech. freeleech is full, partial or no. '
'For a season pack, episodes is how many episodes it holds, size_gb is the whole pack and '
Expand All @@ -63,7 +63,7 @@
'import_identity': (
'Answer match only when title AND year both agree with the matched item. A different year, a remake, a '
'reboot or a different series is a mismatch. Doubled year tokens (Title.2015.2015) are not a mismatch. '
'Use unsure whenever the evidence is thin; unsure sends Penn a notification instead of importing. '
'Use unsure whenever the evidence is thin; unsure sends the owner a notification instead of importing. '
"For Sonarr, queue titles usually carry no year and matched_year is the series' first-air year: judge the "
'series name (and season/episode if present); a missing year is not a mismatch. A later season (S02, S03...) '
'can air in the first-air year or any year after it. '
Expand All @@ -73,7 +73,7 @@
'release, a late-December premiere).'),
'dupe_confirm': (
'Plex lists two files under one library item. The duplicate cleanup keeps the keeper file and removes the '
'other file, because Penn never keeps two copies of exactly the same media. Answer same only when both '
'other file, because the owner never keeps two copies of exactly the same media. Answer same only when both '
'files hold the same film, or the same episode(s) of the same show, in the same cut: a different '
'resolution, codec, size, release group or source is still the same media. Answer different when they '
'are different films or episodes, a remake or another year, or a different cut or edition (Extended, '
Expand Down Expand Up @@ -329,7 +329,7 @@ def sdr_over_hdr(facts):


def non_hevc_over_hevc(facts):
"""A candidate of a known codec other than HEVC that would replace an HEVC file. Penn always keeps HEVC.
"""A candidate of a known codec other than HEVC that would replace an HEVC file. The owner always keeps HEVC.
An unknown codec on either side means no (the model decides)."""
if not isinstance(facts, dict):
return False
Expand All @@ -341,7 +341,7 @@ def non_hevc_over_hevc(facts):


def sdr_surround_exception_possible(facts):
"""Penn's one exception to keeping HDR: the SDR candidate brings 5.1 audio the HDR file lacks. True when the
"""The owner's one exception to keeping HDR: the SDR candidate brings 5.1 audio the HDR file lacks. True when the
channel facts allow it, so the caller should look for an HDR release with 5.1 audio (hdr_surround_available)."""
if not sdr_over_hdr(facts):
return False
Expand All @@ -366,8 +366,8 @@ def upgrade_comparison(context):
parts.append('source tier %s (%s vs %s)' % (word, _TIER_NAME[t_new], _TIER_NAME[t_old]))
c_new, c_old = _codec_family(context.get('codec')), _codec_family(context.get('existing_codec'))
if c_new and c_old:
note = ' (loses HEVC: Penn always keeps HEVC)' if c_old == 'x265' and c_new != 'x265' else \
' (gains HEVC: Penn always prefers HEVC)' if c_new == 'x265' and c_old != 'x265' else ''
note = ' (loses HEVC: the owner always keeps HEVC)' if c_old == 'x265' and c_new != 'x265' else \
' (gains HEVC: the owner always prefers HEVC)' if c_new == 'x265' and c_old != 'x265' else ''
parts.append('codec %s -> %s%s' % (c_old, c_new, note))
ratio = _size_ratio(context)
if ratio is None and context.get('size_gb') is None and _num_or_none(context.get('existing_size_gb')):
Expand Down Expand Up @@ -631,15 +631,15 @@ def country_differs(queue_title, matched_title):
_LOOKALIKE = str.maketrans('013457', 'oieast')


# Release names Penn confirmed are the matched title, for pairs no general rule can safely accept:
# Release names the owner confirmed are the matched title, for pairs no general rule can safely accept:
# (release show name, matched title), both as _title_tokens joined by spaces.
_CONFIRMED_ALIASES = frozenset((
('apollo has fallen', 'has fallen'), # Penn 2026-11-14: Sonarr's 'Has Fallen' is released as 'Apollo Has Fallen'
('apollo has fallen', 'has fallen'), # the owner 2026-11-14: Sonarr's 'Has Fallen' is released as 'Apollo Has Fallen'
))


def confirmed_alias(queue_title, matched_title):
"""True when Penn has confirmed this release name is the matched title."""
"""True when the owner has confirmed this release name is the matched title."""
return (release_show_name(queue_title), ' '.join(_title_tokens(str(matched_title or '')))) in _CONFIRMED_ALIASES


Expand Down
2 changes: 1 addition & 1 deletion supersede_policy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""supersede_policy.py -- Penn's rule for torrent supersede decisions."""
"""supersede_policy.py -- the owner's rule for torrent supersede decisions."""


def _check_upgrade_completes(new_torrent):
Expand Down
2 changes: 1 addition & 1 deletion test_deluge_trim.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def test_enforce_off_and_deluge_failure_never_raise(monkeypatch):


def test_retire_always_keeps_files(monkeypatch):
# Penn 11-15: "we're linking them, so we need to keep them". Imports are
# The owner 11-15: "we're linking them, so we need to keep them". Imports are
# hardlinks, so deleting the download copy frees nothing; files stay even
# when the library verifiably has every video.
monkeypatch.setattr(aw, 'SEED_RETIRE_DAYS', 180)
Expand Down
2 changes: 1 addition & 1 deletion test_hard_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_one_name_ending_the_other_needs_a_matching_year():


def test_confirmed_alias_is_the_matched_show():
# Penn 2026-11-14: Sonarr's 'Has Fallen' is the show released as 'Apollo Has Fallen'.
# The owner 2026-11-14: Sonarr's 'Has Fallen' is the show released as 'Apollo Has Fallen'.
assert _spin('Apollo.Has.Fallen.S02E04.1080p.WEB.h264-GRP', 'Has Fallen') == ('match', None)
assert ld.confirmed_alias('Apollo Has Fallen S01E01 1080p', 'Has Fallen')
# Only that exact pair: other names, or the alias against a different show, still go through the guards.
Expand Down
Loading