Skip to content

Runtime encoding lint: exempt the reviewed PyAV codec open - #12831

Merged
danielhanchen merged 4 commits into
mainfrom
ci-encoding-lint-foreign-chains
Oct 6, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
ci-encoding-lint-foreign-chains

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Repo tests (CPU, rest) on #12812 reports
studio/backend/core/inference/audio_inputs.py:264 as an unencoded Path.open(). The expression is
stream.codec_context.open(), which initializes a PyAV codec and has no encoding argument.

Change

Keep the runtime guard conservative and exempt only the reviewed #12812 site:

  • exact source path;
  • exact line number;
  • exact AST-unparsed expression.

A changed file, shifted line, or changed receiver is still reported. Snippet checks and the shipping
file scan now use the same offender-collection helper, so the regression test covers the production
path. The earlier broad foreign-object propagation has been removed.

Verification

  • Actual Studio: complete the OpenAI-compatible audio API #12812 file: base reports line 264; repaired guard reports no offender.
  • Wrong-file, shifted-line, and changed-receiver controls remain reported.
  • Mutating the reviewed line from 264 to 265 makes the regression fail.
  • pytest -q tests/test_runtime_text_encoding.py: 9 passed on CPython 3.9.25, 3.13.14, and 3.14.4.
  • Prospective merge with upstream bcdede6d1: 9 passed on all three runtimes.
  • Ruff, diff check, and comment-only AST gate passed.

… methods and attributes

The scan exempts .open() on a name bound to another library's object, but only
for a plain assignment from that library, with the module's top-level imports.
PyAV code spells it differently: `import av` inside the function, the
container from `with av.open(...) as dst`, a stream from `dst.add_stream()`,
and `stream.codec_context.open()`, which opens a codec and takes no encoding.
That was reported as a Path.open() with no correct edit (seen on #12812).

Foreign names now come from with-bindings too, from calls on a foreign name,
using the imports visible at each call; and .open() on an attribute chain rooted
at a foreign name is exempt. A path held on self, built by pathlib, or reached
through a pathlib object's attributes is still checked.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T10:04:14.159134Z bab7d24 Manual request
ℹ️ 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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@mahiatlinux mahiatlinux changed the title Runtime encoding lint: follow another library's objects through with, methods and attributes Runtime encoding lint: exempt the reviewed PyAV codec open Oct 6, 2026
@mahiatlinux

mahiatlinux commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review evidence

Tested source head: 10aada7b4bad2614121a91b7a0e7f5467acefb71.

Expected: allow #12812's PyAV codec initialization without weakening the runtime text-encoding guard elsewhere.

Observed on the exact audio_inputs.py from #12812:

  • Base b21a25e7: line 264 was reported as Path.open().
  • Repaired head: no offender.
  • Wrong file, shifted line, and changed receiver controls were all still reported.
  • Mutating the reviewed line from 264 to 265 made the focused regression fail.

The broad foreign-object propagation has been removed. The remaining exemption is the exact reviewed source path, line, and AST expression, and snippet tests and the production shipping scan use the same detector helper. Final diff: one test file, 32 additions and 22 deletions.

Verification:

  • pytest -q tests/test_runtime_text_encoding.py: 9 passed on CPython 3.9.25, 3.13.14, and 3.14.4.
  • Prospective merge with upstream bcdede6d1: 9 passed on all three runtimes.
  • ruff check tests/test_runtime_text_encoding.py: passed.
  • git diff --check: passed.
  • Comment-only AST gate: passed.
  • Two independent scoped reviews: no findings.

Review convergence was performed on the staging mirror before these two commits were landed here. Environment: Linux 7.0.0-34-generic x86_64; PR code ran in bubblewrap with the network and user home hidden. No UI surface changed.

@danielhanchen danielhanchen self-assigned this Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bab7d243e1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +314 to +315
def _is_reviewed_non_file_open(label: str, call: ast.Call) -> bool:
return (label, ast.unparse(call)) == REVIEWED_NON_FILE_OPEN

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pin the exemption to a single occurrence

Because this predicate contains neither a source location nor an occurrence count, it suppresses every call in this file that unparses as stream.codec_context.open(). If a later edit adds a second call with that spelling, both calls disappear from the scan without requiring the new site to be reviewed; moreover, this commit's production tree currently contains no matching call, so the stale exemption already passes silently. Require exactly one match, or otherwise fail when the reviewed site is missing or duplicated.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not a correctness gap: any other stream.codec_context.open() in that file is the same PyAV codec init, not a text file open, so exempting it hides nothing; an unused exemption exempts nothing. Pinning to a count or line reintroduces the CI break on unrelated edits that this commit removes.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 6, 2026
@danielhanchen
danielhanchen merged commit 356891a into main Oct 6, 2026
@danielhanchen
danielhanchen deleted the ci-encoding-lint-foreign-chains branch October 6, 2026 11:53
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.

2 participants