@amoree-code/ocean 2.10.0 → 2.11.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/README.md +3 -2
- package/dist/interfaces/cli/command-registry.js +7 -1
- package/dist/interfaces/cli/failures-command.js +71 -0
- package/dist/interfaces/cli/help-command.js +6 -2
- package/dist/interfaces/cli/scorecard-command.js +15 -1
- package/dist/interfaces/cli/telemetry-command.js +23 -3
- package/node_modules/@ocean/brain/dist/memory/lesson-learning.js +3 -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/runs/run-agent.js +3 -1
- package/node_modules/@ocean/loop/package.json +1 -1
- package/node_modules/@ocean/market/package.json +1 -1
- package/node_modules/@ocean/services/dist/journey/failures.js +252 -0
- package/node_modules/@ocean/services/dist/journey/lesson-effect.js +79 -0
- package/node_modules/@ocean/services/dist/journey/telemetry.js +63 -19
- package/node_modules/@ocean/services/dist/scorecard/scorecard.js +30 -7
- package/node_modules/@ocean/services/package.json +1 -1
- package/ocean-marketplace.json +34 -34
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -168,8 +168,9 @@ prints its usage and never runs it. To hand `--help` to a wrapped client, put it
|
|
|
168
168
|
| `ocean rhythm` | the day's rhythm, once per period and with no model: morning note, harvest, archive, last week's digest, last month's review, then the nightly upkeep (the service runs it) | Writes |
|
|
169
169
|
| `ocean upkeep` | the nightly jobs with no model — doctor, telemetry, reindex, search eval, drift, curator, scorecard, and memory hygiene once a month — then the morning digest in `01-daily/digest/` | Writes with `--yes` |
|
|
170
170
|
| `ocean curator` | marks lessons and skills stale after 30 days unused (or 90 unreviewed) and archives them after 90; `review` undoes a mark | Writes with `--yes` |
|
|
171
|
-
| `ocean telemetry` | recurring session errors and failing providers, as proposed backlog lines | Writes |
|
|
172
|
-
| `ocean
|
|
171
|
+
| `ocean telemetry` | recurring session errors (each named by a signature) and failing providers, as proposed backlog lines; also proposes a guardrail climb for an absorbed failure that came back and retiring a lesson that does no better than without it | Writes |
|
|
172
|
+
| `ocean failures` | failure records by signature in `05-knowledge/failures/`: status `open → fix-landing → absorbed → superseded-by`, guardrail ladder `lesson → doctor → test`, recurrence counted from sessions | Reads; `open`, `status`, `climb` write |
|
|
173
|
+
| `ocean scorecard` | Ocean's health numbers from real data: clients working, sessions verified and linked to tasks, attributed memory writes, search mode, schedules, lessons applied, failures at zero | Reads; `--write` saves `01-daily/scorecard/` |
|
|
173
174
|
| `ocean express` | draft a CV section, LinkedIn post or scholarship paragraph from milestones | Writes |
|
|
174
175
|
| `ocean handoff` | hand work from one session or client to another | Reads; `create` writes |
|
|
175
176
|
| `ocean daily` | the morning half of today's note: focus, coming up, open loops, your hours, what waits on you, the brief | Reads; `--apply` writes |
|
|
@@ -63,6 +63,7 @@ import { runDailyCommand } from "./daily-command.js";
|
|
|
63
63
|
import { runDesktopCommand } from "./desktop-command.js";
|
|
64
64
|
import { runDistillCommand } from "./distill-command.js";
|
|
65
65
|
import { runExpressCommand } from "./express-command.js";
|
|
66
|
+
import { runFailuresCommand } from "./failures-command.js";
|
|
66
67
|
import { gatewayFindings } from "./gateway-findings.js";
|
|
67
68
|
import { runLifecycleCommand, runPolicyCommand } from "./governance-command.js";
|
|
68
69
|
import { runHandoffCommand } from "./handoff-command.js";
|
|
@@ -980,7 +981,11 @@ async function commandSkill() {
|
|
|
980
981
|
else {
|
|
981
982
|
const store = await defaultSessionStoreFactory();
|
|
982
983
|
try {
|
|
983
|
-
|
|
984
|
+
const learning = await learnFromSession(store, sessionId);
|
|
985
|
+
console.log(JSON.stringify(learning, null, 2));
|
|
986
|
+
// Lessons come only from verified sessions (T-323); say so instead of silently learning nothing.
|
|
987
|
+
if (!learning.score.verified)
|
|
988
|
+
console.error(`Session ${sessionId} is not verified: no lessons were learned from it.`);
|
|
984
989
|
}
|
|
985
990
|
finally {
|
|
986
991
|
store.close();
|
|
@@ -1324,6 +1329,7 @@ export const commandRegistry = {
|
|
|
1324
1329
|
harvest: () => runHarvestCommand(process.argv.slice(3)),
|
|
1325
1330
|
rhythm: () => runRhythmCommand(process.argv.slice(3)),
|
|
1326
1331
|
telemetry: () => runTelemetryCommand(process.argv.slice(3)),
|
|
1332
|
+
failures: () => runFailuresCommand(process.argv.slice(3)),
|
|
1327
1333
|
scorecard: () => runScorecardCommand(process.argv.slice(3)),
|
|
1328
1334
|
upkeep: () => runUpkeepCommand(process.argv.slice(3)),
|
|
1329
1335
|
curator: () => runCuratorCommand(process.argv.slice(3)),
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { openSessionStoreReadOnly } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
2
|
+
import { ABSORB_MECHANISMS, climbFailure, failureRecurrence, listFailures, openFailure, RECURRENCE_WINDOW_DAYS, setFailureStatus, } from "@ocean/services/journey/failures.js";
|
|
3
|
+
import { signatureStats } from "@ocean/services/journey/telemetry.js";
|
|
4
|
+
const USAGE = [
|
|
5
|
+
"Usage: ocean failures [list] [--json]",
|
|
6
|
+
" ocean failures open <id> <signature> --title <text> --mechanism <why it happens> [--lesson <id>] [--rung lesson|doctor|test] [--fix <text>] [--guardrail <text>]",
|
|
7
|
+
` ocean failures status <id> fix-landing|open|absorbed --by ${ABSORB_MECHANISMS.join("|")}|superseded-by <id>`,
|
|
8
|
+
" ocean failures climb <id>",
|
|
9
|
+
].join("\n");
|
|
10
|
+
function option(args, name) {
|
|
11
|
+
const at = args.indexOf(name);
|
|
12
|
+
return at >= 0 ? args[at + 1] : undefined;
|
|
13
|
+
}
|
|
14
|
+
// `ocean failures` (T-323): failure records in 05-knowledge/failures/, each tracked by its
|
|
15
|
+
// telemetry signature. Every change goes through code, one field at a time; `climb` is the
|
|
16
|
+
// owner's approval of a guardrail climb that telemetry proposed.
|
|
17
|
+
export async function runFailuresCommand(args) {
|
|
18
|
+
const [action = "list", id, ...rest] = args;
|
|
19
|
+
if (action === "list" || action === "--json") {
|
|
20
|
+
const store = await openSessionStoreReadOnly();
|
|
21
|
+
let recurrence;
|
|
22
|
+
try {
|
|
23
|
+
recurrence = failureRecurrence(await listFailures(), signatureStats(store.list(), (session) => store.listEvents(session), ""));
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
store.close();
|
|
27
|
+
}
|
|
28
|
+
if (args.includes("--json")) {
|
|
29
|
+
console.log(JSON.stringify(recurrence, null, 2));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (!recurrence.length)
|
|
33
|
+
console.log("No failure records with a signature.");
|
|
34
|
+
for (const entry of recurrence)
|
|
35
|
+
console.log(`${entry.id} ${entry.status} rung ${entry.rung} ${entry.recent} sessions in ${RECURRENCE_WINDOW_DAYS} d${entry.cleanDays === null ? "" : ` clean ${entry.cleanDays} d`} ${entry.signature}`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!id)
|
|
39
|
+
throw new Error(USAGE);
|
|
40
|
+
if (action === "open") {
|
|
41
|
+
const [signature] = rest;
|
|
42
|
+
const title = option(rest, "--title");
|
|
43
|
+
const mechanism = option(rest, "--mechanism");
|
|
44
|
+
if (!signature || !title || !mechanism)
|
|
45
|
+
throw new Error(USAGE);
|
|
46
|
+
console.log(JSON.stringify(await openFailure({
|
|
47
|
+
id,
|
|
48
|
+
title,
|
|
49
|
+
signature,
|
|
50
|
+
mechanism,
|
|
51
|
+
lesson: option(rest, "--lesson"),
|
|
52
|
+
rung: option(rest, "--rung"),
|
|
53
|
+
fix: option(rest, "--fix"),
|
|
54
|
+
guardrail: option(rest, "--guardrail"),
|
|
55
|
+
}), null, 2));
|
|
56
|
+
}
|
|
57
|
+
else if (action === "status") {
|
|
58
|
+
const [next, target] = rest;
|
|
59
|
+
if (!next)
|
|
60
|
+
throw new Error(USAGE);
|
|
61
|
+
const status = next === "superseded-by" && target
|
|
62
|
+
? `superseded-by ${target}`
|
|
63
|
+
: next;
|
|
64
|
+
console.log(JSON.stringify(await setFailureStatus(id, status, { by: option(rest, "--by") }), null, 2));
|
|
65
|
+
}
|
|
66
|
+
else if (action === "climb")
|
|
67
|
+
console.log(JSON.stringify(await climbFailure(id), null, 2));
|
|
68
|
+
else
|
|
69
|
+
throw new Error(USAGE);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=failures-command.js.map
|
|
@@ -13,7 +13,7 @@ const commandGroups = [
|
|
|
13
13
|
],
|
|
14
14
|
[
|
|
15
15
|
"Knowledge",
|
|
16
|
-
"memory, pull, desktop, observe, capture, note, brief, interests, distill, harvest, rhythm, upkeep, curator, telemetry, scorecard, express, handoff, idea, daily, skill, catalog",
|
|
16
|
+
"memory, pull, desktop, observe, capture, note, brief, interests, distill, harvest, rhythm, upkeep, curator, telemetry, failures, scorecard, express, handoff, idea, daily, skill, catalog",
|
|
17
17
|
],
|
|
18
18
|
["Integrations", "obsidian, hook, migrate, layout, env"],
|
|
19
19
|
];
|
|
@@ -185,9 +185,13 @@ export const commandHelp = {
|
|
|
185
185
|
"ocean curator [--yes] | review <lesson:id|skill:name>",
|
|
186
186
|
],
|
|
187
187
|
telemetry: [
|
|
188
|
-
"Find recurring errors and failing providers in recent sessions; propose them as backlog lines.",
|
|
188
|
+
"Find recurring errors (by signature) and failing providers in recent sessions; propose them, guardrail climbs for absorbed failures that came back, and lessons that do not help, as backlog lines.",
|
|
189
189
|
"ocean telemetry [--days N] [--yes]",
|
|
190
190
|
],
|
|
191
|
+
failures: [
|
|
192
|
+
"Failure records by signature: open -> fix-landing -> absorbed -> superseded-by; climb the guardrail ladder lesson -> doctor -> test.",
|
|
193
|
+
"ocean failures [list] [--json] | open <id> <signature> --title <t> --mechanism <why> [--lesson <id>] [--rung <r>] | status <id> <status> [--by <mechanism>] | climb <id>",
|
|
194
|
+
],
|
|
191
195
|
scorecard: [
|
|
192
196
|
"Print Ocean's health numbers from real data; --write saves 01-daily/scorecard/YYYY-MM-DD.md.",
|
|
193
197
|
"ocean scorecard [--json] [--write]",
|
|
@@ -4,6 +4,9 @@ import { readAudit } from "@ocean/brain/memory/memory-audit.js";
|
|
|
4
4
|
import { localDate } from "@ocean/core/shared/local-date.js";
|
|
5
5
|
import { openSessionStoreReadOnly } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
6
6
|
import { readDrift, readHygieneHistory, } from "@ocean/services/hygiene/hygiene.js";
|
|
7
|
+
import { failureRecurrence, listFailures, } from "@ocean/services/journey/failures.js";
|
|
8
|
+
import { appliedLessonIds } from "@ocean/services/journey/lesson-effect.js";
|
|
9
|
+
import { isFailureEvent, signatureStats, } from "@ocean/services/journey/telemetry.js";
|
|
7
10
|
import { readLessonFrontmatter, readSearchEval, readTaskFrontmatter, renderTable, scorecardRows, sessionTokens, writeScorecard, } from "@ocean/services/scorecard/scorecard.js";
|
|
8
11
|
import { clientFindings } from "../../application/clients/clients.js";
|
|
9
12
|
import { CLIENT_ADAPTERS } from "../../application/clients/registry.js";
|
|
@@ -39,18 +42,27 @@ async function collect() {
|
|
|
39
42
|
let sessions;
|
|
40
43
|
const providers = new Map();
|
|
41
44
|
const tokens = { sessions: 0, reporting: 0, total: 0 };
|
|
45
|
+
const applied = new Set();
|
|
46
|
+
let failures;
|
|
42
47
|
try {
|
|
43
48
|
const all = store.list();
|
|
44
49
|
sessions = all;
|
|
45
50
|
tokens.sessions = all.length;
|
|
51
|
+
// Only failure events are kept: the store holds far more than the signatures need.
|
|
52
|
+
const failed = new Map();
|
|
46
53
|
for (const session of all) {
|
|
47
54
|
providers.set(session.sessionId, session.provider);
|
|
48
|
-
const
|
|
55
|
+
const listed = store.listEvents(session.sessionId);
|
|
56
|
+
failed.set(session.sessionId, listed.filter((event) => isFailureEvent(event.type)));
|
|
57
|
+
for (const id of appliedLessonIds(listed))
|
|
58
|
+
applied.add(id);
|
|
59
|
+
const used = sessionTokens(listed);
|
|
49
60
|
if (used === null)
|
|
50
61
|
continue;
|
|
51
62
|
tokens.reporting += 1;
|
|
52
63
|
tokens.total += used;
|
|
53
64
|
}
|
|
65
|
+
failures = failureRecurrence(await listFailures(), signatureStats(all, (id) => failed.get(id) ?? [], ""));
|
|
54
66
|
}
|
|
55
67
|
finally {
|
|
56
68
|
store.close();
|
|
@@ -71,6 +83,8 @@ async function collect() {
|
|
|
71
83
|
searchEval: await readSearchEval(),
|
|
72
84
|
schedules: await listSchedules(),
|
|
73
85
|
lessons: await readLessonFrontmatter(),
|
|
86
|
+
lessonsApplied: [...applied],
|
|
87
|
+
failures,
|
|
74
88
|
tokens,
|
|
75
89
|
hygiene: (await readHygieneHistory()).at(-1) ?? null,
|
|
76
90
|
drift: await readDrift().then((drift) => drift
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { openSessionStore } from "@ocean/loop/infrastructure/persistence/session-store.js";
|
|
2
|
-
import {
|
|
2
|
+
import { failureRecurrence, ladderFindings, listFailures, } from "@ocean/services/journey/failures.js";
|
|
3
|
+
import { lessonEffects, retirementFindings, } from "@ocean/services/journey/lesson-effect.js";
|
|
4
|
+
import { analyzeSessions, proposeTelemetry, signatureStats, } from "@ocean/services/journey/telemetry.js";
|
|
3
5
|
// `ocean telemetry [--days N] [--yes]` (T-314): recurring errors and failing providers in the
|
|
4
6
|
// last N days (30) of sessions, proposed as backlog lines for review; a dry run until --yes.
|
|
7
|
+
// T-323: each error carries its signature; one that already has a failure record is tracked
|
|
8
|
+
// there instead, an absorbed one that came back proposes a guardrail climb, and a lesson that
|
|
9
|
+
// does no better than without it is proposed for retirement.
|
|
5
10
|
export async function runTelemetryCommand(args) {
|
|
6
11
|
const at = args.indexOf("--days");
|
|
7
12
|
const days = at >= 0 ? Number(args[at + 1]) : 30;
|
|
@@ -10,9 +15,24 @@ export async function runTelemetryCommand(args) {
|
|
|
10
15
|
const since = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString();
|
|
11
16
|
const store = await openSessionStore();
|
|
12
17
|
try {
|
|
13
|
-
const
|
|
18
|
+
const sessions = store.list();
|
|
19
|
+
// Three passes read the same sessions; each is read from the store once.
|
|
20
|
+
const cache = new Map();
|
|
21
|
+
const eventsOf = (id) => {
|
|
22
|
+
const events = cache.get(id) ?? store.listEvents(id);
|
|
23
|
+
cache.set(id, events);
|
|
24
|
+
return events;
|
|
25
|
+
};
|
|
26
|
+
const records = await listFailures();
|
|
27
|
+
const tracked = new Set(records.map((record) => record.signature));
|
|
28
|
+
const recurrence = failureRecurrence(records, signatureStats(sessions, eventsOf, ""));
|
|
29
|
+
const findings = [
|
|
30
|
+
...analyzeSessions(sessions, eventsOf, since).filter((finding) => !finding.signature || !tracked.has(finding.signature)),
|
|
31
|
+
...ladderFindings(recurrence),
|
|
32
|
+
...retirementFindings(lessonEffects(sessions, eventsOf, since, records)),
|
|
33
|
+
];
|
|
14
34
|
const result = await proposeTelemetry(findings, args.includes("--yes"));
|
|
15
|
-
console.log(JSON.stringify({ findings, proposed: result }, null, 2));
|
|
35
|
+
console.log(JSON.stringify({ findings, failures: recurrence, proposed: result }, null, 2));
|
|
16
36
|
if (!args.includes("--yes"))
|
|
17
37
|
console.error("Dry run: pass --yes to propose them as backlog lines.");
|
|
18
38
|
}
|
|
@@ -117,7 +117,9 @@ function lessonIdFor(signal) {
|
|
|
117
117
|
}
|
|
118
118
|
function activatedLessonIds(events) {
|
|
119
119
|
const ids = events
|
|
120
|
-
|
|
120
|
+
// `lesson_applied` since T-323; sessions recorded before it carry the old name.
|
|
121
|
+
.filter((event) => event.type === "lesson_applied" ||
|
|
122
|
+
event.type === "skill_auto_activated")
|
|
121
123
|
.map((event) => safeJsonParse(event.data)?.id)
|
|
122
124
|
.filter((id) => typeof id === "string");
|
|
123
125
|
return [...new Set(ids)];
|
|
@@ -100,8 +100,10 @@ export async function runAgent(request, deps) {
|
|
|
100
100
|
: { text: "", partial: false };
|
|
101
101
|
const skillIndex = await deps.loadSkillIndex(profile.skills, request.cwd);
|
|
102
102
|
const autoSkills = await deps.loadActiveLessons(request.prompt, PROMOTED_SKILL_MAX_BYTES);
|
|
103
|
+
// One `lesson_applied` per injected lesson (T-323; `skill_auto_activated` before), so a
|
|
104
|
+
// lesson's sessions can be compared with the ones that ran without it.
|
|
103
105
|
for (const skill of autoSkills) {
|
|
104
|
-
sessionStore.appendEvent(sessionId, "
|
|
106
|
+
sessionStore.appendEvent(sessionId, "lesson_applied", JSON.stringify({
|
|
105
107
|
id: skill.id,
|
|
106
108
|
name: skill.title,
|
|
107
109
|
sourceSessionId: skill.sourceSessionId ?? null,
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { mkdir, readdir, readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { setLessonStatus } from "@ocean/brain/memory/lessons.js";
|
|
4
|
+
import { atomicWrite, parseFrontmatter, withFileLock, } from "@ocean/core/shared/fs-utils.js";
|
|
5
|
+
import { localDate } from "@ocean/core/shared/local-date.js";
|
|
6
|
+
import { KNOWLEDGE_DIR, oceanPath } from "@ocean/core/shared/paths.js";
|
|
7
|
+
// Failure records (T-323): one markdown file per failure signature in 05-knowledge/failures/.
|
|
8
|
+
// A record states the mechanism, not the symptom, and carries a closed status
|
|
9
|
+
// open → fix-landing → absorbed → superseded-by <id>
|
|
10
|
+
// changed only by code, one field per update, with a line appended to its status log; the
|
|
11
|
+
// body above that log is never rewritten. A guardrail ladder (lesson → doctor → test) says
|
|
12
|
+
// how the failure is guarded: when an absorbed signature comes back, telemetry proposes
|
|
13
|
+
// climbing one rung and the owner approves with `ocean failures climb`.
|
|
14
|
+
export const RUNGS = ["lesson", "doctor", "test"];
|
|
15
|
+
// F4: absorb with the cheapest mechanism first, in this order.
|
|
16
|
+
export const ABSORB_MECHANISMS = [
|
|
17
|
+
"doctor",
|
|
18
|
+
"template",
|
|
19
|
+
"code",
|
|
20
|
+
"skill-edit",
|
|
21
|
+
"new-skill",
|
|
22
|
+
];
|
|
23
|
+
export class FailureRecordError extends Error {
|
|
24
|
+
}
|
|
25
|
+
const ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,80}$/;
|
|
26
|
+
const SIGNATURE_PATTERN = /^[a-z]+\/[A-Za-z_]+\/[0-9a-f]{8}$/;
|
|
27
|
+
const NEXT = {
|
|
28
|
+
open: ["fix-landing", "absorbed"],
|
|
29
|
+
"fix-landing": ["absorbed", "open"],
|
|
30
|
+
// Back to open only by climbing the ladder.
|
|
31
|
+
absorbed: [],
|
|
32
|
+
};
|
|
33
|
+
export const failuresDir = () => oceanPath(KNOWLEDGE_DIR, "failures");
|
|
34
|
+
const failureFile = (id) => path.join(failuresDir(), `${id}.md`);
|
|
35
|
+
function parse(source) {
|
|
36
|
+
const fields = parseFrontmatter(source);
|
|
37
|
+
// Records written before T-323 carry no signature; the tooling leaves them alone.
|
|
38
|
+
if (!fields.id || !SIGNATURE_PATTERN.test(fields.signature ?? ""))
|
|
39
|
+
return null;
|
|
40
|
+
const superseded = /^superseded-by\s+(\S+)$/.exec(fields.status ?? "");
|
|
41
|
+
const status = superseded ? "superseded" : fields.status;
|
|
42
|
+
if (!superseded && !(status in NEXT))
|
|
43
|
+
return null;
|
|
44
|
+
const rung = fields.rung;
|
|
45
|
+
if (!RUNGS.includes(rung))
|
|
46
|
+
return null;
|
|
47
|
+
const absorbedBy = (fields.absorbed_by || null);
|
|
48
|
+
if (absorbedBy && !ABSORB_MECHANISMS.includes(absorbedBy))
|
|
49
|
+
return null;
|
|
50
|
+
return {
|
|
51
|
+
id: fields.id,
|
|
52
|
+
title: fields.title ?? fields.id,
|
|
53
|
+
signature: fields.signature,
|
|
54
|
+
status,
|
|
55
|
+
supersededBy: superseded?.[1] ?? null,
|
|
56
|
+
rung,
|
|
57
|
+
mechanism: fields.mechanism ?? "",
|
|
58
|
+
absorbedBy,
|
|
59
|
+
absorbedAt: fields.absorbed_at || null,
|
|
60
|
+
lesson: fields.lesson || null,
|
|
61
|
+
created: fields.created ?? "",
|
|
62
|
+
updated: fields.updated ?? "",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function readFailure(id) {
|
|
66
|
+
if (!ID_PATTERN.test(id))
|
|
67
|
+
throw new FailureRecordError(`Invalid id: ${id}`);
|
|
68
|
+
const source = await readFile(failureFile(id), "utf8").catch(() => null);
|
|
69
|
+
return source === null ? null : parse(source);
|
|
70
|
+
}
|
|
71
|
+
export async function listFailures() {
|
|
72
|
+
const names = await readdir(failuresDir()).catch(() => []);
|
|
73
|
+
const records = [];
|
|
74
|
+
for (const name of names.filter((entry) => entry.endsWith(".md")).sort()) {
|
|
75
|
+
const source = await readFile(path.join(failuresDir(), name), "utf8");
|
|
76
|
+
const record = parse(source);
|
|
77
|
+
if (record)
|
|
78
|
+
records.push(record);
|
|
79
|
+
}
|
|
80
|
+
return records;
|
|
81
|
+
}
|
|
82
|
+
export async function openFailure(input, now = new Date()) {
|
|
83
|
+
const rung = input.rung ?? RUNGS[0];
|
|
84
|
+
if (!RUNGS.includes(rung))
|
|
85
|
+
throw new FailureRecordError(`Rung is one of ${RUNGS.join(" → ")}`);
|
|
86
|
+
if (!ID_PATTERN.test(input.id))
|
|
87
|
+
throw new FailureRecordError(`Invalid id: ${input.id}`);
|
|
88
|
+
if (!SIGNATURE_PATTERN.test(input.signature))
|
|
89
|
+
throw new FailureRecordError(`Invalid signature: ${input.signature} (expected <command>/<class>/<hash>, from ocean telemetry)`);
|
|
90
|
+
if (!input.mechanism.trim())
|
|
91
|
+
throw new FailureRecordError("A failure record states its mechanism: why it happens, not what was seen");
|
|
92
|
+
const owner = (await listFailures()).find((record) => record.signature === input.signature);
|
|
93
|
+
if (owner)
|
|
94
|
+
throw new FailureRecordError(`Signature ${input.signature} already has a record: ${owner.id}`);
|
|
95
|
+
const file = failureFile(input.id);
|
|
96
|
+
await mkdir(failuresDir(), { recursive: true });
|
|
97
|
+
return withFileLock(file, async () => {
|
|
98
|
+
if (await readFile(file, "utf8").catch(() => null))
|
|
99
|
+
throw new FailureRecordError(`Failure ${input.id} already exists`);
|
|
100
|
+
const head = [
|
|
101
|
+
`id: ${input.id}`,
|
|
102
|
+
"type: failure",
|
|
103
|
+
`title: ${JSON.stringify(input.title)}`,
|
|
104
|
+
`signature: ${input.signature}`,
|
|
105
|
+
"status: open",
|
|
106
|
+
`rung: ${rung}`,
|
|
107
|
+
`mechanism: ${JSON.stringify(input.mechanism.replace(/\s+/g, " ").trim())}`,
|
|
108
|
+
input.lesson ? `lesson: ${input.lesson}` : "",
|
|
109
|
+
`created: ${localDate(now)}`,
|
|
110
|
+
`updated: ${localDate(now)}`,
|
|
111
|
+
].filter(Boolean);
|
|
112
|
+
await atomicWrite(file, [
|
|
113
|
+
`---\n${head.join("\n")}\n---`,
|
|
114
|
+
`# ${input.title}`,
|
|
115
|
+
`## Mechanism\n\n${input.mechanism.trim()}`,
|
|
116
|
+
`## Fix\n\n${input.fix?.trim() || "Pending."}`,
|
|
117
|
+
`## Guardrail\n\n${input.guardrail?.trim() || "Pending."}`,
|
|
118
|
+
// Recurrence is not stored: `ocean failures` counts it from the sessions.
|
|
119
|
+
`## Status log\n\n- ${now.toISOString()} — open (rung ${rung})\n`,
|
|
120
|
+
].join("\n\n"));
|
|
121
|
+
const record = parse(await readFile(file, "utf8"));
|
|
122
|
+
if (!record)
|
|
123
|
+
throw new FailureRecordError(`Could not read back ${file}`);
|
|
124
|
+
return record;
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// One change per update: the given frontmatter fields are replaced in place, `updated` is
|
|
128
|
+
// stamped and one line is appended to the status log. Nothing else in the file moves.
|
|
129
|
+
async function amend(id, change, now) {
|
|
130
|
+
const file = failureFile(id);
|
|
131
|
+
return withFileLock(file, async () => {
|
|
132
|
+
const source = await readFile(file, "utf8").catch(() => null);
|
|
133
|
+
const record = source === null ? null : parse(source);
|
|
134
|
+
if (!source || !record)
|
|
135
|
+
throw new FailureRecordError(`No failure record: ${id}`);
|
|
136
|
+
const { fields, log } = change(record);
|
|
137
|
+
const end = source.indexOf("\n---", 3);
|
|
138
|
+
let head = source.slice(0, end);
|
|
139
|
+
for (const [key, value] of Object.entries({
|
|
140
|
+
...fields,
|
|
141
|
+
updated: localDate(now),
|
|
142
|
+
})) {
|
|
143
|
+
const line = new RegExp(`^${key}:.*$`, "m");
|
|
144
|
+
head = line.test(head)
|
|
145
|
+
? head.replace(line, `${key}: ${value}`)
|
|
146
|
+
: `${head}\n${key}: ${value}`;
|
|
147
|
+
}
|
|
148
|
+
const body = source.slice(end).replace(/\n*$/, "\n");
|
|
149
|
+
await atomicWrite(file, `${head}${body}- ${now.toISOString()} — ${log}\n`);
|
|
150
|
+
const updated = parse(await readFile(file, "utf8"));
|
|
151
|
+
if (!updated)
|
|
152
|
+
throw new FailureRecordError(`Could not read back ${file}`);
|
|
153
|
+
return updated;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
export async function setFailureStatus(id, next, options = {}) {
|
|
157
|
+
const now = options.now ?? new Date();
|
|
158
|
+
const record = await amend(id, (current) => {
|
|
159
|
+
if (current.status === "superseded")
|
|
160
|
+
throw new FailureRecordError(`${id} is superseded by ${current.supersededBy}; it no longer changes`);
|
|
161
|
+
const superseded = /^superseded-by\s+([a-z0-9][a-z0-9-]*)$/.exec(next);
|
|
162
|
+
if (superseded) {
|
|
163
|
+
if (superseded[1] === id)
|
|
164
|
+
throw new FailureRecordError("A record cannot supersede itself");
|
|
165
|
+
return { fields: { status: next }, log: next };
|
|
166
|
+
}
|
|
167
|
+
if (!NEXT[current.status].includes(next))
|
|
168
|
+
throw new FailureRecordError(`${id}: ${current.status} → ${next} is not allowed (${current.status} → ${NEXT[current.status].join(" | ") || "climb"})`);
|
|
169
|
+
if (next !== "absorbed")
|
|
170
|
+
return { fields: { status: next }, log: next };
|
|
171
|
+
const by = options.by;
|
|
172
|
+
if (!by || !ABSORB_MECHANISMS.includes(by))
|
|
173
|
+
throw new FailureRecordError(`Absorbing needs --by <mechanism>, cheapest first: ${ABSORB_MECHANISMS.join(" → ")}`);
|
|
174
|
+
return {
|
|
175
|
+
fields: {
|
|
176
|
+
status: "absorbed",
|
|
177
|
+
absorbed_by: by,
|
|
178
|
+
absorbed_at: now.toISOString(),
|
|
179
|
+
},
|
|
180
|
+
log: `absorbed by ${by}`,
|
|
181
|
+
};
|
|
182
|
+
}, now);
|
|
183
|
+
// An absorbed failure's lesson has done its job and leaves context.
|
|
184
|
+
if (record.status === "absorbed" && record.lesson)
|
|
185
|
+
await setLessonStatus(record.lesson, "retired").catch(() => undefined);
|
|
186
|
+
return record;
|
|
187
|
+
}
|
|
188
|
+
// The owner's approval of a proposed climb: one rung up, and the failure is open again.
|
|
189
|
+
export async function climbFailure(id, now = new Date()) {
|
|
190
|
+
return amend(id, (current) => {
|
|
191
|
+
if (current.status === "superseded")
|
|
192
|
+
throw new FailureRecordError(`${id} is superseded`);
|
|
193
|
+
const at = RUNGS.indexOf(current.rung);
|
|
194
|
+
const next = RUNGS[at + 1];
|
|
195
|
+
if (!next)
|
|
196
|
+
throw new FailureRecordError(`${id} is already on the top rung (${current.rung}); supersede it with a new record instead`);
|
|
197
|
+
return {
|
|
198
|
+
fields: { rung: next, status: "open", absorbed_at: "" },
|
|
199
|
+
log: `climbed ${current.rung} → ${next}; open`,
|
|
200
|
+
};
|
|
201
|
+
}, now);
|
|
202
|
+
}
|
|
203
|
+
// The Definition of done's bar: an absorbed failure clean this many days is driven to zero.
|
|
204
|
+
export const RECURRENCE_WINDOW_DAYS = 14;
|
|
205
|
+
export function failureRecurrence(records,
|
|
206
|
+
// Read over all history, so a recurrence long after absorption still counts.
|
|
207
|
+
stats, now = new Date(), windowDays = RECURRENCE_WINDOW_DAYS) {
|
|
208
|
+
const windowMs = windowDays * 86_400_000;
|
|
209
|
+
return records.map((record) => {
|
|
210
|
+
const seen = stats.get(record.signature);
|
|
211
|
+
const absorbedAt = record.absorbedAt;
|
|
212
|
+
const sinceAbsorbed = absorbedAt
|
|
213
|
+
? new Set((seen?.hits ?? [])
|
|
214
|
+
.filter((hit) => hit.at > absorbedAt)
|
|
215
|
+
.map((hit) => hit.sessionId)).size
|
|
216
|
+
: 0;
|
|
217
|
+
const lastSeen = seen?.lastSeen ?? null;
|
|
218
|
+
const anchor = record.status === "absorbed" && record.absorbedAt
|
|
219
|
+
? [record.absorbedAt, lastSeen ?? ""].sort().at(-1)
|
|
220
|
+
: null;
|
|
221
|
+
return {
|
|
222
|
+
id: record.id,
|
|
223
|
+
signature: record.signature,
|
|
224
|
+
status: record.status,
|
|
225
|
+
rung: record.rung,
|
|
226
|
+
recent: new Set((seen?.hits ?? [])
|
|
227
|
+
.filter((hit) => Date.parse(hit.at) >= now.getTime() - windowMs)
|
|
228
|
+
.map((hit) => hit.sessionId)).size,
|
|
229
|
+
sinceAbsorbed,
|
|
230
|
+
lastSeen,
|
|
231
|
+
cleanDays: anchor
|
|
232
|
+
? Math.floor((now.getTime() - Date.parse(anchor)) / 86_400_000)
|
|
233
|
+
: null,
|
|
234
|
+
};
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// Telemetry's ladder proposals: an absorbed failure whose signature came back.
|
|
238
|
+
export function ladderFindings(recurrence) {
|
|
239
|
+
return recurrence
|
|
240
|
+
.filter((entry) => entry.status === "absorbed" && entry.sinceAbsorbed > 0)
|
|
241
|
+
.map((entry) => {
|
|
242
|
+
const next = RUNGS[RUNGS.indexOf(entry.rung) + 1];
|
|
243
|
+
return {
|
|
244
|
+
line: next
|
|
245
|
+
? `Failure ${entry.id} came back in ${entry.sinceAbsorbed} sessions after it was absorbed: climb its guardrail ${entry.rung} → ${next} with \`ocean failures climb ${entry.id}\``
|
|
246
|
+
: `Failure ${entry.id} came back in ${entry.sinceAbsorbed} sessions after it was absorbed, on the top rung (${entry.rung}): supersede it with a new record`,
|
|
247
|
+
sessions: entry.sinceAbsorbed,
|
|
248
|
+
signature: entry.signature,
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=failures.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { scoreSession } from "@ocean/brain/memory/lesson-learning.js";
|
|
2
|
+
import { safeJsonParse } from "@ocean/core/shared/fs-utils.js";
|
|
3
|
+
import { failureSignature } from "./telemetry.js";
|
|
4
|
+
// Does a lesson help? (T-323, ACE): every injected lesson leaves a `lesson_applied` event, so the
|
|
5
|
+
// sessions that had it can be compared with comparable sessions that did not — on verified rate,
|
|
6
|
+
// and, for a lesson tied to a failure record, on how often that failure's signature appeared.
|
|
7
|
+
// A lesson that does no better on either, with enough sessions on both sides, is proposed for
|
|
8
|
+
// retirement; nothing is retired without the owner.
|
|
9
|
+
// `skill_auto_activated` is the same event under its name before T-323.
|
|
10
|
+
export const LESSON_APPLIED_TYPES = new Set([
|
|
11
|
+
"lesson_applied",
|
|
12
|
+
"skill_auto_activated",
|
|
13
|
+
]);
|
|
14
|
+
// Lessons are only ever injected into runs that assembled context; others are not comparable.
|
|
15
|
+
const COMPARABLE_EVENT = "context_manifest";
|
|
16
|
+
export const MIN_SAMPLE = 5;
|
|
17
|
+
export function appliedLessonIds(events) {
|
|
18
|
+
const ids = events
|
|
19
|
+
.filter((event) => LESSON_APPLIED_TYPES.has(event.type))
|
|
20
|
+
.map((event) => safeJsonParse(event.data)?.id)
|
|
21
|
+
.filter((id) => typeof id === "string");
|
|
22
|
+
return [...new Set(ids)];
|
|
23
|
+
}
|
|
24
|
+
const rate = (n, of) => (of ? n / of : 0);
|
|
25
|
+
export function lessonEffects(sessions, eventsOf, sinceIso, failures = []) {
|
|
26
|
+
const runs = sessions
|
|
27
|
+
.filter((session) => session.createdAt >= sinceIso)
|
|
28
|
+
.map((session) => {
|
|
29
|
+
const events = eventsOf(session.sessionId);
|
|
30
|
+
return { session, events };
|
|
31
|
+
})
|
|
32
|
+
.filter(({ events }) => events.some((e) => e.type === COMPARABLE_EVENT))
|
|
33
|
+
.map(({ session, events }) => ({
|
|
34
|
+
verified: scoreSession(session, events).verified,
|
|
35
|
+
applied: new Set(appliedLessonIds(events)),
|
|
36
|
+
signatures: new Set(events
|
|
37
|
+
.map((event) => failureSignature(event.type, event.data))
|
|
38
|
+
.filter((signature) => signature !== null)),
|
|
39
|
+
}));
|
|
40
|
+
const lessons = new Set(runs.flatMap((run) => [...run.applied]));
|
|
41
|
+
return [...lessons].sort().map((lesson) => {
|
|
42
|
+
const failure = failures.find((record) => record.lesson === lesson) ?? null;
|
|
43
|
+
const sides = { with: blank(), without: blank() };
|
|
44
|
+
for (const run of runs) {
|
|
45
|
+
const side = run.applied.has(lesson) ? sides.with : sides.without;
|
|
46
|
+
side.sessions++;
|
|
47
|
+
if (run.verified)
|
|
48
|
+
side.verified++;
|
|
49
|
+
if (failure && run.signatures.has(failure.signature))
|
|
50
|
+
side.recurred++;
|
|
51
|
+
}
|
|
52
|
+
const enough = sides.with.sessions >= MIN_SAMPLE && sides.without.sessions >= MIN_SAMPLE;
|
|
53
|
+
const betterVerified = rate(sides.with.verified, sides.with.sessions) >
|
|
54
|
+
rate(sides.without.verified, sides.without.sessions);
|
|
55
|
+
const fewerRecurrences = failure !== null &&
|
|
56
|
+
rate(sides.with.recurred, sides.with.sessions) <
|
|
57
|
+
rate(sides.without.recurred, sides.without.sessions);
|
|
58
|
+
return {
|
|
59
|
+
lesson,
|
|
60
|
+
...sides,
|
|
61
|
+
failure: failure?.id ?? null,
|
|
62
|
+
verdict: !enough
|
|
63
|
+
? "too-few"
|
|
64
|
+
: betterVerified || fewerRecurrences
|
|
65
|
+
? "helps"
|
|
66
|
+
: "no-better",
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const blank = () => ({ sessions: 0, verified: 0, recurred: 0 });
|
|
71
|
+
export function retirementFindings(effects) {
|
|
72
|
+
return effects
|
|
73
|
+
.filter((effect) => effect.verdict === "no-better")
|
|
74
|
+
.map((effect) => ({
|
|
75
|
+
line: `Lesson ${effect.lesson} does no better than without it (verified ${effect.with.verified}/${effect.with.sessions} vs ${effect.without.verified}/${effect.without.sessions}${effect.failure ? `; ${effect.failure} recurred ${effect.with.recurred}/${effect.with.sessions} vs ${effect.without.recurred}/${effect.without.sessions}` : ""}): retire it with \`ocean skill review ${effect.lesson} rejected\``,
|
|
76
|
+
sessions: effect.with.sessions,
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=lesson-effect.js.map
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { proposeMemory } from "@ocean/brain/memory/memory-write.js";
|
|
2
3
|
import { MemoryContractError } from "@ocean/core/domain/mcp/memory-contract.js";
|
|
3
4
|
// Session telemetry (T-314): what keeps going wrong in Ocean's own sessions becomes a proposed
|
|
4
5
|
// backlog line for the owner — never a task, never applied without review. Read from the session
|
|
5
6
|
// store: an error seen in at least MIN_REPEATS sessions, and providers whose sessions fail or are
|
|
6
|
-
// left unfinished.
|
|
7
|
+
// left unfinished. T-323 names each error by a signature so a failure record can track it.
|
|
7
8
|
const MIN_REPEATS = 3;
|
|
8
9
|
const STUCK_AFTER_MS = 6 * 60 * 60 * 1000;
|
|
9
|
-
|
|
10
|
+
// The event type says which step failed; the signature names that step.
|
|
11
|
+
const COMMAND_OF = {
|
|
12
|
+
error: "run",
|
|
13
|
+
provider_blocked: "provider",
|
|
14
|
+
closeout_warning: "closeout",
|
|
15
|
+
};
|
|
16
|
+
export const isFailureEvent = (type) => type in COMMAND_OF;
|
|
10
17
|
// The same failure with different ids, paths or numbers counts as one.
|
|
11
18
|
export function errorShape(text) {
|
|
12
19
|
return text
|
|
@@ -17,26 +24,63 @@ export function errorShape(text) {
|
|
|
17
24
|
.trim()
|
|
18
25
|
.slice(0, 120);
|
|
19
26
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
// What kind of error, without the message: a zod issue code, a Node errno, or an Error's name.
|
|
28
|
+
export function errorClass(text) {
|
|
29
|
+
return (/"code"\s*:\s*"([a-z_]+)"/.exec(text)?.[1] ??
|
|
30
|
+
/\b(E[A-Z]{3,})\b/.exec(text)?.[1] ??
|
|
31
|
+
/\b([A-Z][A-Za-z]*Error)\b/.exec(text)?.[1] ??
|
|
32
|
+
"error");
|
|
33
|
+
}
|
|
34
|
+
// `<command>/<error class>/<hash of the shape>`: stable across ids, paths and numbers, short
|
|
35
|
+
// enough to name a failure record by.
|
|
36
|
+
export function failureSignature(eventType, text) {
|
|
37
|
+
const command = COMMAND_OF[eventType];
|
|
38
|
+
const shape = errorShape(text);
|
|
39
|
+
if (!command || !shape)
|
|
40
|
+
return null;
|
|
41
|
+
const hash = createHash("sha256").update(shape).digest("hex").slice(0, 8);
|
|
42
|
+
return `${command}/${errorClass(text)}/${hash}`;
|
|
43
|
+
}
|
|
44
|
+
// Every signature seen since `sinceIso`, with the sessions it appeared in, however rare.
|
|
45
|
+
export function signatureStats(sessions, eventsOf, sinceIso) {
|
|
46
|
+
const stats = new Map();
|
|
47
|
+
for (const session of sessions) {
|
|
48
|
+
if (session.createdAt < sinceIso)
|
|
49
|
+
continue;
|
|
24
50
|
for (const event of eventsOf(session.sessionId)) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const shape = errorShape(event.data);
|
|
28
|
-
if (!shape)
|
|
51
|
+
const signature = failureSignature(event.type, event.data);
|
|
52
|
+
if (!signature)
|
|
29
53
|
continue;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
const at = event.createdAt ?? session.createdAt;
|
|
55
|
+
const entry = stats.get(signature) ?? {
|
|
56
|
+
shape: errorShape(event.data),
|
|
57
|
+
sessions: new Set(),
|
|
58
|
+
hits: [],
|
|
59
|
+
firstSeen: at,
|
|
60
|
+
lastSeen: at,
|
|
61
|
+
};
|
|
62
|
+
entry.sessions.add(session.sessionId);
|
|
63
|
+
entry.hits.push({ sessionId: session.sessionId, at });
|
|
64
|
+
if (at < entry.firstSeen)
|
|
65
|
+
entry.firstSeen = at;
|
|
66
|
+
if (at > entry.lastSeen)
|
|
67
|
+
entry.lastSeen = at;
|
|
68
|
+
stats.set(signature, entry);
|
|
33
69
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
}
|
|
71
|
+
return stats;
|
|
72
|
+
}
|
|
73
|
+
export function analyzeSessions(sessions, eventsOf, sinceIso, now = Date.now()) {
|
|
74
|
+
const recent = sessions.filter((session) => session.createdAt >= sinceIso);
|
|
75
|
+
const findings = [
|
|
76
|
+
...signatureStats(recent, eventsOf, sinceIso),
|
|
77
|
+
]
|
|
78
|
+
.filter(([, stats]) => stats.sessions.size >= MIN_REPEATS)
|
|
79
|
+
.sort((a, b) => b[1].sessions.size - a[1].sessions.size)
|
|
80
|
+
.map(([signature, stats]) => ({
|
|
81
|
+
line: `Recurring error in ${stats.sessions.size} sessions [${signature}]: ${stats.shape}`,
|
|
82
|
+
sessions: stats.sessions.size,
|
|
83
|
+
signature,
|
|
40
84
|
}));
|
|
41
85
|
const byProvider = new Map();
|
|
42
86
|
for (const session of recent) {
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { atomicWrite, parseFrontmatter } from "@ocean/core/shared/fs-utils.js";
|
|
4
4
|
import { DAILY_DIR, KNOWLEDGE_DIR, listProjectDirs, oceanPath, SYSTEM_DIR, } from "@ocean/core/shared/paths.js";
|
|
5
5
|
import { sessionTokens } from "@ocean/loop/runs/session-tokens.js";
|
|
6
|
+
import { RECURRENCE_WINDOW_DAYS, } from "../journey/failures.js";
|
|
6
7
|
// Moved to the loop package (T-322) so run guards can count tokens; re-exported for callers.
|
|
7
8
|
export { sessionTokens };
|
|
8
9
|
const percent = (n, of) => of ? `${Math.round((n / of) * 1000) / 10}%` : "n/a";
|
|
@@ -129,10 +130,10 @@ export function schedulesRow(schedules) {
|
|
|
129
130
|
source: "ocean schedule list",
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
|
-
// "Used"
|
|
133
|
-
export function lessonsRows(lessons) {
|
|
133
|
+
// "Used" counts lessons injected into at least one run (`lesson_applied`, T-323).
|
|
134
|
+
export function lessonsRows(lessons, applied = []) {
|
|
134
135
|
const active = lessons.filter((fields) => fields.status === "active").length;
|
|
135
|
-
const
|
|
136
|
+
const used = new Set(applied);
|
|
136
137
|
return [
|
|
137
138
|
{
|
|
138
139
|
id: "lessons-active",
|
|
@@ -142,9 +143,30 @@ export function lessonsRows(lessons) {
|
|
|
142
143
|
of: lessons.length,
|
|
143
144
|
source: "05-knowledge/lessons status",
|
|
144
145
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
ratio("lessons-used", "Lessons used", lessons.filter((fields) => used.has(fields.id)).length, lessons.length, "lesson_applied events"),
|
|
147
|
+
];
|
|
148
|
+
}
|
|
149
|
+
// Recurrence per failure signature (T-323): one summary row, then one row per failure record.
|
|
150
|
+
export function failuresRows(failures) {
|
|
151
|
+
const zero = failures.filter((entry) => entry.status === "absorbed" &&
|
|
152
|
+
entry.recent === 0 &&
|
|
153
|
+
(entry.cleanDays ?? 0) >= RECURRENCE_WINDOW_DAYS).length;
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
id: "failures-zero",
|
|
157
|
+
label: `Failures at zero ${RECURRENCE_WINDOW_DAYS}+ days`,
|
|
158
|
+
value: `${zero} of ${failures.length}`,
|
|
159
|
+
n: zero,
|
|
160
|
+
of: failures.length,
|
|
161
|
+
source: "05-knowledge/failures + session signatures",
|
|
162
|
+
},
|
|
163
|
+
...failures.map((entry) => ({
|
|
164
|
+
id: `failure:${entry.id}`,
|
|
165
|
+
label: ` ${entry.id}`,
|
|
166
|
+
value: `${entry.status}, rung ${entry.rung}: ${entry.recent} sessions in ${RECURRENCE_WINDOW_DAYS} d${entry.cleanDays === null ? "" : `, clean ${entry.cleanDays} d`}`,
|
|
167
|
+
n: entry.recent,
|
|
168
|
+
source: `signature ${entry.signature}`,
|
|
169
|
+
})),
|
|
148
170
|
];
|
|
149
171
|
}
|
|
150
172
|
export function tokensRow(tokens) {
|
|
@@ -194,7 +216,8 @@ export function scorecardRows(input) {
|
|
|
194
216
|
tasksVerifiedRow(input.tasks),
|
|
195
217
|
...searchRows(input.search, input.searchEval),
|
|
196
218
|
schedulesRow(input.schedules),
|
|
197
|
-
...lessonsRows(input.lessons),
|
|
219
|
+
...lessonsRows(input.lessons, input.lessonsApplied),
|
|
220
|
+
...failuresRows(input.failures),
|
|
198
221
|
tokensRow(input.tokens),
|
|
199
222
|
hygieneRow(input.hygiene),
|
|
200
223
|
driftRow(input.drift),
|
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.11.0",
|
|
9
9
|
"engines": {
|
|
10
|
-
"ocean": ">=2.
|
|
10
|
+
"ocean": ">=2.11.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.11.0",
|
|
27
27
|
"engines": {
|
|
28
|
-
"ocean": ">=2.
|
|
28
|
+
"ocean": ">=2.11.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.11.0",
|
|
45
45
|
"engines": {
|
|
46
|
-
"ocean": ">=2.
|
|
46
|
+
"ocean": ">=2.11.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.11.0",
|
|
63
63
|
"engines": {
|
|
64
|
-
"ocean": ">=2.
|
|
64
|
+
"ocean": ">=2.11.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.11.0",
|
|
81
81
|
"engines": {
|
|
82
|
-
"ocean": ">=2.
|
|
82
|
+
"ocean": ">=2.11.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.11.0",
|
|
99
99
|
"engines": {
|
|
100
|
-
"ocean": ">=2.
|
|
100
|
+
"ocean": ">=2.11.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.11.0",
|
|
117
117
|
"engines": {
|
|
118
|
-
"ocean": ">=2.
|
|
118
|
+
"ocean": ">=2.11.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.11.0",
|
|
135
135
|
"engines": {
|
|
136
|
-
"ocean": ">=2.
|
|
136
|
+
"ocean": ">=2.11.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.11.0",
|
|
153
153
|
"engines": {
|
|
154
|
-
"ocean": ">=2.
|
|
154
|
+
"ocean": ">=2.11.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.11.0",
|
|
171
171
|
"engines": {
|
|
172
|
-
"ocean": ">=2.
|
|
172
|
+
"ocean": ">=2.11.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.11.0",
|
|
189
189
|
"engines": {
|
|
190
|
-
"ocean": ">=2.
|
|
190
|
+
"ocean": ">=2.11.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.11.0",
|
|
207
207
|
"engines": {
|
|
208
|
-
"ocean": ">=2.
|
|
208
|
+
"ocean": ">=2.11.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.11.0",
|
|
251
251
|
"engines": {
|
|
252
|
-
"ocean": ">=2.
|
|
252
|
+
"ocean": ">=2.11.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.11.0",
|
|
303
303
|
"engines": {
|
|
304
|
-
"ocean": ">=2.
|
|
304
|
+
"ocean": ">=2.11.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.11.0",
|
|
347
347
|
"engines": {
|
|
348
|
-
"ocean": ">=2.
|
|
348
|
+
"ocean": ">=2.11.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.11.0",
|
|
391
391
|
"engines": {
|
|
392
|
-
"ocean": ">=2.
|
|
392
|
+
"ocean": ">=2.11.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.11.0",
|
|
445
445
|
"engines": {
|
|
446
|
-
"ocean": ">=2.
|
|
446
|
+
"ocean": ">=2.11.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.11.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.11.0",
|
|
57
|
+
"@ocean/context": "2.11.0",
|
|
58
|
+
"@ocean/core": "2.11.0",
|
|
59
|
+
"@ocean/loop": "2.11.0",
|
|
60
|
+
"@ocean/market": "2.11.0",
|
|
61
|
+
"@ocean/services": "2.11.0",
|
|
62
62
|
"playwright-core": "^1.48.0",
|
|
63
63
|
"sqlite-vec": "0.1.9",
|
|
64
64
|
"zod": "^4.6.5"
|