Skip to content

More primitives#7

Closed
eanzhao wants to merge 21 commits into
devfrom
feature/workflow-primitives
Closed

More primitives#7
eanzhao wants to merge 21 commits into
devfrom
feature/workflow-primitives

Conversation

@eanzhao
Copy link
Copy Markdown
Contributor

@eanzhao eanzhao commented Feb 19, 2026

模块清单

控制流

模块 别名 说明
workflow_loop 串行调度步骤,统一处理 retry / on_error / timeout / branch
conditional 二元条件分支(keyword contains)
switch 多路分支,按 on 值匹配 branches
while loop 循环直到条件不满足或达上限
race select N 路竞速,取首个成功结果

执行

模块 别名 说明
llm_call 发送 ChatRequestEvent 到目标角色
tool_call 调用 Agent 注册工具
connector_call bridge_call 调用命名 connector(HTTP/CLI/MCP)
workflow_call sub_workflow 递归调用子工作流
wait_signal wait 暂停等待外部信号(human-in-the-loop / webhook)

并行

模块 别名 说明
parallel_fanout parallel, fan_out 并行扇出 + 可选 vote 合并
vote_consensus vote 从多个候选中选出最佳
foreach for_each 遍历列表并行执行子步骤
map_reduce mapreduce map 阶段并行处理 + reduce 阶段汇总

AI 模式

模块 别名 说明
evaluate judge LLM-as-Judge 评估打分,支持阈值分支
reflect 自我反思-修正循环(critique → improve → ...)

数据

模块 别名 说明
assign 变量赋值
transform 确定性文本变换(count、join、split 等)
retrieve_facts Top-K 事实检索
checkpoint 变量快照
guard assert 数据校验(json_valid / regex / not_empty 等)
cache 结果缓存,避免重复执行

其他

模块 别名 说明
delay sleep 定时等待
emit publish 发布自定义事件

loning and others added 21 commits February 18, 2026 15:53
- Introduced a comprehensive refactor plan for the Core CQRS architecture, focusing on establishing a unified abstraction layer for the Workflow and Maker subsystems.
- Documented current state analysis, architectural goals, and phased implementation strategies to enhance modularity and facilitate cross-system integration.
- Included detailed interface specifications and project organization restructuring to support the transition towards a more cohesive CQRS framework.
- Introduced the `Aevatar.CQRS.Core` and `Aevatar.CQRS.Core.Abstractions` projects to establish a unified CQRS framework, including essential interfaces and default implementations for command execution and correlation.
- Integrated the Maker subsystem into the solution, restructuring its components and updating references to improve modularity and maintainability.
- Updated various project files and documentation to reflect the new architecture, including changes to dependency injection and service registration.
- Enhanced the `InMemoryStream` class to support concurrent subscriber dispatching, improving performance in event handling scenarios.
- Revised README files to provide clearer guidance on the new subsystem structure and its components.
…text management

- Introduced a new `CommandContext` structure to replace the previous `CommandCorrelation` model, enhancing clarity in command execution and metadata handling.
- Removed obsolete command correlation policies and streamlined the command execution process by integrating the new context management.
- Updated various components, including command envelope factories and execution services, to utilize the new command context, improving modularity and maintainability.
- Revised dependency injection configurations to reflect the architectural changes and ensure proper service registration.
- Enhanced documentation to provide clear guidance on the new command context structure and its implications for the CQRS framework.
…command context management

- Eliminated the RunId concept from the CQRS framework, simplifying the architecture and reducing complexity in command execution.
- Introduced a new CommandId to replace RunId, improving clarity in command tracking and metadata handling.
- Updated various components, including command context policies and projection lifecycle services, to reflect the removal of RunId and the introduction of CommandId.
- Revised dependency injection configurations and documentation to align with the new command context structure and its implications for the CQRS framework.
- Enhanced the InMemoryStream class to support improved event handling and subscriber dispatching.
- Introduced the Aevatar.Platform and Aevatar.Maker subsystems, establishing a modular architecture for command and query handling.
- Implemented CQRS patterns in the new subsystems, including command dispatching and state management.
- Updated solution and project files to include new components, enhancing overall structure and maintainability.
- Revised README documentation to reflect the new architecture and provide guidance on subsystem usage and integration.
- Improved dependency injection configurations to support the new subsystems and their respective services.
…em implementations

- Introduced `Aevatar.CQRS.Runtime.Abstractions` to define core command and execution contracts, improving modularity and separation of concerns.
- Added `Aevatar.CQRS.Runtime.FileSystem` for local file system storage of command states, inbox, outbox, and dead letters, facilitating persistence without external dependencies.
- Updated solution and project files to include new runtime components, enhancing overall structure and maintainability.
- Created comprehensive documentation for the new abstractions and file system implementations, providing guidance on usage and integration.
- Revised dependency injection configurations to support the new runtime components and their respective services.
- Introduced `Aevatar.Workflow.Host.Api` as the new entry point for workflow-related chat protocols, replacing the previous `Aevatar.Host.Api`.
- Updated project references and configurations to support the new workflow architecture, enhancing modularity and maintainability.
- Revised documentation to reflect the transition from `Aevatar.Host.Api` to `Aevatar.Workflow.Host.Api`, clarifying the roles and responsibilities of the new subsystem.
- Implemented dependency injection for the new runtime hosting components, ensuring seamless integration with existing services.
- Removed obsolete `Aevatar.Host.Api` components, streamlining the codebase and reducing complexity.
- Deleted the `Aevatar.Host.Gateway` project and its associated files, including `Program.cs`, `GlobalUsings.cs`, and `README.md`, to streamline the architecture.
- Updated the solution file to reflect the removal of the `Aevatar.Host.Gateway` project, enhancing modularity and reducing complexity in the codebase.
- Replaced legacy host project references in the solution file with a new long-term architecture maintenance document, enhancing clarity on architectural goals.
- Added checks in the CI workflow to enforce architectural guidelines, preventing the inclusion of legacy host projects and ensuring proper usage of runtime components in host programs.
- Introduced a new documentation file outlining long-term maintenance strategies and subsystem responsibilities, promoting sustainable architecture evolution.
…ion and eliminate redundancy in architectural planning. This deletion supports ongoing efforts to consolidate project documentation and enhance clarity in the refactoring strategy.
- Introduced a new documentation file outlining the complete architecture of the Aevatar project, covering system goals, structure, and responsibilities.
- Updated the solution file to include the new documentation, improving accessibility to architectural guidelines and promoting better understanding of subsystem interactions.
- Introduced a comprehensive README.md file detailing the architecture of the `src/workflow` subsystem, including layered dependencies, execution flow, and internal class relationships.
- Enhanced understanding of the workflow execution process through visual diagrams and descriptions, promoting clarity in subsystem interactions and responsibilities.
- Extended the `IEventPublisher` interface to include an optional `correlationId` parameter in `PublishAsync` and `SendToAsync` methods, ensuring that correlation IDs are passed through the event handling pipeline.
- Updated implementations in `GAgentBase`, `LocalActorPublisher`, and `EventHandlerContext` to support the new correlation ID functionality, enhancing traceability of events across the system.
- Added tests to verify that correlation IDs are correctly propagated during event publishing and sending, ensuring consistency and reliability in event handling.
- Introduced a new documentation file outlining the correlation ID change plan, detailing the rationale, current issues, and implementation steps for the new feature.
…eability

- Replaced `correlationId` with `EventEnvelope` in the `IEventPublisher` interface methods, ensuring that event metadata is consistently propagated through the system.
- Introduced `IEnvelopePropagationPolicy` and `ICorrelationLinkPolicy` to manage correlation and causation links between inbound and outbound envelopes, improving event traceability.
- Updated implementations in `GAgentBase`, `LocalActorPublisher`, and `EventHandlerContext` to utilize the new envelope-based approach, enhancing the clarity of event handling.
- Added a new `ProjectionDispatcher` to streamline the projection process, replacing the previous subscription registry approach, and ensuring a unified dispatch mechanism.
- Enhanced documentation to reflect changes in event handling and projection architecture, promoting better understanding and maintainability of the system.
…d registration handling

- Updated `BuiltInAgentCatalog` to utilize a dictionary for subsystem registrations, enhancing flexibility and maintainability.
- Refactored `List` method to return capabilities from the new registration structure.
- Modified `SubsystemEndpointOptions` to support a list of subsystem registrations, replacing legacy base URL fields with optional properties.
- Introduced `SubsystemEndpointRegistration` class to encapsulate subsystem details and resolve registrations dynamically.
- Added new methods for endpoint resolution and template application, improving the overall architecture of agent command routing.
- Introduced new projects for Saga abstractions, core, and runtime, establishing a foundation for long-running transaction management.
- Updated solution files to include new Saga projects and removed the obsolete LONG_TERM_ARCHITECTURE_MAINTENANCE.md document.
- Enhanced CI workflow to enforce architectural guidelines, including checks for Saga project dependencies and restrictions on read-model usage in Saga states.
- Added comprehensive documentation for Saga introduction, detailing architecture, implementation phases, and compliance with best practices.
- Updated PROJECT_ARCHITECTURE.md to reflect the integration of Saga capabilities and clarify subsystem responsibilities.
- Deleted the `Aevatar.Platform.Sagas` project and its associated files, including saga-related commands, queries, and states, to streamline the architecture and eliminate redundancy.
- Updated solution files to reflect the removal of the Saga project, enhancing modularity and reducing complexity in the codebase.
- Adjusted documentation to remove references to Saga capabilities, ensuring clarity in the project's current architecture and responsibilities.
- Introduced comprehensive documentation for the Aevatar CQRS and Saga architectures, detailing implementation principles, project responsibilities, and execution paths.
- Included diagrams to illustrate the overall architecture and command execution models, enhancing understanding of the system's structure and interactions.
- Removed the obsolete SAGA_INTRODUCTION_ANALYSIS.md file to streamline documentation and focus on the current architecture.
- Added README.md to the demos folder for improved project guidance.
- Replaced COGNITIVE.md with WORKFLOW.md to provide comprehensive insights into the workflow engine design and implementation.
- Introduced new workflow modules and updated the test project structure to enhance modularity and testing capabilities.
- Removed obsolete COGNITIVE.md file to streamline documentation and focus on current architecture.
@eanzhao eanzhao closed this Feb 23, 2026
eanzhao added a commit that referenced this pull request Apr 27, 2026
…ServiceId; share contract math

Addresses PR #457 review.

## Functional fix (the inline review): InvokePath / invoke handler mismatch

The contract returned by the new `GET /members/.../endpoints/.../contract`
was telling the frontend to call `/members/{memberId}/invoke/...`, but the
existing platform handler for that path resolves the member through
`IMemberPublishedServiceResolver` which today returns
`publishedServiceId == memberId`. Studio's bind path persists
`publishedServiceId == "member-{memberId}"`. So the contract was built for
`member-{memberId}` while invoke would target `{memberId}` → 404.

Fix: register `StudioAwareMemberPublishedServiceResolver` from Studio's
DI. It first asks `IStudioMemberQueryPort` for the member's stored
`publishedServiceId`; if no Studio member exists, falls back to the
legacy deterministic mapping (`memberId == publishedServiceId`) so
direct platform binds keep working unchanged. Now contract / activate /
retire / invoke / runs all resolve to the same identity.

## Refactors per the PR review

- **#1 Duplicated contract-building logic**: extracted the pure
  helpers (`ResolveCurrentContractRevision`,
  `EnumeratePreferredContractRevisionIds`, `RevisionContainsEndpoint`,
  `IsChatEndpoint`, `ResolveStreamFrameFormat`,
  `BuildBase64PayloadPlaceholder`, `BuildTypedInvokeRequestExampleBody`)
  into `Aevatar.GAgentService.Abstractions.Services.ServiceEndpointContractMath`.
  Both `ScopeServiceEndpoints.cs` (legacy) and `StudioMemberService.cs`
  (member-first) funnel through it. A bug fix in one helper now
  propagates to both paths automatically.

- **#3 / #4 Repeated resolve+verify pattern**: introduced
  `ResolveBoundServiceContextAsync` returning
  `(ScopeId, MemberId, PublishedServiceId, Identity, Service, Revisions)`.
  The three new methods now all share one query path; activate /
  retire dropped from 4 platform queries to 2.

- **#2 Non-atomic activate**: documented with a `NOTE:` comment that
  `SetDefaultServingRevision` then `ActivateServiceRevision` is
  intentionally non-transactional, mirroring the legacy scope-default
  behavior, and that both commands are platform-side idempotent.

- **#7 Hardcoded "retired" string**: introduced
  `MemberRevisionLifecycleStatusNames.Retired` next to the existing
  `MemberLifecycleStageNames` so future lifecycle verbs declare
  themselves alongside it instead of as scattered magic strings.

- **#6 / #8 Input trimming**: collapsed the four ad-hoc trimming sites
  into a single `NormalizeRequired(value, fieldName)` helper applied at
  the service entry of every public method. Trimming now happens at
  exactly one boundary per call.

## Tests

- 13 new tests pin the resolver's contract (Studio member → stored
  publishedServiceId; non-Studio member → legacy fallback; trim;
  reject malformed input; empty publishedServiceId degrades safely).
- Existing tests unchanged: 327 Studio + 281 platform integration
  passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eanzhao added a commit that referenced this pull request Apr 30, 2026
19 inline comments arrived after de82e0a; verified each. Three of them
(#13, #14, #16) point at the HttpClient captive bug already fixed in
de82e0a — those will be answered with a reply. Three are NyxID-side
contract gaps (#15, #18, #19) verified against ~/Code/NyxID HEAD cdfef0a;
those need separate NyxID PRs and will be tracked. The rest are fixed
here:

- /model list (codex MAJOR #11): read owner default from
  context.RegistrationScopeId, not the ambient queryPort overload —
  channel inbound has no Studio HTTP request behind it, so the ambient
  resolver returned `default`/unrelated state. Falls back to ambient
  only when the scope is empty (defensive). Tests pinned.
- StateTokenCodec.TryDecodeAsync (consensus MINOR #10): map
  AevatarOAuthClientNotProvisionedException to a distinct
  state_client_not_provisioned code instead of state_signature_invalid.
  IdentityOAuthEndpoints surfaces a "正在初始化, 30 秒后重试" detail
  for that code, matching the /init handler's cold-start message.
- AevatarOAuthClientBootstrapService (#8, #9):
  - wrap RunWithRetryAsync in RunSafelyAsync that logs any escape so
    the unobserved-task exception sink is no longer the only safety net.
  - StopAsync now catches TimeoutException too: when the host shutdown
    deadline fires before the bootstrap task observes its own
    _stoppingCts cancellation, log + return cleanly instead of leaking
    a noisy trace.
- AevatarOAuthClientGAgent.HandleEnsureProvisioned (#6, #7): document
  why CancellationToken.None is the contract — the framework's
  EventHandlerDiscoverer requires single-parameter handlers, so a
  turn-scoped CT cannot be surfaced. The named HTTP client's per-
  request timeout bounds the worst case during silo shutdown.
- NyxIdRedirectUriResolver (#4): emit a warning when all URL sources
  are unset and the environment is not developer-shaped, parity with
  NyxIdAuthorityResolver's existing fallback warning. Wired through
  bootstrap + broker call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
eanzhao added a commit that referenced this pull request May 8, 2026
- #7 (major, arch): wrap MEAILLMProvider's Patch.Set("$.reasoning_content")
  in try/catch so a future OpenAI SDK contract break (Patch surface change,
  serializer rewrite, field rename) degrades to "no reasoning replay"
  instead of crashing the chat call. The OpenAI package is already pinned
  to 2.9.1 in Directory.Packages.props, and the existing
  AIComponentCoverageTests already pin the serialized JSON shape so any
  drift fails the build the moment Patch stops landing in the payload.
- Test fix for #22 (skill registry TTL): the old
  TryGet_BeyondTtl_ReturnsFalseSoCallerCanRefetch test relied on TTL
  expiring SkillSource.Local entries — that's the bug #22 flagged. Updated
  the stale-entry tests to use SkillSource.Remote (via remoteId) which is
  the realistic stale scenario. Added a new
  TryGet_LocalSkillBeyondTtl_StillFresh test pinning the new behaviour.

538 AI tests + 897 ChannelRuntime tests + 16 Ornn tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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