@cleocode/core 2026.11.11 → 2026.11.12-rc.ci.729
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/README.md +78 -114
- package/dist/.source-stamp.json +1 -1
- package/dist/build-provenance.json +2 -2
- package/dist/release/ci-evidence.d.ts +12 -8
- package/dist/release/ci-evidence.js +83 -23
- package/dist/release/ci-evidence.js.map +1 -1
- package/dist/release/cut.js +3 -1
- package/dist/release/cut.js.map +1 -1
- package/dist/release/pr-evidence.d.ts +3 -7
- package/dist/release/pr-evidence.js +35 -4
- package/dist/release/pr-evidence.js.map +1 -1
- package/dist/tasks/merge-close.js +4 -2
- package/dist/tasks/merge-close.js.map +1 -1
- package/migrations/README.md +79 -49
- package/package.json +13 -13
- package/schemas/project-context.schema.json +4 -0
- package/templates/CLEO-REFERENCE.md +2 -0
package/README.md
CHANGED
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
> Part of [CLEO](https://github.com/kryptobaseddev/cleo#readme). Start with the root README; run `cleo <command> --help` for any command.
|
|
4
4
|
|
|
5
|
-
CLEO
|
|
5
|
+
CLEO's business logic **and canonical SDK surface**: tasks, sessions, evidence, memory (BRAIN), docs, orchestration, lifecycle and release, with the bundled SQLite store. The `cleo` CLI (`@cleocode/cleo`) is a thin dispatcher over this package.
|
|
6
6
|
|
|
7
|
-
> **`@cleocode/core` IS the CLEO SDK.** There is no separate `@cleocode/cleo-sdk` package. The `Cleo` facade, domain namespaces, and flat free functions are
|
|
7
|
+
> **`@cleocode/core` IS the CLEO SDK.** There is no separate `@cleocode/cleo-sdk` package. The `Cleo` facade, domain namespaces, and flat free functions are exposed through per-subpath exports that follow a CalVer stability contract. See [STABILITY.md](./STABILITY.md) for the contract and `.dts-snapshots/` for the enforced baseline.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
CLEO has no agent loop: agents run in their own harness and call CLEO. For agents and SDK consumers calling core operations directly (no CLI subprocess), see the **[CORE API Agent Guide](../../docs/reference/core-sdk.md)**.
|
|
10
10
|
|
|
11
11
|
## Quickstart
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { startSession } from '@cleocode/core
|
|
15
|
-
import { addTask } from '@cleocode/core/tasks';
|
|
14
|
+
import { addTask, startSession } from '@cleocode/core';
|
|
16
15
|
|
|
17
16
|
const projectRoot = process.cwd();
|
|
18
17
|
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
// Mutations need an active session
|
|
19
|
+
await startSession(projectRoot, { scope: 'global', name: 'my-session' });
|
|
20
|
+
|
|
21
|
+
// Only a saga may be a root: file tasks under an existing epic.
|
|
22
|
+
// By default a task needs at least 3 acceptance criteria.
|
|
23
|
+
const { task } = await addTask(
|
|
24
|
+
{
|
|
25
|
+
title: 'My task',
|
|
26
|
+
type: 'task',
|
|
27
|
+
parentId: 'T002',
|
|
28
|
+
acceptance: ['first criterion', 'second criterion', 'third criterion'],
|
|
29
|
+
},
|
|
25
30
|
projectRoot,
|
|
26
31
|
);
|
|
27
32
|
```
|
|
@@ -33,12 +38,19 @@ import { Cleo } from '@cleocode/core/sdk';
|
|
|
33
38
|
|
|
34
39
|
const cleo = await Cleo.init(process.cwd());
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
await cleo.sessions.start({ scope: 'global', name: 'my-session' });
|
|
42
|
+
await cleo.tasks.add({
|
|
43
|
+
title: 'My task',
|
|
44
|
+
type: 'task',
|
|
45
|
+
parent: 'T002',
|
|
46
|
+
acceptance: ['first criterion', 'second criterion', 'third criterion'],
|
|
47
|
+
});
|
|
48
|
+
await cleo.memory.observe({ text: 'Chose RS256 for JWT validation', title: 'jwt-algo-decision' });
|
|
49
|
+
await cleo.sessions.end({ note: 'Filed the task' });
|
|
40
50
|
```
|
|
41
51
|
|
|
52
|
+
The facade's methods are typed `Promise<unknown>` in `@cleocode/contracts` (`facade.ts`); call the flat functions when you need typed results.
|
|
53
|
+
|
|
42
54
|
## Installation
|
|
43
55
|
|
|
44
56
|
```bash
|
|
@@ -52,58 +64,36 @@ pnpm add @cleocode/core
|
|
|
52
64
|
yarn add @cleocode/core
|
|
53
65
|
```
|
|
54
66
|
|
|
55
|
-
**Node.js requirement**: `>=24.
|
|
56
|
-
|
|
57
|
-
## Available namespaces
|
|
58
|
-
|
|
59
|
-
### Primary dispatch domains (9)
|
|
60
|
-
|
|
61
|
-
These domains map 1:1 to the CLEO CLI dispatch surface and follow the uniform
|
|
62
|
-
`(projectRoot: string, params: <Op>Params) => Promise<<Op>Result>` signature
|
|
63
|
-
mandated by [ADR-057](../../docs/adr/adr-057-contracts-core-ssot.md).
|
|
67
|
+
**Node.js requirement**: `>=24.16.0`
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|--------|---------|---------|
|
|
67
|
-
| `admin` | `@cleocode/core/admin` | Import/export, project health checks, backup |
|
|
68
|
-
| `check` | `@cleocode/core` *(via internal)* | Protocol compliance, canon validation |
|
|
69
|
-
| `conduit` | `@cleocode/core/conduit` | Conduit messages in `cleo.db`, kept as a thin legacy client; AgentMBX is CLEO's messaging layer (D11176) |
|
|
70
|
-
| `nexus` | `@cleocode/core/nexus` | Code-intelligence graph, cross-project linking |
|
|
71
|
-
| `pipeline` | `@cleocode/core/pipeline` | RCASD/IVTR pipeline stage management |
|
|
72
|
-
| `playbook` | `@cleocode/core` *(via internal)* | `.cantbook` playbook runtime |
|
|
73
|
-
| `sentient` | `@cleocode/core/sentient` | Tier-2 autonomous proposals. Its spawning loops are replaced by CLEO Goal, and the sentient subsystem host retires with ADR-098 |
|
|
74
|
-
| `sessions` | `@cleocode/core/sessions` | Session lifecycle, briefing, handoff |
|
|
75
|
-
| `tasks` | `@cleocode/core/tasks` | Task CRUD, dependencies, lifecycle, archival |
|
|
69
|
+
## Dispatch domains
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
| Domain | Subpath | Purpose |
|
|
80
|
-
|--------|---------|---------|
|
|
81
|
-
| `gc` | `@cleocode/core/gc` | Garbage-collection daemon, transcript pruning |
|
|
82
|
-
| `llm` | `@cleocode/core` | LLM-extraction, transcript ingestion, brain backfill |
|
|
83
|
-
| `memory` | `@cleocode/core/memory` | BRAIN storage, search, STDP, observation |
|
|
84
|
-
| `lifecycle` | `@cleocode/core/lifecycle` | Gate verification, evidence, pipeline stages |
|
|
85
|
-
| `harness` | `@cleocode/core/harness` | Provider selection and adapter routing (spawn-provider selection, ask enforcement); CLEO itself ships no agent harness (ADR-098) |
|
|
71
|
+
The CLI dispatches 28 domains, listed in `CANONICAL_DOMAINS` (`packages/contracts/src/dispatch/identity.ts`). Their core operations follow the uniform `(projectRoot: string, params: <Op>Params) => Promise<<Op>Result>` signature mandated by [ADR-057](../../docs/adr/adr-057-contracts-core-ssot.md). The op wrappers (`tasksAddOp`, `tasksShowOp`, …) are exported from `@cleocode/core/internal` for the CLI; third-party code uses the subpaths below.
|
|
86
72
|
|
|
87
73
|
## Subpath exports
|
|
88
74
|
|
|
89
|
-
Prefer the **narrowest** subpath that satisfies your need
|
|
75
|
+
Prefer the **narrowest** subpath that satisfies your need: it reduces import cost and is covered by snapshot-enforced stability gates.
|
|
90
76
|
|
|
91
77
|
| Subpath | Tier | Use when |
|
|
92
78
|
|---------|------|----------|
|
|
93
79
|
| `@cleocode/core/sdk` | stable | External agents, Studio panels — `Cleo` facade only |
|
|
94
80
|
| `@cleocode/core/tasks` | stable | Task CRUD, hierarchy, graph ops |
|
|
95
81
|
| `@cleocode/core/sessions` | stable | Session lifecycle, briefing, handoff |
|
|
96
|
-
| `@cleocode/core/memory` | stable |
|
|
97
|
-
| `@cleocode/core/nexus` | stable |
|
|
98
|
-
| `@cleocode/core/lifecycle` | stable |
|
|
99
|
-
| `@cleocode/core/
|
|
100
|
-
| `@cleocode/core/
|
|
101
|
-
| `@cleocode/core/gc` | stable | Garbage-collection daemon |
|
|
82
|
+
| `@cleocode/core/memory` | stable | Research entries and the agent-output manifest (the BRAIN functions are on the root export) |
|
|
83
|
+
| `@cleocode/core/nexus` | stable | Project registry and cross-project queries |
|
|
84
|
+
| `@cleocode/core/lifecycle` | stable | RCASD-IVTR stage transitions and gate enforcement |
|
|
85
|
+
| `@cleocode/core/harness` | stable | Spawn-provider selection (`selectHarnessSpawnProvider`) |
|
|
86
|
+
| `@cleocode/core/gc` | stable | Transcript cleanup, disk-pressure checks, GC state |
|
|
102
87
|
| `@cleocode/core/contracts` | stable | Pure `@cleocode/contracts` re-export (types only) |
|
|
103
|
-
| `@cleocode/core` | stable | All namespaces + flat free functions |
|
|
88
|
+
| `@cleocode/core` | stable | All namespaces + flat free functions, including BRAIN (`observeBrain`, `searchBrain`, `timelineBrain`) |
|
|
104
89
|
| `@cleocode/core/internal` | **internal** | CLI dispatch only — do NOT import from third-party code |
|
|
105
90
|
|
|
106
|
-
|
|
91
|
+
Two subpaths remain only for existing callers; do not build on them:
|
|
92
|
+
|
|
93
|
+
- `@cleocode/core/conduit` — the legacy Conduit messaging client, retiring (T13933). AgentMBX is CLEO's messaging layer (D11176).
|
|
94
|
+
- `@cleocode/core/sentient` — the sentient loop API (tick, Tier-2 proposals). ADR-098 (`cleo docs fetch adr-098-retire-the-pi-cleoos-harness`) replaces its spawning loops with CLEO Goal (ADR-097), the one autonomous driver, and retires the sentient subsystem host.
|
|
95
|
+
|
|
96
|
+
`package.json` `exports` is the full list (it also exposes wildcard paths such as `./tasks/*`). See [STABILITY.md](./STABILITY.md) for the tier definitions and breaking-change policy.
|
|
107
97
|
|
|
108
98
|
## Type definitions
|
|
109
99
|
|
|
@@ -123,41 +113,46 @@ Do **not** inline or mock types — always import from `@cleocode/contracts`.
|
|
|
123
113
|
### Task operations
|
|
124
114
|
|
|
125
115
|
```ts
|
|
126
|
-
import {
|
|
116
|
+
import { addTask, completeTask, listTasks, showTask } from '@cleocode/core';
|
|
127
117
|
|
|
128
118
|
const root = process.cwd();
|
|
129
119
|
|
|
130
|
-
const task = await
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
const { task } = await addTask(
|
|
121
|
+
{
|
|
122
|
+
title: 'Implement login endpoint',
|
|
123
|
+
type: 'task',
|
|
124
|
+
priority: 'high',
|
|
125
|
+
size: 'medium',
|
|
126
|
+
parentId: 'T1000', // the epic it belongs to
|
|
127
|
+
depends: ['T1001'], // optional dependency list
|
|
128
|
+
acceptance: ['returns a token', 'rejects bad passwords', 'a test covers both'],
|
|
129
|
+
},
|
|
130
|
+
root,
|
|
131
|
+
);
|
|
138
132
|
|
|
139
|
-
const detail
|
|
140
|
-
const list
|
|
141
|
-
await
|
|
133
|
+
const detail = await showTask(task.id, root);
|
|
134
|
+
const list = await listTasks({ status: 'pending' }, root);
|
|
135
|
+
await completeTask({ taskId: task.id }, root);
|
|
142
136
|
```
|
|
143
137
|
|
|
138
|
+
Completing a task still passes CLEO's evidence gates (ADR-051); record them first (`cleo done <id> --plan`).
|
|
139
|
+
|
|
144
140
|
### Session operations
|
|
145
141
|
|
|
146
142
|
```ts
|
|
147
|
-
import {
|
|
143
|
+
import { endSession, sessionStatus, startSession } from '@cleocode/core';
|
|
148
144
|
|
|
149
|
-
const root
|
|
150
|
-
const session = await startSession(root, { scope: 'feature/auth', name: 'auth-session' });
|
|
151
|
-
|
|
152
|
-
const status = await sessionStatus(root, { id: session.id });
|
|
145
|
+
const root = process.cwd();
|
|
153
146
|
|
|
154
|
-
await
|
|
147
|
+
await startSession(root, { scope: 'epic:T1234', name: 'auth-session' });
|
|
148
|
+
const current = await sessionStatus(root, {});
|
|
149
|
+
await endSession(root, { note: 'Completed login endpoint' });
|
|
155
150
|
```
|
|
156
151
|
|
|
157
152
|
### Memory (BRAIN) operations
|
|
158
153
|
|
|
159
154
|
```ts
|
|
160
|
-
import { observeBrain, searchBrain
|
|
155
|
+
import { observeBrain, searchBrain } from '@cleocode/core';
|
|
161
156
|
|
|
162
157
|
const root = process.cwd();
|
|
163
158
|
|
|
@@ -166,63 +161,30 @@ await observeBrain(root, {
|
|
|
166
161
|
title: 'auth-password-hashing',
|
|
167
162
|
});
|
|
168
163
|
|
|
169
|
-
const results
|
|
170
|
-
const timeline = await timelineBrain(root, { limit: 20 });
|
|
164
|
+
const results = await searchBrain(root, 'auth', { limit: 5 });
|
|
171
165
|
```
|
|
172
166
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
```ts
|
|
176
|
-
import { Cleo } from '@cleocode/core/sdk';
|
|
177
|
-
|
|
178
|
-
async function main() {
|
|
179
|
-
const cleo = await Cleo.init(process.cwd());
|
|
180
|
-
|
|
181
|
-
try {
|
|
182
|
-
const epic = await cleo.tasks.add({ title: 'Auth System', type: 'epic', priority: 'high' });
|
|
183
|
-
|
|
184
|
-
const task = await cleo.tasks.add({
|
|
185
|
-
title: 'Implement JWT validation',
|
|
186
|
-
type: 'task',
|
|
187
|
-
priority: 'high',
|
|
188
|
-
parent: epic.data.id,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
await cleo.sessions.start({ scope: 'epic:T1234', name: 'auth-sprint' });
|
|
192
|
-
|
|
193
|
-
await cleo.memory.observe({
|
|
194
|
-
text: 'JWT validated via RS256 — symmetric HMAC rejected',
|
|
195
|
-
title: 'jwt-algo-decision',
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
await cleo.tasks.complete({ taskId: task.data.id });
|
|
199
|
-
} finally {
|
|
200
|
-
await cleo.destroy();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
main().catch(console.error);
|
|
205
|
-
```
|
|
167
|
+
`timelineBrain(root, { anchor: '<entry id>' })` returns the entries around one anchor entry.
|
|
206
168
|
|
|
207
169
|
## Error handling
|
|
208
170
|
|
|
209
|
-
|
|
210
|
-
Errors extend `CleoError` and carry a typed code from the `ERROR_CATALOG`:
|
|
171
|
+
Core functions return plain results and throw `CleoError` on failure. A `CleoError` carries a numeric `code` (an `ExitCode`), an optional `codeName`, and usually a `fix` hint; `ERROR_CATALOG` maps each code to its definition:
|
|
211
172
|
|
|
212
173
|
```ts
|
|
213
|
-
import { CleoError } from '@cleocode/core';
|
|
174
|
+
import { CleoError, showTask } from '@cleocode/core';
|
|
214
175
|
|
|
215
176
|
try {
|
|
216
|
-
await
|
|
177
|
+
await showTask('T9999', process.cwd());
|
|
217
178
|
} catch (err) {
|
|
218
179
|
if (err instanceof CleoError) {
|
|
219
|
-
console.error(err.code); // e.g.
|
|
180
|
+
console.error(err.code); // e.g. 4 (ExitCode.NOT_FOUND)
|
|
220
181
|
console.error(err.message); // human-readable description
|
|
182
|
+
console.error(err.fix); // how to recover, when known
|
|
221
183
|
}
|
|
222
184
|
}
|
|
223
185
|
```
|
|
224
186
|
|
|
225
|
-
See [`@cleocode/contracts`](../contracts/README.md) for the
|
|
187
|
+
The CLI wraps these results and errors in LAFS envelopes. See [`@cleocode/contracts`](../contracts/README.md) for the `ExitCode` enum.
|
|
226
188
|
|
|
227
189
|
## Versioning policy
|
|
228
190
|
|
|
@@ -241,6 +203,8 @@ If this package is ever forked as a standalone SDK (decoupled from the CLEO CLI
|
|
|
241
203
|
|
|
242
204
|
- [ADR-057: Contracts/Core SSoT layering — uniform `(projectRoot, params)` Core API](../../docs/adr/adr-057-contracts-core-ssot.md)
|
|
243
205
|
- [ADR-058: Dispatch type inference via `OpsFromCore<C>`](../../docs/adr/adr-058-dispatch-type-inference.md)
|
|
206
|
+
- ADR-098: CLEO is a harness-agnostic core (`cleo docs fetch adr-098-retire-the-pi-cleoos-harness`; no `docs/adr/` mirror yet)
|
|
207
|
+
- [CLEO architecture guide](../../docs/concept/cleo-architecture-guide.md)
|
|
244
208
|
- [STABILITY.md](./STABILITY.md) — per-subpath stability tiers and breaking-change policy
|
|
245
209
|
- [`@cleocode/contracts`](../contracts/README.md) — all shared types (Params, Results, envelopes)
|
|
246
210
|
|
|
@@ -252,7 +216,7 @@ If this package is ever forked as a standalone SDK (decoupled from the CLEO CLI
|
|
|
252
216
|
|---|---|
|
|
253
217
|
| Import from `@cleocode/core/sdk` or narrow subpaths | Import from `@cleocode/core/internal` in third-party code |
|
|
254
218
|
| Use `@cleocode/contracts` types | Inline or mock types |
|
|
255
|
-
| Call `Cleo.init()` / domain
|
|
219
|
+
| Call `Cleo.init()` / domain functions | Access the SQLite store directly |
|
|
256
220
|
|
|
257
221
|
See the monorepo [AGENTS.md](../../AGENTS.md) for the full package-boundary contract.
|
|
258
222
|
|
package/dist/.source-stamp.json
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
* - the required-check list comes from the SAME resolver `pr:` uses
|
|
15
15
|
* (env → `release.prRequiredWorkflows` → branch protection), and an
|
|
16
16
|
* undetermined list refuses rather than accepting vacuously;
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* only there is named as such.
|
|
17
|
+
* - unscoped required names retain their merge-commit judgement; an explicit
|
|
18
|
+
* `event` requires either the final PR head's `pull_request` checks or the
|
|
19
|
+
* merge commit's `push` checks. Both configured sides must pass (T14602).
|
|
21
20
|
*
|
|
22
21
|
* Pending, failed, cancelled, skipped and missing required checks are each
|
|
23
22
|
* refused with the check's name and state.
|
|
@@ -122,6 +121,8 @@ export type MergeCommitCheckResult = {
|
|
|
122
121
|
};
|
|
123
122
|
/** Options for {@link evaluateMergeCommitChecks}. */
|
|
124
123
|
export interface EvaluateMergeCommitChecksOptions {
|
|
124
|
+
/** Final PR head for checks explicitly scoped to pull_request (T14602). */
|
|
125
|
+
prHeadSha?: string;
|
|
125
126
|
/**
|
|
126
127
|
* PR head whose `pull_request` runs tested exactly the merged tree (tree
|
|
127
128
|
* equal AND the merge's first parent is an ancestor of it). Its runs stand
|
|
@@ -457,8 +458,9 @@ export declare function hasIncompleteIdentity(checks: readonly CommitCheck[], re
|
|
|
457
458
|
* triggering event, and within a group only the LATEST attempt counts; every
|
|
458
459
|
* group on the merge commit must be `completed`/`success`. A pinned name only
|
|
459
460
|
* considers runs from its pinned app/workflow. When `treeEquivalentSha` is
|
|
460
|
-
* given, that commit's `pull_request` runs (and only those) stand in for
|
|
461
|
-
* merge-commit verdict
|
|
461
|
+
* given, that commit's `pull_request` runs (and only those) stand in for an
|
|
462
|
+
* unscoped merge-commit verdict. Explicit event pins require the PR head's
|
|
463
|
+
* `pull_request` run or the merge/descendant's `push` run, respectively.
|
|
462
464
|
*
|
|
463
465
|
* @param required - Required check names.
|
|
464
466
|
* @param checks - Every check reported for the commits involved.
|
|
@@ -743,6 +745,8 @@ export declare function failedBeforeAnyTest(checks: readonly CommitCheck[], sha:
|
|
|
743
745
|
export interface FindGreenDescendantInput {
|
|
744
746
|
/** Required check names. */
|
|
745
747
|
required: readonly string[];
|
|
748
|
+
/** Explicit PR-head checks; push-only names do not need PR runs (T14602). */
|
|
749
|
+
prRequired?: readonly string[];
|
|
746
750
|
/** Checks already fetched for the merge commit (and a tree-equivalent PR head). */
|
|
747
751
|
checks: readonly CommitCheck[];
|
|
748
752
|
/** The merge commit. */
|
|
@@ -755,8 +759,8 @@ export interface FindGreenDescendantInput {
|
|
|
755
759
|
changedPaths: readonly string[];
|
|
756
760
|
/**
|
|
757
761
|
* The PR's final head (`headRefOid`). Its latest `pull_request` runs must be
|
|
758
|
-
* green for every superseded check
|
|
759
|
-
* PR that was not itself green.
|
|
762
|
+
* green for every superseded unscoped check and every `prRequired` check:
|
|
763
|
+
* a later main run never vouches for a PR that was not itself green.
|
|
760
764
|
*/
|
|
761
765
|
prHeadSha?: string;
|
|
762
766
|
/**
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
* - the required-check list comes from the SAME resolver `pr:` uses
|
|
15
15
|
* (env → `release.prRequiredWorkflows` → branch protection), and an
|
|
16
16
|
* undetermined list refuses rather than accepting vacuously;
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* only there is named as such.
|
|
17
|
+
* - unscoped required names retain their merge-commit judgement; an explicit
|
|
18
|
+
* `event` requires either the final PR head's `pull_request` checks or the
|
|
19
|
+
* merge commit's `push` checks. Both configured sides must pass (T14602).
|
|
21
20
|
*
|
|
22
21
|
* Pending, failed, cancelled, skipped and missing required checks are each
|
|
23
22
|
* refused with the check's name and state.
|
|
@@ -480,7 +479,7 @@ function pinMatch(check, pin) {
|
|
|
480
479
|
return unknown ? 'unknown' : 'match';
|
|
481
480
|
}
|
|
482
481
|
function pinMatches(check, pin) {
|
|
483
|
-
return pinMatch(check, pin) === 'match';
|
|
482
|
+
return (pinMatch(check, pin) === 'match' && (pin?.event === undefined || check.event === pin.event));
|
|
484
483
|
}
|
|
485
484
|
/**
|
|
486
485
|
* Whether a fetch left a required check's run without the identity its pin
|
|
@@ -505,8 +504,9 @@ function describeApp(check) {
|
|
|
505
504
|
* triggering event, and within a group only the LATEST attempt counts; every
|
|
506
505
|
* group on the merge commit must be `completed`/`success`. A pinned name only
|
|
507
506
|
* considers runs from its pinned app/workflow. When `treeEquivalentSha` is
|
|
508
|
-
* given, that commit's `pull_request` runs (and only those) stand in for
|
|
509
|
-
* merge-commit verdict
|
|
507
|
+
* given, that commit's `pull_request` runs (and only those) stand in for an
|
|
508
|
+
* unscoped merge-commit verdict. Explicit event pins require the PR head's
|
|
509
|
+
* `pull_request` run or the merge/descendant's `push` run, respectively.
|
|
510
510
|
*
|
|
511
511
|
* @param required - Required check names.
|
|
512
512
|
* @param checks - Every check reported for the commits involved.
|
|
@@ -528,12 +528,24 @@ export function evaluateMergeCommitChecks(required, checks, mergeCommitSha, opts
|
|
|
528
528
|
for (const name of required) {
|
|
529
529
|
const named = checks.filter((c) => c.name === name);
|
|
530
530
|
const pinned = named.filter((c) => pinMatches(c, pins[name]));
|
|
531
|
-
const
|
|
531
|
+
const event = pins[name]?.event;
|
|
532
|
+
if (event === 'pull_request') {
|
|
533
|
+
const head = opts.prHeadSha;
|
|
534
|
+
const onHead = judgeOnSha(pinned, head ?? '', event);
|
|
535
|
+
if (onHead.ok && head)
|
|
536
|
+
matched.push(judged(name, onHead.run, head));
|
|
537
|
+
else
|
|
538
|
+
reasons.push(`${name}: ${onHead.ok ? 'missing' : onHead.verdict} on PR head ${head?.slice(0, 12) ?? '(unknown)'} (pull_request)`);
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
const onMerge = judgeOnSha(pinned, mergeCommitSha, event);
|
|
532
542
|
if (onMerge.ok) {
|
|
533
543
|
matched.push(judged(name, onMerge.run, mergeCommitSha));
|
|
534
544
|
continue;
|
|
535
545
|
}
|
|
536
|
-
if (
|
|
546
|
+
if (event === undefined &&
|
|
547
|
+
treeEquivalentSha !== undefined &&
|
|
548
|
+
treeEquivalentSha !== mergeCommitSha) {
|
|
537
549
|
const onHead = judgeOnSha(pinned, treeEquivalentSha, 'pull_request');
|
|
538
550
|
if (onHead.ok) {
|
|
539
551
|
matched.push(judged(name, onHead.run, treeEquivalentSha));
|
|
@@ -1383,7 +1395,10 @@ export async function findGreenDescendant(input) {
|
|
|
1383
1395
|
return { ok: false, reason: onHead.reason };
|
|
1384
1396
|
headChecks = onHead.checks;
|
|
1385
1397
|
}
|
|
1386
|
-
const
|
|
1398
|
+
const headRequired = input.prRequired === undefined
|
|
1399
|
+
? supersededNames
|
|
1400
|
+
: [...input.prRequired, ...supersededNames.filter((name) => pins[name]?.event === undefined)];
|
|
1401
|
+
const redHead = head ? notGreenOnPrHead(headRequired, headChecks, head, pins) : null;
|
|
1387
1402
|
if (redHead !== null) {
|
|
1388
1403
|
return {
|
|
1389
1404
|
ok: false,
|
|
@@ -1405,7 +1420,7 @@ export async function findGreenDescendant(input) {
|
|
|
1405
1420
|
return refuse(`cannot list commits on ${input.ref} after ${merge.slice(0, 12)}`);
|
|
1406
1421
|
}
|
|
1407
1422
|
const scope = pinnedScope(required, pins);
|
|
1408
|
-
const ciPaths = ciDefinitionPaths(required, pins);
|
|
1423
|
+
const ciPaths = ciDefinitionPaths([...required, ...(input.prRequired ?? [])], pins);
|
|
1409
1424
|
const guarded = [
|
|
1410
1425
|
["the PR's files", input.changedPaths],
|
|
1411
1426
|
[`a CI definition (${ciPaths.join(', ')})`, ciPaths],
|
|
@@ -2266,7 +2281,14 @@ export async function recheckCiDescendantAtom(atom, cwd, fetchChecks = defaultFe
|
|
|
2266
2281
|
}
|
|
2267
2282
|
// T14434: a current-head atom rests on every required check of the PR
|
|
2268
2283
|
// head, not only on those the head run stood in for.
|
|
2269
|
-
|
|
2284
|
+
const required = event === 'push'
|
|
2285
|
+
? stoodIn
|
|
2286
|
+
: atom.pullRequestChecks !== undefined
|
|
2287
|
+
? atom.checks.filter((c) => atom.pullRequestChecks?.includes(c.name))
|
|
2288
|
+
: atom.currentHead
|
|
2289
|
+
? atom.checks
|
|
2290
|
+
: stoodIn;
|
|
2291
|
+
for (const c of required) {
|
|
2270
2292
|
const verdict = judgeOnSha(fetched.checks.filter((run) => sameSource(run, c)), sha, event);
|
|
2271
2293
|
if (!verdict.ok) {
|
|
2272
2294
|
return {
|
|
@@ -2438,7 +2460,7 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2438
2460
|
// Round 2 (MEDIUM): a check that attests a gate must be pinned to the app
|
|
2439
2461
|
// that posts it — an unpinned name would match a run from any app.
|
|
2440
2462
|
const mapped = [...new Set(gateLists.flatMap((g) => g.list ?? []))];
|
|
2441
|
-
const unpinned =
|
|
2463
|
+
const unpinned = required.workflows.filter((name) => (mapped.includes(name) || pins[name]?.event !== undefined) && pins[name]?.app === undefined);
|
|
2442
2464
|
if (unpinned.length > 0) {
|
|
2443
2465
|
return {
|
|
2444
2466
|
ok: false,
|
|
@@ -2472,14 +2494,28 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2472
2494
|
// attested by default-branch `push` runs only — the merge commit's, or a
|
|
2473
2495
|
// later main commit's under the T12742 rule — which run the workflow as it
|
|
2474
2496
|
// stands on main after review. Its PR runs are never consulted.
|
|
2497
|
+
const eventChecks = required.workflows.some((name) => pins[name]?.event !== undefined);
|
|
2475
2498
|
const pinnedWorkflows = [
|
|
2476
|
-
...new Set(mapped.flatMap((name) =>
|
|
2499
|
+
...new Set((eventChecks ? required.workflows : mapped).flatMap((name) => pins[name]?.workflow ? [pins[name].workflow] : [])),
|
|
2477
2500
|
];
|
|
2478
2501
|
const editedWorkflows = pr.changedPaths.filter((path) => pinnedWorkflows.some((workflow) => {
|
|
2479
2502
|
const file = requiredWorkflowFile(workflow);
|
|
2480
2503
|
return file ? path === file : path.startsWith('.github/workflows/');
|
|
2481
2504
|
}));
|
|
2482
2505
|
const mainOnly = editedWorkflows.length > 0;
|
|
2506
|
+
const prRequired = required.workflows.filter((name) => pins[name]?.event === 'pull_request');
|
|
2507
|
+
const pushRequired = required.workflows.filter((name) => pins[name]?.event !== 'pull_request');
|
|
2508
|
+
if (eventChecks &&
|
|
2509
|
+
((!mainOnly && prRequired.length === 0) ||
|
|
2510
|
+
!pushRequired.some((name) => pins[name]?.event === 'push'))) {
|
|
2511
|
+
// @sync-invariant none:input-shape event-scoped CI configuration must declare both sides
|
|
2512
|
+
return {
|
|
2513
|
+
ok: false,
|
|
2514
|
+
codeName: 'E_EVIDENCE_INSUFFICIENT',
|
|
2515
|
+
reason: `ci:${prNumber}: release.prRequiredWorkflows[].event needs both "pull_request" and "push" checks (workflow edits require only "push"); a PR-head check alone proves no main push CI.`,
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
const judgedRequired = mainOnly ? pushRequired : required.workflows;
|
|
2483
2519
|
const fetchChecks = refetchIncompleteIdentity(withoutScheduledRuns(opts.fetchChecks ?? defaultFetchChecks), required.workflows, pins);
|
|
2484
2520
|
const fetched = await fetchChecks(pr.mergeCommitSha, roots.executionRoot);
|
|
2485
2521
|
if (!fetched.ok)
|
|
@@ -2513,7 +2549,7 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2513
2549
|
if (!mainOnly &&
|
|
2514
2550
|
head &&
|
|
2515
2551
|
head !== pr.mergeCommitSha &&
|
|
2516
|
-
(treeEqualHead || eventJobKeys.length > 0)) {
|
|
2552
|
+
(treeEqualHead || eventJobKeys.length > 0 || prRequired.length > 0)) {
|
|
2517
2553
|
const onHead = await fetchChecks(head, cwd);
|
|
2518
2554
|
if (onHead.ok)
|
|
2519
2555
|
checks = [...checks, ...onHead.checks];
|
|
@@ -2527,8 +2563,9 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2527
2563
|
}), ciChecks.jobs, pins).some((job) => !evaluateJobs(job.globs, checks, pr.mergeCommitSha, job.scope, 'push').ok);
|
|
2528
2564
|
// The push stand-in search must see superseded merge checks despite an equal PR tree.
|
|
2529
2565
|
const checkHead = pushUnmet ? undefined : treeEqualHead;
|
|
2530
|
-
let judgedChecks = evaluateMergeCommitChecks(
|
|
2566
|
+
let judgedChecks = evaluateMergeCommitChecks(judgedRequired, checks, pr.mergeCommitSha, {
|
|
2531
2567
|
...(treeEqualHead ? { treeEquivalentSha: treeEqualHead } : {}),
|
|
2568
|
+
...(head && !mainOnly ? { prHeadSha: head } : {}),
|
|
2532
2569
|
pins,
|
|
2533
2570
|
});
|
|
2534
2571
|
// T12742: a merge-commit push run cancelled by a concurrency group (merges
|
|
@@ -2546,7 +2583,8 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2546
2583
|
if ((!judgedChecks.ok || pushUnmet) && onDefault.ref !== null) {
|
|
2547
2584
|
const found = await findGreenDescendant({
|
|
2548
2585
|
...(jobSpecs.length > 0 ? { jobs: jobSpecs } : {}),
|
|
2549
|
-
required:
|
|
2586
|
+
required: pushRequired,
|
|
2587
|
+
...(eventChecks ? { prRequired } : {}),
|
|
2550
2588
|
checks,
|
|
2551
2589
|
mergeCommitSha: pr.mergeCommitSha,
|
|
2552
2590
|
...(checkHead ? { treeEquivalentSha: checkHead } : {}),
|
|
@@ -2567,8 +2605,9 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2567
2605
|
});
|
|
2568
2606
|
if (found.ok) {
|
|
2569
2607
|
const withDescendant = [...checks, ...found.checks];
|
|
2570
|
-
const rejudged = evaluateMergeCommitChecks(
|
|
2608
|
+
const rejudged = evaluateMergeCommitChecks(judgedRequired, withDescendant, pr.mergeCommitSha, {
|
|
2571
2609
|
...(checkHead ? { treeEquivalentSha: checkHead } : {}),
|
|
2610
|
+
...(head && !mainOnly ? { prHeadSha: head } : {}),
|
|
2572
2611
|
pins,
|
|
2573
2612
|
descendantSha: found.sha,
|
|
2574
2613
|
...(found.inherited || found.nonTest || found.untested
|
|
@@ -2623,7 +2662,7 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2623
2662
|
const scopedHead = wide === null ? cleared?.prHeadSha : undefined;
|
|
2624
2663
|
const scoped = cleared && scopedHead ? { ...cleared, prHeadSha: scopedHead } : undefined;
|
|
2625
2664
|
const redHead = scoped
|
|
2626
|
-
? notGreenOnPrHead(required.workflows, scoped.headChecks, scoped.prHeadSha, pins)
|
|
2665
|
+
? notGreenOnPrHead(required.workflows.filter((name) => pins[name]?.event !== 'push'), scoped.headChecks, scoped.prHeadSha, pins)
|
|
2627
2666
|
: null;
|
|
2628
2667
|
const scopedLead = `the merge commit's run is not the PR's failure, so a green push run of the required checks on the current ${onDefault.ref} HEAD would stand in (D11241), but `;
|
|
2629
2668
|
if (redHead !== null) {
|
|
@@ -2632,7 +2671,7 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2632
2671
|
else if (wide !== null || scoped) {
|
|
2633
2672
|
const found = await findGreenCurrentHead({
|
|
2634
2673
|
...(jobSpecs.length > 0 ? { jobs: jobSpecs } : {}),
|
|
2635
|
-
required:
|
|
2674
|
+
required: pushRequired,
|
|
2636
2675
|
mergeCommitSha: pr.mergeCommitSha,
|
|
2637
2676
|
pins,
|
|
2638
2677
|
ref: onDefault.ref,
|
|
@@ -2658,8 +2697,9 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2658
2697
|
? [...checks, ...found.checks, ...(scoped?.headChecks ?? [])]
|
|
2659
2698
|
: checks;
|
|
2660
2699
|
const rejudged = found.ok && missing === null
|
|
2661
|
-
? evaluateMergeCommitChecks(
|
|
2700
|
+
? evaluateMergeCommitChecks(judgedRequired, withHead, pr.mergeCommitSha, {
|
|
2662
2701
|
...(checkHead ? { treeEquivalentSha: checkHead } : {}),
|
|
2702
|
+
...(head && !mainOnly ? { prHeadSha: head } : {}),
|
|
2663
2703
|
pins,
|
|
2664
2704
|
descendantSha: found.sha,
|
|
2665
2705
|
currentHead: true,
|
|
@@ -2671,7 +2711,9 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2671
2711
|
descendant = {
|
|
2672
2712
|
sha: found.sha,
|
|
2673
2713
|
range: found.range,
|
|
2674
|
-
...(scoped?.prHeadSha
|
|
2714
|
+
...(scoped?.prHeadSha || (eventChecks && !mainOnly && head)
|
|
2715
|
+
? { prHeadSha: scoped?.prHeadSha ?? head }
|
|
2716
|
+
: {}),
|
|
2675
2717
|
...(scoped?.inherited ? { inherited: scoped.inherited } : {}),
|
|
2676
2718
|
...(scoped?.nonTest ? { nonTest: scoped.nonTest } : {}),
|
|
2677
2719
|
...(scoped?.untested ? { untested: scoped.untested } : {}),
|
|
@@ -2727,6 +2769,10 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2727
2769
|
reason: `${lead}${next}\n Required checks (source: ${describeRequiredWorkflowsSource(required.source)}):\n - ${judgedChecks.reasons.join('\n - ')}` +
|
|
2728
2770
|
(descendantReason ? `\n No later main run stands in: ${descendantReason}` : '') +
|
|
2729
2771
|
(currentHeadReason ? `\n No current-HEAD run stands in: ${currentHeadReason}` : '') +
|
|
2772
|
+
'\n When PR and main checks differ, set release.prRequiredWorkflows[].event to "pull_request" or "push" for each check.' +
|
|
2773
|
+
(eventChecks
|
|
2774
|
+
? '\n A cancelled merge run is refused unless a qualifying descendant exists under the T12742 descendant rule (or the applicable current-HEAD rule).'
|
|
2775
|
+
: '') +
|
|
2730
2776
|
(eventJobKeys.length
|
|
2731
2777
|
? `\n Check the per-event job requirements: ${eventJobKeys.map((key) => `${key}.pullRequest and ${key}.push`).join('; ')}.`
|
|
2732
2778
|
: ''),
|
|
@@ -2856,7 +2902,10 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2856
2902
|
}
|
|
2857
2903
|
const gateChecks = {};
|
|
2858
2904
|
for (const g of gateLists)
|
|
2859
|
-
gateChecks[g.gate] = [
|
|
2905
|
+
gateChecks[g.gate] = [
|
|
2906
|
+
...(g.list ?? []).filter((name) => !mainOnly || pins[name]?.event !== 'pull_request'),
|
|
2907
|
+
...(jobsByGate[g.gate] ?? []),
|
|
2908
|
+
];
|
|
2860
2909
|
return {
|
|
2861
2910
|
ok: true,
|
|
2862
2911
|
atom: {
|
|
@@ -2864,6 +2913,17 @@ export async function resolveCiEvidenceAtom(prNumber, roots, opts = {}) {
|
|
|
2864
2913
|
prNumber,
|
|
2865
2914
|
mergeCommitSha: pr.mergeCommitSha,
|
|
2866
2915
|
checks: judgedChecks.checks,
|
|
2916
|
+
...(eventChecks && !mainOnly
|
|
2917
|
+
? {
|
|
2918
|
+
pullRequestChecks: [
|
|
2919
|
+
...prRequired,
|
|
2920
|
+
...judgedChecks.checks
|
|
2921
|
+
.filter((c) => pins[c.name]?.event === undefined &&
|
|
2922
|
+
(currentHead || (!workspaceWide && c.sha === descendant?.sha)))
|
|
2923
|
+
.map((c) => c.name),
|
|
2924
|
+
],
|
|
2925
|
+
}
|
|
2926
|
+
: {}),
|
|
2867
2927
|
...(mergeTree !== null ? { testedTree: mergeTree } : {}),
|
|
2868
2928
|
...(descendant
|
|
2869
2929
|
? {
|