From 6bda5005c1c77e5fa3f4f1e5e122de9807ff3190 Mon Sep 17 00:00:00 2001 From: Nora Date: Sat, 4 Jul 2026 20:29:13 -0600 Subject: [PATCH] feat(sp33): resubmit CLI: skipped files don't audit or count as uploads Finishes the in-tree was_skipped draft: size-matched remote files no longer emit clearhouse.submitted events or increment uploaded, and the periodic reconnect now triggers only after real uploads. Co-Authored-By: Claude Fable 5 --- backend/src/cyclone/cli.py | 57 ++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/backend/src/cyclone/cli.py b/backend/src/cyclone/cli.py index 6519d92..e9f3b9e 100644 --- a/backend/src/cyclone/cli.py +++ b/backend/src/cyclone/cli.py @@ -674,6 +674,7 @@ def resubmit_rejected_claims( attempts = 0 ok = False + was_skipped = False while attempts < 3: attempts += 1 if ssh is None: @@ -691,7 +692,7 @@ def resubmit_rejected_claims( rs = sftp.stat(remote_path) # type: ignore[union-attr] if rs.st_size == local_size: skipped += 1 - ok = True + was_skipped = True break except IOError: pass # not on remote yet @@ -710,37 +711,39 @@ def resubmit_rejected_claims( ) continue - if not ok: + if not ok and not was_skipped: failed += 1 continue - # Audit (best-effort; if the DB is unavailable we still keep - # the file on the wire). - try: - with db_mod.SessionLocal()() as session: - append_event(session, AuditEvent( - event_type="clearhouse.submitted", - entity_type="claim_file", - entity_id=src.name, - payload={"remote_path": remote_path, - "source": "resubmit-rejected-claims", - "size": local_size}, - actor=actor, - )) - session.commit() - except Exception as exc: # noqa: BLE001 - click.echo( - f"audit-log write failed for {src.name}: " - f"{exc.__class__.__name__}: {exc}", err=True, - ) + # Audit + reconnect cadence apply only to real uploads. + if not was_skipped: + # Audit (best-effort; if the DB is unavailable we still + # keep the file on the wire). + try: + with db_mod.SessionLocal()() as session: + append_event(session, AuditEvent( + event_type="clearhouse.submitted", + entity_type="claim_file", + entity_id=src.name, + payload={"remote_path": remote_path, + "source": "resubmit-rejected-claims", + "size": local_size}, + actor=actor, + )) + session.commit() + except Exception as exc: # noqa: BLE001 + click.echo( + f"audit-log write failed for {src.name}: " + f"{exc.__class__.__name__}: {exc}", err=True, + ) - uploaded += 1 + uploaded += 1 - # Reconnect periodically to dodge MOVEit's per-session cap. - if uploaded % reconnect_every == 0: - click.echo(f"reconnecting (after {uploaded} uploads)", err=True) - _close_session(ssh) - ssh, sftp = None, None + # Reconnect periodically to dodge MOVEit's per-session cap. + if uploaded % reconnect_every == 0: + click.echo(f"reconnecting (after {uploaded} uploads)", err=True) + _close_session(ssh) + ssh, sftp = None, None # Progress every 10s of wall-clock (or at end). now = time.monotonic()