Skip to content

refactor(core): share one-shot completion delivery - #96

Merged
medz merged 1 commit into
mainfrom
refactor/shared-completion
Oct 25, 2026
Merged

medz merged 1 commit into
mainfrom
refactor/shared-completion

Conversation

@medz

@medz medz commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Deferred, cache loads, shared-resource generations, and Layer readiness now use one internal completion cell for synchronous first-publication, late delivery, and detachable listeners. Payload identity and each consumer's failure and resource ownership remain unchanged. Listener exceptions use the registration Zone without interrupting other deliveries.

Cache retention and capacity changes are applied before notifying waiters. Native resource-close Futures remain separate lifecycle signals.

Related issues

Closes #65

Validation

  • dart pub get passed.
  • Repository formatting and dart analyze --fatal-infos passed.
  • All 1,331 tests passed, including five new completion tests for identity, independent cancellation, publication-time detachment, Zone errors, and reentrant delivery.
  • git diff --check passed.

Summary by CodeRabbit

  • Refactor
    • Async operations that share results now follow more consistent completion and notification behavior. Waiting callers continue to receive results, and callers that begin waiting after completion are notified immediately. Pending notifications can be cancelled, and a listener failure does not prevent other listeners from being notified. Existing cache, deferred, shared-resource, and layer workflows retain their externally visible behavior.

@medz medz added the enhancement New feature or request label Oct 25, 2026 — with ChatGPT Codex Connector
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T10:36:36.724311Z d2c793e Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

medz commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds an internal Completion abstraction that retains a result and delivers it to listeners. Deferred, Layer readiness, Cache entries, and SharedResource generations now use this abstraction for result storage and listener delivery.

Changes: Shared completion delivery

Layer / File(s) Summary
Completion contract and tests
lib/src/core/internal/completion.dart, test/core/completion_test.dart
Completion retains the first value, synchronously notifies listeners, supports listener cancellation, and delivers retained values to late listeners. Tests cover repeated completion, cancellation, listener failures, and reentrant registration.
Deferred and Layer readiness
lib/src/core/deferred.dart, lib/src/core/layer.dart
Deferred delegates completion, waiting, and polling to Completion. Layer build entries use Completion for readiness and waiting.
Cache and SharedResource handoffs
lib/src/core/cache.dart, lib/src/core/internal/shared_resource_state.dart
Cache entries and SharedResource generations use Completion to retain results and notify waiters. Cache removes retired entries before completing them.

Priority: Not assessed

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • Issue 65: The change adds shared one-shot completion delivery to Deferred, Cache entries, SharedResource generations, and Layer readiness.
  • Issue 66: The new Completion implementation covers listener delivery and failure handling, but the changes do not modify the public Fiber.onExit API.
  • Issue 40: The Cache changes update the publication boundary used by refresh behavior; they do not change refresh rules.
  • Issue 42: The Cache changes update occupancy cleanup and publication, but do not define a loading-admission model.
  • Issue 41: The Cache changes preserve result access through Completion, but do not add an outcome-based retention policy.
  • Issue 88: The SharedResource changes refactor generation completion delivery, but do not change subscriber policy or resource ownership.
Merge Risk: Minimal · up to d2c79

No actionable issue remains from the reviewed change; it is mergeable after normal checks.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: d2c793e80f

ℹ️ 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".

@medz
medz merged commit b652f36 into main Oct 25, 2026
2 of 3 checks passed
@medz
medz deleted the refactor/shared-completion branch October 25, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Share one-shot completion delivery across Deferred and resource handoffs

1 participant