Skip to content

fix(command-code): guard own-property model lookups - #1184

Draft
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-command-code-own-lookups
Draft

fix(command-code): guard own-property model lookups#1184
luvs01 wants to merge 1 commit into
lidge-jun:devfrom
luvs01:agent/fix-command-code-own-lookups

Conversation

@luvs01

@luvs01 luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • resolve legacy Command Code model aliases only from own table entries;
  • reject inherited object properties when reading static and refreshed reasoning-effort profiles;
  • cover __proto__, constructor, and toString as literal provider model IDs.

Why

These tables are ordinary JavaScript objects. Direct bracket lookup can read properties inherited from Object.prototype, so a provider model ID with one of those names may be replaced, treated as a profile object, or throw instead of passing through literally.

The patch keeps the existing tables and compatibility aliases; it only makes the lookup boundary explicit with Object.hasOwn.

Verification

  • Bun 1.3.14: tests/command-code-provider.test.ts 23/23 passed, 58 assertions.
  • Bun 1.4.0-canary.1 (5f65d3785): the same suite 23/23 passed, 58 assertions.
  • bun x tsc --noEmit: passed.
  • bun scripts/privacy-scan.ts: passed.
  • git diff --check: passed.
  • Full-suite boundary: a full-suite attempt on the prior patch-equivalent head assertion-crashed in the unrelated tests/api-storage-policy-run.test.ts under Bun 1.3.14. An A-B-A single-file comparison produced branch crash / clean-dev pass / branch pass, so this PR does not claim a green full-suite result.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing behavior or configuration changed.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes

    • Improved compatibility when selecting Command Code models by consistently recognizing supported model aliases.
    • Prevented prototype-property names from being mistaken for valid models or receiving unintended reasoning settings.
    • Ensured outbound requests use the correct canonical model identifier.
  • Tests

    • Added coverage for model IDs that match inherited property names.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Command Code model IDs now use centralized canonicalization. Reasoning-effort lookup and profile refresh accept only own properties of the known-efforts table. Tests cover __proto__, constructor, and toString as literal model IDs.

Changes

Command Code model handling

Layer / File(s) Summary
Canonical model ID handling
src/adapters/command-code.ts
Lines 24–27 add canonicalCommandCodeModelId. Lines 325 and 354 use it for reasoning-effort resolution and outbound params.model values.
Own-property effort validation
src/providers/command-code-efforts.ts, tests/command-code-provider.test.ts
Lines 34–35 and 63–65 restrict effort and profile lookups to own properties. Lines 217–225 test prototype-property model IDs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: guarding command-code model lookups against inherited properties.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (2/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 2/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

2/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@luvs01

luvs01 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lidge-jun
lidge-jun marked this pull request as ready for review August 8, 2026 09:16
@github-actions
github-actions Bot marked this pull request as draft August 8, 2026 09:17
@luvs01
luvs01 force-pushed the agent/fix-command-code-own-lookups branch from cc01ba0 to a2eda3b Compare August 8, 2026 09:39
@lidge-jun

Copy link
Copy Markdown
Owner

Approved the pending Cross-platform CI run at this exact head so it can actually execute — action_required runs are invisible to gh pr checks, so from your side it just looked like nothing was happening.

To be clear about what that does and doesn't do: it only unblocks CI. It does not make this mergeable. The four-box readiness checklist is your attestation, not something a maintainer ticks for you, and the gate keeps the PR in draft until you complete it. Once CI comes back green, tick the boxes and it moves to ready on its own.

If the run comes back red, tell me and I'll dig into it rather than leaving you to guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants