refactor(core): restructure ModeratorContext to { start, steps } #117

Merged
xiaoju merged 1 commits from refactor/110-moderator-context-restructure into main 2026-04-25 02:51:51 +00:00
Owner

What

Restructure ModeratorContext from a discriminated union to a flat { start, steps } object, and simplify Moderator signature from 3 args to 1.

Why

Moderator now receives full workflow history instead of just the latest event. round is derivable from steps.length, maxRounds from start.meta.maxRounds. Simpler API, more powerful.

Changes

  • packages/core/src/types.tsModeratorContext changed from { kind: "start" } | { kind: "step" } to { start: StartStep; steps: RoleStep<M>[] }. Moderator signature reduced to (context) => role | END
  • packages/daemon/src/workflow-worker.ts — builds steps array, passes { start, steps } to moderator. Removed unused ModeratorContext import
  • packages/core/README.md — updated type documentation

Out-of-repo

  • ~/.uncaged-nerve/workflows/sense-generator/index.ts — moderator adapted to new API (not tracked in git)

Ref

Fixes #110

## What Restructure `ModeratorContext` from a discriminated union to a flat `{ start, steps }` object, and simplify `Moderator` signature from 3 args to 1. ## Why Moderator now receives full workflow history instead of just the latest event. `round` is derivable from `steps.length`, `maxRounds` from `start.meta.maxRounds`. Simpler API, more powerful. ## Changes - **`packages/core/src/types.ts`** — `ModeratorContext` changed from `{ kind: "start" } | { kind: "step" }` to `{ start: StartStep; steps: RoleStep<M>[] }`. `Moderator` signature reduced to `(context) => role | END` - **`packages/daemon/src/workflow-worker.ts`** — builds `steps` array, passes `{ start, steps }` to moderator. Removed unused `ModeratorContext` import - **`packages/core/README.md`** — updated type documentation ## Out-of-repo - `~/.uncaged-nerve/workflows/sense-generator/index.ts` — moderator adapted to new API (not tracked in git) ## Ref Fixes #110
xiaoju added 1 commit 2026-04-25 02:49:28 +00:00
- ModeratorContext: discriminated union → { start: StartStep; steps: RoleStep<M>[] }
- Moderator signature: (context, round, maxRounds) → (context)
- round derivable from steps.length, maxRounds from start.meta.maxRounds
- workflow-worker.ts: build steps array, pass full context to moderator
- Remove unused ModeratorContext import from workflow-worker
- Update README.md

Refs #110
xingyue approved these changes 2026-04-25 02:50:29 +00:00
xingyue left a comment
Owner

LGTM 🟢

Discriminated union → flat { start, steps } 简洁多了,moderator 从 3 参数降到 1 参数,round/maxRounds 都可从 context 推导。

worker 里 resume 时从 roleMessages 重建 steps 数组的逻辑也正确。干净!

LGTM 🟢 Discriminated union → flat { start, steps } 简洁多了,moderator 从 3 参数降到 1 参数,round/maxRounds 都可从 context 推导。 worker 里 resume 时从 roleMessages 重建 steps 数组的逻辑也正确。干净!
xiaoju merged commit c6f56155c8 into main 2026-04-25 02:51:51 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#117