Skip to content

refactor(dev): coalescing rebuild scheduler on Effect fiber + Semaphore + Deferred (wave 3.5 stage 3, PR 3) - #160

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
wave35-s3/rebuild-scheduler
Sep 1, 2026
Merged

refactor(dev): coalescing rebuild scheduler on Effect fiber + Semaphore + Deferred (wave 3.5 stage 3, PR 3)#160
ScriptedAlchemy merged 1 commit into
mainfrom
wave35-s3/rebuild-scheduler

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Subsystem 2 of 4 for #152 stage 3. Reordered ahead of the SSE hub and EpochStore with one sentence of justification: the scheduler is a single self-contained seam inside DevCoordinator with unit-pool-only owning suites, while EpochStore carries cross-process durability contracts — smallest remaining blast radius first. (The SSE hub audit outcome is recorded below.)

  • Build passes are Effect fibers. #startBuild runs #performBuild under a Semaphore(1) permit (withPermit); admission already guarantees a single holder, the permit makes the serialization invariant structural rather than implicit.
  • Coalescing on Deferred. Every rebuild that arrives while a build runs merges (unchanged mergeInvalidations) into one queued slot whose requesters share a single Deferred<ArtifactEpochResult>; the drain hook (Effect.onExit, sitting exactly where the pre-Effect finally chain sat) starts the follow-up fiber and completes the deferred with its result, failure('DevCoordinator is closing.') on close, or the sentinel failure if the follow-up rejects.
  • Admission stays synchronous by design (documented in-code): same-turn rebuilds must observe the running build and coalesce into exactly one follow-up — deferring admission into a fiber would split them.
  • Startup cancellation (#awaitStartup races) is deliberately untouched: it is the startup lifecycle, not the rebuild scheduler, and its three blocked-startup suites pin Promise-level sequencing.

SSE hub audit note (subsystem decision, code lands separately)

The planned "PubSub-backed SSE hub" fails the honesty test: the hub's public contract is synchronous re-entrant fan-out — foreground-server.ts documents "EventHub delivery is synchronous" as the invariant that lets shutdown tombstones reach socket buffers before sockets are destroyed, and ~15 tests pin sync replay/removal/ordering. Effect PubSub is an async fan-out structure; fiber delivery changes that observable contract. The hub stays imperative; docs/effect-conventions.md gets the record in the closing docs PR.

Parity (all suites unchanged, zero pin flips)

  • Owning suites (dev-coordinator, dev-watcher, dev-server, dev-events, dev-events.contract): 74 passed / 0 failed
  • Full unit pool: 1999 passed / 5 documented skips / 0 failed
  • pnpm lint + pnpm typecheck: green
  • Changeset: patch (internal rewrite).

Refs #152.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f939694

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 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-09-01T17:47:49.410989Z f939694 PR opened
ℹ️ 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.

@ScriptedAlchemy
ScriptedAlchemy merged commit 87711c4 into main Sep 1, 2026
4 of 9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the wave35-s3/rebuild-scheduler branch September 3, 2026 05:29
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