@hassangameryt/freeflow 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/NOTICE +14 -0
- package/README.md +151 -136
- package/capabilities/cognitive-routing/SKILL.md +110 -96
- package/capabilities/cognitive-routing/references/both-mode.md +36 -0
- package/capabilities/cognitive-routing/references/executor-mode.md +48 -0
- package/capabilities/cognitive-routing/references/helper-mode.md +47 -0
- package/capabilities/compaction/SKILL.md +49 -0
- package/capabilities/compaction/references/summary-format.md +239 -0
- package/command-surface.json +4 -0
- package/gemini-extension.json +1 -1
- package/hooks/shared/runtime-context.mjs +28 -30
- package/licenses/Apache-2.0.txt +55 -0
- package/package.json +22 -9
- package/pi-extension/README.md +41 -0
- package/pi-extension/dist/cognitive-routing/assembler.js +393 -0
- package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/config.js +40 -21
- package/pi-extension/dist/cognitive-routing/economics.js +45 -0
- package/pi-extension/dist/cognitive-routing/event-schema.js +388 -0
- package/pi-extension/dist/cognitive-routing/event-store.js +280 -0
- package/pi-extension/dist/cognitive-routing/gate.js +241 -0
- package/pi-extension/dist/cognitive-routing/handlers.js +899 -0
- package/pi-extension/dist/cognitive-routing/handoffs.js +350 -0
- package/pi-extension/dist/cognitive-routing/model-control.js +467 -0
- package/pi-extension/dist/cognitive-routing/projection.js +503 -0
- package/pi-extension/dist/cognitive-routing/provenance.js +81 -0
- package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/render.js +31 -10
- package/pi-extension/dist/cognitive-routing/runtime.js +396 -0
- package/pi-extension/dist/cognitive-routing/schemas.js +209 -0
- package/pi-extension/dist/cognitive-routing/session.js +221 -0
- package/pi-extension/dist/cognitive-routing/sources.js +291 -0
- package/pi-extension/dist/cognitive-routing/state.js +487 -0
- package/pi-extension/dist/cognitive-routing/status.js +80 -0
- package/pi-extension/dist/cognitive-routing/tools.js +60 -0
- package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/types.js +10 -12
- package/pi-extension/dist/compaction/carry.js +191 -0
- package/pi-extension/dist/compaction/config.js +22 -0
- package/pi-extension/dist/compaction/controller.js +471 -0
- package/pi-extension/dist/compaction/harness.js +77 -0
- package/pi-extension/dist/compaction/results.js +158 -0
- package/pi-extension/dist/compaction/thresholds.js +35 -0
- package/pi-extension/dist/compaction/tool.js +57 -0
- package/pi-extension/dist/host/branch.js +13 -0
- package/pi-extension/dist/host/canonical.js +12 -0
- package/pi-extension/dist/host/catalog.js +77 -0
- package/pi-extension/dist/host/config.js +374 -0
- package/pi-extension/dist/host/projection-tags.js +60 -0
- package/pi-extension/dist/host/prompts.js +82 -0
- package/pi-extension/dist/{session-sources → host}/read-only-session.js +112 -1
- package/pi-extension/dist/host/request-history.js +298 -0
- package/pi-extension/dist/host/runtime-state.js +189 -0
- package/pi-extension/dist/host/settings/freeflow-command.js +1570 -0
- package/pi-extension/dist/{settings/settings-tui.js → host/settings/settings-view.js} +186 -73
- package/pi-extension/dist/host/staging.js +28 -0
- package/pi-extension/dist/host/status.js +101 -0
- package/pi-extension/dist/index.js +441 -170
- package/pi-extension/dist/provider-support/cache/anchor.js +21 -0
- package/pi-extension/dist/provider-support/cache/anthropic.js +102 -0
- package/pi-extension/dist/provider-support/cache/health.js +73 -0
- package/pi-extension/dist/provider-support/cache/index.js +58 -0
- package/pi-extension/dist/provider-support/cache/keepalive.js +210 -0
- package/pi-extension/dist/provider-support/cache/monitor.js +17 -0
- package/pi-extension/dist/provider-support/cache/openai-responses.js +48 -0
- package/pi-extension/dist/provider-support/effort.js +13 -0
- package/pi-extension/dist/provider-support/index.js +45 -0
- package/pi-extension/dist/provider-support/openai/adapter.js +127 -0
- package/pi-extension/dist/provider-support/openai/history.js +127 -0
- package/pi-extension/dist/provider-support/openai/index.js +15 -0
- package/pi-extension/dist/provider-support/openai/session-state.js +105 -0
- package/pi-extension/dist/provider-support/routes.js +17 -0
- package/pi-extension/dist/tool-execution/apply-patch/grammar.js +23 -0
- package/pi-extension/dist/tool-execution/apply-patch/match.js +38 -0
- package/pi-extension/dist/tool-execution/apply-patch/parser.js +177 -0
- package/pi-extension/dist/tool-execution/apply-patch/plan.js +201 -0
- package/pi-extension/dist/tool-execution/apply-patch/tool.js +84 -0
- package/pi-extension/dist/tool-execution/background.js +238 -0
- package/pi-extension/dist/tool-execution/bash-guard.js +23 -0
- package/pi-extension/dist/tool-execution/config.js +22 -0
- package/pi-extension/dist/tool-execution/edit-messages.js +120 -0
- package/pi-extension/dist/tool-execution/file-state.js +138 -0
- package/pi-extension/dist/tool-execution/file-tracking.js +143 -0
- package/pi-extension/dist/tool-execution/prompt.js +54 -0
- package/pi-extension/dist/tool-execution/tools.js +16 -0
- package/pi-extension/freeflow/README.md +9 -0
- package/plugin.json +1 -1
- package/runtime/prompts/cognitive-routing.md +4 -4
- package/runtime/prompts/core.md +22 -75
- package/runtime/prompts/interaction-contract.md +15 -8
- package/runtime/prompts/tool-execution.md +38 -0
- package/runtime/prompts/working-method.md +108 -0
- package/skills/action-selection/SKILL.md +39 -47
- package/skills/action-selection/references/trajectory-stalls.md +2 -0
- package/skills/bypass/SKILL.md +2 -2
- package/skills/commit-work/SKILL.md +31 -83
- package/skills/commit-work/references/git-state-edges.md +1 -1
- package/skills/commit-work/references/simple-push.md +2 -0
- package/skills/commit-work/references/staging-decisions.md +1 -1
- package/skills/decision-gate/SKILL.md +31 -50
- package/skills/design-for-depth/SKILL.md +44 -53
- package/skills/design-for-depth/references/design-pressure-signals.md +46 -144
- package/skills/design-for-depth/references/implementation-decisions.md +4 -4
- package/skills/design-for-depth/references/interface-design-loop.md +5 -36
- package/skills/design-for-depth/references/module-and-dependency-design.md +2 -32
- package/skills/design-for-depth/references/state-and-failure-boundaries.md +2 -13
- package/skills/diagnose-failure/SKILL.md +39 -24
- package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +2 -0
- package/skills/diagnose-failure/references/flaky-and-performance-diagnosis.md +2 -2
- package/skills/discuss/SKILL.md +37 -13
- package/skills/discuss/references/discussion-continuity.md +7 -27
- package/skills/evaluate-skill/SKILL.md +49 -80
- package/skills/evaluate-skill/references/evaluation-definition-schema.md +35 -5
- package/skills/evaluate-skill/references/evaluation-design.md +14 -14
- package/skills/evaluate-skill/references/execution-and-evidence.md +26 -5
- package/skills/evaluate-skill/references/review-and-revision.md +3 -1
- package/skills/evaluate-skill/scripts/lib/definitions.mjs +49 -8
- package/skills/evaluate-skill/scripts/lib/pi.mjs +14 -7
- package/skills/evaluate-skill/scripts/lib/review.mjs +196 -0
- package/skills/evaluate-skill/scripts/lib/runner.mjs +45 -8
- package/skills/evaluate-skill/scripts/lib/sandbox.mjs +2 -0
- package/skills/evaluate-skill/scripts/lib/trials.mjs +103 -0
- package/skills/evaluate-skill/scripts/lib/view.mjs +67 -1
- package/skills/evaluate-skill/scripts/pi-command-tool.mjs +144 -0
- package/skills/evaluate-skill/scripts/pi-guard.mjs +30 -13
- package/skills/evaluate-skill/scripts/skill-eval.mjs +114 -34
- package/skills/execute-work/SKILL.md +41 -9
- package/skills/execute-work/references/code-practices.md +2 -0
- package/skills/execute-work/references/execute-work-edges.md +11 -1
- package/skills/handoff/SKILL.md +1 -1
- package/skills/handoff/references/handoff-templates.md +1 -1
- package/skills/review-artifact/SKILL.md +42 -41
- package/skills/review-artifact/references/adjudicate-artifact-review.md +1 -1
- package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +1 -1
- package/skills/review-work/SKILL.md +38 -32
- package/skills/review-work/references/adjudicate-work-review.md +1 -1
- package/skills/review-work/references/independent-work-reviewer-contract.md +1 -1
- package/skills/review-work/references/security-risk-lens.md +2 -4
- package/skills/setup-freeflow/SKILL.md +3 -1
- package/skills/setup-freeflow/references/activation-contract.md +7 -13
- package/skills/setup-freeflow/references/host-setup.md +3 -3
- package/skills/track-work/SKILL.md +113 -161
- package/skills/track-work/references/working-record-format.md +189 -350
- package/skills/track-work/scripts/lib/document.mjs +62 -6
- package/skills/track-work/scripts/lib/format.mjs +16 -1
- package/skills/track-work/scripts/lib/store.mjs +9 -8
- package/skills/track-work/scripts/lib/transitions.mjs +79 -4
- package/skills/track-work/scripts/working-record.mjs +34 -12
- package/skills/verify-work/SKILL.md +29 -20
- package/skills/verify-work/references/browser-runtime-evidence.md +1 -5
- package/skills/verify-work/references/integration-evidence.md +2 -0
- package/skills/verify-work/references/performance-evidence.md +3 -1
- package/skills/verify-work/references/test-design.md +3 -1
- package/skills/workflow/SKILL.md +65 -21
- package/skills/workflow/references/domain-skill-composition.md +5 -3
- package/skills/write-docs/SKILL.md +83 -0
- package/skills/write-docs/references/documentation-shapes.md +119 -0
- package/skills/write-docs/scripts/docs-check.mjs +139 -0
- package/skills/write-plan/SKILL.md +40 -40
- package/skills/write-plan/references/plan-shapes.md +1 -1
- package/skills/write-skill/SKILL.md +107 -147
- package/skills/write-skill/references/activation-boundaries.md +2 -0
- package/skills/write-skill/references/agent-first-instructions.md +22 -10
- package/skills/write-skill/references/progressive-disclosure.md +4 -2
- package/skills/write-skill/references/skill-dependency-graphs.md +2 -0
- package/skills/write-skill/scripts/lib/similarity.mjs +56 -0
- package/skills/write-skill/scripts/skill-author.mjs +18 -2
- package/skills/write-spec/SKILL.md +34 -41
- package/skills/write-spec/references/artifact-standards.md +1 -1
- package/skills/write-spec/references/decision-records.md +2 -0
- package/skills/write-spec/references/spec-shapes.md +1 -1
- package/capabilities/context-virtualization/SKILL.md +0 -103
- package/capabilities/conversation-history/SKILL.md +0 -53
- package/hooks/tests/check-host-adapters.test.mjs +0 -82
- package/hooks/tests/check-runtime-context-hook.sh +0 -212
- package/pi-extension/dist/cognitive-routing-v2/projection.js +0 -321
- package/pi-extension/dist/cognitive-routing-v2/runtime.js +0 -1585
- package/pi-extension/dist/cognitive-routing-v2/schemas.js +0 -107
- package/pi-extension/dist/cognitive-routing-v2/state.js +0 -612
- package/pi-extension/dist/cognitive-routing-v2/tools.js +0 -91
- package/pi-extension/dist/context-virtualization/commands.js +0 -89
- package/pi-extension/dist/context-virtualization/projector.js +0 -42
- package/pi-extension/dist/context-virtualization/runtime.js +0 -356
- package/pi-extension/dist/context-virtualization/state.js +0 -57
- package/pi-extension/dist/context-virtualization/types.js +0 -10
- package/pi-extension/dist/conversation-history/passages.js +0 -66
- package/pi-extension/dist/conversation-history/ranking.js +0 -105
- package/pi-extension/dist/conversation-history/runtime.js +0 -226
- package/pi-extension/dist/conversation-history/search.js +0 -56
- package/pi-extension/dist/conversation-history/types.js +0 -1
- package/pi-extension/dist/freeflow-context/resolver.js +0 -120
- package/pi-extension/dist/freeflow-context/runtime.js +0 -80
- package/pi-extension/dist/freeflow-context/source-projector.js +0 -95
- package/pi-extension/dist/freeflow-context/tool.js +0 -313
- package/pi-extension/dist/freeflow-context/types.js +0 -12
- package/pi-extension/dist/freeflow-context/visibility.js +0 -28
- package/pi-extension/dist/integrations/mcp-config.js +0 -29
- package/pi-extension/dist/runtime/runtime-context.js +0 -735
- package/pi-extension/dist/runtime/runtime-identity.js +0 -5
- package/pi-extension/dist/session-sources/events.js +0 -195
- package/pi-extension/dist/session-sources/sources.js +0 -233
- package/pi-extension/dist/settings/settings-ui.js +0 -1160
- package/pi-extension/dist/ui/text-component.js +0 -57
- package/pi-extension/src/cognitive-routing-v2/budget.ts +0 -42
- package/pi-extension/src/cognitive-routing-v2/config.ts +0 -143
- package/pi-extension/src/cognitive-routing-v2/projection.ts +0 -365
- package/pi-extension/src/cognitive-routing-v2/render.ts +0 -256
- package/pi-extension/src/cognitive-routing-v2/runtime.ts +0 -1634
- package/pi-extension/src/cognitive-routing-v2/schemas.ts +0 -109
- package/pi-extension/src/cognitive-routing-v2/state.ts +0 -622
- package/pi-extension/src/cognitive-routing-v2/tools.ts +0 -93
- package/pi-extension/src/cognitive-routing-v2/types.ts +0 -222
- package/pi-extension/src/context-virtualization/commands.ts +0 -111
- package/pi-extension/src/context-virtualization/projector.ts +0 -62
- package/pi-extension/src/context-virtualization/runtime.ts +0 -406
- package/pi-extension/src/context-virtualization/state.ts +0 -79
- package/pi-extension/src/context-virtualization/types.ts +0 -92
- package/pi-extension/src/conversation-history/passages.ts +0 -81
- package/pi-extension/src/conversation-history/ranking.ts +0 -155
- package/pi-extension/src/conversation-history/runtime.ts +0 -250
- package/pi-extension/src/conversation-history/search.ts +0 -79
- package/pi-extension/src/conversation-history/types.ts +0 -31
- package/pi-extension/src/freeflow-context/resolver.ts +0 -139
- package/pi-extension/src/freeflow-context/runtime.ts +0 -100
- package/pi-extension/src/freeflow-context/source-projector.ts +0 -106
- package/pi-extension/src/freeflow-context/tool.ts +0 -365
- package/pi-extension/src/freeflow-context/types.ts +0 -70
- package/pi-extension/src/freeflow-context/visibility.ts +0 -53
- package/pi-extension/src/index.ts +0 -368
- package/pi-extension/src/integrations/mcp-config.ts +0 -32
- package/pi-extension/src/runtime/runtime-context.ts +0 -838
- package/pi-extension/src/runtime/runtime-identity.ts +0 -8
- package/pi-extension/src/session-sources/events.ts +0 -208
- package/pi-extension/src/session-sources/read-only-session.ts +0 -170
- package/pi-extension/src/session-sources/sources.ts +0 -263
- package/pi-extension/src/settings/settings-tui.ts +0 -501
- package/pi-extension/src/settings/settings-ui.ts +0 -1422
- package/pi-extension/src/ui/text-component.ts +0 -66
- package/pi-extension/tests/cognitive-routing-v2/communication.test.js +0 -484
- package/pi-extension/tests/cognitive-routing-v2/compaction-input.test.js +0 -183
- package/pi-extension/tests/cognitive-routing-v2/native.test.js +0 -441
- package/pi-extension/tests/cognitive-routing-v2/performance.test.js +0 -87
- package/pi-extension/tests/cognitive-routing-v2/persistence.test.js +0 -245
- package/pi-extension/tests/cognitive-routing-v2/projection.test.js +0 -241
- package/pi-extension/tests/cognitive-routing-v2/recovery.test.js +0 -236
- package/pi-extension/tests/cognitive-routing-v2/render.test.js +0 -230
- package/pi-extension/tests/cognitive-routing-v2/runtime.test.js +0 -153
- package/pi-extension/tests/cognitive-routing-v2/stabilization.test.js +0 -521
- package/pi-extension/tests/cognitive-routing-v2/state.test.js +0 -275
- package/pi-extension/tests/context-virtualization/extension.test.js +0 -765
- package/pi-extension/tests/context-virtualization/projector.test.js +0 -110
- package/pi-extension/tests/context-virtualization/runtime.test.js +0 -216
- package/pi-extension/tests/conversation-history/runtime.test.js +0 -98
- package/pi-extension/tests/conversation-history/search.test.js +0 -97
- package/pi-extension/tests/fixtures/pi-host.js +0 -4
- package/pi-extension/tests/fixtures/routing-native.js +0 -188
- package/pi-extension/tests/integration/mode-free-core.test.js +0 -219
- package/pi-extension/tests/integration/pi-extension.test.js +0 -968
- package/pi-extension/tests/integration/prompt-architecture.test.js +0 -431
- package/pi-extension/tests/integration/unaffected-regressions.test.js +0 -478
- package/pi-extension/tests/settings/settings-tui.test.js +0 -243
- package/pi-extension/tsconfig.json +0 -16
- package/runtime/prompts/context-virtualization.md +0 -3
- package/runtime/prompts/conversation-history.md +0 -3
- package/skills/design-for-depth/references/software-design-philosophy.md +0 -202
- /package/pi-extension/dist/{cognitive-routing-v2 → cognitive-routing}/budget.js +0 -0
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { initialState, reduce, parseRoutingEvent } from "../../dist/cognitive-routing-v2/state.js";
|
|
4
|
-
const pair = { provider: "fixture", modelId: "model", thinking: "off" };
|
|
5
|
-
function machine() {
|
|
6
|
-
let s = initialState(),
|
|
7
|
-
n = 0;
|
|
8
|
-
return {
|
|
9
|
-
get state() {
|
|
10
|
-
return s;
|
|
11
|
-
},
|
|
12
|
-
event(data) {
|
|
13
|
-
return {
|
|
14
|
-
version: 2,
|
|
15
|
-
eventId: `event-${++n}`,
|
|
16
|
-
operationId: `op-${n}`,
|
|
17
|
-
stepId: data.type,
|
|
18
|
-
recordedSessionId: "session",
|
|
19
|
-
data,
|
|
20
|
-
};
|
|
21
|
-
},
|
|
22
|
-
apply(data) {
|
|
23
|
-
const e = this.event(data);
|
|
24
|
-
s = reduce(s, e);
|
|
25
|
-
return e;
|
|
26
|
-
},
|
|
27
|
-
set(e) {
|
|
28
|
-
s = reduce(s, e);
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
const control = (profile) => ({ type: "control", control: "automatic", profile, reason: "fixture control" });
|
|
33
|
-
const opened = (id, profile, assignmentId) => ({
|
|
34
|
-
type: "execution-opened",
|
|
35
|
-
execution: { id, profile, assignmentId, basisUserEntryId: "user", pair, resultEntryIds: [] },
|
|
36
|
-
});
|
|
37
|
-
const bound = (id) => ({
|
|
38
|
-
type: "execution-bound",
|
|
39
|
-
executionId: id,
|
|
40
|
-
assistantEntryId: `assistant-${id}`,
|
|
41
|
-
resultEntryIds: [],
|
|
42
|
-
outcome: "completed",
|
|
43
|
-
});
|
|
44
|
-
function delegated(id = "a1", unitId = "u1", assignmentIds = [id], executionId = "e1", replacement) {
|
|
45
|
-
const hid = `d-${id}`;
|
|
46
|
-
return {
|
|
47
|
-
type: "delegate-accepted",
|
|
48
|
-
unit: { id: unitId, objective: "fixture objective", state: "open", assignmentIds },
|
|
49
|
-
assignment: {
|
|
50
|
-
id,
|
|
51
|
-
unitId,
|
|
52
|
-
contract: "fixture contract",
|
|
53
|
-
basisUserEntryId: "user",
|
|
54
|
-
state: "outstanding",
|
|
55
|
-
delegateHandoffId: hid,
|
|
56
|
-
},
|
|
57
|
-
handoff: {
|
|
58
|
-
id: hid,
|
|
59
|
-
kind: "delegate",
|
|
60
|
-
assignmentId: id,
|
|
61
|
-
text: "fixture contract",
|
|
62
|
-
from: "coordinator",
|
|
63
|
-
to: "executor",
|
|
64
|
-
executionId,
|
|
65
|
-
toolCallId: `call-${executionId}`,
|
|
66
|
-
basisUserEntryId: "user",
|
|
67
|
-
state: "pending",
|
|
68
|
-
reportRevision: 0,
|
|
69
|
-
limitations: [],
|
|
70
|
-
},
|
|
71
|
-
...(replacement ? { replacement } : {}),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function returned(report = "exact report", revision = 1) {
|
|
75
|
-
return {
|
|
76
|
-
type: "return-accepted",
|
|
77
|
-
handoff: {
|
|
78
|
-
id: "return",
|
|
79
|
-
kind: "return",
|
|
80
|
-
assignmentId: "a1",
|
|
81
|
-
text: report,
|
|
82
|
-
from: "executor",
|
|
83
|
-
to: "coordinator",
|
|
84
|
-
executionId: "e2",
|
|
85
|
-
toolCallId: "return-call",
|
|
86
|
-
basisUserEntryId: "user",
|
|
87
|
-
state: "pending",
|
|
88
|
-
reportRevision: revision,
|
|
89
|
-
outcome: "partial",
|
|
90
|
-
limitations: ["uncertainty retained"],
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function started() {
|
|
95
|
-
const m = machine();
|
|
96
|
-
m.apply(control("coordinator"));
|
|
97
|
-
m.apply(opened("e1", "coordinator"));
|
|
98
|
-
m.apply(delegated());
|
|
99
|
-
m.apply(bound("e1"));
|
|
100
|
-
m.apply({ type: "handoff-state", handoffId: "d-a1", state: "configured", observedPair: pair });
|
|
101
|
-
return m;
|
|
102
|
-
}
|
|
103
|
-
const reservation = (revision) => ({
|
|
104
|
-
id: "reservation",
|
|
105
|
-
selectionRevision: revision,
|
|
106
|
-
receiver: "coordinator",
|
|
107
|
-
target: pair,
|
|
108
|
-
qualification: "fixture",
|
|
109
|
-
sources: [],
|
|
110
|
-
maximumInputTokens: 10000,
|
|
111
|
-
outputReserve: 1000,
|
|
112
|
-
estimateMethod: "fixture",
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test("event identity and operation idempotency reject changed payloads", () => {
|
|
116
|
-
const m = machine(),
|
|
117
|
-
e = m.apply(control("coordinator"));
|
|
118
|
-
const before = m.state;
|
|
119
|
-
m.set(e);
|
|
120
|
-
assert.equal(m.state, before);
|
|
121
|
-
assert.throws(
|
|
122
|
-
() => m.set({ ...e, data: control("executor") }),
|
|
123
|
-
(e) => e.code === "event_identity_conflict",
|
|
124
|
-
);
|
|
125
|
-
assert.throws(
|
|
126
|
-
() => m.set({ ...e, eventId: "other", data: control("executor") }),
|
|
127
|
-
(e) => e.code === "operation_conflict",
|
|
128
|
-
);
|
|
129
|
-
});
|
|
130
|
-
test("closed nested schemas reject malformed optional handoff and source fields", () => {
|
|
131
|
-
const m = machine();
|
|
132
|
-
for (const patch of [{ reason: {} }, { outcome: 123 }, { unexpected: "field" }]) {
|
|
133
|
-
const data = delegated();
|
|
134
|
-
Object.assign(data.handoff, patch);
|
|
135
|
-
assert.throws(
|
|
136
|
-
() => parseRoutingEvent(m.event(data)),
|
|
137
|
-
(e) => e.code === "invalid_assignment",
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
const data = opened("e", "executor", "a");
|
|
141
|
-
data.execution.pair = { ...data.execution.pair, extra: "invalid" };
|
|
142
|
-
assert.throws(
|
|
143
|
-
() => parseRoutingEvent(m.event(data)),
|
|
144
|
-
(e) => e.code === "invalid_execution",
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
test("prototype names are bounded malformed events, not raw decoder errors", () => {
|
|
148
|
-
for (const type of ["constructor", "__proto__", "toString", "unknown"])
|
|
149
|
-
assert.throws(
|
|
150
|
-
() =>
|
|
151
|
-
parseRoutingEvent({
|
|
152
|
-
version: 2,
|
|
153
|
-
eventId: "e",
|
|
154
|
-
operationId: "o",
|
|
155
|
-
stepId: "s",
|
|
156
|
-
recordedSessionId: "session",
|
|
157
|
-
data: { type },
|
|
158
|
-
}),
|
|
159
|
-
(e) => e.name === "RoutingError" && e.code === "invalid_event_type",
|
|
160
|
-
);
|
|
161
|
-
});
|
|
162
|
-
test("outstanding assignments cannot be implicitly replaced", () => {
|
|
163
|
-
const m = started();
|
|
164
|
-
assert.throws(
|
|
165
|
-
() => m.apply(delegated("a2", "u1", ["a1", "a2"])),
|
|
166
|
-
(e) => e.code === "wrong_control",
|
|
167
|
-
);
|
|
168
|
-
m.apply(control("coordinator"));
|
|
169
|
-
assert.throws(
|
|
170
|
-
() => m.apply(delegated("a2", "u1", ["a1", "a2"])),
|
|
171
|
-
(e) => e.code === "assignment_outstanding",
|
|
172
|
-
);
|
|
173
|
-
assert.equal(m.state.assignments.size, 1);
|
|
174
|
-
});
|
|
175
|
-
test("replacement retains old assignment and requires old execution to be resolved", () => {
|
|
176
|
-
const m = started();
|
|
177
|
-
m.apply(opened("e2", "executor", "a1"));
|
|
178
|
-
m.apply(control("coordinator"));
|
|
179
|
-
m.apply(opened("e3", "coordinator", "a1"));
|
|
180
|
-
const replacement = delegated("a2", "u1", ["a1", "a2"], "e3", {
|
|
181
|
-
assignmentId: "a1",
|
|
182
|
-
reason: "current direction changed",
|
|
183
|
-
});
|
|
184
|
-
assert.throws(
|
|
185
|
-
() => m.apply(replacement),
|
|
186
|
-
(e) => e.code === "unresolved_executor_execution",
|
|
187
|
-
);
|
|
188
|
-
m.apply(bound("e2"));
|
|
189
|
-
m.apply(replacement);
|
|
190
|
-
assert.equal(m.state.unitId, "u1");
|
|
191
|
-
assert.equal(m.state.assignments.get("a1").state, "superseded");
|
|
192
|
-
assert.equal(m.state.assignments.get("a1").contract, "fixture contract");
|
|
193
|
-
assert.equal(m.state.assignmentId, "a2");
|
|
194
|
-
});
|
|
195
|
-
test("saved report revisions and retries preserve exact earlier events", () => {
|
|
196
|
-
const m = started();
|
|
197
|
-
m.apply(opened("e2", "executor", "a1"));
|
|
198
|
-
const first = m.apply(returned());
|
|
199
|
-
m.apply({ type: "handoff-state", handoffId: "return", state: "blocked", reason: "fixture gap" });
|
|
200
|
-
m.apply({
|
|
201
|
-
type: "handoff-retry-requested",
|
|
202
|
-
handoffId: "return",
|
|
203
|
-
attemptId: "retry",
|
|
204
|
-
executionId: "e2",
|
|
205
|
-
toolCallId: "retry-call",
|
|
206
|
-
reportRevision: 1,
|
|
207
|
-
selectionRevision: 0,
|
|
208
|
-
});
|
|
209
|
-
assert.equal(m.state.handoffs.get("return").text, "exact report");
|
|
210
|
-
assert.equal(m.state.handoffs.get("return").reportRevision, 1);
|
|
211
|
-
m.apply(returned("revised exact report", 2));
|
|
212
|
-
assert.equal(m.state.handoffs.get("return").text, "revised exact report");
|
|
213
|
-
assert.equal([...m.state.events.values()].find((e) => e.eventId === first.eventId).data.handoff.text, "exact report");
|
|
214
|
-
assert.equal(m.state.assignments.size, 1);
|
|
215
|
-
});
|
|
216
|
-
test("assessment resumption rejects stale selection and preserves suspension on failure", () => {
|
|
217
|
-
const m = started();
|
|
218
|
-
m.apply(opened("e2", "executor", "a1"));
|
|
219
|
-
m.apply(returned());
|
|
220
|
-
m.apply({
|
|
221
|
-
type: "selection-changed",
|
|
222
|
-
assignmentId: "a1",
|
|
223
|
-
selection: { revision: 1, selected: [], unresolved: [], withdrawals: [] },
|
|
224
|
-
});
|
|
225
|
-
m.apply({ type: "handoff-state", handoffId: "return", state: "configured", observedPair: pair });
|
|
226
|
-
m.apply({
|
|
227
|
-
type: "assessment-suspended",
|
|
228
|
-
handoffId: "return",
|
|
229
|
-
reason: "user-attention",
|
|
230
|
-
basisUserEntryId: "new-user",
|
|
231
|
-
problems: [],
|
|
232
|
-
});
|
|
233
|
-
assert.throws(
|
|
234
|
-
() =>
|
|
235
|
-
m.apply({
|
|
236
|
-
type: "assessment-resumed",
|
|
237
|
-
handoffId: "return",
|
|
238
|
-
basisUserEntryId: "new-user",
|
|
239
|
-
reservation: reservation(0),
|
|
240
|
-
}),
|
|
241
|
-
(e) => e.code === "stale_selection",
|
|
242
|
-
);
|
|
243
|
-
assert.equal(m.state.assessment.view, "suspended");
|
|
244
|
-
m.apply({
|
|
245
|
-
type: "assessment-resumed",
|
|
246
|
-
handoffId: "return",
|
|
247
|
-
basisUserEntryId: "new-user",
|
|
248
|
-
reservation: reservation(1),
|
|
249
|
-
});
|
|
250
|
-
assert.equal(m.state.assessment.view, "active");
|
|
251
|
-
});
|
|
252
|
-
test("accepted closure cannot conceal work; later work creates a new unit", () => {
|
|
253
|
-
const m = started();
|
|
254
|
-
m.apply(control("coordinator"));
|
|
255
|
-
assert.throws(
|
|
256
|
-
() => m.apply({ type: "unit-closed", unitId: "u1", outcome: "accepted", assessment: "incorrect" }),
|
|
257
|
-
(e) => e.code === "unfinished_work",
|
|
258
|
-
);
|
|
259
|
-
m.apply({
|
|
260
|
-
type: "unit-closed",
|
|
261
|
-
unitId: "u1",
|
|
262
|
-
outcome: "cancelled",
|
|
263
|
-
assessment: "user stopped work",
|
|
264
|
-
supersededAssignmentId: "a1",
|
|
265
|
-
});
|
|
266
|
-
assert.equal(m.state.units.get("u1").state, "closed");
|
|
267
|
-
m.apply(opened("e3", "coordinator"));
|
|
268
|
-
assert.throws(
|
|
269
|
-
() => m.apply(delegated("a2", "u1", ["a2"], "e3")),
|
|
270
|
-
(e) => e.code === "closed_unit_reused",
|
|
271
|
-
);
|
|
272
|
-
m.apply(delegated("a2", "u2", ["a2"], "e3"));
|
|
273
|
-
assert.equal(m.state.unitId, "u2");
|
|
274
|
-
assert.equal(m.state.units.size, 2);
|
|
275
|
-
});
|