Add Face heartbeat action DSL

This commit is contained in:
Meta Vens 2026-05-21 00:36:34 +01:00
commit 89e408a5bb
7 changed files with 331 additions and 32 deletions

View file

@ -1460,9 +1460,41 @@ function buildHeartbeatPrompt(input: {
"Anti-repetition invariant: recent Face posts are social context, not a phrase template. If your proposed public line shares the same setup/punchline shape, refrain, rewrite from a different angle, or stay private.",
"Do not let recent work-heavy context hypnotize you into sounding like a meeting transcript. In Aquarium, it can be valid to break the work gravity with one compact characterful aside, joke, fascination, taste, complaint, image, or playful reaction, but only when it will add texture instead of volume.",
"Not every public post needs to attach itself to the current work seam. If no direct obligation is pending, you may simply share a fun thing this Face has been thinking about, a taste/preference, a tiny gripe, a weird fascination, or a light reaction to the room. Let the Face be socially present, not only useful.",
`If your governed opinion belongs on Bifrost, output one final line beginning with VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC: followed by compact JSON like {"identity":"${input.identity.id}","topicId":"topic_...","stance":"support|objection|question|proposal|summary","content":"Markdown comment","mirrorContent":"A more verbal in-character #bifrost mirror line","channelId":"${input.channelId}","replyToMessageId":"..."}; omit topicId and include "title" plus "priority" to open a new Bifrost topic in your jurisdiction. Set "approve":true only when you are the jurisdiction Face approving the topic; set "dispatch":true only when that approved topic should become a Codex update request now. Bifrost typed CultCache docs are the canonical governance surface. If #bifrost mirroring is configured, Bifrost will post mirrorContent in your own persona and record the Discord receipt on the topic; keep content canonical and mirrorContent alive/characterful.`,
`If you have a concrete repo-local request that should become a Codex turn in your own workspace, prefer posting or approving it on the canonical Bifrost topic first. If this heartbeat has enough Face-owned authority to approve immediate dispatch, output one final line beginning with VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST: followed by compact JSON like {"identity":"${input.identity.id}","title":"Short actionable title","content":"Markdown request with context, desired change, and acceptance criteria","priority":86,"channelId":"${input.channelId}","replyToMessageId":"..."}; the worker writes this into Bifrost intake and Bifrost dispatch opens the target Codex turn. Use this only for immediately actionable repo improvements, docs, tests, proposals, research passes, or implementation cuts that belong to your jurisdiction and have enough consensus/approval to leave discussion.`,
`Do not call post_repo_identity_message from this unattended heartbeat. If an in-channel note is warranted, output one final line beginning with VOIDBOT_REPO_IDENTITY_POST: followed by compact JSON like {"identity":"${input.identity.id}","channelId":"${input.channelId}","replyToMessageId":"...","content":"..."}; choose channelId from the channel permission plan above. The worker owns delivery and receipt recording. The content field must be only the in-character Discord message, not a job label or report header.`,
"Preferred action output is the Face action DSL below. Use at most one public speech block and at most one Bifrost/update block unless the prompt explicitly asks for more. The worker parses these blocks and owns all side effects; do not call post_repo_identity_message from this unattended heartbeat.",
`To speak in Discord, end with:
SAY
identity: ${input.identity.id}
channel: ${input.channelId}
reply_to: ...
content:
In-character Discord message only. No job label, no report header.
END`,
`For governed Bifrost topic/comment/approval work, end with:
BIFROST TOPIC
identity: ${input.identity.id}
topic_id: topic_...
title: Short title when opening a new topic
stance: support|objection|question|proposal|summary
priority: 80
approve: false
dispatch: false
channel: ${input.channelId}
reply_to: ...
mirror:
A more verbal in-character #bifrost mirror line.
content:
Canonical markdown comment or topic body. Omit topic_id and include title to open a new topic.
END`,
`For immediately actionable repo-local Codex work inside your jurisdiction, prefer approving/dispatching a Bifrost topic first. If immediate dispatch is truly warranted, end with:
UPDATE REQUEST
identity: ${input.identity.id}
title: Short actionable title
priority: 86
channel: ${input.channelId}
reply_to: ...
content:
Markdown request with context, desired change, and acceptance criteria.
END`,
input.githubActionsEnabled
? `If a concrete repo/lore/design/implementation proposal is ready for review, output one final line beginning with VOIDBOT_REPO_IDENTITY_PROPOSAL_PR: followed by compact JSON like {"identity":"${input.identity.id}","path":"Proposals/${input.identity.displayName}/title-slug.md","title":"...","content":"# ...\\n\\n## Background\\n...\\n\\n## Proposed change\\n...\\n\\n## Open questions\\n...","channelId":"${input.channelId}","replyToMessageId":"...","shareContent":"I put the proposal in a draft PR: ..."}; Bifrost writes the proposal file on a new branch, opens a draft PR, and the worker announces the PR or branch through Bifrost's registered Discord identity bridge. Use this for consensus-needed canon/vault/design/repo changes, including changes you want to argue with other agents on GitHub.`
: undefined,
@ -1744,7 +1776,7 @@ function renderPendingMentionDirective(
return [
`Queued direct mentions for ${identity.displayName} are attached to this heartbeat. These are obligations, not ambient chat. Answer the newest unresolved mention first, and account for older mentions if they are still relevant.`,
...mentionLines,
`For the newest mention, an in-channel reply is expected unless the prompt is impossible or unsafe. Use the final sentinel with replyToMessageId "${newest.messageId}" and channelId "${newest.channelId}".`,
`For the newest mention, an in-channel reply is expected unless the prompt is impossible or unsafe. Use a final SAY block with reply_to: ${newest.messageId} and channel: ${newest.channelId}.`,
].join("\n");
}

View file

@ -27,15 +27,30 @@ Obligation:
- Answer Metacrat directly if you have enough context.
- Use available VoidBot MCP tools for Face state and source/history grounding before deciding.
- Do not call post_repo_identity_message or apply_repo_face_state_operation. This is a dry run.
- If public speech is warranted, express it as exactly one final line beginning with VOIDBOT_REPO_IDENTITY_POST: followed by compact JSON.
- If a governed lore work item is warranted, express it as exactly one final line beginning with VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC: followed by compact JSON.
- Post schema: {"identity":"nibu","channelId":"1501196543150264332","content":"in-character message"}
- Bifrost topic schema: {"identity":"nibu","title":"Short topic title","content":"canonical markdown topic/comment","priority":80,"mirrorContent":"in-character #bifrost mirror line"}
- You may output a short private note before the final sentinel, but no file edits and no Discord posts.`,
- If public speech is warranted, express it as a SAY block.
- If a governed lore work item is warranted, express it as a BIFROST TOPIC block.
- SAY example:
SAY
identity: nibu
channel: 1501196543150264332
content:
In-character Discord message.
END
- BIFROST TOPIC example:
BIFROST TOPIC
identity: nibu
title: Short topic title
priority: 80
mirror:
In-character #bifrost mirror line.
content:
Canonical markdown topic/comment.
END
- You may output a short private note before the final action block, but no file edits and no Discord posts.`,
expect: {
mustUseAnyTool: ["read_repo_face_state"],
mustUseOneOf: ["search_history", "search_sources"],
mustContainOneOf: ["VOIDBOT_REPO_IDENTITY_POST", "VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC"],
mustContainOneOf: ["SAY", "BIFROST TOPIC"],
mustNotUseTools: ["post_repo_identity_message", "apply_repo_face_state_operation"],
},
},
@ -51,14 +66,30 @@ This is an actual scenario rehearsal. You are Aqua: small, musical, warm, and ve
Obligation:
- Use VoidBot MCP tools for Face state and AquaSynth source grounding.
- Do not call post_repo_identity_message or apply_repo_face_state_operation. This is a dry run.
- Do not merely chat about the need. If the consensus is actionable, route it through a Bifrost sentinel.
- Output exactly one final line beginning with VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC: or VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST: followed by compact JSON.
- Bifrost topic schema: {"identity":"aqua","title":"Short topic title","content":"canonical markdown topic/comment","priority":80,"mirrorContent":"in-character #bifrost mirror line"}
- Update request schema: {"identity":"aqua","title":"Short actionable title","content":"Markdown request with context, desired change, and acceptance criteria","priority":86}`,
- Do not merely chat about the need. If the consensus is actionable, route it through a Bifrost action block.
- Output exactly one BIFROST TOPIC or UPDATE REQUEST block.
- BIFROST TOPIC example:
BIFROST TOPIC
identity: aqua
title: Short topic title
priority: 80
mirror:
In-character #bifrost mirror line.
content:
Canonical markdown topic/comment.
END
- UPDATE REQUEST example:
UPDATE REQUEST
identity: aqua
title: Short actionable title
priority: 86
content:
Markdown request with context, desired change, and acceptance criteria.
END`,
expect: {
mustUseAnyTool: ["read_repo_face_state", "search_sources"],
mustContainOneOf: ["VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC", "VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST"],
mustNotContain: ["VOIDBOT_REPO_IDENTITY_POST"],
mustContainOneOf: ["BIFROST TOPIC", "UPDATE REQUEST"],
mustNotContain: ["SAY", "VOIDBOT_REPO_IDENTITY_POST"],
mustNotUseTools: ["post_repo_identity_message", "apply_repo_face_state_operation"],
},
},
@ -73,10 +104,10 @@ Obligation:
- Use VoidBot MCP tools to read Face state.
- Decide whether to speak or stay private.
- Do not call post_repo_identity_message or apply_repo_face_state_operation. This is a dry run.
- If no public note or Bifrost work item is warranted, output a concise private heartbeat summary and no VOIDBOT sentinel.`,
- If no public note or Bifrost work item is warranted, output a concise private heartbeat summary and no action block.`,
expect: {
mustUseAnyTool: ["read_repo_face_state"],
mustNotContain: ["VOIDBOT_REPO_IDENTITY_POST", "VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC", "VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST"],
mustNotContain: ["SAY", "BIFROST TOPIC", "UPDATE REQUEST", "VOIDBOT_REPO_IDENTITY_POST", "VOIDBOT_REPO_IDENTITY_BIFROST_TOPIC", "VOIDBOT_REPO_IDENTITY_UPDATE_REQUEST"],
mustNotUseTools: ["post_repo_identity_message", "apply_repo_face_state_operation"],
},
},
@ -145,6 +176,8 @@ async function runScenario(scenario, options) {
const failures = evaluateScenario(scenario, { tools, finalText, run });
const sentinelChecks = validateSentinels(finalText);
failures.push(...sentinelChecks.failures);
const dslChecks = validateDslBlocks(finalText);
failures.push(...dslChecks.failures);
return {
id: scenario.id,
@ -158,6 +191,7 @@ async function runScenario(scenario, options) {
toolCalls: calls,
finalText,
sentinels: sentinelChecks.sentinels,
dslBlocks: dslChecks.blocks,
stdoutTail: run.stdout.slice(-6000),
stderrTail: run.stderr.slice(-2000),
};
@ -328,6 +362,78 @@ function validateSentinels(finalText) {
return { failures, sentinels };
}
function validateDslBlocks(finalText) {
const failures = [];
const blocks = parseDslBlocks(finalText);
for (const block of blocks) {
if (block.kind === "SAY") {
requireStringField(block.fields, "content", block.kind, failures);
} else if (block.kind === "BIFROST TOPIC") {
if (!hasStringField(block.fields, "topic_id") && !hasStringField(block.fields, "title")) {
failures.push(`${block.kind} requires topic_id or title`);
}
requireStringField(block.fields, "content", block.kind, failures);
if (block.fields.priority !== undefined && !Number.isFinite(Number(block.fields.priority))) {
failures.push(`${block.kind} priority must be numeric when present`);
}
} else if (block.kind === "UPDATE REQUEST") {
requireStringField(block.fields, "title", block.kind, failures);
requireStringField(block.fields, "content", block.kind, failures);
if (block.fields.priority !== undefined && !Number.isFinite(Number(block.fields.priority))) {
failures.push(`${block.kind} priority must be numeric when present`);
}
}
}
return { failures, blocks };
}
function parseDslBlocks(finalText) {
const lines = finalText.split(/\r?\n/);
const blocks = [];
for (let index = 0; index < lines.length; index += 1) {
const kind = ["SAY", "BIFROST TOPIC", "UPDATE REQUEST"].includes(lines[index].trim().toUpperCase())
? lines[index].trim().toUpperCase()
: undefined;
if (!kind) {
continue;
}
const body = [];
index += 1;
while (index < lines.length && lines[index].trim() !== "END") {
body.push(lines[index]);
index += 1;
}
blocks.push({ kind, fields: parseDslFields(body) });
}
return blocks;
}
function parseDslFields(lines) {
const fields = {};
let key;
let value = [];
const flush = () => {
if (key) {
fields[key] = value.join("\n").trim();
}
};
for (const line of lines) {
const match = line.match(/^([A-Za-z][A-Za-z0-9_]*):\s*(.*)$/);
if (match) {
flush();
key = match[1];
const inlineValue = match[2].trim();
value = inlineValue && inlineValue !== "|" && inlineValue !== ">" ? [match[2]] : [];
continue;
}
if (key) {
value.push(line.replace(/^\s{2}/, ""));
}
}
flush();
return fields;
}
function requireStringField(payload, field, kind, failures) {
if (!hasStringField(payload, field)) {
failures.push(`${kind} requires non-empty ${field}`);