← Back to Pull requests

test: clear the python CodeQL results that turned main red #667

Merged
wallstop merged 2 files (25 lines) on Nov 29, 2026 05:22 UTC
View on GitHub
wallstop wallstop commented on Nov 29, 2026 05:10 UTC
Author

Description

Red-main fix-forward. CI - CodeQL run 46225272808 (scheduled Sunday run, main at fbb6b734) failed the Fail on CodeQL findings step with seven python results in two test files. The workflow's jq allow-list only acknowledges four actions results on .github/workflows/ci-release-state.yml, so every python result fails the gate.

All seven are false positives in test-only code, and the fix follows the #526 precedent: change the test source so the query stops modelling it, without touching production code or any assertion's intent.

| Result | Location | Why it fires | Fix |
| --- | --- | --- | --- |
| py/overly-permissive-file ×5 | scripts/tests/test_session_budget.py, the five os.open fakes | the fake's forwarded mode defaulted to the stdlib 0o777 | documented OPEN_FALLBACK_MODE = 0o600 constant |
| py/incomplete-url-substring-sanitization ×2 | scripts/tests/test_vscode_github_token.py:627,696 | assert "https://github.com" in captured.err looks like URL sanitization | exact stderr equality (stricter assertion) |

The os.open fakes only forward the mode production passes (session-budget.py always passes 0o600); their only two-argument call opens an existing directory, where the mode is ignored. No test was deleted, skipped, or weakened — two assertions became stricter, and the focused suites and full scripts/tests lane are unchanged in count.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

  • ✨ New feature (non-breaking change that adds functionality)

  • 💥 Breaking change (fix or feature that would cause existing functionality to change)

  • 📚 Documentation (changes to documentation only)

  • ♻️ Refactor (code change that neither fixes a bug nor adds a feature)

  • 🧪 Test (adding or updating tests)

  • 🔧 CI/Build (changes to CI configuration or build process)
  • Verification Impact

  • none — no mapped production path or symbol changed (python3 scripts/verification/model-impact.py affected --base origin/main → "No mapped verification impact")

  • updated: <spec/proof>

  • waived: <reason + approver>
  • Any new or changed proof has a RED mutation or a non-vacuity witness (N/A)
  • Checklist

    Required

  • I have read the [CONTRIBUTING guide](../docs/contributing.md)

  • I have followed the zero-panic policy (no Rust or production Python changed)

  • I have added tests that prove my fix is effective (existing tests are unchanged and still run; the differential evidence is the CodeQL red/green pair below)

  • I have run cargo fmt && cargo clippy --workspace --all-targets --features tokio,json with no warnings

  • I have run cargo nextest run and all tests pass
  • If Applicable

  • I have updated the documentation accordingly (test-only)

  • I have added an entry to CHANGELOG.md for user-facing changes (test-only; not required)

  • I have updated relevant examples in the examples/ directory (N/A)

  • My changes generate no new compiler warnings
  • Testing

    Red (before, main fbb6b734, run 46225272808):

    Analyze (python) failure — step 6 "Fail on CodeQL findings" exit 1
    python.sarif results: 7
      py/incomplete-url-substring-sanitization  scripts/tests/test_vscode_github_token.py:627
      py/incomplete-url-substring-sanitization  scripts/tests/test_vscode_github_token.py:696
      py/overly-permissive-file                 scripts/tests/test_session_budget.py:297,330,377,559,892
    

    Green (this branch head 4f380741, dispatched run 46227765435):

    Analyze (actions) success
    Analyze (python)  success — step 6 "Fail on CodeQL findings" success
    python.sarif results: 0
    

    Local validation:

    | Check | Result |
    | --- | --- |
    | .venv/bin/python -m pytest scripts/tests/test_vscode_github_token.py scripts/tests/test_session_budget.py -q | 121 passed (same before/after) |
    | .venv/bin/python -m pytest scripts/tests -q | 2687 passed, 1 skipped |
    | cargo fmt --all -- --check | pass |
    | cargo c (clippy, workspace/all-targets, tokio+json) | clean |
    | cargo tf | 3020 passed, 512 skipped |
    | cargo tfull | 3821 passed, 77 skipped, 0 failed (35.3s) |
    | cargo test --doc | 160 passed, 52 ignored |
    | RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --features hot-join,tokio,json,sync-send --document-private-items | pass |
    | .venv/bin/python scripts/ci/agent-preflight.py --full --auto-fix | all checks passed |
    | .venv/bin/ruff check on both files | pass |

    Tests added/modified: two URL assertions tightened from substring to exact equality; five fake os.open defaults changed. No test added or removed; test counts are identical.

    Manual testing performed: none beyond the checks above.

    Risks and rollback

  • Risk: the os.open fakes' fallback no longer mirrors the stdlib default. Production always passes 0o600 to os.open (scripts/ci/session-budget.py:107,227,231), and the only two-argument call opens an existing directory where the mode is ignored.

  • Risk: CodeQL's python queries are versioned; a future query set can flag new test-only patterns. Tracked in the follow-up issue for schedule-only coverage.

  • Rollback: git revert the squash commit; the seven results return and the gate goes red again.
  • Related Issues

  • Red main: CI - CodeQL run 46225272808 on fbb6b734

  • Precedent: #526 (test-only CodeQL rust/cleartext-logging false positive)
  • Diff: 25 lines (+18 / -7) across 2 files Reviewer: github-actions[bot] Review duration: 12m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.24) × (1 − Review Confidence (0.75)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.24 · 25 lines diff across 2 files
    0.24
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.65 · 1 substantive comment(s)
    0.65
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    75%
    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.195
    Real PR Conversation Timeline
    5 items
    github-actions[bot] github-actions[bot] commented on Nov 29, 2026 05:10 UTC
    Reviewer

    DISCLOSURE: LLM-GENERATED TEXT

    OpenAI review: 0 findings.

    No defects found in the diff. The changed defaults and exact stderr assertions preserve the described test behavior while addressing the reported CodeQL findings.

    <sub>3913 in, 603 out tokens. Comments only; this review never blocks a merge.</sub>

    <!-- openai-review-run: {"v":2,"workflow_sha":"5aabfe60ec294f8160b70d0a712c561db5e3fa29","coverage":"full-eligible-diff","duration_seconds":7.831,"cache_write_tokens":3910,"cache_write_tokens_details":{"ttl_12h_tokens":0,"ttl_30m_tokens":3910},"model":"gpt-6-luna","effort":"default","input_tokens":3913,"output_tokens":603,"reasoning_tokens":560,"findings":0,"inline":0,"diff_chars":3765,"dropped_files":0,"cached_tokens":0,"unchanged_files":0,"usage_complete":true,"reported_models":["gpt-6-luna"]} -->

    <!-- openai-review:4f3807417b16be9f81cb877484614c6565468539 -->

    coderabbitai[bot] coderabbitai[bot] commented on Nov 29, 2026 05:10 UTC
    Bot

    <!-- coderabbit-ai-generated:v1 -->

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

    <a href="https://app.coderabbit.ai/change-stack/Ambiguous-Interactive/fortress-rollback/pull/667?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>

    <!-- review_stack_entry_end -->
    <!-- recent_review_start -->

    No actionable comments were generated in the recent review.

    <!-- review_details_start -->

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review details</strong></summary>
    <dl>
    <dd>
    <br>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/clock-alert-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/clock-alert.svg" width="16" height="16" align="absmiddle" alt=""></picture> Context from checks skipped due to timeout: 4</strong></summary>
    <dl>
    <dd>
    <br>

    GitHub Check: CodeRabbit
    GitHub Check: Fast Gate (Linux)
    GitHub Check: Analyze (rust)
    GitHub Check: Script Tests & Wiki Dry-Run

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/layers-plus-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/layers-plus.svg" width="16" height="16" align="absmiddle" alt=""></picture> Additional context used</strong></summary>
    <dl>
    <dd>
    <br>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/book-open-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/book-open.svg" width="16" height="16" align="absmiddle" alt=""></picture> Code guidelines: 2</strong></summary>
    <dl>
    <dd>
    <br>

    .agents/skills/scripting/SKILL.md — Agent Skill
    .agents/skills/performance/SKILL.md — Agent Skill
    

    </dd>
    </dl>
    </details><details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/route-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/route.svg" width="16" height="16" align="absmiddle" alt=""></picture> Path-based instructions: 2</strong></summary>
    <dl>
    <dd>
    <br>

    <details>
    <summary><strong>Source excerpt: Remove unused imports -- linters flag as errors Source excerpt: Prefix unused variables with _ (e.g., _link_text = match.group(1)) Source excerpt: Type hints on all function signatures Source excerpt: path...</strong></summary>
    <dl>
    <dd>
    <br>

    CodeRabbit inference engine (.agents/skills/scripting/SKILL.md)

    Files:

  • scripts/tests/test_session_budget.py

  • scripts/tests/test_vscode_github_token.py
  • </dd>
    </dl>
    </details>
    <details>
    <summary><strong>Source excerpt: | Technique | Impact | Notes | |-----------|--------|-------| | Faster linker (mold/lld) | 2-10x linking | Always use if available | Source excerpt: | Technique | Impact | Notes | |-----------|--------|-------| | Remove unus...</strong></summary>
    <dl>
    <dd>
    <br>

    CodeRabbit inference engine (.agents/skills/performance/SKILL.md)

    Files:

  • scripts/tests/test_session_budget.py

  • scripts/tests/test_vscode_github_token.py
  • </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/message-square-off-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/message-square-off.svg" width="16" height="16" align="absmiddle" alt=""></picture> Additional comments: 1</strong></summary>
    <dl>
    <dd>
    <br>

    <details>
    <summary><strong>scripts/tests/test_session_budget.py: 1</strong></summary>
    <dl>
    <dd>
    <br>

    36-36: Functional Correctness

    The os.open fakes default to 0o600, which matches every creating call in the reachable lock path. Those calls pass an explicit mode (session-budget.py:107, 227-229, 231-235). The only omitted-mode call, at line 173, opens an existing directory without O_CREAT, so its mode is ignored. The claimed permission mismatch cannot occur on these paths.

    <!-- cr-comment:v1:69edd2dfffff7243fd9ed4cc -->

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- review_details_end -->

    <!-- recent_review_end -->
    <!-- walkthrough_start -->

    <details>
    <summary><strong>Walkthrough</strong></summary>
    <dl>
    <dd>
    <br>

    The changes update session-budget test fakes to use a shared 0o600 fallback mode. Two askpass tests now assert the complete error message for rejected prompts.

    Changes: Python Test Updates

    |Layer / File(s)|Summary|
    |:---|:---|
    |
    Lock-owner open-mode test assumptions <br>
    scripts/tests/test_session_budget.py|Mocked os.open functions use OPEN_FALLBACK_MODE (0o600) as their default mode.|
    |
    Askpass rejection assertions <br> scripts/tests/test_vscode_github_token.py|Tests for non-GitHub prompts and malformed URLs assert the complete error text, including its error: prefix and newline.|

    Estimated code review effort: 2 (Simple) | ~10 minutes

    Possibly related issues

  • Issue 668: These test changes address the Python test findings described in the issue. They do not change the CodeQL schedule or gate.
  • Possibly related PRs

  • Ambiguous-Interactive/fortress-rollback#590: This PR removes the Session Budget checker and tests, including the file changed here.

  • Ambiguous-Interactive/fortress-rollback#560: This PR defines the resolver error messages that the updated askpass tests assert.
  • </dd>
    </dl>
    </details>

    <!-- walkthrough_end -->
    <details>
    <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>d9b88</code></summary>
    <dl>
    <dd>
    <br>

    <!-- final_review_risk_start -->
    <!-- final_review_risk_label
    Merge Risk: ⚪ Minimal · up to
    d9b88`
    -->
    <!-- final_review_risk_coverage:{"sourceCommitId":"d9b8848393e5aa5af1aac027419f2f6bc768cc07","coveredCommitId":"d9b8848393e5aa5af1aac027419f2f6bc768cc07","kind":"reviewed"} -->

    This is a test-only fix for static-analysis findings. It does not change runtime behavior and no actionable merge risk remains.
    <!-- final_review_risk_end -->

    </dd>
    </dl>
    </details>
    <!-- pre_merge_checks_walkthrough_start -->

    <details>
    <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
    <dl>
    <dd>
    <br>

    | Check name | Status | Explanation |
    | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Title check | !Passed | The title names the main change: it clears the Python CodeQL results that made main's CI red. The changeset edits only two test files, changing os.open fake defaults and tightening URL assertions to a… |
    | Description check | !Passed | The description states the purpose (fixing seven Python CodeQL findings that failed the gate on main), lists each affected location and the fix, and explains risks, validation, and rollback. It matche… |
    | 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. |

    <details>
    <summary><strong>Full details: Title check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation

    The title names the main change: it clears the Python CodeQL results that made main's CI red. The changeset edits only two test files, changing os.open fake defaults and tightening URL assertions to address those seven findings, so the title matches the primary intent. It is a conventional test: prefix, 58 characters, one sentence.

    </dd>
    </dl>
    </details>

    <details>
    <summary><strong>Full details: Description check</strong></summary>
    <dl>
    <dd>
    <br>

    Explanation**

    The description states the purpose (fixing seven Python CodeQL findings that failed the gate on main), lists each affected location and the fix, and explains risks, validation, and rollback. It matches the changeset, which modifies the os.open fakes in scripts/tests/test_session_budget.py and the askpass assertions in scripts/tests/test_vscode_github_token.py.

    </dd>
    </dl>
    </details>

    </dd>
    </dl>
    </details>

    <!-- pre_merge_checks_walkthrough_end -->
    <!-- autopilot:start -->

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

  • <!-- autopilot:end -->

    github-actions[bot] github-actions[bot] commented on Nov 29, 2026 05:11 UTC
    Reviewer

    DISCLOSURE: LLM-GENERATED TEXT

    OpenAI review: 0 findings.

    No actionable defects found.

    <sub>3745 in, 335 out tokens. Comments only; this review never blocks a merge.</sub>

    <!-- openai-review-run: {"v":2,"workflow_sha":"5aabfe60ec294f8160b70d0a712c561db5e3fa29","coverage":"full-eligible-diff","duration_seconds":7.364,"cache_write_tokens":3742,"cache_write_tokens_details":{"ttl_12h_tokens":0,"ttl_30m_tokens":3742},"model":"gpt-6-luna","effort":"default","input_tokens":3745,"output_tokens":335,"reasoning_tokens":314,"findings":0,"inline":0,"diff_chars":3313,"dropped_files":0,"cached_tokens":0,"unchanged_files":0,"usage_complete":true,"reported_models":["gpt-6-luna"]} -->

    <!-- openai-review:d9b8848393e5aa5af1aac027419f2f6bc768cc07 -->

    coderabbitai[bot] coderabbitai[bot] approved these changes on Nov 29, 2026 05:15 UTC
    Approved Reviewer

    Approved these changes.

    Assignees
    wallstop wallstop
    Labels
    risk: low confidence: 75.5% 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: 23.9% (LOW) · Higher = larger blast radius
    23.9%
    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: 75.5% · Lower = rushed or shallow review
    75.5%
    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: 5.9% · Safe to merge
    5.9%