Skip to content

[rig-eslint] Add repair-no-args ESLint rule#131

Merged
pelikhan merged 2 commits into
mainfrom
rig-eslint/repair-no-args-2026-07-25-9351f56eaefd812e
Jul 25, 2026
Merged

[rig-eslint] Add repair-no-args ESLint rule#131
pelikhan merged 2 commits into
mainfrom
rig-eslint/repair-no-args-2026-07-25-9351f56eaefd812e

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Recurring mistake

Rig code generators repeatedly write repair({ maxTurns: 3 }), passing arguments to repair() which accepts none. The maxTurns option belongs on the agent spec, not on the addon call.

This pattern was identified explicitly as a lint rule candidate in run 30151480947 and confirmed in runs 30145047695 and 30150181357 of the Daily Rig Task Generator workflow.

Evidence

Run 30151480947 (2026-07-25):

repair() is called with arguments (e.g., repair({ maxTurns: 3 })), which is not accepted. Generators conflate repair retry control with the addon itself. Autofix: strip arguments from repair(...) call and add a comment suggesting maxTurns on the spec.

Run 30145047695 (2026-07-25):

repair() takes no arguments, set maxTurns on agent spec ... The note that repair() takes no arguments and maxTurns goes on the agent spec is documented but tricky.

Run 30150181357 (2026-07-25):
Generated code in 3 tasks used addons: repair() (correct), but the evaluation log notes the maxTurns confusion pattern around repair() configuration.

Why the autofix is safe

repair() is a zero-argument function. Any arguments passed to it are silently incorrect — TypeScript will also flag this at typecheck time. Stripping the arguments to produce repair() is always semantics-preserving: the only correct form is repair() with no arguments.

Code examples

Invalid:

const myAgent = agent({
  name: "myAgent",
  model: "small",
  maxTurns: 3,
  addons: repair({ maxTurns: 3 }),  // ❌ repair() takes no arguments
  output: s.string,
});

Fixed:

const myAgent = agent({
  name: "myAgent",
  model: "small",
  maxTurns: 3,
  addons: repair(),  // ✓ maxTurns lives on the agent spec
  output: s.string,
});

Four integration points

  1. skills/rig/eslint/rules/repair-no-args.js — new ESLint rule module
  2. skills/rig/eslint/index.js — exports the new rule as "repair-no-args"
  3. skills/rig/eslint/lint.js — dependency-free tokenizer-based detection and autofix added to lintSource/fixSource
  4. src/eslint-rules.test.js — invalid, fixed, valid, edge-case, idempotency, and ESLint-rule-alignment coverage

Validation

npm test      — 227 tests passed (9 test files, 21 in eslint-rules.test.js)
npm run lint  — clean
npm run typecheck — clean

Generated by Rig ESLint Rule Miner · sonnet46 131 AIC · ⌖ 8.93 AIC · ⊞ 5.2K ·

Generators repeatedly write repair({ maxTurns: 3 }) which is not accepted
by the API — repair() takes no arguments and maxTurns belongs on the agent
spec. The rule detects this pattern and strips the arguments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread skills/rig/eslint/lint.js Outdated
}
}

for (let index = 0; index <= tokens.length - 3; index += 1) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot keep lint.js generic and move rule specific code in the rule file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Updated in a8c197a. skills/rig/eslint/lint.js is now generic and delegates rule-specific token scanning/fix edits to the rule files (no-object-literal-record.js and repair-no-args.js).

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan July 25, 2026 10:07
@pelikhan
pelikhan marked this pull request as ready for review July 25, 2026 10:12
@github-actions

github-actions Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /tdd and /codebase-design — one minor suggestion, otherwise approving.

📋 Key Themes & Highlights

Key Themes

  • Problem shape inconsistency: no-object-literal-record problems lack a kind field while repair-no-args problems set kind: "repair-no-args". Future rules and callers need a consistent discriminant to filter by rule — suggest adding kind: "no-object-literal-record" to match the new convention.

Positive Highlights

  • ✅ Clean refactor of lint.js — per-rule scanTokens delegation is a great seam for adding future rules
  • ✅ Well-structured test suite: valid, invalid, idempotency, and ESLint-alignment tests are all present
  • . method-call guard (tokens[index-1]?.value === ".") correctly excludes foo.repair() from flagging
  • ✅ Autofix is semantics-preserving — repair() is provably zero-argument

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 42.5 AIC · ⌖ 4.21 AIC · ⊞ 6.3K
Comment /matt to run again

message: "Wrap object-valued record fields with s.object(...).",
edits: [
{ start: object.start, text: "s.object(" },
{ start: tokens[closingIndex].end, text: ")" },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[/codebase-design] no-object-literal-record problems lack a kind field while repair-no-args problems include kind: "repair-no-args". This asymmetry means callers have no consistent way to filter problems by rule.

💡 Suggested fix

Add kind to the problem shape in no-object-literal-record.js:

problems.push({
  kind: "no-object-literal-record",
  start: object.start,
  end: tokens[closingIndex].end,
  message: "Wrap object-valued record fields with s.object(...).",
  edits: [...],
});

Tests can then filter symmetrically, just like the new repair-no-args tests do.

@pelikhan
pelikhan merged commit 5863b97 into main Jul 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants