Skip to content

docs: propose Effect-scoped turn execution and lifecycle migration roadmap - #1057

Open
zxch3n wants to merge 5 commits into
mainfrom
docs/effect-lifecycle-migration-plan
Open

zxch3n wants to merge 5 commits into
mainfrom
docs/effect-lifecycle-migration-plan

Conversation

@zxch3n

@zxch3n zxch3n commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Refs #429

Stack

  1. docs: propose Effect-scoped turn execution and lifecycle migration roadmap #1057 — migration plan (docs), base main
  2. feat(cli): terminate ACP process trees through an Effect process layer #1065 — L0 platform + L1 process-tree layer, ACP processes
  3. refactor(cli): route every CLI process through the Effect process layer #1069 — every remaining CLI process caller + boundary guard
  4. refactor: one Effect process layer for the CLI, Electron main and supervisor #1070 — one process layer for CLI, Electron main, supervisor and shared helpers

Merge in order; after each merge retarget the next PR to main.

Problem / pressure

Turn execution and ACP process shutdown produced the densest run of lifecycle defects in the last two months. Examples: #571, #618, #740, #817, #595 and #759, and the still-open #429. Each was fixed locally, but the shared root cause remains: resource and wait lifetimes are not bound to an owner. They are held together instead by ~15 boolean flags, a dozen per-session registries and five different kill implementations. The team plans to migrate lifecycle-fragile code onto Effect TS and needs an evidence-backed plan and a priority order first.

Summary

Documentation only: two proposed architecture notes, each in English and Chinese.

No code changes. Nothing has been implemented or measured, and both notes say so.

Visual explanation

flowchart TD
    D["DaemonRuntime (ManagedRuntime + root Scope)"] --> R["SessionResource scope: AgentProcess, ACP connection, terminals, sandbox"]
    R --> T["Turn scope: presence, replay suppression, update target, registration"]
    T --> W["rawWork: raw prompt / steer / set_config_option"]
    T --> A["ancillary: yielded-turn finalization"]
    R -.exited Deferred.-> T
Loading

Before / after

Before After
The plan and ranking existed only in a chat Two proposed notes, each in English and Chinese, under .agents/notes/proposed/architecture/

Test plan

  • Ran pnpm run docs check. The new notes produce no errors. The remaining errors were already there: broken links into uninitialized ACP submodules, and older notes with no translation.
  • Checked that every cited PR number resolves to the intended commit. Where the early PR numbers were ambiguous, commit hashes are cited instead.
  • pnpm check / pnpm format were not run: no source changes, and this checkout has no node_modules.

Context handoff

The Lody team asked for an analysis of which modules most need an Effect-based lifecycle refactor, then for a detailed plan for turn execution and ACP shutdown plus a proposed note for the rest.

🤖 Generated with Claude Code

zxch3n and others added 3 commits September 27, 2026 19:36
…admap

Add two proposed architecture notes (English and Chinese):

- a detailed six-phase plan that moves turn execution and ACP process
  ownership onto daemon → session-resource → turn Effect scopes, with typed
  stop reasons, bounded drains, a shared process-tree primitive, and the
  invariants each phase must preserve;
- a roadmap ranking the remaining lifecycle-fragile areas (dispatch, CLI
  connectivity/presence, renderer workspace runtime, data plane, runtime
  install/auth, worktrees, orchestration, Electron/supervisor) with target
  designs, prerequisites, and fixes that need not wait for Effect.

Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…k decision

Restructure both proposed notes around a strict bottom-up layering rule
(L0 platform → L1 OS leaf → L2 state/cloud → L3 ACP connection → L4 session
resource → L5 turn → L6 entry adapters): a layer is done only when all of its
dependencies are Effect services, our own Promise modules are rewritten rather
than wrapped, and only real third-party I/O boundaries are wrapped once.

Record the decisions that loro-repo and streams-crdt move to an Effect core
with both an Effect entry and a Promise facade, after the Flock persistence
migration lands, with Lody's L2 proceeding behind a temporary LoroRepo Layer.
Replace the turn note's phases with layered PRs, PR1 being L0 plus a complete
L1 ProcessService for every ACP-related process.

Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
zxch3n and others added 2 commits September 29, 2026 22:57
Model: claude-opus-5-5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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