← Back to Pull requests

test(audit-ship e2e): wait on the metrics file's content, not one read after the stream grows #312

Merged
jobordu merged 1 files (18 lines) on Oct 04, 2026 01:43 UTC
View on GitHub
jobordu jobordu commented on Oct 04, 2026 01:27 UTC
Author

Fixes #311. The audit-ship e2e's metrics check failed once on #304's run and passed on re-run (reported by regalia-kms-24 and 3e).

Cause: the shipper writes /var/lib/regalia-audit-ship/sync.prom after the collector's receipt comes back, which is after the collector's stream has grown. Each check waited for the stream to reach N lines and then read the metrics file once, so it could still see the previous pass's numbers.

Fix: the three metrics checks now wait, for up to 30 s each, until the file holds exactly what they assert:

  • step 2: 5 committed, not tampered;

  • step 2b: 6 committed, not tampered, under the new certificate. This check now also asserts the committed count, not only "not tampered";

  • step 3: tampered.
  • Only the test changes.

    Read by regalia-kms-24 at f90457b, no hold. Its optional nit, that the shipper should write the textfile temp-then-rename, is already true: cmd/regalia-audit-ship/main.go:427-447 writes with CreateTemp in the same directory, then Rename.

    🤖 Generated with Claude Code

    Diff: 18 lines (+13 / -5) across 1 files Reviewer: jobordu Review duration: 16m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.35) × (1 − Review Confidence (0.80)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 18 lines diff across 1 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    79%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.176
    Self Review self_review
    0.140
    Real PR Conversation Timeline
    11 items
    coderabbitai[bot] coderabbitai[bot] commented on Oct 04, 2026 01:27 UTC
    Bot

    <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
    <!-- This is an auto-generated comment: rate limited by coderabbit.ai -->

    [!WARNING]

    ## Review limit reached

    > You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

    > Next included review available in 52 minutes.

    > Check out review usage here.

    > <details>

    <summary>View limit details</summary>

    > Limit details: You’ve used the included review currently available.

    > Learn how review limits work.

    > Review configuration:

    > <details>

    <summary>⚙️ Run configuration</summary>

    > - Configuration used: defaults

    - Review profile: CHILL

    - Plan: Advanced

    - Run ID: 47d6a69a-caf5-47ae-9cdb-f42e8621e932

    > </details>

    > <details>

    <summary>📥 Commits</summary>

    > Reviewing files that changed from the base of the PR and between 635e187df72efdc1b4972ef2afce76bae192ddb1 and f90457b8a35bc08c2841d217695385a6c02d80e5.

    > </details>

    > <details>

    <summary>📒 Files selected for processing (1)</summary>

    > * e2e/audit-ship-systemd.py

    > </details>

    > </details>

    <!-- end of auto-generated comment: rate limited by coderabbit.ai -->

    <!-- autopilot:start -->

  • <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

  • <!-- autopilot:end -->
    <!-- tips_start -->

    ---

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    gitar-bot[bot] gitar-bot[bot] commented on Oct 04, 2026 01:27 UTC
    Bot

    [!IMPORTANT]

    You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

    <sub>Gitar</sub>

    sentinel-by-digital-frontier[bot] sentinel-by-digital-frontier[bot] commented on code on Oct 04, 2026 01:27 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:135</code>

    These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.

    _Pre-existing — not introduced by this diff. This pull request changes the file, but not line 135, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._

    <!-- sentinel:finding:37f79a4e5c40e488:26a7b2040664ec1b -->

    sentinel-by-digital-frontier[bot] sentinel-by-digital-frontier[bot] commented on code on Oct 04, 2026 01:27 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:142</code>

    These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.

    _Pre-existing — not introduced by this diff. This pull request changes the file, but not line 142, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._

    <!-- sentinel:finding:671d1ca8d39b91e8:26a7b2040664ec1b -->

    sentinel-by-digital-frontier[bot] sentinel-by-digital-frontier[bot] commented on code on Oct 04, 2026 01:27 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    🟡 Medium · insecure file permissions <code>e2e/audit-ship-systemd.py:255</code>

    These permissions '0o755' are widely permissive and grant access to more people than may be necessary. A good default is '0o644' which gives read and write access to yourself and read access to everyone else.

    _Pre-existing — not introduced by this diff. This pull request changes the file, but not line 255, so the finding cannot be commented on the line itself. Resolve this thread once it is fixed or judged not to apply._

    <!-- sentinel:finding:84ccad4764979faa:26a7b2040664ec1b -->

    sentinel-by-digital-frontier[bot] sentinel-by-digital-frontier[bot] commented on Oct 04, 2026 01:27 UTC
    Reviewer

    🛡️ Sentinel review — 3 pre-existing issue(s) in changed files, on lines this diff does not add.

    <details><summary>📋 Walkthrough</summary>

    0 file(s) with findings on changed lines.

    | Signal | Count | Confidence |
    |---|---|---|
    | Tool-proven findings | 0 | deterministic scanners |
    | Model findings (corroborated) | 0 | independent panel agreed |
    | Model findings (unverified) | 0 | shown collapsed, not inline |
    | Nitpicks & observations | 0 | collapsed, no action needed |

    <!-- flynn:rid:om-688168c590044e3c92456775c8bd3c6d -->
    _Reviewed by <code>flynn</code> · panel requested, not applied — fell back to the single-model gate._

    </details>

    <!-- sentinel-pr-review engine=4f28185e72a56658a0a5c68cead30c12f60eea85-main -->
    <!-- sentinel:scan-report -->
    <details><summary>📊 Scan report — every finding in the changed files, ranked, plus the scan summary</summary>

    🛡️ Sentinel PR review

    1 file(s) changed · 3 introduced by this diff (secrets+SAST) · dependencies unchanged — SCA/CVE not re-scanned. _Advisory — the fail-closed gate is the post-merge pentest._

    Findings — ranked by criticality

  • 🟡 [MEDIUM · SAST] e2e/audit-ship-systemd.py:135 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_

  • 🟡 [MEDIUM · SAST] e2e/audit-ship-systemd.py:142 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_

  • 🟡 [MEDIUM · SAST] e2e/audit-ship-systemd.py:255 — insecure file permissions These permissions 0o755 are widely permissive and grant access to more people than may be necessary. A good default is 0o644 which gives read and write access to yourself and read access to everyone else. _(CWE-276)_
  • 🤖 Code review (Flynn)

    No issues found.

    <details><summary>Scan summary</summary>

    | Category | Scope | Findings |
    |---|---|---|
    | Secrets | this diff | 0 |
    | Static analysis | changed files | 3 |
    | Dependencies + IaC | skipped (no manifest changed) | 0 |
    | Known CVEs | skipped (no manifest changed) | 0 |

    </details>

    </details>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 04, 2026 01:27 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

    jobordu jobordu commented on code on Oct 04, 2026 01:42 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    0o755 on the trail's directory (/var/log/regalia stands in, a directory): the trail inside it is 0640 in its reader group, which this test checks. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).

    jobordu jobordu commented on code on Oct 04, 2026 01:42 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    0o755 on the shipper binary: it must be executable. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).

    jobordu jobordu commented on code on Oct 04, 2026 01:42 UTC
    Code Review
    e2e/audit-ship-systemd.py:1

    0o755 on the test's work directory, which the service users must traverse. Not a line this PR changes. A directory mode, not a finding: resolving (with its duplicates).

    Reviewers
    Assignees
    jobordu jobordu
    Labels
    risk: low confidence: 80.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 34.6% (LOW) · Higher = larger blast radius
    34.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 80.0% · Lower = rushed or shallow review
    80.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.9% · Safe to merge
    6.9%