Skip to content

fix: adding axon sql to sdk#760

Merged
dines-rl merged 3 commits intomainfrom
dines/axon-sql
Mar 25, 2026
Merged

fix: adding axon sql to sdk#760
dines-rl merged 3 commits intomainfrom
dines/axon-sql

Conversation

@dines-rl
Copy link
Copy Markdown
Contributor

@dines-rl dines-rl commented Mar 25, 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 SQL access to Axons and keep SSE streams working

What Changed

  • Axons now include SQL support, letting users run a single query or a batch of statements against an axon's SQLite database.
  • The Axon object exposes these SQL actions directly, so SQL can be used alongside publish and subscribe calls.
  • SSE subscription keeps sending the event-stream request header, which helps event streams open correctly.
  • Smoke tests now cover publishing, SSE replay, SQL queries, and SQL batches.

Impact

✅ Axon SQL access
✅ Fewer event stream connection issues
✅ More coverage for Axon workflows

💡 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 25, 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

@dines-rl dines-rl changed the title fix: axon sql fix: adding axon sql to sdk Mar 25, 2026
@codeant-ai codeant-ai bot added the size:L This PR changes 100-499 lines, ignoring generated files label Mar 25, 2026
@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 25, 2026

Sequence Diagram

This PR adds a new axon.sql interface so SDK users can run SQL queries and transactional SQL batches against an axon database through the object-oriented API. The flow delegates SQL calls from the Axon instance to the underlying axons SQL API endpoints and returns structured results.

sequenceDiagram
    participant SDKUser
    participant Axon
    participant AxonSqlOps
    participant AxonsAPI
    participant AxonDatabase

    SDKUser->>Axon: Get axon instance
    Axon-->>SDKUser: Expose sql operations
    SDKUser->>AxonSqlOps: Run query or batch
    AxonSqlOps->>AxonsAPI: Execute SQL with axon id
    AxonsAPI->>AxonDatabase: Run statement or transaction
    AxonDatabase-->>SDKUser: Return SQL result data
Loading

Generated by CodeAnt AI

@codeant-ai
Copy link
Copy Markdown
Contributor

codeant-ai bot commented Mar 25, 2026

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Possible Bug
    The SSE helper always intends to send Accept: text/event-stream, but the current options merge lets a caller-provided headers object completely replace it. If options.headers is passed, the request may stop advertising SSE and the stream endpoint could return a non-stream response.

  • Possible Bug
    The new SSE call no longer sends the Accept: text/event-stream header that the previous implementation used. If the backend relies on that content negotiation, this request may return a non-streaming response or fail to establish the event stream.

  • Flaky State
    The new SQL smoke test uses a fixed table name and primary key in a persistent environment. Because the axon created in this suite is not cleaned up, repeated runs can hit existing rows or leftover schema state and fail nondeterministically. Verify the test is isolated or uses unique identifiers.

Comment on lines +54 to +56
return this._client.get(`/v1/axons/${id}/subscribe/sse`, { ...options, stream: true }) as APIPromise<
Stream<AxonEventView>
>;
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 SSE subscription request no longer sets Accept: text/event-stream, so it falls back to the client's default Accept: application/json. This can make the server negotiate the wrong response format (or reject the request), causing stream parsing to fail at runtime. Restore the SSE accept header when building request options. [logic error]

Severity Level: Major ⚠️
- ⚠️ Axon SSE subscription may negotiate wrong content type.
- ⚠️ `subscribeSse` consumers can see stream parsing/runtime failures.
Suggested change
return this._client.get(`/v1/axons/${id}/subscribe/sse`, { ...options, stream: true }) as APIPromise<
Stream<AxonEventView>
>;
const defaultHeaders = {
Accept: 'text/event-stream',
};
const mergedOptions: Core.RequestOptions = {
headers: defaultHeaders,
...options,
};
return this._client.get(`/v1/axons/${id}/subscribe/sse`, {
...mergedOptions,
stream: true,
}) as APIPromise<Stream<AxonEventView>>;
Steps of Reproduction ✅
1. Call `subscribeSse()` from SDK consumer code; this enters `Axons.subscribeSse` at
`src/resources/axons.ts:53`.

2. The request is built at `src/resources/axons.ts:54` with `{ ...options, stream: true }`
and no explicit `Accept` header.

3. Execute against endpoint `/v1/axons/${id}/subscribe/sse` (same method, line 54), which
is documented as SSE in the method comment at `src/resources/axons.ts:51-52`.

4. When the server requires content negotiation for SSE, absence of `Accept:
text/event-stream` can return non-SSE payload/response, causing stream handling to fail
for `Stream<AxonEventView>`.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/resources/axons.ts
**Line:** 54:56
**Comment:**
	*Logic Error: The SSE subscription request no longer sets `Accept: text/event-stream`, so it falls back to the client's default `Accept: application/json`. This can make the server negotiate the wrong response format (or reject the request), causing stream parsing to fail at runtime. Restore the SSE accept header when building request options.

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 25, 2026

CodeAnt AI finished reviewing your PR.

dines-rl and others added 2 commits March 24, 2026 20:22
Co-authored-by: codeant-ai[bot] <151821869+codeant-ai[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

✅ Object Smoke Tests & Coverage Report

Test Results

✅ All smoke tests passed

Coverage Results

Metric Coverage Required Status
Functions 100% 100%
Lines 89.25% - ℹ️
Branches 66.94% - ℹ️
Statements 88.09% - ℹ️

Coverage Requirement: 100% function coverage (all public methods must be called in smoke tests)

✅ All tests passed and all object methods are covered!

View detailed coverage report
File Functions Lines Branches
src/sdk.ts ✅ 100% 85.3% 72.58%
src/sdk/agent.ts ✅ 100% 100% 100%
src/sdk/axon.ts ✅ 100% 93.75% 100%
src/sdk/blueprint.ts ✅ 100% 100% 80%
src/sdk/devbox.ts ✅ 100% 91.96% 94.28%
src/sdk/execution-result.ts ✅ 100% 92.68% 70.83%
src/sdk/execution.ts ✅ 100% 95.65% 87.5%
src/sdk/gateway-config.ts ✅ 100% 100% 100%
src/sdk/mcp-config.ts ✅ 100% 100% 100%
src/sdk/network-policy.ts ✅ 100% 100% 100%
src/sdk/scenario-run.ts ✅ 100% 96.87% 50%
src/sdk/scenario.ts ✅ 100% 100% 100%
src/sdk/scorer.ts ✅ 100% 100% 100%
src/sdk/secret.ts ✅ 100% 100% 100%
src/sdk/snapshot.ts ✅ 100% 100% 100%
src/sdk/storage-object.ts ✅ 100% 80% 48.93%

📋 View workflow run

...options,
headers: {
Accept: 'text/event-stream',
...options?.headers,
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.

nice

@dines-rl dines-rl merged commit 9683277 into main Mar 25, 2026
9 checks passed
@dines-rl dines-rl deleted the dines/axon-sql branch March 25, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants