Skip to content

perf(syntropy): single-flight + negative-cache for get_health_profile (oc-hygiene #1) - #26

Merged
supmo668 merged 1 commit into
mainfrom
mangyinm/oc-hygiene-1-profile-single-flight
Jun 21, 2026
Merged

supmo668 merged 1 commit into
mainfrom
mangyinm/oc-hygiene-1-profile-single-flight

Conversation

@supmo668

@supmo668 supmo668 commented Jun 21, 2026 •

Copy link
Copy Markdown

Release-prep hygiene #1 of 8 (principal-approved). resolveProfileContext gains OPT-IN inFlight (single-flight — concurrent same-user misses share one get_health_profile fetch) + negativeCache (60s memo of 'no usable profile'). Both optional → when absent behavior is IDENTICAL (sealed referee 38/38 UNCHANGED = behavior-preserving proof). Transient errors are NOT negative-cached (re-fetch next turn); single-flight has finally-cleanup. 23 visible tests (12 orig + 6 new + 5 injection); oxfmt/oxlint/tsgo clean. QGR 47c8e3e. CTO code-reviewed (opt-in default-off confirmed) + receipt-verified.

Summary by CodeRabbit

  • New Features

    • Optimized profile retrieval with request deduplication to eliminate redundant concurrent fetches.
    • Added intelligent short-term caching to prevent repeated attempts for unavailable profiles.
  • Tests

    • Added comprehensive test coverage for profile caching and request deduplication behavior.

… get_health_profile (oc-hygiene #1)

Generated-With: Claude Code
Co-Authored-By: openclaw <[email protected]>
Co-Authored-By: Claude <[email protected]>
@supmo668
supmo668 merged commit ec9e930 into main Jun 21, 2026
@coderabbitai

coderabbitai Bot commented Jun 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 65d1b439-50c2-45b3-a5d6-8f8fe59cce27

📥 Commits

Reviewing files that changed from the base of the PR and between f70b3b9 and ca429a7.

📒 Files selected for processing (3)
  • extensions/syntropy/src/index.ts
  • extensions/syntropy/src/profile-context.test.ts
  • extensions/syntropy/src/profile-context.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

Adds single-flight deduplication (inFlight map) and short-TTL negative memoization (negativeCache) to resolveProfileContext in the Syntropy extension. The plugin constructs both caches, wires them into decideProfileInjection, and clears the negative memo when the user becomes unpaired.

Changes

Profile fetch deduplication and negative caching

Layer / File(s) Summary
resolveProfileContext contract, implementation, and tests
extensions/syntropy/src/profile-context.ts, extensions/syntropy/src/profile-context.test.ts
Extends the opts type with optional inFlight (Map<string, Promise<string | null>>) and negativeCache (TtlCache<string, true>); reworks the function body to implement positive-cache fast-return, negative-cache short-circuit, single-flight coalescing via the in-flight map, and selective negative memoization after fetch/format; inFlight entries are always removed in finally. Tests cover all six cache interaction paths: concurrent coalescing, in-flight cleanup, negative caching within TTL, negative-cache expiry, transient failures not being cached, and positive-cache precedence over negative.
Plugin construction and wiring
extensions/syntropy/src/index.ts
Constructs profileInFlight and profileNegative (60s TTL TtlCache) during plugin registration. Extends decideProfileInjection opts with both fields, clears the negative memo on user unpair, passes both to resolveProfileContext, and threads them into the before_agent_start handler.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A fetch once was many, now coalesced to one,
The negative cache guards when nothing gets done.
In-flight map dedupes the concurrent race,
Sixty seconds of quiet, a negative grace.
The rabbit hops lighter, no double-fetch fuss—
One profile resolved, shared among all of us!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mangyinm/oc-hygiene-1-profile-single-flight

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@supmo668
supmo668 deleted the mangyinm/oc-hygiene-1-profile-single-flight branch October 17, 2026 17:35
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