Skip to content

Apply review feedback: trace panic safety, cost pre-check, parallel JoinSet, ToolFuture alias#137

Merged
Tuntii merged 2 commits intoai-corefrom
copilot/sub-pr-134
Feb 25, 2026
Merged

Apply review feedback: trace panic safety, cost pre-check, parallel JoinSet, ToolFuture alias#137
Tuntii merged 2 commits intoai-corefrom
copilot/sub-pr-134

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Four targeted fixes addressing reviewer feedback on the AI-native runtime crates.

rustapi-contexttrace.rs

  • SpanGuard::drop: Clarified comment — this is a panic-safety path, not a general "forgot to call complete" warning. Explicit callers use mem::forget to skip it; the Drop impl only fires on unwinding.

rustapi-contextcost.rs

  • CostTracker::record: Switched from fail-open (apply → check) to pre-check (check projected totals → apply only if within limits). A rejected call no longer mutates any atomic counters. Added a doc-comment concurrency note explaining the intentional TOCTOU trade-off in the lock-free design.

rustapi-toolsgraph.rs

  • ToolNode::Parallel: Replaced Vec<JoinHandle> + sequential in-order awaiting with tokio::task::JoinSet. Results are collected as tasks complete rather than in submission order; a first failure immediately calls set.abort_all().

rustapi-toolstool.rs

  • ClosureTool: Added a ToolFuture<'a> type alias for the full Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'a>> type. All ClosureTool bounds now use the alias:
// Before
F: Fn(&RequestContext, serde_json::Value)
    -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<ToolOutput, ToolError>> + Send + '_>>
    + Send + Sync + 'static

// After
F: Fn(&RequestContext, serde_json::Value) -> ToolFuture<'_> + Send + Sync + 'static

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- trace.rs: Clarify SpanGuard::drop comment to explain it handles panics
- cost.rs: Pre-check budget before applying delta to avoid fail-open overrun
- graph.rs: Use JoinSet for parallel execution; collect results as tasks finish
- tool.rs: Add ToolFuture<'a> type alias to simplify ClosureTool signatures"

Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AI-native runtime to RustAPI project Apply review feedback: trace panic safety, cost pre-check, parallel JoinSet, ToolFuture alias Feb 25, 2026
Copilot AI requested a review from Tuntii February 25, 2026 05:33
@Tuntii Tuntii marked this pull request as ready for review February 25, 2026 16:52
@Tuntii Tuntii merged commit 6b86603 into ai-core Feb 25, 2026
2 checks passed
@Tuntii Tuntii deleted the copilot/sub-pr-134 branch February 26, 2026 05:49
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.

2 participants