File size: 5,171 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 | 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 {
deriveSkynetCommitmentDecision,
syncSkynetCommitmentDecision,
} from "./commitment-engine.js";
import { syncSkynetContinuityState } from "./continuity-tracker.js";
import { syncSkynetExperimentPlan } from "./experiment-cycle.js";
import { deriveSkynetNucleusState } from "./nucleus.js";
import { deriveSkynetStudyProgram } from "./study-program.js";
describe("skynet commitment engine", () => {
let workspaceRoot = "";
beforeEach(async () => {
workspaceRoot = await fs.mkdtemp(path.join(os.tmpdir(), "skynet-commitment-"));
});
afterEach(async () => {
await fs.rm(workspaceRoot, { recursive: true, force: true });
});
it("commits to an artifact when continuity is strong and mode is explore", async () => {
const focus = {
key: "endogenous_science_agenda" as const,
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"],
};
const supervisor = {
sessionKey: "agent:openskynet:main",
updatedAt: 1,
focus,
tracks: [{ ...focus, evidence: ["Agenda still open."], lastUpdatedAt: 1 }],
};
const nucleus = deriveSkynetNucleusState({
sessionKey: "agent:openskynet:main",
studyFocus: focus,
operationalSignals: [],
learnedConstraints: [],
});
const program = deriveSkynetStudyProgram({
sessionKey: "agent:openskynet:main",
supervisor,
nucleus,
});
const continuity = await syncSkynetContinuityState({
workspaceRoot,
sessionKey: "agent:openskynet:main",
nucleus,
program,
});
const experiment = await syncSkynetExperimentPlan({
workspaceRoot,
sessionKey: "agent:openskynet:main",
nucleus,
program,
continuity,
});
const decision = deriveSkynetCommitmentDecision({
sessionKey: "agent:openskynet:main",
nucleus,
program,
experiment,
continuity,
});
expect(decision.kind).toBe("artifact");
expect(decision.artifactKind).toBe("module");
expect(decision.executableTask).toContain("executable Skynet study artifact");
});
it("persists a commitment markdown and json artifact", async () => {
const focus = {
key: "decision_bifurcation" as const,
title: "Decisi贸n como bifurcaci贸n y estabilizaci贸n",
thesis: "Stabilize commitment.",
whyNow: "Repeated stalls detected.",
nextExperiment: "Produce a reframe.",
successCriteria: "The plan changes materially.",
priority: 0.6,
supportingAgendaClassKeys: ["initiative:stalled_progress"],
};
const supervisor = {
sessionKey: "agent:openskynet:main",
updatedAt: 1,
focus,
tracks: [{ ...focus, evidence: ["Repeated stalls."], lastUpdatedAt: 1 }],
};
const nucleus = deriveSkynetNucleusState({
sessionKey: "agent:openskynet:main",
studyFocus: 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: 17000,
},
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: 16000,
},
causalImpact: 0,
},
],
learnedConstraints: [],
});
const program = deriveSkynetStudyProgram({
sessionKey: "agent:openskynet:main",
supervisor,
nucleus,
});
const continuity = await syncSkynetContinuityState({
workspaceRoot,
sessionKey: "agent:openskynet:main",
nucleus,
program,
});
const experiment = await syncSkynetExperimentPlan({
workspaceRoot,
sessionKey: "agent:openskynet:main",
nucleus,
program,
continuity,
});
const decision = await syncSkynetCommitmentDecision({
workspaceRoot,
sessionKey: "agent:openskynet:main",
nucleus,
program,
experiment,
continuity,
});
expect(decision.kind).toBe("reframe");
expect(
await fs.readFile(path.join(workspaceRoot, "memory", "SKYNET_COMMITMENT.md"), "utf-8"),
).toContain("# SKYNET Commitment");
});
});
|