GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix gem source-block detection for multi-line and brace openers (#1509) by mikolalysenko · Pull Request #1520 · SocketDev/socket-patch

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 14, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

LLM Description written by Claude Code:claude-opus-5-5

Fixes #1509

Summary

A gem declared inside the user's own source block keeps its ! pin
through hosted rollback / remove (#1056). That only worked for the
one-line source "…" do spelling. Two other valid spellings lost the
!, and Bundler 4.0.19+ then refused every frozen install of the
restored pair (exit 16):

  • a source( opener whose arguments span lines before ) do
  • a source("…") { … } brace block, which also came back with the gem
    at column 0 after an extra blank line

Root cause

block_stack in crates/socket-patch-core/src/patch/redirect/upstream/gem.rs
is the Gemfile scanner behind both the ! check (in_source_block) and the
restored declaration's indent (declaration_prefix). It ended a statement
at the end of any line not ending in an operator, so an unclosed ( didn't
keep the source statement open until its do. It also never opened a
frame for { … }.

Fix

  • A statement stays open while a (, [ or hash { is unclosed, and
    remembers that it began with source until its block opens. The do
    at depth 0 is the source's block.
  • { opens a frame that } closes. A { in expression position is a
    hash, which counts toward depth and has no frame. Only the brace block
    directly after the source(…) argument list is the source's, so in
    source ENV.fetch("S") { … } do the do is still the source block. A
    stray } never closes a do block.
  • Character literals (?(, ?}) are masked so they aren't read as
    brackets.
  • Frame records the line its opener sits on, so a gem restored first
    in a multi-line source( block gets no blank line after ) do.
  • Only the end of an unfinished line is carried forward, since that is
    all starts_expression reads. This keeps a long open bracket linear.

The second and third commits apply the /code-review high findings: the brace
binding, hash braces in arguments, a ; inside the argument list, stray
} and ?( literals, the multi-line opener's blank line, quadratic
carry, and a duplicate ident helper. The third commit fixes a review finding: a leading if inside an open bracket or -> { lambda now opens its own frame, and an open bracket only carries a source statement.

Tests (red → green)

Issue shape Test
#1509 multi-line source(…) do source_block_detection, source_block_declaration_keeps_its_bang_through_restore, e2e gem_hosted_unwind_keeps_a_source_block_bang (ScanVexSourceBlockMultiLineOpener, rollback + remove)
#1509 source(…) { } (! and indent) same unit tests, e2e ScanVexSourceBlockBraces (rollback + remove, lock and Gemfile byte-restored, frozen install)
  • Red, before the fix: both unit tests failed (assertion failed: at("source(\n \"https://x\"\n) do …"), and the restore lost the !: rails (= 7.0.0) vs rails (= 7.0.0)!). The e2e test failed on Bundler 4.0.22 with rollback: the lock comes back byte for byte, ! included and DEPENDENCIES\n vuln-gem (= 1.0.0) without the !.
  • Green, after the fix:
    • cargo test -p socket-patch-core --all-features --lib -- gem: 357 passed
    • cargo test -p socket-patch-cli --all-features --test e2e_redirect_gem_build -- --ignored (Ruby 3.3.6, Bundler 4.0.22): 30 passed
    • cargo fmt --all -- --check and cargo clippy --workspace --all-features -- -D warnings: clean
    • cargo test --workspace --all-features: couldn't finish locally: the session's disk allowance ran out linking every integration-test binary, so CI runs it. cargo test -p socket-patch-core --all-features --lib (all 6472) passes except 4 chmod-based permission tests (copy_tree::relax_loop_must_not_traverse_symlinked_root, vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry, pypi_poetry::wire_write_failure_…, pypi_requirements::wire_failure_rolls_back_…). Those can't fail as expected under uid 0 in this sandbox, and this diff doesn't touch them.

No wrapper changes: npm/, pypi/ and gem/ only dispatch to the binary.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hsu76uJiHbbPSV1iSeEukP


Generated by Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@claude
Start fix for #1509
466f92c
Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) force-pushed the agent/fix-gem-source-block-scanner branch from cb269c1 to 466f92c Compare October 14, 2026 04:23
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 14, 2026
Hosted gem rollback / remove strip the DEPENDENCIES ! when the user's source block opener spans lines or uses braces, so frozen installs fail on Bundler 4.0.19+ #1509
Closed
@claude
Keep gem source pins for multi-line and {} blocks
be61cfe
Hosted rollback and remove dropped the `!` source pin from a gem
declared inside a `source(...)` block whose arguments span lines, or
inside a `source("...") { ... }` brace block. Bundler 4.0.19+ then
refused every frozen install of the restored Gemfile.lock, and the
brace form also came back with the gem at the wrong indent.

The Gemfile block scanner now keeps a statement open while a `(` or
`[` is unclosed, remembers that the statement began with `source`
until its `do` or `{`, and tracks `{ }` blocks alongside `do ... end`.

Fixes #1509

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko Mikola Lysenko (mikolalysenko) mentioned this pull request Oct 14, 2026
Swarm health manager log #1382
Open
@claude
Tighten gem source-block brace and paren rules
7be2d98
A brace block now counts as the source's own block only right after
the `source(...)` argument list, so `source ENV.fetch(...) { ... } do`
keeps its `!` pin. Hash braces keep a statement open like parens, a
stray `}` no longer closes a `do` block, and `?(`-style character
literals are no longer read as brackets. A restored first gem in a
multi-line `source(` block no longer gets a blank line after the
opener. Only the end of an unfinished line is carried forward, so a
long open bracket no longer costs quadratic time.

Refs #1509

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 14, 2026 05:35
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Tanmay182003
Tanmay Singla (Tanmay182003) reviewed Oct 14, 2026
View reviewed changes
Comment thread crates/socket-patch-core/src/patch/redirect/upstream/gem.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@claude
Keep keyword blocks inside brackets in gem scan
943ec44
An `if` at the start of a line inside an open `(`, `[` or hash was
read as a modifier, so it opened nothing while its `end` still closed
the enclosing `source` block, and the gem lost its `!` pin on
rollback or remove. A stabby lambda's `-> {` was read as a hash.

A line that leaves only a bracket open now starts a fresh expression
on the next line, `-> {` opens a block, and an open bracket carries
only a `source` statement on to its block, so a bracket the scanner
misses elsewhere no longer hides every later source block.

Refs #1509

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Mikola Lysenko (mikolalysenko) commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

BugBot review


Generated by Claude Code

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 14, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 943ec44. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Tanmay182003
Tanmay Singla (Tanmay182003) approved these changes Oct 14, 2026
View reviewed changes
@mikolalysenko
Mikola Lysenko (mikolalysenko) added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit f1264cd Oct 14, 2026
54 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agent/fix-gem-source-block-scanner branch October 14, 2026 06:57
This was referenced Oct 14, 2026
CI perf (settings): slow Depot 16-core hosts since 10-13 15:20 add ~1.5–2.5 min to the merge-queue critical path (~0.6k Linux job-min/day) #1512
Open
Hosted gem rollback / remove strip the DEPENDENCIES ! when the user's source … do block opens after a ; on the same line, so frozen installs fail on Bundler 4.0.19+ #1531
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@Tanmay182003 Tanmay Singla (Tanmay182003) Tanmay182003 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Hosted gem rollback / remove strip the DEPENDENCIES ! when the user's source block opener spans lines or uses braces, so frozen installs fail on Bundler 4.0.19+

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@mikolalysenko @Tanmay182003 @claude
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.