Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";

import { changeStewardExecutorDraft, goalExploreEditorValue, goalExploreWriteValue, goalReplanCadenceEditorValue, goalReplanCadenceWriteValue, hasReplanCadenceOverride, goalStorageEditorValue, parseEditableCapabilityJson, projectEditableCapabilityConfiguration, replanCadenceEditorDefaults } from "../src/data/capability-configuration.js";
import { changeStewardExecutorDraft, goalExploreEditorValue, goalExploreWriteValue, goalReplanCadenceEditorValue, goalReplanCadenceWriteValue, hasReplanCadenceOverride, goalStorageEditorValue, parseEditableCapabilityJson, projectEditableCapabilityConfiguration, replanCadenceEditorDefaults, replanCadenceEditorValue } from "../src/data/capability-configuration.js";

const exploreEditor = {fields: [{key: "mode"}, {key: "profile"}, {key: "composition_mode"}, {key: "composition_scope_id", nullable: true}]};
const exploreEffective = {mode: "planning", profile: "generic", composition_mode: "disabled", composition_scope_id: null};
Expand Down Expand Up @@ -40,53 +40,65 @@ const periodicReportEditor = {
};

const storageEditor = { fields: [{ key: "new_goal_provider" }, { key: "canonical_creation" }, { key: "new_goal_handoff_mode" }] };
const cadenceEditor = { fields: [{ key: "count_unit" }, { key: "count" }, { key: "stride_strategy" }] };
const cadenceDefault = { count_unit: "effective_turns", count: 6, stride_strategy: "off" };
const cadenceEditor = { fields: [{ key: "count_unit" }, { key: "count" }, { key: "planning_horizon_goal" }] };
const cadenceDefault = { count_unit: "effective_turns", count: 6 };
assert.deepEqual(projectEditableCapabilityConfiguration(cadenceEditor,
{ stride_strategy: "evidence_conditioned_v1" },
replanCadenceEditorDefaults({ count_unit: "effective_turns", count: 3, stride_strategy: "off" }, cadenceDefault)),
{ count_unit: "effective_turns", count: 3, stride_strategy: "evidence_conditioned_v1" },
{ planning_horizon_goal: false },
replanCadenceEditorDefaults({ count_unit: "effective_turns", count: 3 }, cadenceDefault)),
{ count_unit: "effective_turns", count: 3, planning_horizon_goal: false },
"a sparse JSON draft returning to the form preserves the effective review interval");
assert.deepEqual(projectEditableCapabilityConfiguration(cadenceEditor,
{ count_unit: "completed_todos", count: 2 },
replanCadenceEditorDefaults({ count_unit: "effective_turns", count: 3, stride_strategy: "evidence_conditioned_v1" }, cadenceDefault)),
{ count_unit: "completed_todos", count: 2, stride_strategy: "off" },
"an explicit cadence wins and omitted strategy retains default-off semantics");
replanCadenceEditorDefaults({ count_unit: "effective_turns", count: 3 }, cadenceDefault)),
{ count_unit: "completed_todos", count: 2 },
"an explicit cadence wins over the effective interval");
assert.deepEqual(replanCadenceEditorDefaults(
{ schema_version: "todo_replan_cadence_machine_defaults_v0", completed_todos: 4 }, cadenceDefault),
{ count_unit: "completed_todos", count: 4, stride_strategy: "off" },
{ count_unit: "completed_todos", count: 4 },
"legacy effective intervals retain their own unit and count");
const inheritedReview = { count_unit: "effective_turns", count: 3, stride_strategy: "off" };
// The stride switch was removed: evidence-conditioned v1 is always on. Legacy
// saved values are history only and never displayed or resubmitted.
for (const legacy of ["off", "evidence_conditioned_v1"]) {
assert.deepEqual(replanCadenceEditorValue({ count_unit: "effective_turns", count: 3, stride_strategy: legacy }),
{ count_unit: "effective_turns", count: 3 }, `legacy stride_strategy=${legacy} is not displayed`);
assert.equal(Object.hasOwn(goalReplanCadenceEditorValue({ stride_strategy: legacy }, cadenceDefault), "stride_strategy"), false,
`legacy Goal stride_strategy=${legacy} is not displayed`);
assert.equal(Object.hasOwn(replanCadenceEditorDefaults({ ...cadenceDefault, stride_strategy: legacy }, cadenceDefault), "stride_strategy"), false);
}
assert.deepEqual(replanCadenceEditorValue({ completed_todos: 2 }), { count_unit: "completed_todos", count: 2 });
assert.equal(parseEditableCapabilityJson(cadenceEditor, JSON.stringify({ stride_strategy: "off" })), null,
"the removed stride switch is not an editable JSON field");
const inheritedReview = { count_unit: "effective_turns", count: 3 };
assert.deepEqual(goalReplanCadenceWriteValue({...inheritedReview, planning_horizon_goal: true}, false, false),
{stride_strategy: "off"}, "displaying the default Goal context does not create an override");
{}, "displaying the default Goal context does not create an override");
for (const enabled of [true, false]) {
assert.deepEqual(goalReplanCadenceWriteValue({...inheritedReview, planning_horizon_goal: enabled}, false, true),
{stride_strategy: "off", planning_horizon_goal: enabled}, "explicit horizon choices survive a form save");
{planning_horizon_goal: enabled}, "explicit horizon choices survive a form save");
}
assert.equal(replanCadenceEditorDefaults({...inheritedReview, planning_horizon_goal: false},
{...cadenceDefault, planning_horizon_goal: true}).planning_horizon_goal, false,
"a sparse Goal form displays the effective machine opt-out");
assert.deepEqual(goalReplanCadenceEditorValue({ stride_strategy: "evidence_conditioned_v1" }, inheritedReview),
{ ...inheritedReview, stride_strategy: "evidence_conditioned_v1" },
"strategy-only Goal settings display the live review interval");
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview, stride_strategy: "evidence_conditioned_v1" }, false),
{ stride_strategy: "evidence_conditioned_v1" },
"changing only the strategy must not pin the displayed interval");
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview, count: 2, stride_strategy: "evidence_conditioned_v1" }, true),
{ count_unit: "effective_turns", count: 2, stride_strategy: "evidence_conditioned_v1" },
assert.deepEqual(goalReplanCadenceEditorValue({ planning_horizon_goal: false }, inheritedReview),
{ ...inheritedReview, planning_horizon_goal: false },
"horizon-only Goal settings display the live review interval");
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview, planning_horizon_goal: false }, false),
{ planning_horizon_goal: false },
"changing only the horizon must not pin the displayed interval");
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview, count: 2 }, true),
{ count_unit: "effective_turns", count: 2 },
"an edited interval remains an explicit Goal override");
assert.deepEqual(goalReplanCadenceWriteValue({ count_unit: "completed_todos", count: 2, stride_strategy: "off" },
assert.deepEqual(goalReplanCadenceWriteValue({ count_unit: "completed_todos", count: 2 },
false),
{ stride_strategy: "off" },
{},
"legacy device units can be inherited without pinning their count");
assert.equal(hasReplanCadenceOverride({ stride_strategy: "evidence_conditioned_v1" }), false);
assert.equal(hasReplanCadenceOverride({ planning_horizon_goal: false }), false);
assert.equal(hasReplanCadenceOverride({ count_unit: "effective_turns", count: 3 }), true);
assert.equal(hasReplanCadenceOverride({ completed_todos: 2 }), true, "legacy pinned cadences stay explicit");
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview, stride_strategy: "evidence_conditioned_v1" }, true),
{ ...inheritedReview, stride_strategy: "evidence_conditioned_v1" },
assert.deepEqual(goalReplanCadenceWriteValue({ ...inheritedReview }, true),
{ ...inheritedReview },
"an explicit interval remains pinned even when it matches the machine policy");
assert.deepEqual(goalReplanCadenceWriteValue({ count_unit: "effective_turns", count: 2, stride_strategy: "evidence_conditioned_v1" }, false),
{ stride_strategy: "evidence_conditioned_v1" },
assert.deepEqual(goalReplanCadenceWriteValue({ count_unit: "effective_turns", count: 2, yardstick_enabled: true }, false),
{ yardstick_enabled: true },
"removing JSON interval fields clears only the cadence, including a previously pinned value");
const storageDefault = { schema_version: "loopx_goal_storage_defaults_v1", new_goal_provider: "sqlite",
canonical_creation: true, new_goal_handoff_mode: "hard_lease" };
Expand Down Expand Up @@ -172,12 +184,8 @@ assert.deepEqual(
"an explicit Goal CI opt-out must survive default projection and omit envelope fields",
);

// Capability defaults may enable Stride without changing saved legacy choices.
const enabledStrideDefault = {...cadenceDefault, stride_strategy: "evidence_conditioned_v1"};
assert.deepEqual(goalReplanCadenceEditorValue(null, enabledStrideDefault), enabledStrideDefault);
assert.equal(goalReplanCadenceEditorValue({stride_strategy: "off"}, enabledStrideDefault).stride_strategy, "off");
assert.equal(goalReplanCadenceEditorValue({count_unit: "effective_turns", count: 3}, enabledStrideDefault).stride_strategy, "off");
assert.equal(projectEditableCapabilityConfiguration(cadenceEditor, {}, enabledStrideDefault).stride_strategy, "evidence_conditioned_v1");
// An unconfigured Goal displays the live inherited review value unchanged.
assert.deepEqual(goalReplanCadenceEditorValue(null, cadenceDefault), cadenceDefault);

// Independent Yardstick inheritance must not be pinned by editing the interval.
const yardstickEffective = {...inheritedReview, yardstick_enabled: true};
Expand All @@ -186,6 +194,6 @@ assert.deepEqual(goalReplanCadenceWriteValue({...yardstickEffective, count: 2},
{...inheritedReview, count: 2}, "an unchanged inherited measurement choice stays live");
for (const enabled of [true, false]) {
assert.deepEqual(goalReplanCadenceWriteValue({...yardstickEffective, yardstick_enabled: enabled}, false, false, true),
{stride_strategy: "off", yardstick_enabled: enabled}, "explicit measurement opt-in and opt-out survive form saving");
{yardstick_enabled: enabled}, "explicit measurement opt-in and opt-out survive form saving");
}
assert.equal(replanCadenceEditorDefaults(yardstickEffective, {...cadenceDefault, yardstick_enabled: false}).yardstick_enabled, true);
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ export function parseEditableCapabilityJson(
return value as Record<string, unknown>;
}

/** Read the legacy cadence without reinterpreting its unit or writing it back. */
/**
* Read the legacy cadence without reinterpreting its unit or writing it back.
* Evidence-conditioned stride is always on; a legacy saved `stride_strategy`
* is history only, so the editor never displays or resubmits it.
*/
export function replanCadenceEditorValue(value: unknown): unknown {
const record = configurationObject(value);
if (Object.hasOwn(record, "completed_todos") && !Object.hasOwn(record, "count_unit")) {
return { count_unit: "completed_todos", count: record.completed_todos, stride_strategy: "off" };
return { count_unit: "completed_todos", count: record.completed_todos };
}
return { ...record, stride_strategy: record.stride_strategy ?? "off" };
const editable = { ...record };
delete editable.stride_strategy;
return editable;
}

/** Fill omitted review interval fields from the currently effective value. */
Expand All @@ -79,11 +85,10 @@ export function replanCadenceEditorDefaults(effective: unknown, fallback: unknow
if (Object.hasOwn(live, "count")) defaults.count = live.count;
if (Object.hasOwn(live, "planning_horizon_goal")) defaults.planning_horizon_goal = live.planning_horizon_goal;
if (Object.hasOwn(live, "yardstick_enabled")) defaults.yardstick_enabled = live.yardstick_enabled;
// Strategy omission keeps the existing default-off meaning.
return defaults;
}

/** Show the live interval when a Goal stores only its strategy choice. */
/** Show the live interval when a Goal stores only horizon or Yardstick choices. */
export function goalReplanCadenceEditorValue(current: unknown, effective: unknown): Record<string, unknown> {
const inherited = configurationObject(replanCadenceEditorValue(effective));
return current == null ? inherited : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const capabilityCopy: Record<WorkspaceLocale, Record<string, LocalizedCopy>> = {
displayName: "Isolated OpenViking memory",
description: "Connects owner private steward conversations to an isolated OpenViking memory namespace with per-speaker preferences and bounded recall.",
},
todo_replan_cadence: { displayName: "Goal review and stride", description: "Set review frequency and optionally choose a versioned stride strategy for work scope and route changes." },
todo_replan_cadence: { displayName: "Goal review and stride", description: "Set review frequency. Evidence-conditioned stride (v1) is always on and reviews work scope and route changes." },
change_quality_qualification: {
displayName: "Change quality qualification",
description: "Prepares a provider-neutral review packet, allows at most one policy-authorized safe-fix pass, and can require an exact-diff receipt.",
Expand Down Expand Up @@ -103,7 +103,7 @@ const capabilityCopy: Record<WorkspaceLocale, Record<string, LocalizedCopy>> = {
displayName: "独立 OpenViking 长期记忆",
description: "为本人私聊管家启用独立身份的 OpenViking 记忆命名空间:按已验证发言人持久化偏好、跨会话按需检索并限制超时,不向群聊或工作 Agent 泄露。",
},
todo_replan_cadence: { displayName: "Goal 复盘与步幅", description: "设置复盘周期,可选用带版本的步幅策略,调节工作大小与路线变化。" },
todo_replan_cadence: { displayName: "Goal 复盘与步幅", description: "设置复盘周期。依据证据的步幅策略(v1)始终开启,复核工作大小与路线变化。" },
change_quality_qualification: {
displayName: "变更质量验证",
description: "生成与 Provider 无关的审阅包,最多允许一次策略授权的安全修复,并可要求精确 diff 回执。",
Expand Down Expand Up @@ -178,7 +178,6 @@ const fieldCopy: Record<WorkspaceLocale, FieldCopy> = {
count_unit: { label: "Review after", description: "Work Turns require accepted settlement; polls and retries do not count.", options: { completed_todos: "Completed Todos", effective_turns: "Settled work Turns" } },
planning_horizon_goal: { label: "Show Goal in planning horizon", description: "Default on. Keep the original Goal and acceptance visible before choosing work. Turn off for rollback or comparisons; replan, stride and execution authority are unchanged." },
yardstick_enabled: { label: "Review measurement criteria", description: "Default off. Review measurement scope and feedback using available Explore evidence. Requires Explore evidence; does not enable it or authorize execution." },
stride_strategy: { label: "Stride strategy", description: "Structured work scope, route and validation proposals are required for enabled fresh Vision reviews. Does not grant execution authority.", options: { off: "Off", evidence_conditioned_v1: "Evidence-conditioned · v1" } },
count: { label: "Number between reviews", description: "Settled work Turns: 1–6; completed Todos: 1–5. Goal overrides take precedence over device defaults." },
allowed_domains: { label: "Allowed responsibility domains", description: "Enter one bounded, public-safe domain per line." },
coordinator_agent_id: { label: "Coordinator Agent", description: "Use an already registered Agent id; leave blank to disable coordination." },
Expand Down Expand Up @@ -219,7 +218,6 @@ const fieldCopy: Record<WorkspaceLocale, FieldCopy> = {
count_unit: { label: "复核计数依据", description: "有效工作 Turn 须完成结算;轮询和重复重试不计数。", options: { completed_todos: "已完成 Todo", effective_turns: "已结算工作 Turn" } },
planning_horizon_goal: { label: "在规划视野中显示 Goal", description: "默认开启,选择工作前可见原目标与验收要求。可为回滚或对照实验关闭;不改变复盘、步幅策略或执行权限。" },
yardstick_enabled: { label: "复核衡量标准", description: "默认关闭。使用已有 Explore 证据复核测量范围与反馈;需有可用的 Explore 证据,不会自动启用它或授予执行权限。" },
stride_strategy: { label: "步幅策略", description: "启用后,新的 Vision 路线复盘须提交工作大小、路线及验证范围的结构化提案,不授予执行权限。", options: { off: "关闭", evidence_conditioned_v1: "依据证据调整 · v1" } },
count: { label: "两次复核间的数量", description: "已结算工作 Turn 为 1–6,已完成 Todo 为 1–5;Goal 显式设置优先于设备默认值。" },
allowed_domains: { label: "允许的职责域", description: "每行填写一个有边界、可公开的职责域。" },
coordinator_agent_id: { label: "协调 Agent", description: "填写一个已经注册的 Agent ID;留空表示关闭协调。" },
Expand Down
Loading
Loading