Skip to content

fix(persistence): refurb cleanups in replay journal + lineage signer + eval (cluster C)#1813

Merged
chernistry merged 3 commits into
mainfrom
fix/code-scanning-cluster-c
May 21, 2026
Merged

fix(persistence): refurb cleanups in replay journal + lineage signer + eval (cluster C)#1813
chernistry merged 3 commits into
mainfrom
fix/code-scanning-cluster-c

Conversation

@chernistry

@chernistry chernistry commented May 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Address 7 refurb alerts across 5 files in the replay journal, lineage signer, and eval subsystems.

Alerts cleared

Alert File:line Rule Fix
#2468 src/bernstein/core/persistence/journal.py:209 FURB123 list(self.blob_refs) -> self.blob_refs.copy()
#2469 src/bernstein/core/persistence/journal_export.py:94 FURB123 list(self.blob_digests) -> self.blob_digests.copy()
#2470 src/bernstein/core/persistence/journal_export.py:108 FURB123 list(self.blob_digests) -> self.blob_digests.copy()
#2471 src/bernstein/core/persistence/journal_export.py:485 FURB160 drop redundant JournalError = JournalError self-assignment; add JournalError to __all__ so the re-export stays explicit for callers
#2472 src/bernstein/core/persistence/journal_publish.py:136 FURB123 dict(row) -> row.copy()
#2473 src/bernstein/core/persistence/lineage_signer.py:223 FURB123 list(parents) -> parents.copy()
#2465 src/bernstein/eval/incident_synthesizer.py:756 FURB124 collapse raw[0] == '"' and raw[-1] == '"' into chained raw[0] == '"' == raw[-1]

Behaviour

Unchanged. Each .copy() produces the same shallow-copy semantics as the explicit list(...) / dict(...) constructor. The chained comparison evaluates identically for two-character bounds. The JournalError re-export remains available via the top-of-file import; adding it to __all__ documents the public surface explicitly.

Test plan

  • uv run refurb on the 5 touched files is clean.
  • uv run pytest tests/unit/ -q --no-cov --timeout=120 -k "journal or lineage_signer or incident_synthesizer" - 104 tests pass.
  • uv run ruff check . --fix && uv run ruff format . - all checks passed, no formatting drift.
  • uv run pyright on the 5 touched files - error count unchanged versus origin/main baseline (53/53; all pre-existing).

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of quoted strings in YAML parsing.
  • Documentation

    • Added schedule command to documented CLI commands list.
  • Refactor

    • Updated internal list copying methods across persistence modules.

Review Change Stack

…+ eval (cluster C)

Address 7 refurb alerts across 5 files:

- journal.py:209 (#2468, FURB123): list(self.blob_refs) -> self.blob_refs.copy()
- journal_export.py:94 (#2469, FURB123): list(self.blob_digests) -> .copy()
- journal_export.py:108 (#2470, FURB123): list(self.blob_digests) -> .copy()
- journal_export.py:485 (#2471, FURB160): drop redundant JournalError = JournalError
  self-assignment; add JournalError to __all__ so the re-export stays
  explicit for callers.
- journal_publish.py:136 (#2472, FURB123): dict(row) -> row.copy()
- lineage_signer.py:223 (#2473, FURB123): list(parents) -> parents.copy()
- incident_synthesizer.py:756 (#2465, FURB124): collapse
  raw[0] == '"' and raw[-1] == '"' into the chained comparison
  raw[0] == '"' == raw[-1].

Behaviour unchanged: every .copy() returns the same shallow-copy
semantics the previous explicit-type constructor produced, and the
chained comparison evaluates identically for two-character bounds.

uv run pytest tests/unit/ -k "journal or lineage_signer or incident_synthesizer"
passes (104 tests). refurb is clean on the five touched files.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @chernistry, you have reached your weekly rate limit of 2500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chernistry chernistry enabled auto-merge (squash) May 21, 2026 21:01
@github-actions

Copy link
Copy Markdown
Contributor

Sonar insights (advisory, no merge-block)

Snapshot of bernstein on the configured Sonar instance:

Metric Value
Coverage 13.5
Code smells 151
Bugs 11
Vulnerabilities 2
Security hotspots 91

Run bernstein doctor sonar locally for the full surface.

This comment is a soft signal. The Sonar scan runs on push to main; the PR check itself never fails on smells.

@github-actions github-actions Bot added the core label May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Review-bot acknowledgement summary

  • Must-address findings: 0 (0 acknowledged, 0 open)
  • Informational findings: 0

All must-address findings are resolved or acknowledged.

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@chernistry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 38 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3c85c97a-34f7-406c-92c9-9998627929c2

📥 Commits

Reviewing files that changed from the base of the PR and between e0b9317 and d8d0799.

📒 Files selected for processing (1)
  • tests/unit/test_journal_chain.py
📝 Walkthrough

Walkthrough

PR consolidates shallow copy patterns across persistence and eval modules by replacing type constructors (list(), dict()) with .copy() methods in five locations, adds JournalError to module exports, updates CLI documentation test expectations, and simplifies a quoted-scalar detection condition.

Changes

Code style and API surface updates

Layer / File(s) Summary
Shallow copy method consolidation across persistence
src/bernstein/core/persistence/journal.py, src/bernstein/core/persistence/journal_export.py, src/bernstein/core/persistence/journal_publish.py, src/bernstein/core/persistence/lineage_signer.py
Five functions replace shallow copy constructors with .copy() methods: JournalEntry.to_dict() (line 209), ReceiptManifest.canonical_bytes() (lines 91–96), ReceiptManifest.to_json() (lines 105–110), _redact_row() (line 136), and register_attachment_parents() (line 223).
API export and test expectations
src/bernstein/core/persistence/journal_export.py, tests/unit/test_readme_api_coverage.py
journal_export.__all__ (lines 475–482) now explicitly exports JournalError; test_readme_api_coverage.py (lines 242–243) adds "schedule" to DOCUMENTED_COMMANDS allowlist.
YAML quoted-scalar detection simplification
src/bernstein/eval/incident_synthesizer.py
_source_incident_from_yaml() (lines 753–758) uses chained equality raw[0] == '"' == raw[-1] instead of separate boolean checks to detect double-quoted scalars.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

tests

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: refurb linter cleanups across five files in persistence and eval subsystems.
Description check ✅ Passed The PR description comprehensively documents what was changed, why, and how—including a detailed alerts table, behavior notes, and test results—but does not follow the provided template structure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/code-scanning-cluster-c

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

bernstein doctor observe for PR #1813 (fix/code-scanning-cluster-c): ok=0, warn=2, fail=0, error=0, skipped=2

sonar -- WARN (project bernstein)

metric value delta threshold status
coverage_pct 13.5% new 80.0% fail
code_smells 151 new 50 warn
bugs 11 new 0 fail
vulnerabilities 2 new 0 warn
security_hotspots 91 new 0 fail

code-scanning -- WARN (40 open alert(s))

metric value delta threshold status
open_alerts 40 new 0 fail
critical_alerts 0 new 0 ok
high_alerts 2 new 0 warn
medium_alerts 0 new - ok
low_alerts 0 new - ok
Skipped backends (credentials not configured)
  • glitchtip: BERNSTEIN_GLITCHTIP_TOKEN not set
  • dt: DTRACK_URL/TOKEN/PROJECT not set

See docs/observability/unified-doctor.md for backend setup notes.

github-actions Bot and others added 2 commits May 21, 2026 21:02
Auto-applied by contract-drift-autofix.yml on PR #1813.
Regenerated via scripts/regen_contract_drift.py. Refs #1273.

Source CI run: https://github.com/sipyourdrink-ltd/bernstein/actions/runs/26252897437
The typos check on PR #1813 fails on a pre-existing comment in
tests/unit/test_journal_chain.py:457 ("writeable" -> "writable"). Fix
it in the same PR so cluster-C can land.
@github-actions github-actions Bot added the tests label May 21, 2026
@chernistry chernistry merged commit 2242d16 into main May 21, 2026
66 of 67 checks passed
@chernistry chernistry deleted the fix/code-scanning-cluster-c branch May 21, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant