Skip to content

ruff_ruby_spo: migration-replay codex fixes — skip def down bodies + parenthesized add_column (#73 follow-up)#74

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/openproject-transcode-status-c6e8in
Jul 10, 2026
Merged

ruff_ruby_spo: migration-replay codex fixes — skip def down bodies + parenthesized add_column (#73 follow-up)#74
AdaWorldAPI merged 1 commit into
mainfrom
claude/openproject-transcode-status-c6e8in

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Addresses the two codex P2 review comments on the merged #73, both in the post-baseline migration-replay (schema.rs).

1. Skip def down rollback bodies (#73 comment)

def up/def change describe the schema after the migration; def down reverses it. The replay was scanning both halves, so an add_column in up followed by its remove_column in down netted the column away — dropping valid columns.

A lightweight Ruby block-depth tracker (is_ruby_block_opener + an == "end" close check) now suppresses mutations while inside a def down method.

Corpus impact, verified: WorkPackage is 33 columns, not 31. 20260330100000_create_work_package_semantic_ids.rb's def up adds sequence_number/identifier, and its def down removes them — Rails applies only up, so they are retained. The old "net to zero" pin of 31 was precisely the bug the reviewer caught. The corpus schema gate and drift fuse are updated 31 → 33 with the corrected provenance comment.

2. Parse parenthesized add_column(:t, :c, :type) (#73 comment)

parse_add_column did not strip_call_parens while the rename/remove/change parsers did, so the common add_column(...) form was silently ignored — leaving newly-added columns out of baseline+replay. The argument tail is now normalized like its siblings.

Tests

Two regressions added: replay_add_column_parenthesized_form_applies, replay_skips_def_down_rollback_body. Full run: ruff_ruby_spo 151 + ruff_spo_triplet 133 passed; clippy-clean; corpus schema gate + routes fuse green under RAILS_CORPUS_SRC/OPENPROJECT_PATH=/home/user/openproject.

Follow-up to merged #73; branch restarted from main per the merged-PR protocol. Only schema.rs changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LcsmBBVpETdnTqvDzx6ZiG


Generated by Claude Code

…hesized add_column (codex #73 P2)

Two P2 correctness fixes from codex review on the merged PR #73, both in
the post-baseline migration-replay (schema.rs):

1. Skip `def down` rollback bodies. `def up`/`def change` describe the
   schema AFTER the migration; `def down` reverses it. Replaying the down
   half undid valid columns. A lightweight Ruby block-depth tracker
   (is_ruby_block_opener + an == "end" close check) now suppresses
   mutations while inside a `def down` method. Corpus impact, verified:
   WorkPackage is 33 columns, not 31 — create_work_package_semantic_ids's
   `def up` adds sequence_number/identifier and its `def down` removes
   them; Rails applies only up, so they are RETAINED. The old "net to
   zero" pin of 31 was exactly the bug the reviewer caught. Corpus schema
   gate + drift fuse updated 31 -> 33 with the corrected provenance.

2. Parse parenthesized add_column(:t, :c, :type). parse_add_column did
   not strip_call_parens while the rename/remove/change parsers did, so
   the common parenthesized form was silently dropped. Normalized the
   argument tail like its siblings.

Two regression tests added (replay_add_column_parenthesized_form_applies,
replay_skips_def_down_rollback_body). Follow-up to merged #73; branch
restarted from main per merged-PR protocol. Tests 151 (ruby) + 133
(triplet), clippy-clean, corpus gates green.
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_55c14eec-41f4-46bd-80d9-cc20f54ec0f5)

@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: 695bf79dc3

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

/// with an `== "end"` close check; single-line `def … end` (absent from
/// real migrations) is out of scope.
fn is_ruby_block_opener(line: &str) -> bool {
if line.ends_with(" do") || line.contains(" do ") || line.contains(" do|") {

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 Avoid substring matches when tracking Ruby blocks

When a valid migration declares def down before def up and the rollback body contains a string or comment with a phrase like we do nothing, this substring check increments depth even though no Ruby block was opened. The real end of down then does not clear down_from, so the following def up body is still treated as rollback and its add_column mutations are skipped, making baseline+replay silently lose columns.

Useful? React with 👍 / 👎.

Comment on lines +495 to +497
&& (line == "def down"
|| line.starts_with("def down(")
|| line.starts_with("def down "))

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 Skip class-method down migrations too

Post-baseline migrations that use the classic Rails class-method style def self.up / def self.down still replay the rollback body because this detector only recognizes bare def down. Since the replay otherwise accepts mutations inside def self.up, a paired remove_column in def self.down will undo the valid column exactly like the bug this patch is fixing for instance-method migrations.

Useful? React with 👍 / 👎.

@AdaWorldAPI AdaWorldAPI merged commit a5dedf5 into main Jul 10, 2026
1 check passed
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