Skip to content

feat: add shared Time_compat, Resilience, Result_extra modules#34

Merged
jeong-sik merged 4 commits intomainfrom
feat/cross-project-consolidation
Mar 17, 2026
Merged

feat: add shared Time_compat, Resilience, Result_extra modules#34
jeong-sik merged 4 commits intomainfrom
feat/cross-project-consolidation

Conversation

@jeong-sik
Copy link
Owner

Summary

  • Result_extra (lib/): traverse_list and filter_map_list combinators that eliminate the repeated fold_left + Result pattern across MCP projects.
  • Time_compat (eio/): Eio-native timestamp API with Unix fallback, copied verbatim from masc-mcp as the canonical source.
  • Resilience (eio/): Circuit breaker, exponential retry with jitter, and Eio-based timeout. Based on figma-mcp with Unix.gettimeofday replaced by Time_compat.now().

Version bumped from 0.12.4 to 0.13.0 (new features, no breaking changes).

Test plan

  • dune build passes with all new modules
  • dune runtest passes (490 existing tests unaffected)
  • Downstream projects (masc-mcp, figma-mcp) can switch to these shared modules

Generated with Claude Code

jeong-sik and others added 4 commits March 17, 2026 12:47
Provides Result combinators for list traversal, eliminating the
ubiquitous fold_left + Result pattern across MCP projects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Unified timestamp API for gradual migration from Unix.gettimeofday to
Eio.Time.now. Canonical source from masc-mcp, now shared across projects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Circuit breaker, exponential retry with jitter, and Eio-based timeout.
Based on figma-mcp mcp_resilience.ml with Unix.gettimeofday replaced
by Time_compat.now for Eio-native timestamp consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jeong-sik jeong-sik marked this pull request as ready for review March 17, 2026 03:48
@jeong-sik jeong-sik merged commit ac057d8 into main Mar 17, 2026
5 of 6 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6eeb58180a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +203 to +204
| CircuitOpen -> CircuitOpen
| TimedOut -> TimedOut

Choose a reason for hiding this comment

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

P1 Badge Record circuit failure on TimedOut/CircuitOpen outcomes

When retry runs with a circuit breaker in HalfOpen, circuit_allows sets probe_in_progress <- true before calling f. If f returns TimedOut or CircuitOpen, this branch exits immediately without circuit_record_failure or circuit_record_success, so the probe flag is never cleared and subsequent circuit_allows checks in HalfOpen keep rejecting requests, effectively wedging the breaker.

Useful? React with 👍 / 👎.

try
Eio.Time.sleep clock timeout_sec;
Error "Timeout"
with Eio.Cancel.Cancelled _ -> Error "Cancelled")

Choose a reason for hiding this comment

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

P2 Badge Let cancellation propagate from timeout sentinel fiber

Catching Eio.Cancel.Cancelled here converts cancellation into a normal Error path, and the outer match then maps it to Error "Timeout". Under parent-fiber cancellation (e.g., shutdown/abort), this can mask cooperative cancellation as a timeout result instead of propagating cancellation upstream, which breaks expected Eio cancellation behavior.

Useful? React with 👍 / 👎.

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