@amoree-code/ocean 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/infrastructure/providers/task-reviewer.js +35 -0
- package/dist/interfaces/cli/operate-command.js +2 -0
- package/dist/interfaces/cli/tasks-command.js +18 -3
- package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +35 -3
- package/node_modules/@ocean/brain/dist/memory/session-promotion.js +2 -1
- package/node_modules/@ocean/brain/package.json +1 -1
- package/node_modules/@ocean/context/package.json +1 -1
- package/node_modules/@ocean/core/package.json +1 -1
- package/node_modules/@ocean/loop/dist/infrastructure/persistence/session-store.js +15 -0
- package/node_modules/@ocean/loop/dist/operations/task-operations.js +6 -1
- package/node_modules/@ocean/loop/dist/tasks/archive-tasks.js +11 -9
- package/node_modules/@ocean/loop/dist/tasks/claim-task.js +11 -3
- package/node_modules/@ocean/loop/dist/tasks/task-git.js +28 -0
- package/node_modules/@ocean/loop/dist/tasks/task-verification.js +302 -0
- package/node_modules/@ocean/loop/dist/tasks/verify-task.js +69 -21
- package/node_modules/@ocean/loop/package.json +1 -1
- package/node_modules/@ocean/market/package.json +1 -1
- package/node_modules/@ocean/services/package.json +1 -1
- package/ocean-marketplace.json +34 -34
- package/package.json +7 -7
- package/templates/workspace/charter/policies/contracts/task.md +44 -1
- package/templates/workspace/charter/policies/task.md +5 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { oceanEnv, oceanEnvPair, oceanRoot } from "@ocean/core/shared/paths.js";
|
|
2
|
+
import { resolveOriginalExecutable } from "./provider-registry.js";
|
|
3
|
+
import { runProvider } from "./providers.js";
|
|
4
|
+
import { FACTS_CALL_ENV, finalText } from "./session-facts-completer.js";
|
|
5
|
+
// The optional independent review of `ocean tasks verify` (T-320 F2): read-only, on the
|
|
6
|
+
// cheapest model, run only for a task that sets `review: agent`. It reads the workspace (to
|
|
7
|
+
// check that cited files exist) and never writes. OCEAN_TASK_REVIEW_MODEL overrides the model.
|
|
8
|
+
const PROVIDER = "claude";
|
|
9
|
+
const DEFAULT_MODEL = "haiku";
|
|
10
|
+
const TIMEOUT_MS = 180_000;
|
|
11
|
+
const REVIEW_SYSTEM_PROMPT = "You are a strict, read-only verifier. You never edit files or run commands that change state. You check that claims point to evidence and finish with one verdict line.";
|
|
12
|
+
export function taskReviewer(run = runProvider) {
|
|
13
|
+
try {
|
|
14
|
+
resolveOriginalExecutable(PROVIDER);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const model = oceanEnv("TASK_REVIEW_MODEL") ?? DEFAULT_MODEL;
|
|
20
|
+
return async (prompt) => {
|
|
21
|
+
const result = await run({
|
|
22
|
+
provider: PROVIDER,
|
|
23
|
+
prompt,
|
|
24
|
+
cwd: oceanRoot(),
|
|
25
|
+
readOnly: true,
|
|
26
|
+
bare: { systemPrompt: REVIEW_SYSTEM_PROMPT },
|
|
27
|
+
model,
|
|
28
|
+
timeoutMs: TIMEOUT_MS,
|
|
29
|
+
// The same flag the fact-capture call carries: its hooks see it and record no session.
|
|
30
|
+
env: oceanEnvPair(FACTS_CALL_ENV, "1"),
|
|
31
|
+
});
|
|
32
|
+
return result.exitCode === 0 ? finalText(result.events) : null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=task-reviewer.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { classifyIntent } from "@ocean/context/context/intent-router.js";
|
|
2
2
|
import { oceanRoot } from "@ocean/core/shared/paths.js";
|
|
3
3
|
import { knownTaskPrefixes } from "@ocean/core/shared/project-resolution.js";
|
|
4
|
+
import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
4
5
|
import { operationForIntent, } from "@ocean/loop/operations/operation-contract.js";
|
|
5
6
|
import { runOperation } from "@ocean/loop/operations/record-operations.js";
|
|
6
7
|
import { guardedRunOperation, } from "@ocean/loop/operations/write-guard.js";
|
|
@@ -40,6 +41,7 @@ export async function runOperateCommand(text) {
|
|
|
40
41
|
query: text,
|
|
41
42
|
approval: approval ?? undefined,
|
|
42
43
|
indexPort: defaultBrainIndexPort,
|
|
44
|
+
openStore: openSessionStore,
|
|
43
45
|
}));
|
|
44
46
|
console.log(JSON.stringify({
|
|
45
47
|
classification,
|
|
@@ -5,14 +5,16 @@ import { promisify } from "node:util";
|
|
|
5
5
|
import { enginePath, oceanPath, projectDir, resolveWithin, WORKSPACE_PROJECT_ID, } from "@ocean/core/shared/paths.js";
|
|
6
6
|
import { folderProject, projectsWithTasks, } from "@ocean/core/shared/project-resolution.js";
|
|
7
7
|
import { resolveTaskReference } from "@ocean/core/shared/task-reference.js";
|
|
8
|
+
import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
8
9
|
import { archiveDoneTasks, completeTask, } from "@ocean/loop/tasks/archive-tasks.js";
|
|
9
10
|
import { checkpointTask } from "@ocean/loop/tasks/checkpoint-task.js";
|
|
10
11
|
import { claimTask, releaseTask } from "@ocean/loop/tasks/claim-task.js";
|
|
11
12
|
import { listTasks, listTasksForFolder, } from "@ocean/loop/tasks/list-tasks.js";
|
|
12
13
|
import { newTask } from "@ocean/loop/tasks/new-task.js";
|
|
13
14
|
import { renumberTasks } from "@ocean/loop/tasks/renumber-tasks.js";
|
|
15
|
+
import { verifyAndRecord } from "@ocean/loop/tasks/task-verification.js";
|
|
14
16
|
import { verificationReadiness } from "@ocean/loop/tasks/verification-readiness.js";
|
|
15
|
-
import {
|
|
17
|
+
import { taskReviewer } from "../../infrastructure/providers/task-reviewer.js";
|
|
16
18
|
const execFile = promisify(execFileCallback);
|
|
17
19
|
// Re-exported for existing importers (daily/context commands, tests). The
|
|
18
20
|
// implementation and the MCP server both live in the application layer now.
|
|
@@ -32,6 +34,15 @@ async function liveTask(id, explicitProject, cwdProject) {
|
|
|
32
34
|
root: resolveWithin(oceanPath(projectDir(location.projectId)), "tasks"),
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
// `tasks verify` and `tasks complete` record their verdict on the task and its sessions (T-320).
|
|
38
|
+
// The model review is built only for a task that opted in, so a plain verify never resolves a
|
|
39
|
+
// provider.
|
|
40
|
+
function recordedVerification(id, root) {
|
|
41
|
+
return verifyAndRecord(id, root, {
|
|
42
|
+
openStore: openSessionStore,
|
|
43
|
+
reviewer: taskReviewer,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
35
46
|
// `ocean tasks list --pretty`: one aligned row per task, for a person rather than a tool.
|
|
36
47
|
function taskTable(tasks) {
|
|
37
48
|
if (!tasks.length)
|
|
@@ -165,8 +176,10 @@ export async function runTasksCommand(action, args) {
|
|
|
165
176
|
return;
|
|
166
177
|
}
|
|
167
178
|
const task = await liveTask(id, explicitProject, cwdProject);
|
|
168
|
-
const outcome = await
|
|
179
|
+
const outcome = await recordedVerification(task.id, task.root);
|
|
169
180
|
console.log(JSON.stringify(outcome, null, 2));
|
|
181
|
+
if (outcome.recordError)
|
|
182
|
+
console.error(`warning: evidence not recorded: ${outcome.recordError}`);
|
|
170
183
|
if (!outcome.passed)
|
|
171
184
|
process.exitCode = 1;
|
|
172
185
|
return;
|
|
@@ -185,7 +198,9 @@ export async function runTasksCommand(action, args) {
|
|
|
185
198
|
}
|
|
186
199
|
try {
|
|
187
200
|
const task = await liveTask(id, explicitProject, cwdProject);
|
|
188
|
-
console.log(JSON.stringify(await completeTask(task.id, task.root
|
|
201
|
+
console.log(JSON.stringify(await completeTask(task.id, task.root, {
|
|
202
|
+
verify: recordedVerification,
|
|
203
|
+
}), null, 2));
|
|
189
204
|
}
|
|
190
205
|
catch (error) {
|
|
191
206
|
console.error(error instanceof Error ? error.message : String(error));
|
|
@@ -6,7 +6,22 @@ import { addLesson, confirmLesson, contradictLesson, LessonRejectedError, readLe
|
|
|
6
6
|
// session recorded itself — its exit, its evidence events — never the model's own claims.
|
|
7
7
|
export const PROMOTION_HITS = 3;
|
|
8
8
|
const MAX_NEW_LESSONS = 4;
|
|
9
|
-
//
|
|
9
|
+
// Evidence that checked an outcome (T-320): a task's verify commands, or a test run. A provider
|
|
10
|
+
// exiting 0 says the CLI finished, not that the work is right, so `provider_exit` never proves.
|
|
11
|
+
export const PROVING_EVIDENCE_TYPES = new Set([
|
|
12
|
+
"task_verify",
|
|
13
|
+
"test",
|
|
14
|
+
]);
|
|
15
|
+
// Whether one evidence event's data counts as outcome proof.
|
|
16
|
+
export function isProvingEvidence(data) {
|
|
17
|
+
const parsed = safeJsonParse(data);
|
|
18
|
+
return (parsed?.result === "proven" &&
|
|
19
|
+
PROVING_EVIDENCE_TYPES.has(String(parsed?.type ?? "")));
|
|
20
|
+
}
|
|
21
|
+
// verified = completed, exited 0, at least one proving evidence event (task_verify or test),
|
|
22
|
+
// and none unproven. `provider_exit` is ignored here: the exit code is read from process_exit.
|
|
23
|
+
// A task re-verified later supersedes its earlier verdict, so only the latest task_verify per
|
|
24
|
+
// task and acceptance criterion counts.
|
|
10
25
|
export function scoreSession(session, events) {
|
|
11
26
|
const exit = [...events].reverse().find((e) => e.type === "process_exit");
|
|
12
27
|
const exitCode = exit
|
|
@@ -16,14 +31,31 @@ export function scoreSession(session, events) {
|
|
|
16
31
|
: 1;
|
|
17
32
|
let provenCount = 0;
|
|
18
33
|
let unprovenCount = 0;
|
|
34
|
+
const latestTaskVerdict = new Map();
|
|
19
35
|
for (const event of events) {
|
|
20
36
|
if (event.type !== "evidence")
|
|
21
37
|
continue;
|
|
22
|
-
|
|
38
|
+
const data = safeJsonParse(event.data);
|
|
39
|
+
const type = String(data?.type ?? "");
|
|
40
|
+
if (type === "provider_exit")
|
|
41
|
+
continue;
|
|
42
|
+
const proven = data?.result === "proven";
|
|
43
|
+
if (type === "task_verify") {
|
|
44
|
+
const key = `${data?.taskId ?? ""}:${data?.criterion ?? ""}`;
|
|
45
|
+
latestTaskVerdict.delete(key);
|
|
46
|
+
latestTaskVerdict.set(key, proven);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!proven)
|
|
50
|
+
unprovenCount += 1;
|
|
51
|
+
else if (PROVING_EVIDENCE_TYPES.has(type))
|
|
52
|
+
provenCount += 1;
|
|
53
|
+
}
|
|
54
|
+
for (const proven of latestTaskVerdict.values())
|
|
55
|
+
if (proven)
|
|
23
56
|
provenCount += 1;
|
|
24
57
|
else
|
|
25
58
|
unprovenCount += 1;
|
|
26
|
-
}
|
|
27
59
|
return {
|
|
28
60
|
verified: session.status === "completed" &&
|
|
29
61
|
exitCode === 0 &&
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { redactRuntimeText } from "@ocean/core/domain/redaction/redaction.js";
|
|
4
4
|
import { KNOWLEDGE_DIR, oceanPath } from "@ocean/core/shared/paths.js";
|
|
5
5
|
import { syncMemoryIndexes } from "./index-sync.js";
|
|
6
|
+
import { isProvingEvidence } from "./lesson-learning.js";
|
|
6
7
|
const kinds = new Set([
|
|
7
8
|
"architecture",
|
|
8
9
|
"decisions",
|
|
@@ -30,7 +31,7 @@ export async function promoteSessionToKnowledge(sessionId, openStore, target = "
|
|
|
30
31
|
const evidence = events
|
|
31
32
|
.filter((event) => event.type === "evidence")
|
|
32
33
|
.map((event) => event.data)
|
|
33
|
-
.some(
|
|
34
|
+
.some(isProvingEvidence);
|
|
34
35
|
if (!evidence)
|
|
35
36
|
throw new Error("Session lacks independently recorded successful evidence");
|
|
36
37
|
const input = events.find((event) => event.type === "user_input")?.data ?? "";
|
|
@@ -453,6 +453,21 @@ export class SessionStore {
|
|
|
453
453
|
const foreignKeys = this.database.prepare("PRAGMA foreign_key_check").all();
|
|
454
454
|
return { integrity, foreignKeys };
|
|
455
455
|
}
|
|
456
|
+
listTaskSessions(taskId, projectId) {
|
|
457
|
+
const rows = (projectId
|
|
458
|
+
? this.database
|
|
459
|
+
.prepare("SELECT * FROM sessions WHERE task_id = ? AND (project_id = ? OR project_id IS NULL) ORDER BY created_at")
|
|
460
|
+
.all(taskId, projectId)
|
|
461
|
+
: this.database
|
|
462
|
+
.prepare("SELECT * FROM sessions WHERE task_id = ? ORDER BY created_at")
|
|
463
|
+
.all(taskId));
|
|
464
|
+
return rows.map((row) => this.toSession(row));
|
|
465
|
+
}
|
|
466
|
+
setVerificationStatus(sessionId, status) {
|
|
467
|
+
this.database
|
|
468
|
+
.prepare("UPDATE sessions SET verification_status = ?, updated_at = ? WHERE session_id = ?")
|
|
469
|
+
.run(status, new Date().toISOString(), sessionId);
|
|
470
|
+
}
|
|
456
471
|
appendEvent(sessionId, type, data) {
|
|
457
472
|
const createdAt = new Date().toISOString();
|
|
458
473
|
const result = this.database
|
|
@@ -8,6 +8,7 @@ import { withNextTaskId } from "@ocean/core/shared/project-resolution.js";
|
|
|
8
8
|
import { resolveTaskReference, } from "@ocean/core/shared/task-reference.js";
|
|
9
9
|
import { completeTask } from "../tasks/archive-tasks.js";
|
|
10
10
|
import { taskRecord, validTaskTitle } from "../tasks/new-task.js";
|
|
11
|
+
import { verifyAndRecord } from "../tasks/task-verification.js";
|
|
11
12
|
import { approvalMatchesTarget, operationResult, selectFields, shapeRecords, validateTaskIdentifier, validateWriteTarget, } from "./operation-contract.js";
|
|
12
13
|
import { crossProjectGuard, taskRoot, } from "./operation-scope.js";
|
|
13
14
|
import { freshnessFor, readFrontmatterFile, relativeToOcean, requireAbsentTarget, } from "./record-io.js";
|
|
@@ -261,7 +262,11 @@ export async function taskCompleteOperation(classification, _budget, options, cw
|
|
|
261
262
|
return operationResult("task.complete", approvalCheck.reason);
|
|
262
263
|
try {
|
|
263
264
|
// Reuses the existing governed completion path: it refuses a task with unchecked work.
|
|
264
|
-
const result = await completeTask(resolved.location.id, taskRoot(project.projectId)
|
|
265
|
+
const result = await completeTask(resolved.location.id, taskRoot(project.projectId), options.openStore
|
|
266
|
+
? {
|
|
267
|
+
verify: (id, root) => verifyAndRecord(id, root, { openStore: options.openStore }),
|
|
268
|
+
}
|
|
269
|
+
: {});
|
|
265
270
|
return {
|
|
266
271
|
operation: "task.complete",
|
|
267
272
|
ok: true,
|
|
@@ -2,7 +2,7 @@ import { access, mkdir, readdir, readFile, rename, rmdir, writeFile, } from "nod
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { resolveWithin, WORKSPACE_PROJECT_ID, workspaceTasksRoot, } from "@ocean/core/shared/paths.js";
|
|
4
4
|
import { projectArchiveName, WORKSPACE_ARCHIVE_NAMESPACE, } from "@ocean/core/shared/task-reference.js";
|
|
5
|
-
import { verifyTask } from "./verify-task.js";
|
|
5
|
+
import { verifyTask, } from "./verify-task.js";
|
|
6
6
|
const field = (source, name) => source
|
|
7
7
|
.match(new RegExp(`^${name}:\\s*(.+)$`, "m"))?.[1]
|
|
8
8
|
?.trim()
|
|
@@ -76,22 +76,24 @@ export async function completeTask(id, root = workspaceTasksRoot(), options = {}
|
|
|
76
76
|
const issues = completionIssues(source);
|
|
77
77
|
if (issues.length)
|
|
78
78
|
throw new Error(`Cannot complete ${id}: ${issues.join("; ")}`);
|
|
79
|
-
const outcome =
|
|
80
|
-
|
|
81
|
-
run: options.run
|
|
82
|
-
});
|
|
79
|
+
const outcome = options.verify
|
|
80
|
+
? await options.verify(id, root)
|
|
81
|
+
: await verifyTask(id, root, { cwd: options.cwd, run: options.run });
|
|
83
82
|
if (!outcome.passed)
|
|
84
83
|
throw new Error(`Cannot complete ${id}: ${outcome.reason}`);
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
// Re-read: a recording verifier has just written the verdict into the file.
|
|
85
|
+
const verifiedSource = await readFile(taskFile, "utf8");
|
|
86
|
+
if (field(verifiedSource, "state") !== "done")
|
|
87
|
+
await writeFile(taskFile, setState(verifiedSource, "done"));
|
|
87
88
|
const archived = await archiveDoneTasks(root, true, {
|
|
88
|
-
|
|
89
|
+
cwd: options.cwd,
|
|
90
|
+
run: options.run,
|
|
89
91
|
verified: new Set([id]),
|
|
90
92
|
only: new Set([id]),
|
|
91
93
|
});
|
|
92
94
|
const skipped = archived.skipped.find((entry) => entry.id === id);
|
|
93
95
|
if (skipped) {
|
|
94
|
-
await writeFile(taskFile,
|
|
96
|
+
await writeFile(taskFile, verifiedSource, "utf8");
|
|
95
97
|
throw new Error(`Cannot complete ${id}: ${skipped.reason}`);
|
|
96
98
|
}
|
|
97
99
|
return { id, state: "done", ...archived };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdir, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { localDate } from "@ocean/core/shared/local-date.js";
|
|
3
|
-
import { resolveWithin } from "@ocean/core/shared/paths.js";
|
|
3
|
+
import { oceanRoot, resolveWithin } from "@ocean/core/shared/paths.js";
|
|
4
|
+
import { headCommit } from "./task-git.js";
|
|
4
5
|
// Keep equal to CLAIM_TTL_MS in scripts/validate-tasks.mjs (a test pins the two together).
|
|
5
6
|
export const CLAIM_TTL_MS = 2 * 60 * 60 * 1000;
|
|
6
7
|
const OWNER = /^[\w.@/-]{1,64}$/;
|
|
@@ -41,7 +42,7 @@ export function isStale(claim, now = new Date()) {
|
|
|
41
42
|
const STARTS_ON_CLAIM = new Set(["todo", "paused"]);
|
|
42
43
|
// Replace the claim lines in the frontmatter (and bump `updated`), keeping every other line.
|
|
43
44
|
// Claiming also moves a `todo`/`paused` task to `active`; releasing leaves the state alone.
|
|
44
|
-
function withClaim(source, claim, today) {
|
|
45
|
+
function withClaim(source, claim, today, baseCommit = null) {
|
|
45
46
|
const end = source.indexOf("\n---", 4);
|
|
46
47
|
const kept = source
|
|
47
48
|
.slice(4, end)
|
|
@@ -59,6 +60,10 @@ function withClaim(source, claim, today) {
|
|
|
59
60
|
if (claim.paths.length)
|
|
60
61
|
kept.push(`claimed_paths: [${claim.paths.join(", ")}]`);
|
|
61
62
|
}
|
|
63
|
+
// Sticky: written by the first claim only, and kept through release and re-claim, so
|
|
64
|
+
// `tasks verify` can tell whether the claimed paths changed at all since work began.
|
|
65
|
+
if (baseCommit && !kept.some((line) => /^base_commit:/.test(line)))
|
|
66
|
+
kept.push(`base_commit: ${baseCommit}`);
|
|
62
67
|
return `---\n${kept.join("\n")}${source.slice(end)}`;
|
|
63
68
|
}
|
|
64
69
|
async function liveClaimsElsewhere(root, id, now) {
|
|
@@ -108,7 +113,10 @@ export async function claimTask(id, root, input) {
|
|
|
108
113
|
throw new Error(`${clash} overlaps ${other.claim.paths.join(", ")} claimed by ${other.claim.by} on ${other.id}.`);
|
|
109
114
|
}
|
|
110
115
|
const claim = { by: input.by, at: now.toISOString(), paths };
|
|
111
|
-
|
|
116
|
+
const baseCommit = fields.base_commit
|
|
117
|
+
? null
|
|
118
|
+
: await (input.head ?? (() => headCommit(oceanRoot())))();
|
|
119
|
+
await writeFile(taskFile, withClaim(source, claim, localDate(now), baseCommit), "utf8");
|
|
112
120
|
// Read-modify-write is not atomic: if a concurrent claim landed between our read and write,
|
|
113
121
|
// the file now names someone else. Re-read so the loser finds out instead of assuming it won.
|
|
114
122
|
const written = parseClaim(frontmatterFields(await readFile(taskFile, "utf8")));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { execFile as execFileCallback } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execFile = promisify(execFileCallback);
|
|
4
|
+
// The commit checked out at `cwd`, or null outside a repository (T-320 F1).
|
|
5
|
+
export async function headCommit(cwd) {
|
|
6
|
+
try {
|
|
7
|
+
const { stdout } = await execFile("git", ["rev-parse", "HEAD"], { cwd });
|
|
8
|
+
return stdout.trim() || null;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Whether anything under `paths` differs from `base`: committed since, staged, unstaged or
|
|
15
|
+
// untracked. null when git cannot answer (no repository, unknown commit).
|
|
16
|
+
export async function changedSince(cwd, base, paths) {
|
|
17
|
+
try {
|
|
18
|
+
const { stdout: diff } = await execFile("git", ["diff", "--name-only", base, "--", ...paths], { cwd, maxBuffer: 16 * 1024 * 1024 });
|
|
19
|
+
if (diff.trim())
|
|
20
|
+
return true;
|
|
21
|
+
const { stdout: untracked } = await execFile("git", ["ls-files", "--others", "--exclude-standard", "--", ...paths], { cwd, maxBuffer: 16 * 1024 * 1024 });
|
|
22
|
+
return Boolean(untracked.trim());
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=task-git.js.map
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
|
|
4
|
+
import { localDate } from "@ocean/core/shared/local-date.js";
|
|
5
|
+
import { oceanRoot, projectOfTasksRoot, repoRoot, resolveWithin, } from "@ocean/core/shared/paths.js";
|
|
6
|
+
import { changedSince } from "./task-git.js";
|
|
7
|
+
import { verifyTask, } from "./verify-task.js";
|
|
8
|
+
const VERIFY_PROFILE = "tasks-verify";
|
|
9
|
+
const REVIEW_LANE_CLASSES = new Set(["high", "large"]);
|
|
10
|
+
function inlineList(value) {
|
|
11
|
+
const inner = value?.match(/^\[(.*)\]$/)?.[1] ?? "";
|
|
12
|
+
return inner
|
|
13
|
+
.split(",")
|
|
14
|
+
.map((item) => item.trim().replace(/^['"]|['"]$/g, ""))
|
|
15
|
+
.filter(Boolean);
|
|
16
|
+
}
|
|
17
|
+
function section(source, heading) {
|
|
18
|
+
const header = new RegExp(`^## ${heading}[ \\t]*\\r?$`, "m").exec(source);
|
|
19
|
+
if (!header)
|
|
20
|
+
return "";
|
|
21
|
+
const start = source.indexOf("\n", header.index) + 1;
|
|
22
|
+
const next = /^## /m.exec(source.slice(start));
|
|
23
|
+
return source.slice(start, next ? start + next.index : source.length);
|
|
24
|
+
}
|
|
25
|
+
// `AC-n` ids named by the Definition of done (C3), in order of first appearance.
|
|
26
|
+
export function acceptanceIds(source) {
|
|
27
|
+
const ids = [
|
|
28
|
+
...section(source, "Definition of done").matchAll(/\bAC-\d+\b/gi),
|
|
29
|
+
].map((match) => match[0].toUpperCase());
|
|
30
|
+
return [...new Set(ids)];
|
|
31
|
+
}
|
|
32
|
+
// The review's verdict is its last non-empty line: `pass`, or `fail — <reason>`.
|
|
33
|
+
export function parseReviewVerdict(answer) {
|
|
34
|
+
const line = answer
|
|
35
|
+
?.split("\n")
|
|
36
|
+
.map((entry) => entry.trim().replace(/^[`*]+|[`*]+$/g, ""))
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.at(-1);
|
|
39
|
+
if (!line)
|
|
40
|
+
return null;
|
|
41
|
+
if (/^pass\b/i.test(line))
|
|
42
|
+
return { passed: true, line };
|
|
43
|
+
if (/^fail\b/i.test(line))
|
|
44
|
+
return { passed: false, line };
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function reviewPrompt(id, source, outcome) {
|
|
48
|
+
return [
|
|
49
|
+
`You are a read-only verifier for task ${id}. Do not edit, fix or run anything that changes state.`,
|
|
50
|
+
"Check only one thing: every claimed item (each checked box `[x]` in Scope and Definition of done) points to evidence — a passing check listed below, a commit, a file path that exists, or an event id. An item claimed with no evidence fails the review.",
|
|
51
|
+
"Deterministic checks already ran; their result is below. Do not repeat them.",
|
|
52
|
+
"",
|
|
53
|
+
"## Deterministic result",
|
|
54
|
+
JSON.stringify({
|
|
55
|
+
passed: outcome.passed,
|
|
56
|
+
reason: outcome.reason,
|
|
57
|
+
checks: outcome.checks,
|
|
58
|
+
}, null, 2),
|
|
59
|
+
"",
|
|
60
|
+
"## Task file",
|
|
61
|
+
source,
|
|
62
|
+
"",
|
|
63
|
+
"End your answer with exactly one line: `pass` or `fail — <reason>`.",
|
|
64
|
+
].join("\n");
|
|
65
|
+
}
|
|
66
|
+
// Replace (or add) frontmatter fields, keeping every other line. A block-list value under a
|
|
67
|
+
// replaced key (`key:` then indented `- item` lines) is replaced with it.
|
|
68
|
+
export function setFrontmatterFields(source, fields) {
|
|
69
|
+
const end = source.indexOf("\n---", 4);
|
|
70
|
+
if (!source.startsWith("---\n") || end < 0)
|
|
71
|
+
return source;
|
|
72
|
+
const lines = source.slice(4, end).split("\n");
|
|
73
|
+
const kept = [];
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
let skippingList = false;
|
|
76
|
+
for (const line of lines) {
|
|
77
|
+
if (skippingList && /^\s+-\s/.test(line))
|
|
78
|
+
continue;
|
|
79
|
+
skippingList = false;
|
|
80
|
+
const key = line.match(/^([\w-]+):/)?.[1];
|
|
81
|
+
if (key && key in fields) {
|
|
82
|
+
kept.push(`${key}: ${fields[key]}`);
|
|
83
|
+
seen.add(key);
|
|
84
|
+
skippingList = true;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
kept.push(line);
|
|
88
|
+
}
|
|
89
|
+
for (const [key, value] of Object.entries(fields))
|
|
90
|
+
if (!seen.has(key))
|
|
91
|
+
kept.push(`${key}: ${value}`);
|
|
92
|
+
return `---\n${kept.join("\n")}${source.slice(end)}`;
|
|
93
|
+
}
|
|
94
|
+
// Frontmatter lists are inline; an item never carries a comma or a bracket.
|
|
95
|
+
const listItem = (text) => text.replace(/[,[\]]/g, ";");
|
|
96
|
+
/**
|
|
97
|
+
* Run a task's declared checks with no model, decide `verified`, and record it: one evidence
|
|
98
|
+
* event per check in a `tasks-verify` session linked to the task (copied to every session
|
|
99
|
+
* already linked to it, whose `verification_status` follows), and `verified`, `verified_at`,
|
|
100
|
+
* `evidence` (event ids) and `assumed` in the task's frontmatter.
|
|
101
|
+
*/
|
|
102
|
+
export async function verifyAndRecord(id, root, options = {}) {
|
|
103
|
+
const now = options.now ?? new Date();
|
|
104
|
+
const taskFile = resolveWithin(root, id, "task.md");
|
|
105
|
+
const source = await readFile(taskFile, "utf8");
|
|
106
|
+
const fields = parseFrontmatter(source);
|
|
107
|
+
const outcome = await verifyTask(id, root, {
|
|
108
|
+
cwd: options.cwd,
|
|
109
|
+
run: options.run,
|
|
110
|
+
});
|
|
111
|
+
let passed = outcome.passed;
|
|
112
|
+
let reason = outcome.reason;
|
|
113
|
+
const assumed = new Set(inlineList(fields.assumed));
|
|
114
|
+
// F1: work that changed nothing under its claimed paths is not done, whatever the checks say.
|
|
115
|
+
let change = null;
|
|
116
|
+
const paths = inlineList(fields.claimed_paths);
|
|
117
|
+
if (fields.base_commit && paths.length) {
|
|
118
|
+
const changed = await (options.changed ?? ((base, list) => changedSince(oceanRoot(), base, list)))(fields.base_commit, paths);
|
|
119
|
+
change = { base: fields.base_commit, paths, changed };
|
|
120
|
+
if (changed === false) {
|
|
121
|
+
passed = false;
|
|
122
|
+
reason = `no change in ${paths.join(", ")} since base commit ${fields.base_commit.slice(0, 12)}`;
|
|
123
|
+
}
|
|
124
|
+
else if (changed === null)
|
|
125
|
+
assumed.add(listItem(`claimed paths changed since ${fields.base_commit.slice(0, 12)} (git could not tell)`));
|
|
126
|
+
}
|
|
127
|
+
// C3: each acceptance criterion needs a passing check of its own.
|
|
128
|
+
const acceptance = acceptanceIds(source).map((ac) => {
|
|
129
|
+
const checks = outcome.checks.filter((check) => check.ac === ac);
|
|
130
|
+
return { id: ac, ok: checks.length ? checks.every((c) => c.ok) : null };
|
|
131
|
+
});
|
|
132
|
+
const uncovered = acceptance.filter((entry) => entry.ok === null);
|
|
133
|
+
let verified = !passed
|
|
134
|
+
? "no"
|
|
135
|
+
: uncovered.length
|
|
136
|
+
? "partial"
|
|
137
|
+
: "yes";
|
|
138
|
+
if (uncovered.length && passed)
|
|
139
|
+
reason = `${reason}; no check for ${uncovered.map((entry) => entry.id).join(", ")}`;
|
|
140
|
+
// F2 + C3 lane: class high asks for a review; it runs only when the owner opts in per task
|
|
141
|
+
// (`review: agent`), after the deterministic checks, and never when they already failed.
|
|
142
|
+
const taskClass = (fields.class ?? "").toLowerCase();
|
|
143
|
+
const lane = REVIEW_LANE_CLASSES.has(taskClass)
|
|
144
|
+
? "verify+review"
|
|
145
|
+
: "verify";
|
|
146
|
+
const optedIn = (fields.review ?? "").toLowerCase() === "agent";
|
|
147
|
+
const review = { ran: false };
|
|
148
|
+
const records = [];
|
|
149
|
+
if (optedIn && verified !== "no") {
|
|
150
|
+
const reviewer = options.reviewer?.() ?? null;
|
|
151
|
+
const answer = reviewer
|
|
152
|
+
? await reviewer(reviewPrompt(id, source, outcome)).catch(() => null)
|
|
153
|
+
: null;
|
|
154
|
+
const verdict = parseReviewVerdict(answer);
|
|
155
|
+
if (!verdict) {
|
|
156
|
+
review.skipped = reviewer
|
|
157
|
+
? "the review gave no pass or fail line"
|
|
158
|
+
: "no reviewer is available";
|
|
159
|
+
verified = "partial";
|
|
160
|
+
assumed.add(listItem(`independent review did not run: ${review.skipped}`));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
review.ran = true;
|
|
164
|
+
review.passed = verdict.passed;
|
|
165
|
+
review.line = verdict.line;
|
|
166
|
+
records.push({
|
|
167
|
+
criterion: "review",
|
|
168
|
+
result: verdict.passed ? "proven" : "not_proven",
|
|
169
|
+
type: "task_review",
|
|
170
|
+
payload: { line: verdict.line },
|
|
171
|
+
});
|
|
172
|
+
if (!verdict.passed) {
|
|
173
|
+
verified = "no";
|
|
174
|
+
passed = false;
|
|
175
|
+
reason = `review: ${verdict.line}`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (optedIn)
|
|
180
|
+
review.skipped = "deterministic checks failed";
|
|
181
|
+
else if (lane === "verify+review") {
|
|
182
|
+
review.skipped = "review: agent not set";
|
|
183
|
+
assumed.add(listItem(`independent review not run (class ${taskClass}; set review: agent to run it)`));
|
|
184
|
+
}
|
|
185
|
+
outcome.checks.forEach((check, index) => {
|
|
186
|
+
records.push({
|
|
187
|
+
criterion: check.ac ?? `check-${index + 1}`,
|
|
188
|
+
result: check.ok ? "proven" : "not_proven",
|
|
189
|
+
type: "task_verify",
|
|
190
|
+
payload: { command: check.command, exitCode: check.exitCode },
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
for (const entry of uncovered)
|
|
194
|
+
records.push({
|
|
195
|
+
criterion: entry.id,
|
|
196
|
+
result: "limitation",
|
|
197
|
+
type: "task_verify",
|
|
198
|
+
payload: { reason: "no check declared for this acceptance criterion" },
|
|
199
|
+
});
|
|
200
|
+
if (change)
|
|
201
|
+
records.push({
|
|
202
|
+
criterion: "claimed-paths-changed",
|
|
203
|
+
result: change.changed === false
|
|
204
|
+
? "not_proven"
|
|
205
|
+
: change.changed
|
|
206
|
+
? "proven"
|
|
207
|
+
: "limitation",
|
|
208
|
+
type: "task_verify",
|
|
209
|
+
payload: { base: change.base, paths: change.paths },
|
|
210
|
+
});
|
|
211
|
+
if (!outcome.checks.length)
|
|
212
|
+
records.push({
|
|
213
|
+
criterion: "verification",
|
|
214
|
+
result: "not_proven",
|
|
215
|
+
type: "task_verify",
|
|
216
|
+
payload: { reason: outcome.reason },
|
|
217
|
+
});
|
|
218
|
+
const verifiedAt = now.toISOString();
|
|
219
|
+
const evidence = [];
|
|
220
|
+
const sessions = [];
|
|
221
|
+
let recordError;
|
|
222
|
+
const projectId = projectOfTasksRoot(root) ?? null;
|
|
223
|
+
if (options.openStore) {
|
|
224
|
+
let store = null;
|
|
225
|
+
try {
|
|
226
|
+
store = await options.openStore();
|
|
227
|
+
const linked = store
|
|
228
|
+
.listTaskSessions(id, projectId)
|
|
229
|
+
.filter((session) => session.profile !== VERIFY_PROFILE);
|
|
230
|
+
const sessionId = randomUUID();
|
|
231
|
+
store.create({
|
|
232
|
+
sessionId,
|
|
233
|
+
title: `tasks verify ${id}`,
|
|
234
|
+
taskId: id,
|
|
235
|
+
projectId,
|
|
236
|
+
provider: "ocean",
|
|
237
|
+
providerSessionId: null,
|
|
238
|
+
parentSessionId: null,
|
|
239
|
+
profile: VERIFY_PROFILE,
|
|
240
|
+
profileIdentity: "",
|
|
241
|
+
workingDirectory: options.cwd ?? repoRoot(),
|
|
242
|
+
resumeData: null,
|
|
243
|
+
});
|
|
244
|
+
store.updateStatus(sessionId, "running");
|
|
245
|
+
const status = verified === "yes" ? "proven" : "not_proven";
|
|
246
|
+
for (const record of records) {
|
|
247
|
+
const data = JSON.stringify({
|
|
248
|
+
evidenceId: randomUUID(),
|
|
249
|
+
sessionId,
|
|
250
|
+
type: record.type,
|
|
251
|
+
source: "ocean-tasks-verify",
|
|
252
|
+
observedAt: verifiedAt,
|
|
253
|
+
result: record.result,
|
|
254
|
+
criterion: record.criterion,
|
|
255
|
+
taskId: id,
|
|
256
|
+
payload: JSON.stringify(record.payload),
|
|
257
|
+
});
|
|
258
|
+
const event = store.appendEvent(sessionId, "evidence", data);
|
|
259
|
+
evidence.push(listItem(`${record.criterion}:event:${event.eventId}`));
|
|
260
|
+
for (const session of linked)
|
|
261
|
+
store.appendEvent(session.sessionId, "evidence", data);
|
|
262
|
+
}
|
|
263
|
+
store.updateStatus(sessionId, "completed");
|
|
264
|
+
store.setVerificationStatus(sessionId, status);
|
|
265
|
+
for (const session of linked) {
|
|
266
|
+
store.setVerificationStatus(session.sessionId, status);
|
|
267
|
+
sessions.push(session.sessionId);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
recordError = error instanceof Error ? error.message : String(error);
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
store?.close();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Re-read: the checks may have run for minutes, and the task file is the record.
|
|
278
|
+
const current = await readFile(taskFile, "utf8");
|
|
279
|
+
await writeFile(taskFile, setFrontmatterFields(current, {
|
|
280
|
+
verified,
|
|
281
|
+
verified_at: verifiedAt,
|
|
282
|
+
evidence: `[${evidence.join(", ")}]`,
|
|
283
|
+
...(assumed.size ? { assumed: `[${[...assumed].join(", ")}]` } : {}),
|
|
284
|
+
updated: localDate(now),
|
|
285
|
+
}), "utf8");
|
|
286
|
+
return {
|
|
287
|
+
...outcome,
|
|
288
|
+
passed,
|
|
289
|
+
reason,
|
|
290
|
+
verified,
|
|
291
|
+
verifiedAt,
|
|
292
|
+
lane,
|
|
293
|
+
acceptance,
|
|
294
|
+
change,
|
|
295
|
+
review,
|
|
296
|
+
evidence,
|
|
297
|
+
assumed: [...assumed],
|
|
298
|
+
sessions,
|
|
299
|
+
...(recordError ? { recordError } : {}),
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=task-verification.js.map
|
|
@@ -43,23 +43,63 @@ const defaultRunner = async (command, cwd) => {
|
|
|
43
43
|
return { exitCode: code };
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
+
// `AC-3: pnpm test` labels a check with the Definition-of-done item it proves (T-320).
|
|
47
|
+
const AC_LABEL = /^(AC-\d+):\s*/i;
|
|
48
|
+
function labelled(raw) {
|
|
49
|
+
const trimmed = raw.trim();
|
|
50
|
+
const label = trimmed.match(AC_LABEL);
|
|
51
|
+
return label
|
|
52
|
+
? { ac: label[1].toUpperCase(), command: trimmed.slice(label[0].length) }
|
|
53
|
+
: { command: trimmed };
|
|
54
|
+
}
|
|
55
|
+
// The `verify:` field, read from the frontmatter only (a body line never counts). Inline
|
|
56
|
+
// (`verify: a, b`) splits on `,`, `&&` and `;`; a block list (`verify:` then ` - AC-1: a`)
|
|
57
|
+
// keeps each item whole, so one acceptance criterion may chain its own steps.
|
|
58
|
+
function frontmatterVerify(source) {
|
|
59
|
+
if (!source.startsWith("---\n"))
|
|
60
|
+
return null;
|
|
61
|
+
const end = source.indexOf("\n---", 4);
|
|
62
|
+
if (end < 0)
|
|
63
|
+
return null;
|
|
64
|
+
const lines = source.slice(4, end).split("\n");
|
|
65
|
+
const at = lines.findIndex((line) => /^verify:/.test(line));
|
|
66
|
+
if (at < 0)
|
|
67
|
+
return null;
|
|
68
|
+
const inline = lines[at]
|
|
69
|
+
.slice("verify:".length)
|
|
70
|
+
.trim()
|
|
71
|
+
.replace(/^['"]|['"]$/g, "");
|
|
72
|
+
if (inline && inline !== "[]") {
|
|
73
|
+
const list = inline.match(/^\[(.*)\]$/)?.[1] ?? inline;
|
|
74
|
+
return list
|
|
75
|
+
.split(/\s*(?:,|&&|;)\s*/)
|
|
76
|
+
.map((part) => part.trim())
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.map(labelled)
|
|
79
|
+
.filter((entry) => entry.command);
|
|
80
|
+
}
|
|
81
|
+
const items = [];
|
|
82
|
+
for (const line of lines.slice(at + 1)) {
|
|
83
|
+
const item = line.match(/^\s+-\s+(.+)$/);
|
|
84
|
+
if (!item)
|
|
85
|
+
break;
|
|
86
|
+
const entry = labelled(item[1]);
|
|
87
|
+
if (entry.command)
|
|
88
|
+
items.push(entry);
|
|
89
|
+
}
|
|
90
|
+
return items.length ? items : null;
|
|
91
|
+
}
|
|
46
92
|
/**
|
|
47
93
|
* Pull runnable commands out of a task's verification declaration. A `verify:`
|
|
48
|
-
* frontmatter field
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
94
|
+
* frontmatter field wins; otherwise each non-empty line inside a fenced code block of
|
|
95
|
+
* the `## Verification` section. Inline-backtick spans are prose, never commands: on
|
|
96
|
+
* T-308 a prose span naming `npm publish` was run (T-317). Any command may carry an
|
|
97
|
+
* `AC-n:` label naming the acceptance criterion it proves.
|
|
52
98
|
*/
|
|
53
|
-
function
|
|
54
|
-
const frontmatter = source
|
|
55
|
-
.match(/^verify:\s*(.+)$/m)?.[1]
|
|
56
|
-
?.trim()
|
|
57
|
-
.replace(/^['"]|['"]$/g, "");
|
|
99
|
+
export function declaredCommands(source) {
|
|
100
|
+
const frontmatter = frontmatterVerify(source);
|
|
58
101
|
if (frontmatter)
|
|
59
|
-
return frontmatter
|
|
60
|
-
.split(/\s*(?:,|&&|;)\s*/)
|
|
61
|
-
.map((part) => part.trim())
|
|
62
|
-
.filter(Boolean);
|
|
102
|
+
return frontmatter;
|
|
63
103
|
const section = source
|
|
64
104
|
.match(/\n## Verification\n\n([\s\S]*?)(?=\n## |$)/)?.[1]
|
|
65
105
|
?.trim();
|
|
@@ -70,10 +110,11 @@ function candidateCommands(source) {
|
|
|
70
110
|
for (const line of match[1].split("\n")) {
|
|
71
111
|
const trimmed = line.trim();
|
|
72
112
|
if (trimmed && !trimmed.startsWith("#"))
|
|
73
|
-
fenced.push(trimmed);
|
|
113
|
+
fenced.push(labelled(trimmed));
|
|
74
114
|
}
|
|
75
|
-
return fenced;
|
|
115
|
+
return fenced.filter((entry) => entry.command);
|
|
76
116
|
}
|
|
117
|
+
const candidateCommands = (source) => declaredCommands(source).map((entry) => entry.command);
|
|
77
118
|
export function extractVerificationCommands(source) {
|
|
78
119
|
return candidateCommands(source).filter((command) => isAllowedCommand(command));
|
|
79
120
|
}
|
|
@@ -152,8 +193,10 @@ function isAllowedCommand(command, origin = "task") {
|
|
|
152
193
|
export async function verifyTask(id, root = workspaceTasksRoot(), options = {}) {
|
|
153
194
|
const taskFile = resolveWithin(root, id, "task.md");
|
|
154
195
|
const source = await readFile(taskFile, "utf8");
|
|
155
|
-
const
|
|
156
|
-
const
|
|
196
|
+
const declared = declaredCommands(source);
|
|
197
|
+
const candidates = declared.map((entry) => entry.command);
|
|
198
|
+
const taskEntries = declared.filter((entry) => isAllowedCommand(entry.command));
|
|
199
|
+
const taskCommands = taskEntries.map((entry) => entry.command);
|
|
157
200
|
const fail = (reason, from) => ({
|
|
158
201
|
id,
|
|
159
202
|
passed: false,
|
|
@@ -165,7 +208,7 @@ export async function verifyTask(id, root = workspaceTasksRoot(), options = {})
|
|
|
165
208
|
// Commands were declared but none may run: that is a failure, never a reason to fall back.
|
|
166
209
|
if (candidates.length > 0 && taskCommands.length === 0)
|
|
167
210
|
return fail(`declared verification commands are not allowed: ${candidates.join(", ")}`, "task");
|
|
168
|
-
let commands =
|
|
211
|
+
let commands = taskEntries;
|
|
169
212
|
let cwd = options.cwd ?? repoRoot();
|
|
170
213
|
let from = "task";
|
|
171
214
|
const project = projectOfTasksRoot(root);
|
|
@@ -209,13 +252,18 @@ export async function verifyTask(id, root = workspaceTasksRoot(), options = {})
|
|
|
209
252
|
return fail(`project verify needs the project's first path to be an absolute, existing directory: ${manifest.paths[0] ? expandHome(manifest.paths[0]) : "(none)"}`, from);
|
|
210
253
|
cwd = dir;
|
|
211
254
|
}
|
|
212
|
-
commands = verify;
|
|
255
|
+
commands = verify.map((command) => ({ command }));
|
|
213
256
|
}
|
|
214
257
|
const run = options.run ?? defaultRunner;
|
|
215
258
|
const checks = [];
|
|
216
|
-
for (const command of commands) {
|
|
259
|
+
for (const { command, ac } of commands) {
|
|
217
260
|
const { exitCode } = await run(command, cwd);
|
|
218
|
-
checks.push({
|
|
261
|
+
checks.push({
|
|
262
|
+
command,
|
|
263
|
+
exitCode,
|
|
264
|
+
ok: exitCode === 0,
|
|
265
|
+
...(ac ? { ac } : {}),
|
|
266
|
+
});
|
|
219
267
|
}
|
|
220
268
|
const passed = checks.every((check) => check.ok);
|
|
221
269
|
return {
|
package/ocean-marketplace.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
{
|
|
6
6
|
"kind": "skill",
|
|
7
7
|
"name": "dev.ocean.skills.business-logic",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.8.0",
|
|
9
9
|
"engines": {
|
|
10
|
-
"ocean": ">=2.
|
|
10
|
+
"ocean": ">=2.8.0"
|
|
11
11
|
},
|
|
12
12
|
"source": {
|
|
13
13
|
"type": "path",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
{
|
|
24
24
|
"kind": "skill",
|
|
25
25
|
"name": "dev.ocean.skills.catch-up",
|
|
26
|
-
"version": "2.
|
|
26
|
+
"version": "2.8.0",
|
|
27
27
|
"engines": {
|
|
28
|
-
"ocean": ">=2.
|
|
28
|
+
"ocean": ">=2.8.0"
|
|
29
29
|
},
|
|
30
30
|
"source": {
|
|
31
31
|
"type": "path",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
{
|
|
42
42
|
"kind": "skill",
|
|
43
43
|
"name": "dev.ocean.skills.core-thinking",
|
|
44
|
-
"version": "2.
|
|
44
|
+
"version": "2.8.0",
|
|
45
45
|
"engines": {
|
|
46
|
-
"ocean": ">=2.
|
|
46
|
+
"ocean": ">=2.8.0"
|
|
47
47
|
},
|
|
48
48
|
"source": {
|
|
49
49
|
"type": "path",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
{
|
|
60
60
|
"kind": "skill",
|
|
61
61
|
"name": "dev.ocean.skills.daily-harvest",
|
|
62
|
-
"version": "2.
|
|
62
|
+
"version": "2.8.0",
|
|
63
63
|
"engines": {
|
|
64
|
-
"ocean": ">=2.
|
|
64
|
+
"ocean": ">=2.8.0"
|
|
65
65
|
},
|
|
66
66
|
"source": {
|
|
67
67
|
"type": "path",
|
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
{
|
|
78
78
|
"kind": "skill",
|
|
79
79
|
"name": "dev.ocean.skills.design-thinking",
|
|
80
|
-
"version": "2.
|
|
80
|
+
"version": "2.8.0",
|
|
81
81
|
"engines": {
|
|
82
|
-
"ocean": ">=2.
|
|
82
|
+
"ocean": ">=2.8.0"
|
|
83
83
|
},
|
|
84
84
|
"source": {
|
|
85
85
|
"type": "path",
|
|
@@ -95,9 +95,9 @@
|
|
|
95
95
|
{
|
|
96
96
|
"kind": "skill",
|
|
97
97
|
"name": "dev.ocean.skills.graft",
|
|
98
|
-
"version": "2.
|
|
98
|
+
"version": "2.8.0",
|
|
99
99
|
"engines": {
|
|
100
|
-
"ocean": ">=2.
|
|
100
|
+
"ocean": ">=2.8.0"
|
|
101
101
|
},
|
|
102
102
|
"source": {
|
|
103
103
|
"type": "path",
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
{
|
|
114
114
|
"kind": "skill",
|
|
115
115
|
"name": "dev.ocean.skills.loop",
|
|
116
|
-
"version": "2.
|
|
116
|
+
"version": "2.8.0",
|
|
117
117
|
"engines": {
|
|
118
|
-
"ocean": ">=2.
|
|
118
|
+
"ocean": ">=2.8.0"
|
|
119
119
|
},
|
|
120
120
|
"source": {
|
|
121
121
|
"type": "path",
|
|
@@ -131,9 +131,9 @@
|
|
|
131
131
|
{
|
|
132
132
|
"kind": "skill",
|
|
133
133
|
"name": "dev.ocean.skills.memory-review",
|
|
134
|
-
"version": "2.
|
|
134
|
+
"version": "2.8.0",
|
|
135
135
|
"engines": {
|
|
136
|
-
"ocean": ">=2.
|
|
136
|
+
"ocean": ">=2.8.0"
|
|
137
137
|
},
|
|
138
138
|
"source": {
|
|
139
139
|
"type": "path",
|
|
@@ -149,9 +149,9 @@
|
|
|
149
149
|
{
|
|
150
150
|
"kind": "skill",
|
|
151
151
|
"name": "dev.ocean.skills.session-handoff",
|
|
152
|
-
"version": "2.
|
|
152
|
+
"version": "2.8.0",
|
|
153
153
|
"engines": {
|
|
154
|
-
"ocean": ">=2.
|
|
154
|
+
"ocean": ">=2.8.0"
|
|
155
155
|
},
|
|
156
156
|
"source": {
|
|
157
157
|
"type": "path",
|
|
@@ -167,9 +167,9 @@
|
|
|
167
167
|
{
|
|
168
168
|
"kind": "skill",
|
|
169
169
|
"name": "dev.ocean.skills.use-browser",
|
|
170
|
-
"version": "2.
|
|
170
|
+
"version": "2.8.0",
|
|
171
171
|
"engines": {
|
|
172
|
-
"ocean": ">=2.
|
|
172
|
+
"ocean": ">=2.8.0"
|
|
173
173
|
},
|
|
174
174
|
"source": {
|
|
175
175
|
"type": "path",
|
|
@@ -185,9 +185,9 @@
|
|
|
185
185
|
{
|
|
186
186
|
"kind": "skill",
|
|
187
187
|
"name": "dev.ocean.skills.verification",
|
|
188
|
-
"version": "2.
|
|
188
|
+
"version": "2.8.0",
|
|
189
189
|
"engines": {
|
|
190
|
-
"ocean": ">=2.
|
|
190
|
+
"ocean": ">=2.8.0"
|
|
191
191
|
},
|
|
192
192
|
"source": {
|
|
193
193
|
"type": "path",
|
|
@@ -203,9 +203,9 @@
|
|
|
203
203
|
{
|
|
204
204
|
"kind": "skill",
|
|
205
205
|
"name": "dev.ocean.skills.weekly-review",
|
|
206
|
-
"version": "2.
|
|
206
|
+
"version": "2.8.0",
|
|
207
207
|
"engines": {
|
|
208
|
-
"ocean": ">=2.
|
|
208
|
+
"ocean": ">=2.8.0"
|
|
209
209
|
},
|
|
210
210
|
"source": {
|
|
211
211
|
"type": "path",
|
|
@@ -247,9 +247,9 @@
|
|
|
247
247
|
"npx"
|
|
248
248
|
]
|
|
249
249
|
},
|
|
250
|
-
"version": "2.
|
|
250
|
+
"version": "2.8.0",
|
|
251
251
|
"engines": {
|
|
252
|
-
"ocean": ">=2.
|
|
252
|
+
"ocean": ">=2.8.0"
|
|
253
253
|
},
|
|
254
254
|
"source": {
|
|
255
255
|
"type": "path",
|
|
@@ -299,9 +299,9 @@
|
|
|
299
299
|
"kind": "mcp",
|
|
300
300
|
"name": "dev.ocean/mcp-gateway",
|
|
301
301
|
"description": "One MCP endpoint for every registered server: Ocean's own and those installed from the marketplace.",
|
|
302
|
-
"version": "2.
|
|
302
|
+
"version": "2.8.0",
|
|
303
303
|
"engines": {
|
|
304
|
-
"ocean": ">=2.
|
|
304
|
+
"ocean": ">=2.8.0"
|
|
305
305
|
},
|
|
306
306
|
"source": {
|
|
307
307
|
"type": "path",
|
|
@@ -343,9 +343,9 @@
|
|
|
343
343
|
"kind": "mcp",
|
|
344
344
|
"name": "dev.ocean/obsidian",
|
|
345
345
|
"description": "Ocean's Obsidian vault bridge over MCP.",
|
|
346
|
-
"version": "2.
|
|
346
|
+
"version": "2.8.0",
|
|
347
347
|
"engines": {
|
|
348
|
-
"ocean": ">=2.
|
|
348
|
+
"ocean": ">=2.8.0"
|
|
349
349
|
},
|
|
350
350
|
"source": {
|
|
351
351
|
"type": "path",
|
|
@@ -387,9 +387,9 @@
|
|
|
387
387
|
"kind": "mcp",
|
|
388
388
|
"name": "dev.ocean/ocean",
|
|
389
389
|
"description": "Ocean's own MCP server: workspace status, tasks, handoffs, sessions and the brain.",
|
|
390
|
-
"version": "2.
|
|
390
|
+
"version": "2.8.0",
|
|
391
391
|
"engines": {
|
|
392
|
-
"ocean": ">=2.
|
|
392
|
+
"ocean": ">=2.8.0"
|
|
393
393
|
},
|
|
394
394
|
"source": {
|
|
395
395
|
"type": "path",
|
|
@@ -441,9 +441,9 @@
|
|
|
441
441
|
"npx"
|
|
442
442
|
]
|
|
443
443
|
},
|
|
444
|
-
"version": "2.
|
|
444
|
+
"version": "2.8.0",
|
|
445
445
|
"engines": {
|
|
446
|
-
"ocean": ">=2.
|
|
446
|
+
"ocean": ">=2.8.0"
|
|
447
447
|
},
|
|
448
448
|
"source": {
|
|
449
449
|
"type": "path",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amoree-code/ocean",
|
|
3
3
|
"description": "Local-first memory, tasks and session capture shared by every AI coding client: one private workspace for Claude, Codex, Gemini and more.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.8.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "AMEER ABDULKAREEM JABBAR LAMI",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"@langchain/core": "1.2.14",
|
|
54
54
|
"@langchain/langgraph": "1.4.19",
|
|
55
55
|
"@modelcontextprotocol/sdk": "1.32.0",
|
|
56
|
-
"@ocean/brain": "2.
|
|
57
|
-
"@ocean/context": "2.
|
|
58
|
-
"@ocean/core": "2.
|
|
59
|
-
"@ocean/loop": "2.
|
|
60
|
-
"@ocean/market": "2.
|
|
61
|
-
"@ocean/services": "2.
|
|
56
|
+
"@ocean/brain": "2.8.0",
|
|
57
|
+
"@ocean/context": "2.8.0",
|
|
58
|
+
"@ocean/core": "2.8.0",
|
|
59
|
+
"@ocean/loop": "2.8.0",
|
|
60
|
+
"@ocean/market": "2.8.0",
|
|
61
|
+
"@ocean/services": "2.8.0",
|
|
62
62
|
"playwright-core": "^1.48.0",
|
|
63
63
|
"sqlite-vec": "0.1.9",
|
|
64
64
|
"zod": "^4.6.5"
|
|
@@ -75,6 +75,48 @@ session is working on the task right now (T-270). `claimed_at` is an ISO-8601 UT
|
|
|
75
75
|
removed by `ocean tasks release` — it is not part of the task's lasting description. Rules
|
|
76
76
|
and commands: `ocean policy task`, "Claims".
|
|
77
77
|
|
|
78
|
+
### Verification fields (T-320)
|
|
79
|
+
|
|
80
|
+
```yaml
|
|
81
|
+
verify: # the checks · inline `verify: pnpm test, ocean tasks doctor`, or a block list:
|
|
82
|
+
- AC-1: pnpm build && pnpm test # `AC-n:` names the Definition-of-done item it proves
|
|
83
|
+
- AC-2: ocean tasks doctor
|
|
84
|
+
review: agent # optional · agent | none — owner opt-in to the model review
|
|
85
|
+
verified: yes # written by `ocean tasks verify` · yes | no | partial | unknown
|
|
86
|
+
verified_at: 2026-11-21T09:00:00.000Z # written · ISO-8601 UTC
|
|
87
|
+
evidence: [AC-1:event:812, AC-2:event:813] # written · one event id per check
|
|
88
|
+
assumed: [independent review not run] # what was not checked; verify appends, never removes
|
|
89
|
+
base_commit: 3f2a… # written by the first `ocean tasks claim`, never changed after
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`verify:` is read from the frontmatter only (never a body line); without it, the fenced block
|
|
93
|
+
in `## Verification`, where a line may also start with `AC-n:`. Only allowlisted commands run
|
|
94
|
+
— a check never publishes, signs in or installs globally.
|
|
95
|
+
|
|
96
|
+
`ocean tasks verify <ID>` runs the checks with no model involved, then decides:
|
|
97
|
+
|
|
98
|
+
| `verified` | when |
|
|
99
|
+
| ---------- | ------------------------------------------------------------------------------------------ |
|
|
100
|
+
| `yes` | every check passed, and every `AC-n` in the Definition of done has a passing check |
|
|
101
|
+
| `partial` | every check passed, but an `AC-n` has no check of its own, or an opted-in review could not run |
|
|
102
|
+
| `no` | a check failed, nothing runnable was declared, the claimed paths never changed, or the review failed |
|
|
103
|
+
| `unknown` | never verified |
|
|
104
|
+
|
|
105
|
+
Each check becomes a `task_verify` evidence event in a `tasks-verify` session linked to the
|
|
106
|
+
task; the same events are copied to every session already linked to it, whose
|
|
107
|
+
`verification_status` becomes `proven` (yes) or `not_proven`. Lesson learning counts only
|
|
108
|
+
`task_verify` and `test` evidence — a provider exiting 0 proves nothing.
|
|
109
|
+
|
|
110
|
+
**Base commit.** While the task is claimed with `claimed_paths`, verify fails when nothing
|
|
111
|
+
under those paths changed since `base_commit` (committed, staged, unstaged or untracked).
|
|
112
|
+
|
|
113
|
+
**Lanes.** `class: low | medium` (or `small`) is verify only. `class: high | large` asks for
|
|
114
|
+
verify + review, but the review runs only when the task sets `review: agent` (the owner opts in
|
|
115
|
+
per task — no subagent runs on its own); without it the verdict stands and `assumed:` records
|
|
116
|
+
that no review ran. The review runs after the deterministic checks and never when they failed:
|
|
117
|
+
the cheapest model, read-only, checking only that every claimed item points to evidence, ending
|
|
118
|
+
with one line, `pass` or `fail — <reason>`.
|
|
119
|
+
|
|
78
120
|
`artifacts` lists what actually exists beside `task.md`, and nothing more. It is a
|
|
79
121
|
manifest, not a plan: a name appears here the moment the file is written and never
|
|
80
122
|
before. An empty list is the normal, healthy value.
|
|
@@ -179,7 +221,8 @@ checklist to satisfy.
|
|
|
179
221
|
|
|
180
222
|
When a task reaches `done`:
|
|
181
223
|
|
|
182
|
-
1.
|
|
224
|
+
1. `ocean tasks verify <ID>` has run, and the task carries `verified: yes` (or `partial`)
|
|
225
|
+
with its `evidence` ids — `ocean tasks doctor` fails a `done` task without them.
|
|
183
226
|
2. Each artifact is resolved once — promoted to `05-knowledge/<kind>/` if reusable,
|
|
184
227
|
left with the task if not. Nothing is copied to both places.
|
|
185
228
|
3. `state: done`, `updated:` bumped, the index line updated.
|
|
@@ -111,7 +111,11 @@ Most tasks produce `task.md` and nothing else. That is the correct outcome, not
|
|
|
111
111
|
|
|
112
112
|
## On completion — automatic, not on request
|
|
113
113
|
|
|
114
|
-
1. **Final verification** —
|
|
114
|
+
1. **Final verification** — `ocean tasks verify <ID>` runs the task's `verify:` commands with
|
|
115
|
+
no model, and writes `verified`, `verified_at` and `evidence` (event ids) into the task
|
|
116
|
+
and `verification_status` onto its sessions; report its real output. `tasks complete`
|
|
117
|
+
runs the same thing. A model's "done" is never evidence. A `done` task with no recorded
|
|
118
|
+
evidence fails `ocean tasks doctor`. Fields and lanes: the task contract, §2.
|
|
115
119
|
2. **Lifecycle reading** — `ocean lifecycle --task <ID> --complete --verification passed|failed`.
|
|
116
120
|
This is the boundary hook: a task finishing is exactly the `TASK_COMPLETED` trigger, and
|
|
117
121
|
this is the one place it fires, deterministically, on every completion. Act on the
|