Skip to content

feat: adding axon sdk methods#758

Merged
dines-rl merged 5 commits intomainfrom
dines/axon-sdk
Mar 25, 2026
Merged

feat: adding axon sdk methods#758
dines-rl merged 5 commits intomainfrom
dines/axon-sdk

Conversation

@dines-rl
Copy link
Copy Markdown
Contributor

@dines-rl dines-rl commented Mar 24, 2026

User description

⚠️ PR Title Must Follow Conventional Commits

Format: feat[optional scope]: <description>

Examples: feat: add new SDK method · feat(storage): support file uploads · feat!: breaking API change


Description

Motivation

Changes

Testing

  • Unit tests added
  • Integration tests added
  • Smoke Tests added/updated
  • Tested locally

Breaking Changes

Checklist

  • PR title follows Conventional Commits format (feat: or feat(scope):)
  • Documentation updated (if needed)
  • Breaking changes documented (if applicable)

CodeAnt-AI Description

Add object-oriented Axon support to the SDK

What Changed

  • Added a new axon area on the SDK for creating Axons, opening an existing Axon by ID, listing Axons, publishing events, and subscribing to event streams.
  • Exposed Axon types and the Axon class from the public SDK so it can be used alongside the other object-oriented resources.
  • Added smoke tests and unit tests that cover creating, reading, listing, publishing, and streaming Axons.

Impact

✅ Can create and use Axons from the SDK
✅ Can publish events and read live event streams
✅ SDK users can discover and list active Axons

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 24, 2026

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai bot added the size:XL This PR changes 500-999 lines, ignoring generated files label Mar 24, 2026
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 24, 2026

Sequence Diagram

This PR adds a new axon interface to the SDK that wraps low level axon API calls in an object oriented Axon class. The main flow is creating an axon through sdk.axon and then using the returned Axon object to publish events or subscribe to its event stream.

sequenceDiagram
    participant Developer
    participant RunloopSDK
    participant AxonOps
    participant Axon
    participant RunloopAPI

    Developer->>RunloopSDK: Initialize SDK client
    RunloopSDK->>AxonOps: Expose axon operations
    Developer->>AxonOps: Create axon
    AxonOps->>RunloopAPI: Create axon request
    RunloopAPI-->>AxonOps: Return axon id
    AxonOps-->>Developer: Return Axon object
    Developer->>Axon: Publish event or subscribe stream
    Axon->>RunloopAPI: Call publish or subscribe using axon id
    RunloopAPI-->>Developer: Return publish result or event stream
Loading

Generated by CodeAnt AI

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 24, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Resource Leak
    The smoke test creates axon resources in beforeAll and again via Axon.create(sdk.api) without any cleanup path. If these tests run repeatedly, they may leave persistent test data behind and make later runs noisier or more expensive.

Comment on lines +160 to +166
const mockStream = { [Symbol.asyncIterator]: jest.fn() };
mockClient.axons.subscribeSse.mockResolvedValue(mockStream);

const stream = await axon.subscribeSse();

expect(mockClient.axons.subscribeSse).toHaveBeenCalledWith('axn_123456789', undefined);
expect(stream).toBe(mockStream);
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.

Suggestion: The mocked SSE stream is not a valid async iterator because its Symbol.asyncIterator returns undefined, so this test can pass while real consumer iteration would fail at runtime. Mock a real async iterator and assert it exposes next(). [possible bug]

Severity Level: Major ⚠️
- ⚠️ Axon subscribeSse test misses iterator contract validation.
- ⚠️ Iteration-time stream failures can evade unit coverage.
Suggested change
const mockStream = { [Symbol.asyncIterator]: jest.fn() };
mockClient.axons.subscribeSse.mockResolvedValue(mockStream);
const stream = await axon.subscribeSse();
expect(mockClient.axons.subscribeSse).toHaveBeenCalledWith('axn_123456789', undefined);
expect(stream).toBe(mockStream);
const mockStream = {
[Symbol.asyncIterator]: () => ({
next: async () => ({ done: true, value: undefined }),
}),
};
mockClient.axons.subscribeSse.mockResolvedValue(mockStream);
const stream = await axon.subscribeSse();
const iterator = stream[Symbol.asyncIterator]();
expect(mockClient.axons.subscribeSse).toHaveBeenCalledWith('axn_123456789', undefined);
expect(typeof iterator.next).toBe('function');
Steps of Reproduction ✅
1. In `tests/objects/axon.test.ts:160`, the mock stream is `{ [Symbol.asyncIterator]:
jest.fn() }`, where invoking `stream[Symbol.asyncIterator]()` returns `undefined` by
default.

2. In `tests/objects/axon.test.ts:163-166`, the test only checks that
`Axon.subscribeSse()` returns the same object and that the client method was called; it
never validates iterator behavior.

3. In real usage docs at `src/sdk/axon.ts:139-143`, consumers use `for await (const event
of stream)`, which requires a valid async iterator with `next()`.

4. Since `src/sdk/axon.ts:148-149` is a passthrough (`return
this.client.axons.subscribeSse(this._id, options)`), a malformed stream contract would not
be caught by this test and would fail only when consumers iterate.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/objects/axon.test.ts
**Line:** 160:166
**Comment:**
	*Possible Bug: The mocked SSE stream is not a valid async iterator because its `Symbol.asyncIterator` returns `undefined`, so this test can pass while real consumer iteration would fail at runtime. Mock a real async iterator and assert it exposes `next()`.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 24, 2026

CodeAnt AI finished reviewing your PR.

@dines-rl dines-rl requested review from alb-rl and sid-rl March 24, 2026 23:26
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

❌ Object Smoke Tests Failed

Test Results

❌ Some smoke tests failed

Failed Tests:

  • smoketest: object-oriented blueprint › blueprint lifecycle › create devbox from blueprint (SDK method)
  • smoketest: object-oriented blueprint › blueprint lifecycle › create devbox from blueprint (instance method)
  • smoketest: object-oriented blueprint › blueprint build context with object storage and .dockerignore › creates blueprint with COPY using object-based build context honoring .dockerignore
  • smoketest: object-oriented blueprint › blueprint build context with object storage and .dockerignore › creates blueprint with build_context_dir parameter (string path)
  • smoketest: object-oriented blueprint › blueprint list and retrieval › get blueprint by ID

Please fix the failing tests before checking coverage.

📋 View full test logs

@dines-rl dines-rl merged commit 1681eb3 into main Mar 25, 2026
8 of 9 checks passed
@dines-rl dines-rl deleted the dines/axon-sdk branch March 25, 2026 00:43
Comment on lines +57 to +60
const mergedOptions: Core.RequestOptions = {
headers: defaultHeaders,
...options,
};
Copy link
Copy Markdown
Contributor

@sid-rl sid-rl Mar 25, 2026

Choose a reason for hiding this comment

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

doesn't this drop defaultHeaders if user provides any headers? we should make this headers: {Accept: 'text/event-stream', ...options?.headers,}

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

Labels

size:XL This PR changes 500-999 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants