Skip to content

feat(mapper): map literal Rails routes#102

Merged
steipete merged 4 commits into
openclaw:mainfrom
rohitjavvadi:feat/rails-route-seeds
May 22, 2026
Merged

feat(mapper): map literal Rails routes#102
steipete merged 4 commits into
openclaw:mainfrom
rohitjavvadi:feat/rails-route-seeds

Conversation

@rohitjavvadi
Copy link
Copy Markdown
Contributor

Summary

  • add Rails route-level seeds for literal root and HTTP verb declarations in config/routes.rb
  • resolve controller handlers when present, falling back to the route file when handlers are absent or unsafe
  • skip nested or unsupported route DSL blocks conservatively, with coverage for block-depth recovery and symlink safety

Why

Rails apps currently get broad config/view/database seeds but no focused route-level entries. Literal routes are a useful, low-risk starting point because they map directly from config/routes.rb to controller handlers without needing to infer scoped DSL composition.

Tests

  • ./node_modules/.bin/vitest run src/mapper.test.ts -t 'Rails route'
  • ./node_modules/.bin/vitest run src/mapper.test.ts
  • ./node_modules/.bin/tsc -p tsconfig.json --noEmit
  • ./node_modules/.bin/oxlint . --config oxlint.json
  • ./node_modules/.bin/oxfmt --check src/mappers/ruby.ts src/mapper.test.ts
  • git diff --check
  • ./node_modules/.bin/vitest run
  • ./node_modules/.bin/tsc -p tsconfig.build.json

@rohitjavvadi rohitjavvadi requested a review from a team as a code owner May 21, 2026 17:50
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: eb0f1f0fdf

ℹ️ 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 thread src/mappers/ruby.ts
Comment on lines +524 to +527
function railsLineBlockDelta(line: string): number {
const code = rubyLineWithoutStrings(line);
return rubyTokenCount(code, "do") - rubyTokenCount(code, "end");
}
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 Track brace-delimited route blocks before parsing nested routes

The block-depth guard only counts do/end, so unsupported Rails DSL blocks written with { ... } are never marked as skipped. In files that use brace-style scope/namespace blocks across multiple lines, inner get/post/... lines are parsed as if they were top-level routes, producing incorrect route seeds (for example missing scoped prefixes like /api). This breaks the “skip unsupported nested DSL conservatively” behavior and can yield inaccurate feature mappings for valid routes.rb syntax.

Useful? React with 👍 / 👎.

@rohitjavvadi
Copy link
Copy Markdown
Contributor Author

Addressed in 91fec30: brace-delimited route DSL blocks are now skipped conservatively, while top-level routes with multiline option hashes and regex constraints remain mapped. Added regressions for brace scopes, multiline option hashes, regex braces, and hash-rocket regex constraints.

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(mapper): map literal Rails routes This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete steipete merged commit 5de565c into openclaw:main May 22, 2026
6 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 0ae06e2bc4

ℹ️ 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 thread src/mappers/ruby.ts
Comment on lines +534 to +536
function railsLineBlockDelta(line: string): number {
const code = rubyLineWithoutStrings(line);
return rubyTokenCount(code, "do") - rubyTokenCount(code, "end") + rubyBraceDelta(code);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Count non-do Ruby blocks when tracking route nesting

railsLineBlockDelta only increments depth for do and {, but decrements for every end, so common route wrappers like if ... end inside Rails.application.routes.draw desynchronize drawBlockDepth. In that case, nested routes can be incorrectly emitted as top-level and the parser can stop before later valid top-level routes, because the first conditional end can prematurely bring draw depth to zero.

Useful? React with 👍 / 👎.

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