Complete six-command Epiphany operator surface
This commit is contained in:
parent
03edb8fffc
commit
329e33bda0
6 changed files with 173 additions and 12 deletions
|
|
@ -29,7 +29,7 @@ assert.notEqual(digest, epiphanyOperatorRequestPayloadSha256({ ...request, disco
|
|||
assert.notEqual(digest, epiphanyOperatorRequestPayloadSha256({ ...request, command: { kind: "wake" } }));
|
||||
|
||||
const completed: EpiphanyOperatorDeliveryDocument = {
|
||||
schemaVersion: "bifrost.discord.epiphany_operator_delivery.v0",
|
||||
schemaVersion: "bifrost.discord.epiphany_operator_delivery.v1",
|
||||
deliveryId: request.requestId, requestId: request.requestId, requestPayloadSha256: digest,
|
||||
commandId: request.commandId, discordGuildId: request.discordGuildId,
|
||||
discordChannelId: request.discordChannelId, discordInteractionId: request.sourceEventId,
|
||||
|
|
@ -38,6 +38,7 @@ const completed: EpiphanyOperatorDeliveryDocument = {
|
|||
coordinatorAction: "none", brakeStatus: "engaged",
|
||||
sealedResultPayloadSha256: `sha256-${"a".repeat(64)}`,
|
||||
executorSignatureSha256: `sha256-${"b".repeat(64)}`, resultProviderIdentityId: "bifrost-yggdrasil",
|
||||
reviews: [], reviewCandidateId: "", reviewDecision: "",
|
||||
recordedAt: "2026-07-19T12:00:01.000Z", privateStateExposed: false,
|
||||
};
|
||||
assert.equal(validateDelivery(completed).status, "completed");
|
||||
|
|
@ -46,6 +47,7 @@ const refused: EpiphanyOperatorDeliveryDocument = {
|
|||
...completed, status: "refused", disposition: "", failureCode: "brakes_engaged", detail: "refused",
|
||||
operatorStatus: "", stateStatus: "", coordinatorAction: "", brakeStatus: "",
|
||||
sealedResultPayloadSha256: "", executorSignatureSha256: "", resultProviderIdentityId: "",
|
||||
reviews: [], reviewCandidateId: "", reviewDecision: "",
|
||||
};
|
||||
assert.equal(validateDelivery(refused).status, "refused");
|
||||
|
||||
|
|
@ -62,6 +64,8 @@ rejects({ deliveryId: "collision" }, /identity/);
|
|||
rejects({ executorSignatureSha256: "signature-bytes" }, /sealed bindings/);
|
||||
rejects({ resultProviderIdentityId: "" }, /resultProviderIdentityId|sealed bindings/);
|
||||
rejects({ surprisePrivatePayload: "secret" }, /field set/);
|
||||
rejects({ reviews: [{ mindRequestId: "m", candidateId: "c", candidateSha256: "1".repeat(64), modelRevision: 1, modelHash: "2".repeat(64), frontierItemId: "f", requestedAt: "2026-07-19T12:00:00Z", proposalText: "private" }] }, /inexact field set/);
|
||||
rejects({ reviews: Array.from({ length: 11 }, () => ({ mindRequestId: "m", candidateId: "c", candidateSha256: "1".repeat(64), modelRevision: 1, modelHash: "2".repeat(64), frontierItemId: "f", requestedAt: "2026-07-19T12:00:00Z" })) }, /at most ten/);
|
||||
assert.throws(() => validateDelivery({ ...refused, brakeStatus: "not empty" }), /completed-result bindings/);
|
||||
assert.throws(() => validateDelivery({ ...refused, failureCode: "" }), /failureCode|failure code/);
|
||||
|
||||
|
|
@ -102,6 +106,43 @@ let collisionCheckpoint = { ...baseCheckpoint, observedDeliverySha256: `sha256-$
|
|||
assert.equal(await processEpiphanyOperatorDelivery(completed, request, collisionCheckpoint, async () => { throw new Error("must not edit"); }, async (next) => { collisionCheckpoint = next; }), "failed");
|
||||
assert.match(collisionCheckpoint.lastError, /collision/);
|
||||
|
||||
const reviewRequest = buildEpiphanyOperatorRequest({
|
||||
interactionId: "interaction-review", actorDiscordId: "owner-1", guildId: "guild-1", channelId: "channel-1",
|
||||
command: { kind: "reviews" }, issuedAt: "2026-07-19T12:00:00.000Z",
|
||||
}, "voidbot-yggdrasil");
|
||||
const reviewDelivery: EpiphanyOperatorDeliveryDocument = {
|
||||
...completed,
|
||||
deliveryId: reviewRequest.requestId, requestId: reviewRequest.requestId, commandId: reviewRequest.commandId,
|
||||
discordInteractionId: reviewRequest.sourceEventId, requestPayloadSha256: epiphanyOperatorRequestPayloadSha256(reviewRequest),
|
||||
reviews: [{ mindRequestId: "mind-1", candidateId: "candidate-1", candidateSha256: "1".repeat(64), modelRevision: 7,
|
||||
modelHash: "2".repeat(64), frontierItemId: "frontier-1", requestedAt: "2026-07-19T11:59:00Z" }],
|
||||
};
|
||||
let renderedReview = "";
|
||||
let reviewCheckpoint = { ...baseCheckpoint, requestId: reviewRequest.requestId, discordInteractionId: reviewRequest.sourceEventId };
|
||||
assert.equal(await processEpiphanyOperatorDelivery(reviewDelivery, reviewRequest, reviewCheckpoint,
|
||||
async (_app, _token, content) => { renderedReview = content; }, async (next) => { reviewCheckpoint = next; }), "responded");
|
||||
assert.match(renderedReview, /candidate-1.*request mind-1.*revision 7.*frontier frontier-1/);
|
||||
assert.doesNotMatch(renderedReview, /proposal|private|sha256/i);
|
||||
let substitutedCheckpoint = { ...baseCheckpoint };
|
||||
assert.equal(await processEpiphanyOperatorDelivery({ ...completed, reviews: reviewDelivery.reviews }, request, substitutedCheckpoint,
|
||||
async () => { throw new Error("must not render substituted review state"); }, async (next) => { substitutedCheckpoint = next; }), "failed");
|
||||
assert.match(substitutedCheckpoint.lastError, /non-review/);
|
||||
|
||||
const decisionRequest = buildEpiphanyOperatorRequest({
|
||||
interactionId: "interaction-decision", actorDiscordId: "owner-1", guildId: "guild-1", channelId: "channel-1",
|
||||
command: { kind: "review", mindRequestId: "mind-1", candidateId: "candidate-1", candidateSha256: "1".repeat(64),
|
||||
expectedModelRevision: 7, expectedModelHash: "2".repeat(64), decision: "hold" }, issuedAt: "2026-07-19T12:00:00.000Z",
|
||||
}, "voidbot-yggdrasil");
|
||||
const decisionDelivery: EpiphanyOperatorDeliveryDocument = {
|
||||
...completed, deliveryId: decisionRequest.requestId, requestId: decisionRequest.requestId, commandId: decisionRequest.commandId,
|
||||
discordInteractionId: decisionRequest.sourceEventId, requestPayloadSha256: epiphanyOperatorRequestPayloadSha256(decisionRequest),
|
||||
reviewCandidateId: "candidate-1", reviewDecision: "hold",
|
||||
};
|
||||
let decisionCheckpoint = { ...baseCheckpoint, requestId: decisionRequest.requestId, discordInteractionId: decisionRequest.sourceEventId };
|
||||
assert.equal(await processEpiphanyOperatorDelivery({ ...decisionDelivery, reviewCandidateId: "candidate-2" }, decisionRequest, decisionCheckpoint,
|
||||
async () => { throw new Error("must not render substituted decision"); }, async (next) => { decisionCheckpoint = next; }), "failed");
|
||||
assert.match(decisionCheckpoint.lastError, /exact candidate and decision/);
|
||||
|
||||
const temp = await mkdtemp(join(tmpdir(), "voidbot-epiphany-delivery-"));
|
||||
try {
|
||||
const bifrostRoot = resolve("../Bifrost");
|
||||
|
|
|
|||
|
|
@ -18,7 +18,16 @@ assert.equal(isExactDiscordOwner("tier-one-1", owner), false);
|
|||
|
||||
const epiphany = commandDefinitions.map((command) => command.toJSON()).find((command) => command.name === "epiphany");
|
||||
assert.ok(epiphany, "slash command is registered");
|
||||
assert.deepEqual(epiphany.options?.map((option) => option.name), ["status", "sleep", "wake", "direct"]);
|
||||
assert.deepEqual(epiphany.options?.map((option) => option.name), ["status", "sleep", "wake", "direct", "reviews", "review"]);
|
||||
|
||||
const protocolPath = process.env.EPIPHANY_OPERATOR_PROTOCOL_FIXTURE
|
||||
?? resolve("..", "EpiphanyAgent", ".epiphany-smoke", "operator-command-interop-rust", "protocol.json");
|
||||
const protocol = JSON.parse(await readFile(protocolPath, "utf8"));
|
||||
assert.equal(protocol.schemaVersion, "epiphany.operator_command.protocol_fixture.v1");
|
||||
assert.equal(protocol.admissionSchemaVersion, "bifrost.operator_command.delivery.v1");
|
||||
assert.equal(protocol.resultSchemaVersion, "epiphany.operator_command.result.v1");
|
||||
assert.deepEqual(protocol.commands.map((command: { kind: string }) => command.kind), ["status", "sleep", "wake", "directive", "reviews", "review"]);
|
||||
assert.deepEqual(protocol.reviewDecisions, ["adopt", "refuse", "hold"]);
|
||||
|
||||
const issuedAt = "2026-07-19T12:00:00.000Z";
|
||||
const commands = [
|
||||
|
|
@ -26,6 +35,8 @@ const commands = [
|
|||
{ kind: "sleep", reason: "Operator is packing the workstation." } as const,
|
||||
{ kind: "wake" } as const,
|
||||
{ kind: "directive", objective: "Inspect the current domain map and propose the next bounded improvement." } as const,
|
||||
{ kind: "reviews" } as const,
|
||||
protocol.commands[5],
|
||||
];
|
||||
for (const [index, command] of commands.entries()) {
|
||||
const id = `interaction-${index}`;
|
||||
|
|
@ -80,6 +91,11 @@ await assert.rejects(
|
|||
);
|
||||
assert.throws(() => buildEpiphanyOperatorRequest({ ...input, command: { kind: "sleep", reason: "x".repeat(501) } }, "voidbot-yggdrasil"), /500/);
|
||||
assert.throws(() => buildEpiphanyOperatorRequest({ ...input, command: { kind: "directive", objective: "x".repeat(2001) } }, "voidbot-yggdrasil"), /2000/);
|
||||
const review = commands[5] as Extract<(typeof commands)[number], { kind: "review" }>;
|
||||
assert.deepEqual(Object.keys(protocol.commands[5]).sort(), ["candidateId", "candidateSha256", "decision", "expectedModelHash", "expectedModelRevision", "kind", "mindRequestId"].sort());
|
||||
assert.throws(() => buildEpiphanyOperatorRequest({ ...input, command: { ...review, candidateSha256: "0".repeat(63) } }, "voidbot-yggdrasil"), /64 lowercase/);
|
||||
assert.throws(() => buildEpiphanyOperatorRequest({ ...input, command: { ...review, expectedModelRevision: -1 } }, "voidbot-yggdrasil"), /non-negative/);
|
||||
assert.throws(() => buildEpiphanyOperatorRequest({ ...input, command: { ...review, decision: "approve" as "adopt" } }, "voidbot-yggdrasil"), /decision/);
|
||||
|
||||
const botSource = await readFile(resolve("apps/bot/src/discord-bot.ts"), "utf8");
|
||||
const messageCreate = botSource.slice(botSource.indexOf("client.on(Events.MessageCreate"), botSource.indexOf("client.on(Events.MessageUpdate"));
|
||||
|
|
@ -88,7 +104,8 @@ assert.ok(!messageCreate.includes("submitEpiphanyOperatorRequest"), "ordinary me
|
|||
|
||||
console.log(JSON.stringify({
|
||||
schemaVersion: EPIPHANY_OPERATOR_REQUEST_SCHEMA,
|
||||
commands: ["status", "sleep", "wake", "direct"],
|
||||
commands: ["status", "sleep", "wake", "direct", "reviews", "review"],
|
||||
rustProtocolFixtureConsumed: true,
|
||||
exactOwnerOnly: true,
|
||||
ordinaryMessagesRemainFeedbackOnly: true,
|
||||
localExecutionAuthorized: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue