M4: 范式引擎与任务运行时

skill-engine(L4):载方法不载权力(白名单外工具即拒)、结晶片段经 ToolInvoker 留痕、
  装配入信封、技能目录渐进披露

flow-engine(L5):四种步型、确定性谓词跳步、重试与声明给定的兜底、
  异步步即监听(时限必配)、写类工具登记动作意向、步序位置持久

loop-engine(L5):自研 CMMN 子集解析器(表外构件直接报错,子集封顶可机器证明)、
  两副标准生命周期与迁移拓扑(引擎不得私改)、Enabled ≠ Active、
  语义性前提标待裁量评估(引擎不代裁量)、DMN 确定性求值 + 命中行留痕、
  DRD 缺口演绎与拓扑序、双向驱动与交集导航(断点即人环)、三型行动、
  终局唯放行与 Harness

task(L6):终态五名裁定(released 唯一成功)、Harness 预算环外强制与停滞熔断
  (监听中是健康态)、控制三语义(叫停不是终态,记最重档纠正)、改派留痕通知双方、
  断点续跑三份持久状态、封卷触发蒸馏钩子

301 个测试通过,门禁五道全绿

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
JCAI Main Agent
2026-07-27 01:51:22 +08:00
co-authored by Claude Opus 5
parent 2850e6d4ef
commit 3c974d2860
55 changed files with 7113 additions and 1 deletions
@@ -0,0 +1,42 @@
/**
* module: skill-engine —— 对外类型(编码规范 §10.1;语义出处 AM 08)。
*
* 技能不是独立范式:没有自己的约束体系 —— 留痕、治理、权力边界与生命周期全部继承本规范。
* **内容软**(方法正文自由,用不用由 AI 决断),**边框硬**(装配入信封 · 脚本注册留痕 ·
* 不得扩权 · 版本过进化关口)。
*/
import type { Skill, TaskId } from '@contracts';
import type { AssemblyContext, CrystallizedStep, SkillIndexEntry, SkillStamp, SkillViolation } from './internal/domain/skill-assembly.ts';
export type { AssemblyContext, CrystallizedStep, Skill, SkillIndexEntry, SkillStamp, SkillViolation };
export declare class SkillPowerEscalationError extends Error {
readonly violations: readonly SkillViolation[];
constructor(violations: readonly SkillViolation[]);
}
export type RunScriptInput = {
readonly taskId: TaskId;
readonly activityId: string;
readonly skillId: string;
/** 任务数据 —— 结晶片段的入参插值面 */
readonly scope: Readonly<Record<string, unknown>>;
readonly stepNo?: number;
};
export type ScriptOutcome = {
readonly ok: boolean;
readonly steps: ReadonlyArray<{
tool: string;
ok: boolean;
output?: Record<string, unknown>;
error?: string;
}>;
readonly stamp: readonly SkillStamp[];
};
export type SkillEngineService = {
/** 常驻上下文只有目录 —— 渐进披露 */
index(activityId: string): Promise<SkillIndexEntry[]>;
/** 按事加载正文;装配前过扩权检查 */
load(activityId: string, skillIds: readonly string[]): Promise<Skill[]>;
/** 结晶片段脚本 = 确定性动作链;经 ToolInvoker 调用而留痕,不得内联绕过 */
runScript(input: RunScriptInput): Promise<ScriptOutcome>;
/** 装配入信封 —— 供任务记忆盖戳 */
stamp(activityId: string, skillIds: readonly string[]): Promise<SkillStamp[]>;
};
@@ -0,0 +1,9 @@
/**
* module: skill-engine —— 唯一出口。只做 re-export,不写逻辑(编码规范 §10.1)。
*/
export type { AssemblyContext, CrystallizedStep, RunScriptInput, ScriptOutcome, Skill, SkillEngineService, SkillIndexEntry, SkillStamp, SkillViolation, } from './contract.ts';
export { SkillPowerEscalationError } from './contract.ts';
export type { Clock, MemoryRecorder, ScriptToolInvoker, SkillCatalog } from './port.ts';
export type { SkillEngineDeps } from './internal/usecase/skill-engine-service.ts';
export { createSkillEngineService } from './internal/usecase/skill-engine-service.ts';
export { checkCatalog, checkSkillPower, crystallizedChain, interpolate, skillIndex, stampOf, } from './internal/domain/skill-assembly.ts';
+39
View File
@@ -0,0 +1,39 @@
/**
* module: skill-engine —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
*/
import type { Skill, TaskId } from '@contracts';
export type Clock = {
now(): Date;
};
/** 技能目录 —— app 注入 `activity-registry`(L4 同层):技能是活动的资产之一 */
export type SkillCatalog = {
skillsOf(activityId: string): Promise<Skill[]>;
allowlistOf(activityId: string): Promise<string[]>;
};
/**
* 工具调用 —— app 注入 `toolbox`(L2)的 `ToolInvoker`。
* 脚本引用的工具**仍过本活动白名单与调用契约** —— 载方法不载权力。
*/
export type ScriptToolInvoker = {
invoke(input: {
tool: string;
input: Record<string, unknown>;
activityId: string;
taskId: TaskId;
stepNo?: number;
}): Promise<{
ok: boolean;
output?: Record<string, unknown>;
error?: {
message: string;
};
}>;
};
export type MemoryRecorder = {
append(input: {
taskId: TaskId;
kind: 'action' | 'result';
title: string;
detail?: Record<string, unknown>;
}): Promise<void>;
};