Skip to content

Add further support for DO cohorts#6198

Open
maxmcd wants to merge 1 commit intomainfrom
mmcdonnell/do-cohort-support
Open

Add further support for DO cohorts#6198
maxmcd wants to merge 1 commit intomainfrom
mmcdonnell/do-cohort-support

Conversation

@maxmcd
Copy link
Contributor

@maxmcd maxmcd commented Feb 27, 2026

Uses the more specific getEnableVersionApi flag and adds some missing interface additions.

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Feb 27, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR migrates the version option gate in DurableObjectNamespace::getImpl() from getWorkerdExperimental() to getEnableVersionApi(), and plumbs ActorVersion through Worker::Actor into DurableObjectState.

Issue: Flag mismatch for state.version property (medium severity)

In src/workerd/api/actor-state.h:676-680, the version property on DurableObjectState is still gated behind getWorkerdExperimental():

    if (flags.getWorkerdExperimental()) {
      // Experimental new API, details may change!
      JSG_LAZY_INSTANCE_PROPERTY(facets, getFacets);
      JSG_LAZY_INSTANCE_PROPERTY(version, getVersion);
    }

But this PR changes the sender side (actor.c++:161) to use getEnableVersionApi(). This means if a user sets the enable_version_api compat flag without experimental, the version will be sent when routing the DO request, but the state.version property won't be visible on the receiving DurableObjectState object.

Should the version property registration be split out of the experimental block and gated by getEnableVersionApi() instead? Something like:

    if (flags.getWorkerdExperimental()) {
      // Experimental new API, details may change!
      JSG_LAZY_INSTANCE_PROPERTY(facets, getFacets);
    }
    if (flags.getEnableVersionApi()) {
      JSG_LAZY_INSTANCE_PROPERTY(version, getVersion);
    }

@ask-bonk
Copy link
Contributor

ask-bonk bot commented Feb 27, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR migrates the version option gate from getWorkerdExperimental() to the more specific getEnableVersionApi() flag and plumbs ActorVersion through Worker::Actor into DurableObjectState. The code changes in the three modified files look correct.

One issue found: The JSG registration of the state.version property in actor-state.h:676-680 is still gated behind getWorkerdExperimental(), not getEnableVersionApi(). This creates a flag mismatch where the sender side (actor.c++) uses the new flag but the receiver side (DurableObjectState) still uses the old one. I posted a comment on the PR with details and a suggested fix.

github run

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will degrade performance by 21.93%

❌ 1 regressed benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
bodyWithHeaders[Response] 30.2 µs 38.7 µs -21.93%

Comparing mmcdonnell/do-cohort-support (b2245a9) with main (a84fcaa)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.59%. Comparing base (bf2e6bf) to head (b2245a9).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
src/workerd/io/worker.c++ 50.00% 2 Missing ⚠️
src/workerd/api/actor.c++ 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6198      +/-   ##
==========================================
- Coverage   70.65%   70.59%   -0.06%     
==========================================
  Files         413      413              
  Lines      109868   109995     +127     
  Branches    18100    18120      +20     
==========================================
+ Hits        77624    77648      +24     
- Misses      21436    21538     +102     
- Partials    10808    10809       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maxmcd maxmcd force-pushed the mmcdonnell/do-cohort-support branch from aba2381 to b93fd73 Compare February 27, 2026 20:25
@maxmcd maxmcd force-pushed the mmcdonnell/do-cohort-support branch from b93fd73 to b2245a9 Compare February 27, 2026 20:31
@maxmcd maxmcd marked this pull request as ready for review February 27, 2026 22:24
@maxmcd maxmcd requested review from a team as code owners February 27, 2026 22:24
@ask-bonk
Copy link
Contributor

ask-bonk bot commented Feb 27, 2026

I've now reviewed all the changes thoroughly. Let me summarize what this PR does and verify correctness:

  1. actor-state.h: Splits the version property out of the getWorkerdExperimental() block and gates it behind getEnableVersionApi() instead. This is correct — it fixes the flag mismatch that the previous Bonk review identified.

  2. actor.c++: Changes the version option gate from getWorkerdExperimental() to getEnableVersionApi(). Correct.

  3. worker.h: Adds kj::Maybe<ActorVersion> version = kj::none parameter to the Actor constructor. Correct — default value ensures backward compatibility with existing callers.

  4. worker.c++:

    • Adds kj::Maybe<ActorVersion> version field to Impl.
    • Sets it post-construction: impl->version = kj::mv(version).
    • Deep-copies the ActorVersion when passing to DurableObjectState via .map() with kj::str() for the string field.

The deep copy in worker.c++:3795-3797 is necessary because ActorVersion contains a kj::String which must be cloned (the impl->version is stored on the Impl struct and the DurableObjectState needs its own copy). This is correct.

All the changes are consistent, the flag usage is aligned (both sender and receiver now use getEnableVersionApi()), and the new constructor parameter has a safe default. No memory safety, backward compatibility, or security issues.

LGTM

github run

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