@cleocode/contracts 2026.6.12 → 2026.6.14
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/dist/__tests__/operation-def.test.js +5 -1
- package/dist/__tests__/operation-def.test.js.map +1 -1
- package/dist/__tests__/provider-def.test.d.ts +12 -0
- package/dist/__tests__/provider-def.test.d.ts.map +1 -0
- package/dist/__tests__/provider-def.test.js +84 -0
- package/dist/__tests__/provider-def.test.js.map +1 -0
- package/dist/__tests__/sealed-credential.test.d.ts +19 -0
- package/dist/__tests__/sealed-credential.test.d.ts.map +1 -0
- package/dist/__tests__/sealed-credential.test.js +74 -0
- package/dist/__tests__/sealed-credential.test.js.map +1 -0
- package/dist/__tests__/service-provider.test.d.ts +17 -0
- package/dist/__tests__/service-provider.test.d.ts.map +1 -0
- package/dist/__tests__/service-provider.test.js +108 -0
- package/dist/__tests__/service-provider.test.js.map +1 -0
- package/dist/__tests__/skill-executor-contract.test.js +3 -0
- package/dist/__tests__/skill-executor-contract.test.js.map +1 -1
- package/dist/acceptance-gate.d.ts +2 -3
- package/dist/acceptance-gate.d.ts.map +1 -1
- package/dist/boundary.d.ts +52 -0
- package/dist/boundary.d.ts.map +1 -1
- package/dist/boundary.js +24 -19
- package/dist/boundary.js.map +1 -1
- package/dist/conduit.d.ts +171 -0
- package/dist/conduit.d.ts.map +1 -1
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +22 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config.d.ts +104 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/data-accessor.d.ts +21 -1
- package/dist/data-accessor.d.ts.map +1 -1
- package/dist/data-accessor.js.map +1 -1
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts +21 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.d.ts.map +1 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js +84 -0
- package/dist/dispatch/__tests__/tasks-gateway-crud-ops.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +1 -1
- package/dist/dispatch/identity.d.ts.map +1 -1
- package/dist/dispatch/identity.js +25 -0
- package/dist/dispatch/identity.js.map +1 -1
- package/dist/dispatch/operation-def.d.ts +20 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +1044 -182
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/docs/read.d.ts +2 -2
- package/dist/index.d.ts +25 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/lease-ipc/__tests__/freeze.test.d.ts +15 -0
- package/dist/lease-ipc/__tests__/freeze.test.d.ts.map +1 -0
- package/dist/lease-ipc/__tests__/freeze.test.js +313 -0
- package/dist/lease-ipc/__tests__/freeze.test.js.map +1 -0
- package/dist/lease-ipc/index.d.ts +17 -0
- package/dist/lease-ipc/index.d.ts.map +1 -0
- package/dist/lease-ipc/index.js +16 -0
- package/dist/lease-ipc/index.js.map +1 -0
- package/dist/lease-ipc/messages.d.ts +918 -0
- package/dist/lease-ipc/messages.d.ts.map +1 -0
- package/dist/lease-ipc/messages.js +476 -0
- package/dist/lease-ipc/messages.js.map +1 -0
- package/dist/lease-ipc/version.d.ts +41 -0
- package/dist/lease-ipc/version.d.ts.map +1 -0
- package/dist/lease-ipc/version.js +43 -0
- package/dist/lease-ipc/version.js.map +1 -0
- package/dist/llm/catalog-schema.d.ts +242 -0
- package/dist/llm/catalog-schema.d.ts.map +1 -0
- package/dist/llm/catalog-schema.js +153 -0
- package/dist/llm/catalog-schema.js.map +1 -0
- package/dist/llm/catalog-schema.json +139 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +14 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/interfaces.d.ts +23 -0
- package/dist/llm/interfaces.d.ts.map +1 -1
- package/dist/llm/oauth.d.ts +16 -2
- package/dist/llm/oauth.d.ts.map +1 -1
- package/dist/llm/onboarding.d.ts +126 -0
- package/dist/llm/onboarding.d.ts.map +1 -0
- package/dist/llm/onboarding.js +34 -0
- package/dist/llm/onboarding.js.map +1 -0
- package/dist/llm/provider-def.d.ts +254 -0
- package/dist/llm/provider-def.d.ts.map +1 -0
- package/dist/llm/provider-def.js +93 -0
- package/dist/llm/provider-def.js.map +1 -0
- package/dist/llm/sealed-credential.d.ts +164 -0
- package/dist/llm/sealed-credential.d.ts.map +1 -0
- package/dist/llm/sealed-credential.js +43 -0
- package/dist/llm/sealed-credential.js.map +1 -0
- package/dist/llm/system-of-use.d.ts +383 -0
- package/dist/llm/system-of-use.d.ts.map +1 -0
- package/dist/llm/system-of-use.js +238 -0
- package/dist/llm/system-of-use.js.map +1 -0
- package/dist/llm/system-resolver.d.ts +87 -11
- package/dist/llm/system-resolver.d.ts.map +1 -1
- package/dist/llm/system-resolver.js +14 -7
- package/dist/llm/system-resolver.js.map +1 -1
- package/dist/operations/__tests__/ensures-schema-registry.test.d.ts +17 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.d.ts.map +1 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.js +113 -0
- package/dist/operations/__tests__/ensures-schema-registry.test.js.map +1 -0
- package/dist/operations/admin.d.ts +124 -1
- package/dist/operations/admin.d.ts.map +1 -1
- package/dist/operations/ensures-schema-registry.d.ts +172 -0
- package/dist/operations/ensures-schema-registry.d.ts.map +1 -0
- package/dist/operations/ensures-schema-registry.js +226 -0
- package/dist/operations/ensures-schema-registry.js.map +1 -0
- package/dist/operations/entities.d.ts +110 -0
- package/dist/operations/entities.d.ts.map +1 -0
- package/dist/operations/entities.js +695 -0
- package/dist/operations/entities.js.map +1 -0
- package/dist/operations/llm.d.ts +116 -9
- package/dist/operations/llm.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.d.ts.map +1 -1
- package/dist/operations/output-contracts-data.js +230 -0
- package/dist/operations/output-contracts-data.js.map +1 -1
- package/dist/operations/service.d.ts +68 -0
- package/dist/operations/service.d.ts.map +1 -0
- package/dist/operations/service.js +336 -0
- package/dist/operations/service.js.map +1 -0
- package/dist/operations/tasks.d.ts +109 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/operations/tasks.js.map +1 -1
- package/dist/operations/validate.d.ts +1 -12
- package/dist/operations/validate.d.ts.map +1 -1
- package/dist/operations/validate.js +1 -1
- package/dist/playbook.d.ts +116 -0
- package/dist/playbook.d.ts.map +1 -1
- package/dist/release/plan.d.ts +5 -5
- package/dist/session.d.ts +11 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/templates/manifest.d.ts +1 -1
- package/dist/tools/agent-tools.d.ts +231 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +25 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/atomic.d.ts +19 -0
- package/dist/tools/atomic.d.ts.map +1 -1
- package/dist/tools/atomic.js +17 -0
- package/dist/tools/atomic.js.map +1 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/skill-executor.d.ts +7 -0
- package/dist/tools/skill-executor.d.ts.map +1 -1
- package/dist/tools/web-tools.d.ts +217 -0
- package/dist/tools/web-tools.d.ts.map +1 -0
- package/dist/tools/web-tools.js +31 -0
- package/dist/tools/web-tools.js.map +1 -0
- package/dist/vault/service-provider.d.ts +343 -0
- package/dist/vault/service-provider.d.ts.map +1 -0
- package/dist/vault/service-provider.js +857 -0
- package/dist/vault/service-provider.js.map +1 -0
- package/dist/workgraph.d.ts +12 -12
- package/package.json +14 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/__tests__/operation-def.test.ts +7 -1
- package/src/__tests__/provider-def.test.ts +93 -0
- package/src/__tests__/sealed-credential.test.ts +100 -0
- package/src/__tests__/service-provider.test.ts +129 -0
- package/src/__tests__/skill-executor-contract.test.ts +3 -0
- package/src/acceptance-gate.ts +2 -3
- package/src/boundary.ts +70 -20
- package/src/conduit.ts +200 -0
- package/src/config/index.ts +35 -0
- package/src/config.ts +106 -1
- package/src/data-accessor.ts +22 -1
- package/src/dispatch/__tests__/tasks-gateway-crud-ops.test.ts +99 -0
- package/src/dispatch/identity.ts +25 -0
- package/src/dispatch/operation-def.ts +21 -0
- package/src/dispatch/operations-registry.ts +1083 -176
- package/src/index.ts +240 -25
- package/src/lease-ipc/__tests__/freeze.test.ts +342 -0
- package/src/lease-ipc/index.ts +75 -0
- package/src/lease-ipc/messages.ts +588 -0
- package/src/lease-ipc/version.ts +46 -0
- package/src/llm/catalog-schema.json +139 -0
- package/src/llm/catalog-schema.ts +184 -0
- package/src/llm/index.ts +29 -0
- package/src/llm/interfaces.ts +23 -0
- package/src/llm/oauth.ts +16 -2
- package/src/llm/onboarding.ts +131 -0
- package/src/llm/provider-def.ts +291 -0
- package/src/llm/sealed-credential.ts +166 -0
- package/src/llm/system-of-use.ts +503 -0
- package/src/llm/system-resolver.ts +91 -11
- package/src/operations/__tests__/ensures-schema-registry.test.ts +169 -0
- package/src/operations/admin.ts +144 -0
- package/src/operations/ensures-schema-registry.ts +260 -0
- package/src/operations/entities.ts +758 -0
- package/src/operations/llm.ts +120 -8
- package/src/operations/output-contracts-data.ts +264 -0
- package/src/operations/service.ts +360 -0
- package/src/operations/tasks.ts +119 -0
- package/src/operations/validate.ts +1 -14
- package/src/playbook.ts +117 -0
- package/src/session.ts +11 -0
- package/src/tools/agent-tools.ts +270 -0
- package/src/tools/atomic.ts +21 -0
- package/src/tools/index.ts +46 -0
- package/src/tools/skill-executor.ts +7 -0
- package/src/tools/web-tools.ts +247 -0
- package/src/vault/service-provider.ts +1137 -0
- package/dist/tessera.d.ts +0 -32
- package/dist/tessera.d.ts.map +0 -1
- package/dist/tessera.js +0 -11
- package/dist/tessera.js.map +0 -1
- package/dist/warp-chain.d.ts +0 -129
- package/dist/warp-chain.d.ts.map +0 -1
- package/dist/warp-chain.js +0 -13
- package/dist/warp-chain.js.map +0 -1
- package/src/tessera.ts +0 -35
- package/src/warp-chain.ts +0 -185
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SystemOfUse` taxonomy — the structured identity of every CLEO subsystem that
|
|
3
|
+
* may request an LLM through the E9 chokepoint (`resolveLLMForSystem`).
|
|
4
|
+
*
|
|
5
|
+
* ## Why a discriminated descriptor (the hermes `_AUX_TASKS` analog)
|
|
6
|
+
*
|
|
7
|
+
* The first cut of the E9 chokepoint (T11749) accepted a flat string-literal
|
|
8
|
+
* label ({@link SystemOfUseLabel} — `'sentient' | 'memory' | …`). That covered
|
|
9
|
+
* the seven role-mapped background subsystems but had no room for the OTHER
|
|
10
|
+
* axes CLEO routes LLMs along:
|
|
11
|
+
*
|
|
12
|
+
* - **orchestration tiers** (`frontier`/`standard`/`fast`/`local`) — the
|
|
13
|
+
* capability lane a delegated turn runs in, independent of any role;
|
|
14
|
+
* - **tools / skills** — atomic tool primitives and `ct-*` skills that each
|
|
15
|
+
* may pin a model (the hermes `_AUX_TASKS` registry: one entry per named
|
|
16
|
+
* auxiliary task, each with its own provider/model binding);
|
|
17
|
+
* - **cantbook nodes** — per-node model selection inside a `.cantbook` flow;
|
|
18
|
+
* - **spawn units** — orchestrator-spawned worker agents that resolve their
|
|
19
|
+
* own LLM.
|
|
20
|
+
*
|
|
21
|
+
* `SystemOfUse` is the discriminated `{ kind, id }` descriptor that unifies all
|
|
22
|
+
* of these axes under ONE identity type. {@link BUILTIN_SYSTEMS_OF_USE} is the
|
|
23
|
+
* static registry of the well-known systems (orchestration tiers + the seven
|
|
24
|
+
* {@link RoleName}s + the auxiliary systems); `tool:` / `skill:` / `cantbook:` /
|
|
25
|
+
* `spawn-unit:` keys are OPEN — any runtime id is a valid `SystemOfUse` of the
|
|
26
|
+
* corresponding kind without a registry edit (see {@link OPEN_SYSTEM_KEY_PREFIXES}).
|
|
27
|
+
*
|
|
28
|
+
* ## Relationship to the resolver input
|
|
29
|
+
*
|
|
30
|
+
* This descriptor is the *taxonomy / identity* layer. The E9 resolver
|
|
31
|
+
* (`resolveLLMForSystem`) still accepts the ergonomic flat {@link SystemOfUseLabel}
|
|
32
|
+
* for the seven role-mapped background subsystems (its locked contract); this
|
|
33
|
+
* file is the SSoT that label set is derived against ({@link AUX_SYSTEM_IDS}),
|
|
34
|
+
* and the home of the richer descriptor that profile-axis routing (tiers,
|
|
35
|
+
* tools, skills, cantbook nodes, spawn units) keys off.
|
|
36
|
+
*
|
|
37
|
+
* Contracts-purity: this module is **types + `as const` DATA + type guards**
|
|
38
|
+
* only — no runtime logic (Gate 10 · T11418). The runtime encode/decode for the
|
|
39
|
+
* open-axis string keys (`parseSystemKey` / `formatSystemKey`) is intentionally
|
|
40
|
+
* NOT defined here; it lives in `@cleocode/core` so this package stays type-only
|
|
41
|
+
* (this module exposes only the {@link OPEN_SYSTEM_KEY_PREFIXES} DATA those
|
|
42
|
+
* helpers read).
|
|
43
|
+
*
|
|
44
|
+
* @module llm/system-of-use
|
|
45
|
+
* @task T11747
|
|
46
|
+
* @epic T11745
|
|
47
|
+
*/
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Closed-axis value SSoTs (the type↔value mirrors)
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Value-level SSoT for the seven {@link RoleName}s.
|
|
53
|
+
*
|
|
54
|
+
* The `RoleName` *type* lives in `config.ts`; this `as const` tuple is the
|
|
55
|
+
* single iterable VALUE mirror used to build the registry (and any other
|
|
56
|
+
* `for (const role of ROLE_SYSTEM_IDS)` loop) so the role axis is enumerated
|
|
57
|
+
* from ONE place. A compile-time `satisfies readonly RoleName[]` keeps it
|
|
58
|
+
* locked to the type — adding a role to `RoleName` without extending this tuple
|
|
59
|
+
* is a type error.
|
|
60
|
+
*
|
|
61
|
+
* @task T11747
|
|
62
|
+
*/
|
|
63
|
+
export const ROLE_SYSTEM_IDS = [
|
|
64
|
+
'extraction',
|
|
65
|
+
'consolidation',
|
|
66
|
+
'derivation',
|
|
67
|
+
'hygiene',
|
|
68
|
+
'judgement',
|
|
69
|
+
'plugin',
|
|
70
|
+
'compression',
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Value-level SSoT for the user-facing, *enumerable* background {@link RoleName}s
|
|
74
|
+
* — the set `cleo llm whoami` reports and `cleo llm profile` accepts.
|
|
75
|
+
*
|
|
76
|
+
* This is the proper subset of {@link ROLE_SYSTEM_IDS} that excludes the two
|
|
77
|
+
* internal sandbox/utility roles (`plugin`, `compression`): they are resolved
|
|
78
|
+
* by code paths (plugin-scoped single-turn calls, context compression) rather
|
|
79
|
+
* than configured per-call by users, so they are intentionally NOT enumerated
|
|
80
|
+
* by the `whoami` / `profile` CLI surface.
|
|
81
|
+
*
|
|
82
|
+
* Sourcing the `cli-ops.ts` role list from THIS one tuple (instead of a
|
|
83
|
+
* duplicated inline array) is the AC3 "ALL_ROLES from one SSoT" requirement
|
|
84
|
+
* (T11750): the type-checker's `satisfies readonly RoleName[]` keeps every id
|
|
85
|
+
* locked to {@link RoleName}, so the enumerable set can never silently drift
|
|
86
|
+
* from the config vocabulary.
|
|
87
|
+
*
|
|
88
|
+
* @task T11750
|
|
89
|
+
* @epic T11745
|
|
90
|
+
*/
|
|
91
|
+
export const WHOAMI_ROLE_IDS = [
|
|
92
|
+
'extraction',
|
|
93
|
+
'consolidation',
|
|
94
|
+
'derivation',
|
|
95
|
+
'hygiene',
|
|
96
|
+
'judgement',
|
|
97
|
+
];
|
|
98
|
+
/**
|
|
99
|
+
* Value-level SSoT for the four orchestration capability tiers. Mirrors the
|
|
100
|
+
* {@link ProviderTier} type, most→least capable.
|
|
101
|
+
*
|
|
102
|
+
* @task T11747
|
|
103
|
+
*/
|
|
104
|
+
export const ORCHESTRATION_TIER_IDS = [
|
|
105
|
+
'frontier',
|
|
106
|
+
'standard',
|
|
107
|
+
'fast',
|
|
108
|
+
'local',
|
|
109
|
+
];
|
|
110
|
+
/**
|
|
111
|
+
* Value-level SSoT for the auxiliary subsystem ids (the hermes `_AUX_TASKS`
|
|
112
|
+
* key set). These are the stable, code-referenced background subsystems CLEO
|
|
113
|
+
* resolves an LLM for outside the role/tier/tool axes.
|
|
114
|
+
*
|
|
115
|
+
* The seven role-mapped resolver labels in {@link SystemOfUseLabel} are derived
|
|
116
|
+
* from this set plus `default` — keeping the flat resolver vocabulary and the
|
|
117
|
+
* structured taxonomy in lock-step.
|
|
118
|
+
*
|
|
119
|
+
* @task T11747
|
|
120
|
+
*/
|
|
121
|
+
export const AUX_SYSTEM_IDS = [
|
|
122
|
+
/** Dream-cycle / consolidation subsystem (BRAIN sentient layer). */
|
|
123
|
+
'sentient',
|
|
124
|
+
/** BRAIN memory extraction subsystem. */
|
|
125
|
+
'memory',
|
|
126
|
+
/** Task-executor judgement subsystem. */
|
|
127
|
+
'task-executor',
|
|
128
|
+
/** BRAIN deriver subsystem. */
|
|
129
|
+
'deriver',
|
|
130
|
+
/** Hygiene-scan subsystem. */
|
|
131
|
+
'hygiene',
|
|
132
|
+
/** Plugin-scoped single-turn calls. */
|
|
133
|
+
'plugin',
|
|
134
|
+
/** Context-compression / summarization subsystem. */
|
|
135
|
+
'compression',
|
|
136
|
+
/** Decision conflict-validator (ADR write-gate). */
|
|
137
|
+
'decision-validator',
|
|
138
|
+
/** Title / summary generation (cheap aux tier). */
|
|
139
|
+
'title-generation',
|
|
140
|
+
/** Embedding generation for vector retrieval. */
|
|
141
|
+
'embedding',
|
|
142
|
+
];
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
// Open-axis runtime key prefixes
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
/**
|
|
147
|
+
* The four OPEN {@link SystemOfUseKind}s and the string-key prefix each is
|
|
148
|
+
* encoded with for transport across string-only boundaries (config keys, CLI
|
|
149
|
+
* args, audit logs). E.g. `{ kind: 'tool', id: 'web-search' }` ↔ `'tool:web-search'`.
|
|
150
|
+
*
|
|
151
|
+
* Declared as DATA so encode/decode never branches on a hardcoded prefix —
|
|
152
|
+
* `@cleocode/core` reads this map (Gate 10 keeps the runtime split out).
|
|
153
|
+
*
|
|
154
|
+
* @task T11747
|
|
155
|
+
*/
|
|
156
|
+
export const OPEN_SYSTEM_KEY_PREFIXES = {
|
|
157
|
+
tool: 'tool:',
|
|
158
|
+
skill: 'skill:',
|
|
159
|
+
'cantbook-node': 'cantbook:',
|
|
160
|
+
'spawn-unit': 'spawn-unit:',
|
|
161
|
+
};
|
|
162
|
+
// ---------------------------------------------------------------------------
|
|
163
|
+
// BUILTIN_SYSTEMS_OF_USE registry
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
/**
|
|
166
|
+
* Static registry of every well-known (closed-axis) {@link SystemOfUse}: the
|
|
167
|
+
* four orchestration tiers, the seven {@link RoleName}s, and the ~10 auxiliary
|
|
168
|
+
* subsystems — the hermes `_AUX_TASKS` analog as a single typed table.
|
|
169
|
+
*
|
|
170
|
+
* Open-axis systems (`tool:`/`skill:`/`cantbook:`/`spawn-unit:`) are NOT listed
|
|
171
|
+
* here — they are valid without a registry edit (see {@link OPEN_SYSTEM_KEY_PREFIXES}).
|
|
172
|
+
*
|
|
173
|
+
* Built by spreading the three closed-axis value SSoTs so the registry can
|
|
174
|
+
* never drift from {@link ROLE_SYSTEM_IDS} / {@link ORCHESTRATION_TIER_IDS} /
|
|
175
|
+
* {@link AUX_SYSTEM_IDS}.
|
|
176
|
+
*
|
|
177
|
+
* @task T11747
|
|
178
|
+
* @epic T11745
|
|
179
|
+
*/
|
|
180
|
+
export const BUILTIN_SYSTEMS_OF_USE = [
|
|
181
|
+
...ORCHESTRATION_TIER_IDS.map((id) => ({ kind: 'orchestration', id })),
|
|
182
|
+
...ROLE_SYSTEM_IDS.map((id) => ({ kind: 'role', id })),
|
|
183
|
+
...AUX_SYSTEM_IDS.map((id) => ({ kind: 'aux', id })),
|
|
184
|
+
];
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
// Type guards (contracts-pure — Gate 10 allows `v is T` guards)
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
/**
|
|
189
|
+
* Type guard: is `value` a {@link SystemOfUse} descriptor (a `{ kind, id }`
|
|
190
|
+
* object whose `kind` is a known {@link SystemOfUseKind})?
|
|
191
|
+
*
|
|
192
|
+
* Structural-only — does NOT assert that closed-axis ids are registered (use
|
|
193
|
+
* {@link isBuiltinSystemOfUse} for that); an open-axis or as-yet-unregistered
|
|
194
|
+
* id still passes.
|
|
195
|
+
*
|
|
196
|
+
* @param value - The candidate value.
|
|
197
|
+
* @returns `true` when `value` is shaped like a {@link SystemOfUse}.
|
|
198
|
+
* @task T11747
|
|
199
|
+
*/
|
|
200
|
+
export function isSystemOfUse(value) {
|
|
201
|
+
if (typeof value !== 'object' || value === null)
|
|
202
|
+
return false;
|
|
203
|
+
const v = value;
|
|
204
|
+
if (typeof v.id !== 'string')
|
|
205
|
+
return false;
|
|
206
|
+
return (v.kind === 'role' ||
|
|
207
|
+
v.kind === 'orchestration' ||
|
|
208
|
+
v.kind === 'aux' ||
|
|
209
|
+
v.kind === 'tool' ||
|
|
210
|
+
v.kind === 'skill' ||
|
|
211
|
+
v.kind === 'cantbook-node' ||
|
|
212
|
+
v.kind === 'spawn-unit');
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Type guard: is `value` a closed-axis {@link SystemOfUse} present in
|
|
216
|
+
* {@link BUILTIN_SYSTEMS_OF_USE} (an exact `kind`+`id` match)?
|
|
217
|
+
*
|
|
218
|
+
* @param value - The candidate value.
|
|
219
|
+
* @returns `true` when `value` is a registered builtin system-of-use.
|
|
220
|
+
* @task T11747
|
|
221
|
+
*/
|
|
222
|
+
export function isBuiltinSystemOfUse(value) {
|
|
223
|
+
if (!isSystemOfUse(value))
|
|
224
|
+
return false;
|
|
225
|
+
return BUILTIN_SYSTEMS_OF_USE.some((s) => s.kind === value.kind && s.id === value.id);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Type guard: is `kind` an OPEN-axis {@link OpenSystemKind} (one whose ids are
|
|
229
|
+
* encoded with an {@link OPEN_SYSTEM_KEY_PREFIXES} prefix)?
|
|
230
|
+
*
|
|
231
|
+
* @param kind - The kind discriminant to test.
|
|
232
|
+
* @returns `true` for `tool` / `skill` / `cantbook-node` / `spawn-unit`.
|
|
233
|
+
* @task T11747
|
|
234
|
+
*/
|
|
235
|
+
export function isOpenSystemKind(kind) {
|
|
236
|
+
return kind === 'tool' || kind === 'skill' || kind === 'cantbook-node' || kind === 'spawn-unit';
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=system-of-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-of-use.js","sourceRoot":"","sources":["../../src/llm/system-of-use.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAmJH,8EAA8E;AAC9E,mDAAmD;AACnD,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,SAAS;IACT,WAAW;IACX,QAAQ;IACR,aAAa;CACyB,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,SAAS;IACT,WAAW;CAC2B,CAAC;AAUzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV,UAAU;IACV,MAAM;IACN,OAAO;CACmC,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,oEAAoE;IACpE,UAAU;IACV,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KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC3C,OAAO,CACL,CAAC,CAAC,IAAI,KAAK,MAAM;QACjB,CAAC,CAAC,IAAI,KAAK,eAAe;QAC1B,CAAC,CAAC,IAAI,KAAK,KAAK;QAChB,CAAC,CAAC,IAAI,KAAK,MAAM;QACjB,CAAC,CAAC,IAAI,KAAK,OAAO;QAClB,CAAC,CAAC,IAAI,KAAK,eAAe;QAC1B,CAAC,CAAC,IAAI,KAAK,YAAY,CACxB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC;AACxF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,OAAO,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,YAAY,CAAC;AAClG,CAAC"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `SystemOfUseLabel` contract types for the `resolveLLMForSystem` chokepoint (E9).
|
|
3
3
|
*
|
|
4
|
-
* A "system of use" is the
|
|
5
|
-
*
|
|
6
|
-
* a higher-level, stable identity that
|
|
7
|
-
* config resolution. This indirection
|
|
8
|
-
* vocabulary (roles) and from
|
|
4
|
+
* A "system of use label" is the flat, ergonomic vocabulary the E9 resolver
|
|
5
|
+
* accepts for the seven role-mapped background subsystems — e.g. `'sentient'`,
|
|
6
|
+
* `'memory'`, `'task-executor'`. It is a higher-level, stable identity that
|
|
7
|
+
* CLEO maps to a {@link RoleName} for config resolution. This indirection
|
|
8
|
+
* insulates call-sites from the config vocabulary (roles) and from
|
|
9
|
+
* model/provider churn.
|
|
10
|
+
*
|
|
11
|
+
* The richer, structured `{ kind, id }` taxonomy that covers the OTHER routing
|
|
12
|
+
* axes (orchestration tiers, tools, skills, cantbook nodes, spawn units) lives
|
|
13
|
+
* in {@link import('./system-of-use.js').SystemOfUse} (T11747). This label set
|
|
14
|
+
* is the flat resolver-input subset; both are kept in lock-step (the label set
|
|
15
|
+
* mirrors the `aux` axis plus `default`).
|
|
9
16
|
*
|
|
10
17
|
* `resolveLLMForSystem` is the single DRY chokepoint that the 4-resolver /
|
|
11
18
|
* 3-picker sprawl will collapse onto (E9 · T11745).
|
|
@@ -15,14 +22,20 @@
|
|
|
15
22
|
* @epic T11745
|
|
16
23
|
*/
|
|
17
24
|
import type { RoleName } from '../config.js';
|
|
25
|
+
import type { RoleSystem } from './system-of-use.js';
|
|
18
26
|
/**
|
|
19
|
-
*
|
|
27
|
+
* Flat, ergonomic label for a CLEO background subsystem that requests an LLM
|
|
28
|
+
* client through the E9 resolver.
|
|
20
29
|
*
|
|
21
|
-
* Each `
|
|
30
|
+
* Each `SystemOfUseLabel` value maps to a canonical {@link RoleName} used by
|
|
22
31
|
* `resolveLLMForSystem` for config and credential resolution. Subsystems
|
|
23
32
|
* MUST declare their identity so the resolver can apply the correct
|
|
24
33
|
* per-system overrides and audit trails.
|
|
25
34
|
*
|
|
35
|
+
* For the full structured taxonomy (tools/skills/cantbook nodes/spawn units/
|
|
36
|
+
* orchestration tiers), see the discriminated
|
|
37
|
+
* {@link import('./system-of-use.js').SystemOfUse} descriptor (T11747).
|
|
38
|
+
*
|
|
26
39
|
* ### Role mapping (static default; overridable via config `systemRoles`)
|
|
27
40
|
*
|
|
28
41
|
* | System | Default role |
|
|
@@ -38,15 +51,36 @@ import type { RoleName } from '../config.js';
|
|
|
38
51
|
*
|
|
39
52
|
* @task T11749
|
|
40
53
|
*/
|
|
41
|
-
export type
|
|
54
|
+
export type SystemOfUseLabel = 'sentient' | 'memory' | 'task-executor' | 'deriver' | 'hygiene' | 'plugin' | 'compression' | 'default';
|
|
42
55
|
/**
|
|
43
|
-
* Static mapping from {@link
|
|
56
|
+
* Static mapping from {@link SystemOfUseLabel} to the {@link RoleName} used for
|
|
44
57
|
* config resolution. This is the canonical default; callers may override
|
|
45
58
|
* individual systems via `config.llm.systemRoles[system]`.
|
|
46
59
|
*
|
|
47
60
|
* @task T11749
|
|
48
61
|
*/
|
|
49
|
-
export declare const SYSTEM_ROLE_MAP: Readonly<Record<
|
|
62
|
+
export declare const SYSTEM_ROLE_MAP: Readonly<Record<SystemOfUseLabel, RoleName | null>>;
|
|
63
|
+
/**
|
|
64
|
+
* Input accepted by `resolveLLMForSystem()`.
|
|
65
|
+
*
|
|
66
|
+
* The chokepoint accepts EITHER:
|
|
67
|
+
*
|
|
68
|
+
* - the flat, ergonomic {@link SystemOfUseLabel} for the role-mapped background
|
|
69
|
+
* subsystems (`'sentient'`, `'memory'`, … — the original locked vocabulary), OR
|
|
70
|
+
* - a structured {@link RoleSystem} descriptor (`{ kind: 'role', id: RoleName }`)
|
|
71
|
+
* for a *direct* role resolution.
|
|
72
|
+
*
|
|
73
|
+
* The descriptor form makes the E9 equivalence
|
|
74
|
+
* `resolveLLMForRole(role) ≡ resolveLLMForSystem({ kind: 'role', id: role })`
|
|
75
|
+
* (T11750 · AC1) directly expressible at the chokepoint, so role callers can
|
|
76
|
+
* collapse onto the same single resolution path with ZERO duplicate resolution
|
|
77
|
+
* logic. Both forms funnel through the SAME `resolveLLMForRole` core inside
|
|
78
|
+
* `@cleocode/core`.
|
|
79
|
+
*
|
|
80
|
+
* @task T11750
|
|
81
|
+
* @epic T11745
|
|
82
|
+
*/
|
|
83
|
+
export type SystemResolverInput = SystemOfUseLabel | RoleSystem;
|
|
50
84
|
/**
|
|
51
85
|
* Options accepted by `resolveLLMForSystem()`.
|
|
52
86
|
*
|
|
@@ -76,5 +110,47 @@ export interface ResolveLLMForSystemOptions {
|
|
|
76
110
|
* @internal
|
|
77
111
|
*/
|
|
78
112
|
skipCatalogDefault?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Raw prompt used to derive a role from complexity when neither an explicit
|
|
115
|
+
* tier/role nor a role-mapped system label is available (L1 proposer · T11906).
|
|
116
|
+
*
|
|
117
|
+
* When the `system` argument is the flat `'default'` label (which maps to NO
|
|
118
|
+
* role) and `roleOverride` is unset, the resolver runs the L1 complexity
|
|
119
|
+
* classifier over this prompt and proposes a {@link RoleName} from the
|
|
120
|
+
* resulting tier (`low → hygiene`, `mid → consolidation`, `high → judgement`).
|
|
121
|
+
* This is a COMPLEMENT to the resolver — it only supplies a role when one is
|
|
122
|
+
* otherwise absent; an explicit label, descriptor, or `roleOverride` always
|
|
123
|
+
* wins. The classifier returns a TIER only and constructs no LLM client.
|
|
124
|
+
*
|
|
125
|
+
* Ignored when the role is already determined by the input or `roleOverride`.
|
|
126
|
+
*/
|
|
127
|
+
complexityPrompt?: string;
|
|
128
|
+
/**
|
|
129
|
+
* Explicit encoded system-of-use key for the `llm.systems[key]` granular
|
|
130
|
+
* override tier (T11759 · M4).
|
|
131
|
+
*
|
|
132
|
+
* The flat-label input form derives this key from `system` itself; this option
|
|
133
|
+
* lets a caller resolving an OPEN-axis system (whose identity is NOT a flat
|
|
134
|
+
* {@link SystemOfUseLabel}) — e.g. a `.cantbook` node keyed
|
|
135
|
+
* `cantbook:<playbook>#<nodeId>` — supply that identity as the granular
|
|
136
|
+
* override + audit key while passing a resolvable background label as
|
|
137
|
+
* `system`. When set, it OVERRIDES the label-derived key. Omit it and the
|
|
138
|
+
* pre-T11759 derivation is unchanged.
|
|
139
|
+
*
|
|
140
|
+
* @task T11759
|
|
141
|
+
*/
|
|
142
|
+
systemKey?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Optional named profile (a key of `llm.profiles`) that pins the resolution to
|
|
145
|
+
* a specific provider/model/credential, winning over the role tier (T11759 ·
|
|
146
|
+
* M4).
|
|
147
|
+
*
|
|
148
|
+
* Threaded down to `ResolveLLMForRoleOptions.profileOverride`. A `.cantbook`
|
|
149
|
+
* stage's `profile:` flows through here. When the named profile is
|
|
150
|
+
* absent/incomplete, resolution falls through the normal chain unchanged.
|
|
151
|
+
*
|
|
152
|
+
* @task T11759
|
|
153
|
+
*/
|
|
154
|
+
profile?: string;
|
|
79
155
|
}
|
|
80
156
|
//# sourceMappingURL=system-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"system-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,QAAQ,GACR,eAAe,GACf,SAAS,GACT,SAAS,GACT,QAAQ,GACR,aAAa,GACb,SAAS,CAAC;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC,CAUtE,CAAC;AAEX;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC;IAExB;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* `SystemOfUseLabel` contract types for the `resolveLLMForSystem` chokepoint (E9).
|
|
3
3
|
*
|
|
4
|
-
* A "system of use" is the
|
|
5
|
-
*
|
|
6
|
-
* a higher-level, stable identity that
|
|
7
|
-
* config resolution. This indirection
|
|
8
|
-
* vocabulary (roles) and from
|
|
4
|
+
* A "system of use label" is the flat, ergonomic vocabulary the E9 resolver
|
|
5
|
+
* accepts for the seven role-mapped background subsystems — e.g. `'sentient'`,
|
|
6
|
+
* `'memory'`, `'task-executor'`. It is a higher-level, stable identity that
|
|
7
|
+
* CLEO maps to a {@link RoleName} for config resolution. This indirection
|
|
8
|
+
* insulates call-sites from the config vocabulary (roles) and from
|
|
9
|
+
* model/provider churn.
|
|
10
|
+
*
|
|
11
|
+
* The richer, structured `{ kind, id }` taxonomy that covers the OTHER routing
|
|
12
|
+
* axes (orchestration tiers, tools, skills, cantbook nodes, spawn units) lives
|
|
13
|
+
* in {@link import('./system-of-use.js').SystemOfUse} (T11747). This label set
|
|
14
|
+
* is the flat resolver-input subset; both are kept in lock-step (the label set
|
|
15
|
+
* mirrors the `aux` axis plus `default`).
|
|
9
16
|
*
|
|
10
17
|
* `resolveLLMForSystem` is the single DRY chokepoint that the 4-resolver /
|
|
11
18
|
* 3-picker sprawl will collapse onto (E9 · T11745).
|
|
@@ -15,7 +22,7 @@
|
|
|
15
22
|
* @epic T11745
|
|
16
23
|
*/
|
|
17
24
|
/**
|
|
18
|
-
* Static mapping from {@link
|
|
25
|
+
* Static mapping from {@link SystemOfUseLabel} to the {@link RoleName} used for
|
|
19
26
|
* config resolution. This is the canonical default; callers may override
|
|
20
27
|
* individual systems via `config.llm.systemRoles[system]`.
|
|
21
28
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-resolver.js","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"system-resolver.js","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA2CH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAwD;IAClF,QAAQ,EAAE,eAAe;IACzB,MAAM,EAAE,YAAY;IACpB,eAAe,EAAE,WAAW;IAC5B,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,aAAa;IAC1B,qEAAqE;IACrE,OAAO,EAAE,IAAI;CACL,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the ensures-schema Zod registry (T11762 ST-1 · T11900).
|
|
3
|
+
*
|
|
4
|
+
* Behavior-parity guard: every input the deleted bespoke validators
|
|
5
|
+
* (`validateDecompositionTaskTree` / `validateIvtrEvidenceOutput`,
|
|
6
|
+
* `packages/playbooks/src/runtime.ts:794-902`) REJECTED must still be rejected
|
|
7
|
+
* here, with the FIRST Zod issue message equal to the SUFFIX of the original
|
|
8
|
+
* violation string (the part after the `ensures.schema[<name>] on <nodeId>: `
|
|
9
|
+
* prefix that ST-2's runtime wrapper re-applies). Every input they ACCEPTED must
|
|
10
|
+
* still parse. The ACs call out: empty array, missing title, empty acceptance,
|
|
11
|
+
* `{}` evidence, numeric evidence.
|
|
12
|
+
*
|
|
13
|
+
* @task T11900
|
|
14
|
+
* @epic T11762
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=ensures-schema-registry.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensures-schema-registry.test.d.ts","sourceRoot":"","sources":["../../../src/operations/__tests__/ensures-schema-registry.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the ensures-schema Zod registry (T11762 ST-1 · T11900).
|
|
3
|
+
*
|
|
4
|
+
* Behavior-parity guard: every input the deleted bespoke validators
|
|
5
|
+
* (`validateDecompositionTaskTree` / `validateIvtrEvidenceOutput`,
|
|
6
|
+
* `packages/playbooks/src/runtime.ts:794-902`) REJECTED must still be rejected
|
|
7
|
+
* here, with the FIRST Zod issue message equal to the SUFFIX of the original
|
|
8
|
+
* violation string (the part after the `ensures.schema[<name>] on <nodeId>: `
|
|
9
|
+
* prefix that ST-2's runtime wrapper re-applies). Every input they ACCEPTED must
|
|
10
|
+
* still parse. The ACs call out: empty array, missing title, empty acceptance,
|
|
11
|
+
* `{}` evidence, numeric evidence.
|
|
12
|
+
*
|
|
13
|
+
* @task T11900
|
|
14
|
+
* @epic T11762
|
|
15
|
+
*/
|
|
16
|
+
import { describe, expect, it } from 'vitest';
|
|
17
|
+
import { ENSURES_SCHEMA_REGISTRY, evidenceSchema, LEGACY_PASSTHROUGH_SCHEMA_NAMES, passthroughSchema, taskTreeSchema, } from '../ensures-schema-registry.js';
|
|
18
|
+
/** First Zod issue message for a failing parse (or `undefined` if it parsed). */
|
|
19
|
+
function firstIssueMessage(schema, value) {
|
|
20
|
+
const result = schema.safeParse(value);
|
|
21
|
+
return result.success ? undefined : result.error.issues[0]?.message;
|
|
22
|
+
}
|
|
23
|
+
describe('ensures-schema-registry — registry DATA', () => {
|
|
24
|
+
it('registers the two strict schemas plus every legacy passthrough name', () => {
|
|
25
|
+
// T11762 ST-2 (R1): the two strict ports (`task_tree`, `evidence`) PLUS the
|
|
26
|
+
// legacy starter `.cantbook` schema names — registered with passthrough so
|
|
27
|
+
// the fail-closed flip does not regress the shipped playbooks.
|
|
28
|
+
expect([...ENSURES_SCHEMA_REGISTRY.keys()].sort()).toEqual(['task_tree', 'evidence', ...LEGACY_PASSTHROUGH_SCHEMA_NAMES].sort());
|
|
29
|
+
});
|
|
30
|
+
it('each strict spec carries name, contextKey (= name by default), and a schema', () => {
|
|
31
|
+
for (const name of ['task_tree', 'evidence']) {
|
|
32
|
+
const spec = ENSURES_SCHEMA_REGISTRY.get(name);
|
|
33
|
+
expect(spec).toBeDefined();
|
|
34
|
+
expect(spec.name).toBe(name);
|
|
35
|
+
expect(spec.contextKey).toBe(name);
|
|
36
|
+
expect(typeof spec.schema.safeParse).toBe('function');
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
it('every legacy passthrough name is registered with the passthrough schema', () => {
|
|
40
|
+
// R1: passthrough accepts ANY value (including `undefined`) so the historical
|
|
41
|
+
// "silently skipped" behavior is preserved EXACTLY.
|
|
42
|
+
for (const name of LEGACY_PASSTHROUGH_SCHEMA_NAMES) {
|
|
43
|
+
const spec = ENSURES_SCHEMA_REGISTRY.get(name);
|
|
44
|
+
expect(spec).toBeDefined();
|
|
45
|
+
expect(spec.name).toBe(name);
|
|
46
|
+
expect(spec.schema).toBe(passthroughSchema);
|
|
47
|
+
expect(spec.schema.safeParse(undefined).success).toBe(true);
|
|
48
|
+
expect(spec.schema.safeParse({ anything: 1 }).success).toBe(true);
|
|
49
|
+
expect(spec.schema.safeParse(42).success).toBe(true);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe('ensures-schema-registry — task_tree (ports validateDecompositionTaskTree)', () => {
|
|
54
|
+
it('accepts a minimal valid task tree', () => {
|
|
55
|
+
expect(taskTreeSchema.safeParse([{ title: 'Build X', acceptance: ['does X'] }]).success).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
it('accepts a tree with optional id/parentId/depends populated', () => {
|
|
58
|
+
expect(taskTreeSchema.safeParse([
|
|
59
|
+
{ title: 'Root', acceptance: ['ac1'], id: 'T1' },
|
|
60
|
+
{ title: 'Child', acceptance: ['ac2', 'ac3'], id: 'T2', parentId: 'T1', depends: ['T1'] },
|
|
61
|
+
]).success).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
it('rejects a non-array (parity: "task_tree must be a non-empty array")', () => {
|
|
64
|
+
expect(firstIssueMessage(taskTreeSchema, 'not-an-array')).toBe('task_tree must be a non-empty array');
|
|
65
|
+
});
|
|
66
|
+
it('rejects an EMPTY ARRAY (parity: empty-array message)', () => {
|
|
67
|
+
expect(firstIssueMessage(taskTreeSchema, [])).toBe('task_tree is an empty array — decomposition produced no tasks');
|
|
68
|
+
});
|
|
69
|
+
it('rejects a MISSING TITLE (parity: "title must be a non-empty string")', () => {
|
|
70
|
+
expect(firstIssueMessage(taskTreeSchema, [{ acceptance: ['ac1'] }])).toBe('title must be a non-empty string');
|
|
71
|
+
});
|
|
72
|
+
it('rejects a whitespace-only title (parity: same non-empty-title message)', () => {
|
|
73
|
+
expect(firstIssueMessage(taskTreeSchema, [{ title: ' ', acceptance: ['ac1'] }])).toBe('title must be a non-empty string');
|
|
74
|
+
});
|
|
75
|
+
it('rejects an EMPTY ACCEPTANCE array (parity: non-empty-acceptance message)', () => {
|
|
76
|
+
expect(firstIssueMessage(taskTreeSchema, [{ title: 'X', acceptance: [] }])).toBe('must have a non-empty acceptance array');
|
|
77
|
+
});
|
|
78
|
+
it('rejects an acceptance array with no non-empty strings (parity message)', () => {
|
|
79
|
+
expect(firstIssueMessage(taskTreeSchema, [{ title: 'X', acceptance: [' ', ''] }])).toBe('acceptance array contains no non-empty strings');
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('ensures-schema-registry — evidence (ports validateIvtrEvidenceOutput)', () => {
|
|
83
|
+
it('accepts a non-empty string', () => {
|
|
84
|
+
expect(evidenceSchema.safeParse('commit:abc123').success).toBe(true);
|
|
85
|
+
});
|
|
86
|
+
it('accepts a non-empty array', () => {
|
|
87
|
+
expect(evidenceSchema.safeParse(['atom']).success).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
it('accepts an object with at least one key', () => {
|
|
90
|
+
expect(evidenceSchema.safeParse({ commit: 'abc' }).success).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
it('rejects null/undefined (parity: must-be-present message)', () => {
|
|
93
|
+
expect(firstIssueMessage(evidenceSchema, null)).toBe('evidence must be present (non-null, non-undefined)');
|
|
94
|
+
expect(firstIssueMessage(evidenceSchema, undefined)).toBe('evidence must be present (non-null, non-undefined)');
|
|
95
|
+
});
|
|
96
|
+
it('rejects an empty / whitespace-only string (parity message)', () => {
|
|
97
|
+
expect(firstIssueMessage(evidenceSchema, '')).toBe('evidence string must not be empty');
|
|
98
|
+
expect(firstIssueMessage(evidenceSchema, ' ')).toBe('evidence string must not be empty');
|
|
99
|
+
});
|
|
100
|
+
it('rejects an empty array (parity message)', () => {
|
|
101
|
+
expect(firstIssueMessage(evidenceSchema, [])).toBe('evidence array must not be empty');
|
|
102
|
+
});
|
|
103
|
+
it('rejects an EMPTY OBJECT {} (parity: at-least-one-key message)', () => {
|
|
104
|
+
expect(firstIssueMessage(evidenceSchema, {})).toBe('evidence object must have at least one key (got {})');
|
|
105
|
+
});
|
|
106
|
+
it('rejects NUMERIC evidence (parity: wrong-type message with typeof)', () => {
|
|
107
|
+
expect(firstIssueMessage(evidenceSchema, 42)).toBe('evidence must be a string, array, or object (got number)');
|
|
108
|
+
});
|
|
109
|
+
it('rejects boolean evidence (parity: wrong-type message with typeof)', () => {
|
|
110
|
+
expect(firstIssueMessage(evidenceSchema, true)).toBe('evidence must be a string, array, or object (got boolean)');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=ensures-schema-registry.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensures-schema-registry.test.js","sourceRoot":"","sources":["../../../src/operations/__tests__/ensures-schema-registry.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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