@cleocode/contracts 2026.10.18 → 2026.10.19
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/branch-lock.d.ts +14 -3
- package/dist/branch-lock.d.ts.map +1 -1
- package/dist/branch-lock.js +8 -3
- package/dist/branch-lock.js.map +1 -1
- package/dist/dispatch/operations-registry.d.ts.map +1 -1
- package/dist/dispatch/operations-registry.js +7 -0
- package/dist/dispatch/operations-registry.js.map +1 -1
- package/dist/done-plan.d.ts +69 -0
- package/dist/done-plan.d.ts.map +1 -1
- package/dist/goal-contract.d.ts +44 -4
- package/dist/goal-contract.d.ts.map +1 -1
- package/dist/goal-contract.js +2 -2
- package/dist/goal-contract.js.map +1 -1
- package/dist/goal-runtime.d.ts +89 -0
- package/dist/goal-runtime.d.ts.map +1 -0
- package/dist/goal-runtime.js +13 -0
- package/dist/goal-runtime.js.map +1 -0
- package/dist/goal.d.ts +12 -116
- package/dist/goal.d.ts.map +1 -1
- package/dist/goal.js +9 -72
- package/dist/goal.js.map +1 -1
- package/dist/heavy-command-hook.d.ts +6 -0
- package/dist/heavy-command-hook.d.ts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/invariants/sync-write-invariants.js +6 -5
- package/dist/invariants/sync-write-invariants.js.map +1 -1
- package/dist/operations/docs.d.ts +2 -2
- package/dist/operations/docs.d.ts.map +1 -1
- package/dist/project-hooks.d.ts +15 -2
- package/dist/project-hooks.d.ts.map +1 -1
- package/dist/project-hooks.js +8 -0
- package/dist/project-hooks.js.map +1 -1
- package/dist/release/hook-pilot.d.ts +141 -2
- package/dist/release/hook-pilot.d.ts.map +1 -1
- package/dist/release/hook-pilot.js +75 -3
- package/dist/release/hook-pilot.js.map +1 -1
- package/dist/task.d.ts +23 -0
- package/dist/task.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/operations-registry.test.ts.snap +1 -1
- package/src/branch-lock.ts +14 -3
- package/src/dispatch/operations-registry.ts +8 -0
- package/src/done-plan.ts +73 -0
- package/src/goal-contract.ts +48 -4
- package/src/goal-runtime.ts +105 -0
- package/src/goal.ts +12 -133
- package/src/heavy-command-hook.ts +9 -0
- package/src/index.ts +18 -7
- package/src/invariants/sync-write-invariants.ts +5 -5
- package/src/operations/docs.ts +3 -2
- package/src/project-hooks.ts +15 -1
- package/src/release/hook-pilot.ts +85 -3
- package/src/task.ts +23 -0
package/src/project-hooks.ts
CHANGED
|
@@ -6,6 +6,15 @@ import type { HookJsonValue } from './heavy-command-hook.js';
|
|
|
6
6
|
export const HookSourceSchema = z.enum(['agent', 'git', 'worktree', 'direct', 'ci']);
|
|
7
7
|
/** Shared invocation origin. */
|
|
8
8
|
export type HookSource = z.infer<typeof HookSourceSchema>;
|
|
9
|
+
/** Native provenance supplied by the harness payload, never guessed from the working directory. */
|
|
10
|
+
export const HookNativeSessionSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
sessionId: z.string().min(1).max(256),
|
|
13
|
+
harness: z.string().regex(/^[a-z][a-z0-9-]{0,63}$/),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
/** Session and provider carried from a native agent event into its redacted receipt. */
|
|
17
|
+
export type HookNativeSession = z.infer<typeof HookNativeSessionSchema>;
|
|
9
18
|
/** A checkout-relative path; runtime validation also resolves symlinks. */
|
|
10
19
|
export const ProjectHookPathSchema = z
|
|
11
20
|
.string()
|
|
@@ -41,6 +50,8 @@ export const ProjectHookDefinitionSchema = z
|
|
|
41
50
|
.strict();
|
|
42
51
|
/** Validated project checker configuration. Handler is executable's first argument. */
|
|
43
52
|
export type ProjectHookDefinition = z.infer<typeof ProjectHookDefinitionSchema>;
|
|
53
|
+
/** One source/event binding, shared by retained-receipt selectors. */
|
|
54
|
+
export type ProjectHookBinding = ProjectHookDefinition['bindings'][number];
|
|
44
55
|
/** Tracked single source of truth; array order defines execution order. */
|
|
45
56
|
export const ProjectHooksManifestSchema = z
|
|
46
57
|
.object({
|
|
@@ -88,6 +99,8 @@ export interface HookInvocation {
|
|
|
88
99
|
source: HookSource;
|
|
89
100
|
/** Canonical event name. */
|
|
90
101
|
event: string;
|
|
102
|
+
/** Optional native harness identity; absent inputs stay unverified. */
|
|
103
|
+
nativeSession?: HookNativeSession;
|
|
91
104
|
/** Optional remote name and URL/path as Git supplies them. */
|
|
92
105
|
remote?: { name: string; location: string };
|
|
93
106
|
/** All pushed ref updates in original order. */
|
|
@@ -168,7 +181,7 @@ export const ProjectHooksLocalStateSchema = z
|
|
|
168
181
|
/** Local activation settings stored independently of tracked project configuration. */
|
|
169
182
|
export type ProjectHooksLocalState = z.infer<typeof ProjectHooksLocalStateSchema>;
|
|
170
183
|
/** Bounded last execution metadata; contains no input or arbitrary output. */
|
|
171
|
-
export interface HookExecutionReceipt {
|
|
184
|
+
export interface HookExecutionReceipt extends Partial<HookNativeSession> {
|
|
172
185
|
/** Receipt format version. */
|
|
173
186
|
schemaVersion: 1;
|
|
174
187
|
/** Activated source digest. */
|
|
@@ -186,6 +199,7 @@ export interface HookExecutionReceipt {
|
|
|
186
199
|
export const HookExecutionReceiptSchema = z
|
|
187
200
|
.object({
|
|
188
201
|
schemaVersion: z.literal(1),
|
|
202
|
+
...HookNativeSessionSchema.partial().shape,
|
|
189
203
|
manifestHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
190
204
|
source: HookSourceSchema,
|
|
191
205
|
event: z.string().max(128),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Bound, retained evidence required before promoting project hooks to stable (T13350). */
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { HookExecutionReceiptSchema, HookNativeSessionSchema } from '../project-hooks.js';
|
|
3
4
|
|
|
4
5
|
/** Required pilot checks; every named check must pass on the same implementation. */
|
|
5
6
|
export const HOOK_PILOT_CHECKS = [
|
|
@@ -42,6 +43,8 @@ export const HookPilotProofReferenceSchema = z
|
|
|
42
43
|
sha256: HookPilotDigestSchema,
|
|
43
44
|
})
|
|
44
45
|
.strict();
|
|
46
|
+
/** Hash-bound artifact reference reused by native receipts and phase proofs. */
|
|
47
|
+
export type HookPilotProofReference = z.infer<typeof HookPilotProofReferenceSchema>;
|
|
45
48
|
/** Common identity attached to every retained proof, never inferred from similar releases. */
|
|
46
49
|
export const HookPilotIdentitySchema = z
|
|
47
50
|
.object({
|
|
@@ -53,7 +56,7 @@ export const HookPilotIdentitySchema = z
|
|
|
53
56
|
.strict();
|
|
54
57
|
/** A bounded collection of actual pilot receipts. Missing or partial checks hold promotion. */
|
|
55
58
|
export const HookPilotEvidenceSchema = HookPilotIdentitySchema.extend({
|
|
56
|
-
schemaVersion: z.literal(1),
|
|
59
|
+
schemaVersion: z.union([z.literal(1), z.literal(2)]),
|
|
57
60
|
vidaRepository: z
|
|
58
61
|
.string()
|
|
59
62
|
.regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/)
|
|
@@ -73,9 +76,64 @@ export const HookPilotEvidenceSchema = HookPilotIdentitySchema.extend({
|
|
|
73
76
|
}).strict();
|
|
74
77
|
/** Validated evidence bundle index. */
|
|
75
78
|
export type HookPilotEvidence = z.infer<typeof HookPilotEvidenceSchema>;
|
|
79
|
+
/** Strict runner receipt binding native agent delivery to its session and provider. */
|
|
80
|
+
export const HookPilotNativeReceiptSchema = HookExecutionReceiptSchema.extend({
|
|
81
|
+
...HookNativeSessionSchema.shape,
|
|
82
|
+
source: z.literal('agent'),
|
|
83
|
+
event: z.string().min(1).max(128),
|
|
84
|
+
recordedAt: z.string().datetime(),
|
|
85
|
+
}).strict();
|
|
86
|
+
/** Retained native session evidence; receipt content is read and hash-checked by the release gate. */
|
|
87
|
+
export const HookPilotNativeEvidenceSchema = z
|
|
88
|
+
.object({
|
|
89
|
+
sessionId: z.string().min(1).max(256),
|
|
90
|
+
checkout: z.enum(['standalone', 'linked-worktree']),
|
|
91
|
+
startedAt: z.string().datetime(),
|
|
92
|
+
endedAt: z.string().datetime(),
|
|
93
|
+
receipt: HookPilotProofReferenceSchema.extend(
|
|
94
|
+
HookPilotNativeReceiptSchema.pick({
|
|
95
|
+
source: true,
|
|
96
|
+
event: true,
|
|
97
|
+
recordedAt: true,
|
|
98
|
+
sessionId: true,
|
|
99
|
+
harness: true,
|
|
100
|
+
}).shape,
|
|
101
|
+
).strict(),
|
|
102
|
+
trust: z.discriminatedUnion('mode', [
|
|
103
|
+
z
|
|
104
|
+
.object({
|
|
105
|
+
mode: z.literal('persisted'),
|
|
106
|
+
home: z.enum(['isolated', 'user-global']),
|
|
107
|
+
grantedBy: z.enum(['native-interactive', 'native-command']),
|
|
108
|
+
})
|
|
109
|
+
.strict(),
|
|
110
|
+
z
|
|
111
|
+
.object({
|
|
112
|
+
mode: z.literal('bypassed'),
|
|
113
|
+
home: z.enum(['isolated', 'user-global']),
|
|
114
|
+
flag: z.literal('--dangerously-bypass-hook-trust'),
|
|
115
|
+
})
|
|
116
|
+
.strict(),
|
|
117
|
+
]),
|
|
118
|
+
contextInjection: z.enum(['observed', 'unverified', 'not-observed']),
|
|
119
|
+
contextEvidence: HookPilotProofReferenceSchema.optional(),
|
|
120
|
+
infrastructureFaults: z
|
|
121
|
+
.array(
|
|
122
|
+
z
|
|
123
|
+
.object({
|
|
124
|
+
source: z.enum(['agent', 'git', 'sandbox']),
|
|
125
|
+
code: z.string().regex(/^[A-Z][A-Z0-9_]{0,127}$/),
|
|
126
|
+
})
|
|
127
|
+
.strict(),
|
|
128
|
+
)
|
|
129
|
+
.max(100),
|
|
130
|
+
})
|
|
131
|
+
.strict();
|
|
132
|
+
/** Typed, redacted native delivery and its known limitations. */
|
|
133
|
+
export type HookPilotNativeEvidence = z.infer<typeof HookPilotNativeEvidenceSchema>;
|
|
76
134
|
/** Structured, redacted proof produced by a real check and retained with its hash. */
|
|
77
135
|
export const HookPilotProofSchema = HookPilotIdentitySchema.extend({
|
|
78
|
-
schemaVersion: z.literal(1),
|
|
136
|
+
schemaVersion: z.union([z.literal(1), z.literal(2)]),
|
|
79
137
|
check: z.enum(HOOK_PILOT_CHECKS),
|
|
80
138
|
status: z.literal('pass'),
|
|
81
139
|
observedAt: z.string().datetime(),
|
|
@@ -85,15 +143,39 @@ export const HookPilotProofSchema = HookPilotIdentitySchema.extend({
|
|
|
85
143
|
packageVersions: z.record(z.string().max(256), z.string().max(128)).optional(),
|
|
86
144
|
ordinaryCommands: z.number().int().min(1).max(100000).optional(),
|
|
87
145
|
disposablePushes: z.number().int().min(1).max(100000).optional(),
|
|
146
|
+
native: HookPilotNativeEvidenceSchema.optional(),
|
|
88
147
|
hostedRunId: z.number().int().positive().safe().optional(),
|
|
89
148
|
url: z.string().url().max(2048).optional(),
|
|
90
|
-
})
|
|
149
|
+
})
|
|
150
|
+
.strict()
|
|
151
|
+
.superRefine((proof, ctx) => {
|
|
152
|
+
if (
|
|
153
|
+
proof.schemaVersion === 2 &&
|
|
154
|
+
(proof.check === 'liveClaude' || proof.check === 'liveCodex') &&
|
|
155
|
+
!proof.native
|
|
156
|
+
) {
|
|
157
|
+
ctx.addIssue({
|
|
158
|
+
code: 'custom',
|
|
159
|
+
path: ['native'],
|
|
160
|
+
message: 'Required native agent receipt missing',
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (proof.native?.contextInjection === 'observed' && !proof.native.contextEvidence) {
|
|
164
|
+
ctx.addIssue({
|
|
165
|
+
code: 'custom',
|
|
166
|
+
path: ['native', 'contextEvidence'],
|
|
167
|
+
message: 'Observed context requires retained evidence',
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
91
171
|
/** A validated retained proof. */
|
|
92
172
|
export type HookPilotProof = z.infer<typeof HookPilotProofSchema>;
|
|
93
173
|
/** Minimal authoritative GitHub response required for an actual successful workflow run. */
|
|
94
174
|
export const HookPilotHostedRunSchema = z.object({
|
|
95
175
|
id: z.number().int().positive(),
|
|
96
176
|
head_sha: z.string().regex(/^[a-f0-9]{40}$/),
|
|
177
|
+
/** Historical responses may omit the trigger; future proofs require an exact-commit dispatch. */
|
|
178
|
+
event: z.string().min(1).max(64).optional(),
|
|
97
179
|
status: z.literal('completed'),
|
|
98
180
|
conclusion: z.literal('success'),
|
|
99
181
|
path: z.string().max(4096),
|
package/src/task.ts
CHANGED
|
@@ -320,6 +320,14 @@ export type EvidenceAtom =
|
|
|
320
320
|
* `tool:test-affected`'s `untestedPackages` (T12965 review).
|
|
321
321
|
*/
|
|
322
322
|
untestedPackages?: string[];
|
|
323
|
+
/** Changed CLEO config this result leaves to `tool:config-schema` in the same gate write (T13778). */
|
|
324
|
+
configPaths?: string[];
|
|
325
|
+
/**
|
|
326
|
+
* Dependents of a declared generated package this report left to a
|
|
327
|
+
* typecheck (T13783): a `tool:typecheck` or a qa-run typecheck receipt
|
|
328
|
+
* covering them must be in the same gate write.
|
|
329
|
+
*/
|
|
330
|
+
typecheckDirs?: string[];
|
|
323
331
|
/**
|
|
324
332
|
* Tracked files matching `evidence.runtimePaths` whose working-tree
|
|
325
333
|
* edits the tree hash left out (T13554).
|
|
@@ -355,6 +363,8 @@ export type EvidenceAtom =
|
|
|
355
363
|
uncovered?: string[];
|
|
356
364
|
/** Dependent packages this receipt's roots leave uncovered (T13580). */
|
|
357
365
|
uncoveredPackages?: string[];
|
|
366
|
+
/** Changed CLEO config this result leaves to `tool:config-schema` in the same gate write (T13778). */
|
|
367
|
+
configPaths?: string[];
|
|
358
368
|
/** The change it checked is non-code only, so no typecheck is owed (T13745). */
|
|
359
369
|
nonCodeChange?: boolean;
|
|
360
370
|
}
|
|
@@ -386,6 +396,17 @@ export type EvidenceAtom =
|
|
|
386
396
|
* qa-run receipt: a moved tree voids it.
|
|
387
397
|
*/
|
|
388
398
|
configSchema?: string[];
|
|
399
|
+
/**
|
|
400
|
+
* `tool:config-schema` on a change that also touches other paths (T13778):
|
|
401
|
+
* those paths, which another result in the same gate write must cover.
|
|
402
|
+
*/
|
|
403
|
+
otherPaths?: string[];
|
|
404
|
+
/**
|
|
405
|
+
* `tool:config-schema` judged an already-merged change (T13781): the
|
|
406
|
+
* `commit:`/`pr:` merge commit whose config files it validated, in place
|
|
407
|
+
* of a tree pin.
|
|
408
|
+
*/
|
|
409
|
+
configSchemaCommit?: string;
|
|
389
410
|
/**
|
|
390
411
|
* `affected`: the run covered only the packages the branch diff touches
|
|
391
412
|
* plus their dependents (D11150, T12635). It satisfies testsPassed before
|
|
@@ -411,6 +432,8 @@ export type EvidenceAtom =
|
|
|
411
432
|
affectedTestFiles?: string[];
|
|
412
433
|
/** Affected DEPENDENT packages with no test project (a changed one refuses the scope). */
|
|
413
434
|
untestedPackages?: string[];
|
|
435
|
+
/** Changed CLEO config this result leaves to `tool:config-schema` in the same gate write (T13778). */
|
|
436
|
+
configPaths?: string[];
|
|
414
437
|
/**
|
|
415
438
|
* Test files that failed and then passed on their single retry
|
|
416
439
|
* (T12961). The run counts as a pass; this marks it as a FLAKY pass so
|