Skip to content

The opening writer's marks refuse a re-bound path, a shadowed opened or request, and an unformatted path, and assume good faith (#868, record 0215) - #870

Merged
don-petry merged 4 commits into
mainfrom
claude/opening-writer-fail-open
Nov 14, 2026
Merged

don-petry merged 4 commits into
mainfrom
claude/opening-writer-fail-open

Conversation

@don-petry

@don-petry don-petry commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #868

This is the follow-on to #819, record 0215. tools/check_authority.py holds that a configuration names no Role to open pull requests until open_pull_request has its writer, read as three marks in the code's syntax. The check fails closed on what it can't read. Reviewers of #819 found six ways crafted code could pass the marks without a real writer, and reviewers of this PR found seven more. All are refused here. #819 merged first so records 0216 to 0221 kept their approvals. The gaps were unreachable meanwhile, because no opening Role is named.

What is refused now

  • A name counts only when it is bound once, directly in its own scope's body. Not when it is nested in a def, lambda, class or comprehension, under an if, loop, try or with, rebound, augmented, deleted, or used as a target. That holds for the path and the verb alike.
  • The path counts only when it is formatted once, from a function parameter that nothing else binds, or that parameter's attribute: '/repos/%s/pulls' % repo, or an f-string with one plain hole. A bare literal, a literal or computed value, any tuple, a conversion or a format spec are refused.
  • request counts only as adapters.github's: from adapters.github import request [as X], from adapters import github, or import adapters.github as G, at the module's top and bound nowhere else.
  • opened counts the same way. In harness/apply.py it counts only through an undecorated top-level def opened.
  • Attributes: setting, augmenting or deleting an attribute of any of those names counts as rebinding it.
  • The opener: a decorated or rebound opener function is not read.
  • Dynamic names: a module that names globals, locals, vars, setattr, delattr, exec, eval, compile, __import__, importlib, modules, __dict__ or __builtins__ is not read.
  • Live code only: calls count only in the function's own live code, never in nested scopes or after a return or raise.

Record 0215 gains one Boundaries row, and no existing row changes. The row names the test, the check and the mutants. It states what syntax can't hold:

  • a request built and not sent;
  • a parameter that holds a tuple;
  • calls in different flows;
  • the class the Factory Builder ruled out of code on 2026-11-14: "the marks are syntax, and assume code written in good faith; a crafted evasion is for the reviewers and the Maintainer's hand approval of the naming to catch". Its examples are a from-import of importlib, calls in postponed annotations, an alias's attribute rebound, and a method rebound in its class.

Findings of that class are declined with the row cited.

Held by

  • The test: tests/test_tools.py::test_a_role_named_to_open_pull_requests_waits_on_its_writer gains each crafted refusal, plus the accepted forms.
  • Mutants: all 137 of tools/check_authority.py and tools/check_examples.py are killed, and 30 of them are new.
  • make checks: passes on this head, with main merged in.

Second readers

Reader Head Result
Kimi af0bbc2 2 findings, 2 taken: a nested-scope binding, a tuple behind a name
Astra af0bbc2 3 findings, 3 taken: the same two, plus a module's attribute replaced
Claude + security af0bbc2 5 fail-opens taken: scope lookup, the formatted value, attribute replacement, a decorated or rebound opener, dynamic rebinding. Dead and nested code was taken too. "Built but not sent" is written into the limit
Kimi 37562b0 3 findings. One taken: a decorated opened in apply.py. Two declined into the limit: an importlib from-import, postponed annotations
Astra 37562b0 5 findings. The decorated opened taken. The rest declined into the limit as crafted evasions, per the ruling: an importlib from-import, annotations, an alias's attribute, a method rebound in its class
Carbon — not run: this week's quota goes to the S3 stack first. Owed
Muse — not run (quota: the window resets 2026-11-16). Owed

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

don-petry and others added 4 commits November 13, 2026 19:29
…e-bound, a request or an opened shadowed, and a path not formatted (#868, record 0215)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…matted in, and not where a name is rebound unseen (#868, record 0215)

The second reviews of PR 819 found seven more ways the marks failed open. A name is read only from `name = ` in its
scope's own body, and a module's value in the module. The value formatted into the path is a parameter given once,
or its attribute. An attribute or an item set on request's module, apply or harness rebinds that name. An opener
decorated or named again is not the def. A module naming globals, setattr, exec, sys.modules and the like is not
read. A call in a nested def, lambda, class or comprehension, or after a return or a raise, is not made. Record
0215's new row says what the syntax cannot hold: a request built and never sent, and a parameter holding a tuple.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd record 0215 says the marks assume good faith (#868, record 0215)

The Factory Builder's ruling. A decorator over the top-level def may replace opened, so a decorated one fails closed.
Four further evasions stay unfixed by design: importlib by a from-import, a call in a postponed annotation, an
attribute set through another name for a module, and a method rebound in its class. The record's row names them as
examples: the marks are syntax and assume code written in good faith; a crafted evasion is for the reviewers and the
Maintainer's hand approval of the naming to catch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@don-petry
don-petry requested a review from a team as a code owner November 14, 2026 02:00
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codeant-ai

codeant-ai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #37d45 Reviewed your PR 5461756 Nov 14, 2026 · 02:00 02:09

@codeant-ai

codeant-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T02:02:50.486105Z 5461756 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sonarqubecloud

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the static analysis tool tools/check_authority.py and its corresponding decision documentation to enforce stricter rules on how pull requests are opened and recorded. It introduces checks for dynamic name rebinding (using a new _dynamic helper to detect functions like eval, exec, and importlib), restricts scope traversal to the current scope's own body, and refines parameter and import tracking. A security review comment points out that the _dynamic check can be bypassed using from importlib import ... style imports because ast.ImportFrom nodes are not checked for their module attribute, and suggests a fix to include n.module in the scanned words.

Comment thread tools/check_authority.py Resolved
Comment thread tools/check_authority.py Resolved

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread tools/check_authority.py Resolved
Comment thread tools/check_authority.py Resolved
@codeant-ai

codeant-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

5 code suggestions

1. An async function's body runs only when its coroutine is awaited; an un-awaited call can still satisfy the writer or opening-record check.

Incomplete implementation · tools/check_authority.py:65-66


2. _own walks annotation fields as function code; with postponed annotations, a request(...) there is never called but can satisfy the writer check.

Incorrect condition logic · tools/check_authority.py:76-77


3. A return inside try does not stop this outer traversal, so a write after the try is counted even though it cannot run.

Incorrect condition logic · tools/check_authority.py:80-82


4. _written accepts assignments regardless of order, so a request before its local path assignment is counted although it raises UnboundLocalError at runtime.

Logic error · tools/check_authority.py:147-149


5. request() only builds a request dictionary; an unused /pulls request passes here even if the function sends another endpoint, so no pull request is opened.

Api mismatch · tools/check_authority.py:189-190

@codeant-ai

codeant-ai Bot commented Nov 14, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 5461756d7f94

@combsmith-sf-pr-review combsmith-sf-pr-review 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.

No findings: each of issue 868's six fail-open marks is refused, with test cases and mutants.

@don-petry
don-petry added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit 24ff2a1 Nov 14, 2026
33 checks passed
@don-petry
don-petry deleted the claude/opening-writer-fail-open branch November 14, 2026 02:40
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.

The opening writer's marks refuse a re-bound path, a shadowed opened or apply, a local request, and an unformatted or converted pulls path

2 participants