Skip to content

test(aimlapi): consolidate malformed lease-receipt tests into one table - #2327

Merged
jatmn merged 1 commit into
mainfrom
test/0e3-trim-aimlapi-catalog-tests
Oct 22, 2026
Merged

jatmn merged 1 commit into
mainfrom
test/0e3-trim-aimlapi-catalog-tests

Conversation

@jatmn

@jatmn jatmn commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • what changed: Consolidates the eight malformed AIMLAPI lease-receipt tests in src/integrations/aimlapi/topupState.test.ts (a for loop over exchangeLease/keyMintLease that declared four near-identical test bodies each) into one test.each table, malformed lease pairs fail closed: %s. All eight cases stay independently registered with the same fixture values and the same /does not match the expected format/ assertion.
  • why it changed: Phase 0 item 0-E-3 (test audit TA-004, AIMLAPI slice): trim the topupState.test.ts literal matrices, keep the client/transport/onboarding integration boundaries and the topup.test.ts parse/validation table.

Impact

  • user-facing impact: none (test-only).
  • developer/maintainer impact: one table instead of four copied bodies; the other five AIMLAPI test files are unchanged. After review, none of them contain model-catalog membership matrices: their literal assertions protect routing, auth, payment validation, persisted-state compatibility and state transitions, so nothing else was trimmed. There is no src/integrations/models/aimlapi.ts, so no model capability/limit table applies to this slice, and no removed-model deny-list existed here to keep.

Tests: 177 registered before, 177 after (topupState.test.ts: 75 to 75 registered, 71 to 68 declarations). No tests removed.

Loosened assertions: none. The two inline comments explaining the non-string owner and one-sided pair cases were folded into the table row labels.

Testing

  • I ran the required local preflight.
  • exact commands and results:
    • bun test --isolate src/integrations/aimlapi/*.test.ts: 177 pass, 0 fail
    • bun run integrations:check: pass
    • bun run typecheck: pass
    • bun run check: pass (all shards exit 0)
  • focused tests: src/integrations/aimlapi/topupState.test.ts
  • documented skipped checks, platform limitations, or verified pre-existing failures: none

Notes

  • provider/model path tested: AIMLAPI top-up state (unit tests only)
  • screenshots attached (if UI changed): n/a
  • follow-up work or known limitations: standalone; no overlap with the open 0-E-1/0-E-2 PRs (no CONTRIBUTING or shared helper changes).

Summary by CodeRabbit

  • Tests
    • Expanded and consolidated coverage for malformed lease receipts, verifying that claims fail for invalid or missing owner and timestamp data across both lease types.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Twigpine/openclaude/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 7f3838a9-6cab-4246-9b7c-1603dbb42594
📥 Commits

Reviewing files that changed from the base of the PR and between 19bb39c and 4eb59f4.

📒 Files selected for processing: 1
  • src/integrations/aimlapi/topupState.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 17
  • GitHub Check: typecheck
  • GitHub Check: unit-tests (3)
  • GitHub Check: unit-tests (1)
  • GitHub Check: unit-tests (5)
  • GitHub Check: unit-tests (7)
  • GitHub Check: unit-tests (6)
  • GitHub Check: unit-tests (2)
  • GitHub Check: unit-tests (4)
  • GitHub Check: unit-tests (8)
  • GitHub Check: launcher-compatibility (24.11.x)
  • GitHub Check: smoke-and-tests
  • GitHub Check: launcher-node-floor
  • GitHub Check: launcher-compatibility (22)
  • GitHub Check: dedicated-tests
  • GitHub Check: CodeQL (actions)
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions: 3
Review provider routing, model selection, env precedence, auth/token handling, OpenAI-compatible shims, retries, proxy behavior, and outbound HTTP behavior with high scrutiny.

⚙️ CodeRabbit configuration file

Files:

  • src/integrations/aimlapi/topupState.test.ts
Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions.

⚙️ CodeRabbit configuration file

Files:

  • src/integrations/aimlapi/topupState.test.ts
Apply the OpenClaude maintainer review rubric from AGENTS.md.

⚙️ CodeRabbit configuration file

Files:

  • src/integrations/aimlapi/topupState.test.ts
🧠 Learnings: 1
📓 Common learnings
Learnt from: CR
Repo: Twigpine/openclaude

Timestamp: 2026-10-22T04:07:17.616Z
Learning: Applicability reference:
AGENTS.md: # AGENTS.md - AI Agent Coding Guide
This guide is for AI coding agents working in the OpenClaude repository. Read it before changing code, and also follow [CONTRIBUTING.md](CONTRIBUTING.md) for contributor policy, PR expectations, review follow-up, and project scope.

AGENTS.md: # AGENTS.md - AI Agent Coding Guide
## Work Style
- For new features, larger refactors, dependencies, or runtime changes, follow the issue-first guidance in [CONTRIBUTING.md](CONTRIBUTING.md).

AGENTS.md: # AGENTS.md - AI Agent Coding Guide
## Work Style
- Keep PR branches current with `main` using the synchronization and guarded-push workflow in [CONTRIBUTING.md § Keep Your Branch Current](CONTRIBUTING.md#keep-your-branch-current). Rebase whenever resuming work or pushing follow-up fixes, but never overwrite remote PR-head updates with an unguarded force-push.

AGENTS.md: # AGENTS.md - AI Agent Coding Guide
## Work Style
- Run the authoritative local pre-push validation cont...
🔇 Additional comments: 1
src/integrations/aimlapi/topupState.test.ts: 1

956-967: LGTM!

Also applies to: 977-987, 993-994

📝 Walkthrough

The malformed-lease receipt tests now use parameterized cases for exchangeLease and keyMintLease. They check invalid or missing owners and timestamps, and expect schema validation to reject each claim.

Changes: Lease receipt validation

Layer / File(s) Summary
Parameterized malformed lease cases
src/integrations/aimlapi/topupState.test.ts
Parameterized tests cover non-string and missing owners, malformed and missing timestamps, and verify that each malformed receipt causes a claim to fail with a schema-format error.

Priority: ⬇️ Low

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

Change: Other

Suggested reviewers: lookoff-aimlapi

Merge Risk: ⚪ Minimal · up to 4eb59

The test consolidation has no identified user-facing impact or merge-blocking issue; merge after normal checks.

Pre-merge checks: Passed 7
Check name Status Explanation
Title check Passed The title is concise, scoped to AIMLAPI tests, and accurately describes consolidating malformed lease-receipt tests into one table.
Description check Passed The description includes all required sections, explains the change and rationale, documents impact, lists exact test commands and results, and records notes and limitations.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Risk Surface Disclosed Passed The PR changes only src/integrations/aimlapi/topupState.test.ts. The diff only consolidates existing malformed lease-receipt test cases into test.each; it does not change authentication, provider …
No Hidden Policy Change Passed PASS: The PR changes only src/integrations/aimlapi/topupState.test.ts and only consolidates eight existing malformed lease-receipt cases into one test.each table. The diff contains no production f…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

Full details: Risk Surface Disclosed

Explanation

The PR changes only src/integrations/aimlapi/topupState.test.ts. The diff only consolidates existing malformed lease-receipt test cases into test.each; it does not change authentication, provider routing, permissions, network behavior, background execution, startup/config-home behavior, plugins/MCP, CI permissions, or release scripts. The review description identifies the change as test-only with no user-facing impact, so no listed risk surface or blocker requires disclosure.

Full details: No Hidden Policy Change

Explanation

PASS: The PR changes only src/integrations/aimlapi/topupState.test.ts and only consolidates eight existing malformed lease-receipt cases into one test.each table. The diff contains no production files or changes to product behavior, trust rules, routing defaults, telemetry, network behavior, or permission policy. The table preserves the existing owner, timestamp, missing-field, and schema-error assertions.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

— jatmn's PR Review agent

Head: 4eb59f43a65f7a91115eac7b15dd43e7d93f55df
Range reviewed: 78445348676d6c5797fc11d89eaaf0157d69de1b..4eb59f43a65f7a91115eac7b15dd43e7d93f55df (one commit, one file)

Merge readiness

  • Scope: Surgical and standalone — only src/integrations/aimlapi/topupState.test.ts changes; no production, docs, or workflow drift. Fits an upgrade-plan test-audit slice.
  • Branch freshness: Head is 2 commits behind live main (19bb39c8845a6920bb04ad8d70652ad520861b87). GitHub reports mergeable: true with mergeable_state: blocked (typical for required checks / branch policy). Rebase before merge if your stack requires a linear history on current main.
  • CI at head (4eb59f43): All 21 check runs completed — 20 success, web skipped. Includes typecheck, smoke-and-tests, dedicated-tests, all eight unit-tests shards, launcher compatibility, pr-intent-scan, and CodeQL / CodeQL (javascript-typescript) / Analyze (javascript-typescript) success. Commit status context CodeRabbit: success.

Consolidation verification (requested)

# Row label (head) Lease field Owner fixture Timestamp fixture Asserted function Oracle
1 exchangeLease / malformed owner exchangeLease 12345 Date.now() via 'now' claimAimlapiTopupState /does not match the expected format/
2 exchangeLease / malformed timestamp exchangeLease 'some-owner' 'not-a-number' same same
3 exchangeLease / missing timestamp exchangeLease 'some-owner' field deleted same same
4 exchangeLease / missing owner exchangeLease field deleted Date.now() via 'now' same same
5–8 keyMintLease / … keyMintLease (same four patterns) (same) same same
  • Fixtures one-to-one: Each row matches the corresponding merge-base test title and seeded JSON (*Owner / *At mutations). Using 'now' → Date.now() at write time is equivalent to the prior inline Date.now() calls.
  • Per-case extras: The eight lease tests never asserted receipt bytes, lock cleanup, or a second throw (unlike the schema-validation test immediately above, which still does). Nothing was dropped from these cases.
  • Function coverage: Every row still calls claimAimlapiTopupState({ ...intent, amountUsdMinor: 5000 }) after useTemporaryConfig → claim → saveAimlapiTopupState → corrupt file — same setup as merge-base.
  • Regression signal: bun test src/integrations/aimlapi/topupState.test.ts — 75 pass, 219 expect() calls on merge-base and head; filtered malformed lease pairs — 8/8 on head. Removing fail-closed validation would fail these rows.

Minor PR-description drift (not a code finding): Inline comments explaining fail-closed vs isLeaseLive were removed; row labels name scenarios but do not fully replace that prose.

Automated review audit

Source Status Action
CodeRabbit Issue comment shows review in progress on this head; no inline review comments on the diff. Commit status success. No unaddressed actionable findings to promote.
CodeQL At head: analysis checks success. (Earlier snapshot had a neutral aggregate warning about a missing javascript-typescript config on the PR ref; live head runs completed green.) Drift only — not a PR defect; no open CodeQL alert tied to this hunk.

Value recommendation

Keep (modest, real value — not churn). The refactor removes four near-copied loop bodies, keeps eight independent registrations and the same oracles, and makes adding a ninth malformed lease case a one-line table edit. Benefit is maintainability inside a deliberate test-audit pass, not new coverage — but the consolidation is faithful and low risk.

Outcome

🟢 Thanks for the contribution. I do not see any actionable issues from my review.

@jatmn
jatmn marked this pull request as ready for review October 22, 2026 04:27
@jatmn
jatmn merged commit 3a29928 into main Oct 22, 2026
22 checks passed
@jatmn
jatmn deleted the test/0e3-trim-aimlapi-catalog-tests branch October 22, 2026 04:28
@jatmn jatmn self-assigned this Oct 22, 2026
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.

1 participant