Skip to content

fix(guard): satisfy ruff format and repair stale/flaky tests#1307

Merged
kantorcodes merged 2 commits into
mainfrom
fix/ruff-format-command-queue
Jul 4, 2026
Merged

fix(guard): satisfy ruff format and repair stale/flaky tests#1307
kantorcodes merged 2 commits into
mainfrom
fix/ruff-format-command-queue

Conversation

@kantorcodes

@kantorcodes kantorcodes commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

CI failed on the ruff format --check src/ step. After fixing the formatting, two additional pre-existing test failures surfaced that were previously hidden because the format check blocked them from running.

Changes

  1. src/codex_plugin_scanner/guard/runtime/command_queue.py — collapse the multi-line dict comprehension returned by _local_requests_snapshot into the single-line form ruff format expects. Formatting-only; no behavior change.

  2. tests/test_guard_receipt_redaction_cursor.py — fix stale assertion. _RECEIPT_COMMAND_DETAIL_BACKFILL_LIMIT was reduced from 1000 to 200 in the receipt backfill persistence change, but this test still expected limit: 1000. Updated to 200 to match the constant.

  3. tests/test_guard_supply_chain_daemon.py — increase _wait_for_aibom_status default timeout from 1.0s to 5.0s. The 1.0s timeout was too tight for shared CI runners under full-suite load, causing intermittent failures in test_daemon_aibom_refresh_records_synced_on_success. The happy path still returns in ~20ms.

Verification

  • ruff format --check src/ → 334 files already formatted ✅
  • ruff check src/ → OK ✅
  • basedpyright --level error on modified source → OK ✅
  • pytest tests/test_guard_command_queue.py tests/test_guard_command_queue_stale_pending_result.py tests/test_guard_headless_daemon_api.py → 129 passed ✅
  • pytest tests/test_guard_receipt_redaction_cursor.py tests/test_guard_supply_chain_daemon.py → all passed ✅

CI fix

Resolves the failure on run https://github.com/hashgraph-online/hol-guard/actions/runs/28718065590/job/85162822350 — step 7 ruff format --check src/, plus two pre-existing test failures that were hidden behind the format check.

CI failed on `ruff format --check src/` because the lease snapshot
dict comprehension exceeded the line-length budget and ruff format
collapsed it to a single line. Apply the formatter output so the
format check passes.

Signed-off-by: Michael Kantor <6068672+kantorcodes@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes small formatting and test-stability updates. The main changes are:

  • Collapses the lease snapshot dict comprehension in command_queue.py.
  • Updates the expected receipt redaction backfill marker limit.
  • Extends the AIBOM daemon status polling timeout in the supply-chain daemon tests.

Confidence Score: 5/5

Safe to merge with minimal risk.

The production change is an equivalent formatting-only rewrite, and the test changes adjust expected metadata and polling timing without changing runtime behavior.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex ran the Python guard contract-validation suite, including the formatter, linter, type-checker, and pytest runtime tests, and used the 02-after logs as proof.
  • T-Rex compared the 02-after results to the earlier 01-before formatter capture and observed the sequence of checks that were executed as part of the post-run proof.
  • T-Rex confirmed that all checks reported in the 02-after proof set—formatter, lint, type-check, and runtime tests—completed successfully, demonstrating adherence to the Python guard contract.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/codex_plugin_scanner/guard/runtime/command_queue.py Collapsed the local request snapshot dict comprehension without changing the lease payload behavior.
tests/test_guard_receipt_redaction_cursor.py Updated the expected redaction backfill marker limit to match current behavior.
tests/test_guard_supply_chain_daemon.py Increased the AIBOM daemon status polling timeout in the test helper.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Queue as Command Queue
participant Store as GuardStore
participant Snapshot as _local_requests_snapshot
participant Cloud as Guard Cloud Lease

Queue->>Store: load OAuth metadata
Queue->>Snapshot: build localRequestsSnapshot
Snapshot->>Store: read local request snapshot payload
alt payload is dict
    Snapshot-->>Queue: selected lease snapshot keys
else missing or invalid payload
    Snapshot-->>Queue: "{requests: []}"
end
Queue->>Cloud: send lease payload
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Queue as Command Queue
participant Store as GuardStore
participant Snapshot as _local_requests_snapshot
participant Cloud as Guard Cloud Lease

Queue->>Store: load OAuth metadata
Queue->>Snapshot: build localRequestsSnapshot
Snapshot->>Store: read local request snapshot payload
alt payload is dict
    Snapshot-->>Queue: selected lease snapshot keys
else missing or invalid payload
    Snapshot-->>Queue: "{requests: []}"
end
Queue->>Cloud: send lease payload
Loading

Reviews (2): Last reviewed commit: "test(guard): fix stale backfill limit an..." | Re-trigger Greptile

@kilo-code-bot

kilo-code-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

This PR resolves a CI formatting failure and repairs stale/flaky tests. The command_queue.py change is purely cosmetic; the other two changes correct a stale assertion and reduce CI flakiness.

Files Reviewed (3 files)
  • src/codex_plugin_scanner/guard/runtime/command_queue.py - formatting-only change (dict comprehension collapsed to single line)
  • tests/test_guard_receipt_redaction_cursor.py - updated stale limit assertion from 1000 to 200 to match _RECEIPT_COMMAND_DETAIL_BACKFILL_LIMIT = 200
  • tests/test_guard_supply_chain_daemon.py - increased _wait_for_aibom_status default timeout from 1.0s to 5.0s to reduce CI flakiness
Previous Review Summary (commit c88352b)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit c88352b)

Status: No Issues Found | Recommendation: Merge

This PR resolves a CI formatting failure by collapsing a multi-line dict comprehension into a single line as ruff format expects. The change is purely cosmetic with no functional impact.

Files Reviewed (1 file)
  • src/codex_plugin_scanner/guard/runtime/command_queue.py - formatting-only change (dict comprehension collapsed to single line)

Reviewed by step-3.7-flash-20260528 · Input: 99.6K · Output: 4.2K · Cached: 281.9K

`_RECEIPT_COMMAND_DETAIL_BACKFILL_LIMIT` was reduced from 1000 to 200 in
the receipt backfill persistence change, but the assertion in
`test_relaxed_redaction_sync_adds_recent_blocked_command_detail_backfill`
still expected 1000. Update the expectation to match the constant.

The AIBOM daemon status poll used a 1.0s timeout, which is too tight for
shared CI runners under full-suite load and caused intermittent failures
in `test_daemon_aibom_refresh_records_synced_on_success`. Increase the
default to 5.0s; the happy path still returns in ~20ms.

Signed-off-by: Michael Kantor <6068672+kantorcodes@users.noreply.github.com>
@kantorcodes kantorcodes changed the title style(guard): collapse dict comprehension to satisfy ruff format fix(guard): satisfy ruff format and repair stale/flaky tests Jul 4, 2026
@kantorcodes kantorcodes merged commit d7676be into main Jul 4, 2026
22 checks passed
@kantorcodes kantorcodes deleted the fix/ruff-format-command-queue branch July 4, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant