File size: 7,220 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { deriveSkynetNucleusState } from "./nucleus.js";
import { deriveSkynetStudyProgram, syncSkynetStudyProgram } from "./study-program.js";
describe("skynet study program", () => {
let workspaceRoot = "";
beforeEach(async () => {
workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "skynet-study-program-"));
});
afterEach(async () => {
await fs.rm(workspaceRoot, { recursive: true, force: true });
});
it("derives concrete work items from the current focus and nucleus mode", () => {
const nucleus = deriveSkynetNucleusState({
sessionKey: "agent:openskynet:main",
studyFocus: {
key: "endogenous_science_agenda",
title: "Agenda cient铆fica end贸gena",
thesis: "Persist a study agenda across cycles.",
whyNow: "No persistent agenda exists yet.",
nextExperiment: "Define a persistent study queue.",
successCriteria: "A concrete queue is produced.",
priority: 0.62,
supportingAgendaClassKeys: ["initiative:autonomy_improvement"],
},
operationalSignals: [],
learnedConstraints: [],
});
const program = deriveSkynetStudyProgram({
sessionKey: "agent:openskynet:main",
supervisor: {
sessionKey: "agent:openskynet:main",
updatedAt: 1,
focus: {
key: "endogenous_science_agenda",
title: "Agenda cient铆fica end贸gena",
thesis: "Persist a study agenda across cycles.",
whyNow: "No persistent agenda exists yet.",
nextExperiment: "Define a persistent study queue.",
successCriteria: "A concrete queue is produced.",
priority: 0.62,
supportingAgendaClassKeys: ["initiative:autonomy_improvement"],
},
tracks: [
{
key: "endogenous_science_agenda",
title: "Agenda cient铆fica end贸gena",
thesis: "Persist a study agenda across cycles.",
whyNow: "No persistent agenda exists yet.",
nextExperiment: "Define a persistent study queue.",
successCriteria: "A concrete queue is produced.",
priority: 0.62,
evidence: ["Agenda still open."],
supportingAgendaClassKeys: ["initiative:autonomy_improvement"],
lastUpdatedAt: 1,
},
{
key: "bicameral_core",
title: "N煤cleo dual o bicameral",
thesis: "Separate executive logic from dynamic pattern processing.",
whyNow: "The stack remains monolithic.",
nextExperiment: "Define the dual prototype.",
successCriteria: "A causal interface exists.",
priority: 0.56,
evidence: ["Historic line survives."],
supportingAgendaClassKeys: ["initiative:autonomy_improvement"],
lastUpdatedAt: 1,
},
{
key: "cognitive_metabolism",
title: "Metabolismo cognitivo real",
thesis: "Thinking should have cost.",
whyNow: "Loop cost still diffuses.",
nextExperiment: "Measure metabolic strain.",
successCriteria: "Budget changes behavior.",
priority: 0.51,
evidence: ["Metabolic debt remains."],
supportingAgendaClassKeys: ["initiative:somatic_optimization"],
lastUpdatedAt: 1,
},
],
},
nucleus,
});
expect(program.items).toHaveLength(3);
expect(program.items[0]?.trackKey).toBe("endogenous_science_agenda");
expect(program.items[0]?.deliverable).toContain("Define a persistent study queue");
expect(program.items[2]?.title).toContain("bucle emp铆rico");
});
it("persists the study program to json and markdown artifacts", async () => {
const supervisor = {
sessionKey: "agent:openskynet:main",
updatedAt: 1,
focus: {
key: "decision_bifurcation" as const,
title: "Decisi贸n como bifurcaci贸n y estabilizaci贸n",
thesis: "Stabilize commitment.",
whyNow: "Stalls were observed.",
nextExperiment: "Produce a new reframe.",
successCriteria: "The next plan changes materially.",
priority: 0.59,
supportingAgendaClassKeys: ["initiative:stalled_progress"],
},
tracks: [
{
key: "decision_bifurcation" as const,
title: "Decisi贸n como bifurcaci贸n y estabilizaci贸n",
thesis: "Stabilize commitment.",
whyNow: "Stalls were observed.",
nextExperiment: "Produce a new reframe.",
successCriteria: "The next plan changes materially.",
priority: 0.59,
evidence: ["Repeated stalls."],
supportingAgendaClassKeys: ["initiative:stalled_progress"],
lastUpdatedAt: 1,
},
{
key: "cognitive_metabolism" as const,
title: "Metabolismo cognitivo real",
thesis: "Thinking should have cost.",
whyNow: "Loop cost still diffuses.",
nextExperiment: "Measure metabolic strain.",
successCriteria: "Budget changes behavior.",
priority: 0.52,
evidence: ["Metabolic debt remains."],
supportingAgendaClassKeys: ["initiative:somatic_optimization"],
lastUpdatedAt: 1,
},
],
};
const nucleus = deriveSkynetNucleusState({
sessionKey: "agent:openskynet:main",
studyFocus: supervisor.focus,
operationalSignals: [
{
id: "op-1",
recordedAt: 1,
iteration: 1,
terminationReason: "completed",
turnHealth: "stalled",
progressObserved: false,
timelineDelta: 0,
kernelUpdated: true,
latencyBreakdown: {
sendAgentTurnMs: 1000,
loadSnapshotMs: 100,
readLatestReplyMs: 100,
totalMs: 16000,
},
causalImpact: 0,
},
{
id: "op-2",
recordedAt: 2,
iteration: 2,
terminationReason: "completed",
turnHealth: "stalled",
progressObserved: false,
timelineDelta: 0,
kernelUpdated: true,
latencyBreakdown: {
sendAgentTurnMs: 1000,
loadSnapshotMs: 100,
readLatestReplyMs: 100,
totalMs: 15000,
},
causalImpact: 0,
},
],
learnedConstraints: [],
});
const program = await syncSkynetStudyProgram({
workspaceRoot,
sessionKey: "agent:openskynet:main",
supervisor,
nucleus,
});
expect(program.mode).toBe("reframe");
const jsonPath = path.join(
workspaceRoot,
".openskynet",
"skynet-study-program",
"agent_openskynet_main.json",
);
const markdownPath = path.join(workspaceRoot, "memory", "SKYNET_STUDY_PROGRAM.md");
expect(JSON.parse(await fs.readFile(jsonPath, "utf-8")).items).toHaveLength(3);
expect(await fs.readFile(markdownPath, "utf-8")).toContain("# SKYNET Study Program");
});
});
|