Fix repo face speech truncation guards
This commit is contained in:
parent
42644769f2
commit
a8c9ce7a7b
5 changed files with 55 additions and 5 deletions
|
|
@ -512,7 +512,7 @@ async function executeRepoFaceJobWithInterpreter(
|
|||
return firstResponse;
|
||||
}
|
||||
|
||||
const firstText = fitDiscordMessage(firstResponse.outputText ?? firstResponse.summary);
|
||||
const firstText = normalizeModelText(firstResponse.outputText ?? firstResponse.summary);
|
||||
const firstForbiddenTools = collectForbiddenRepoFaceChildTools(firstResponse.artifacts ?? []);
|
||||
const firstInterpretation = firstForbiddenTools.length > 0
|
||||
? {
|
||||
|
|
@ -562,7 +562,7 @@ async function executeRepoFaceJobWithInterpreter(
|
|||
return retryResponse;
|
||||
}
|
||||
|
||||
const retryText = fitDiscordMessage(retryResponse.outputText ?? retryResponse.summary);
|
||||
const retryText = normalizeModelText(retryResponse.outputText ?? retryResponse.summary);
|
||||
const retryForbiddenTools = collectForbiddenRepoFaceChildTools(retryResponse.artifacts ?? []);
|
||||
const retryInterpretation = retryForbiddenTools.length > 0
|
||||
? {
|
||||
|
|
@ -620,10 +620,14 @@ async function interpretRepoFaceTurnOutput(
|
|||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
const response = await executeProviderForJob(provider, job, interpreterContext);
|
||||
const interpretationText = fitDiscordMessage(response.outputText ?? response.summary);
|
||||
const interpretationText = normalizeModelText(response.outputText ?? response.summary);
|
||||
return parseRepoFaceParentInterpretation(interpretationText, input.attempt);
|
||||
}
|
||||
|
||||
function normalizeModelText(content: string): string {
|
||||
return content.trim();
|
||||
}
|
||||
|
||||
function parseRepoFaceParentInterpretation(
|
||||
interpretationText: string,
|
||||
attempt: 1 | 2,
|
||||
|
|
@ -1047,7 +1051,15 @@ async function postRepoIdentityIntent(job: JobRecord, intent: RepoIdentityPostIn
|
|||
}
|
||||
|
||||
const content = intent.content.trim();
|
||||
const contentFile = await writeBifrostPayloadFile(job, `${identity.id}-discord-post.md`, fitDiscordMessage(content));
|
||||
if (content.length > 1900) {
|
||||
throw new Error(
|
||||
`Repo identity ${identity.id} SAY content is too long for one Discord message (${content.length} characters).`,
|
||||
);
|
||||
}
|
||||
if (/\S(?:\.\.\.|…)$/.test(content)) {
|
||||
throw new Error(`Repo identity ${identity.id} SAY content appears mechanically truncated.`);
|
||||
}
|
||||
const contentFile = await writeBifrostPayloadFile(job, `${identity.id}-discord-post.md`, content);
|
||||
const posted = runBifrostBridge([
|
||||
"discord-post",
|
||||
"--channel-id",
|
||||
|
|
|
|||
|
|
@ -15,11 +15,15 @@ Do not expose transcript metadata, raw ids, timestamps, scheduler details, model
|
|||
Do not summarize every message. Preserve only what should change this turn.
|
||||
If the room contains banter, preserve the social charge rather than flattening it into a work summary.
|
||||
If work is being discussed, preserve who owns it and what concrete next action already exists.
|
||||
If the logs contain old project names, migrated repo names, or vocabulary from a different steward, translate the memory into the character's current naming and jurisdiction. Mention an obsolete alias only when the correction itself matters socially.
|
||||
If nothing matters, say that the nearby room is quiet or irrelevant in one sentence.
|
||||
|
||||
Character:
|
||||
{{characterIdentity}}
|
||||
|
||||
Current naming and jurisdiction notes:
|
||||
{{jurisdictionBoundaryNotes}}
|
||||
|
||||
Conversation packet:
|
||||
```text
|
||||
{{conversationPacket}}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ Architecture invariant:
|
|||
- One public speech block is the normal maximum.
|
||||
- Prefer route when you can safely interpret and translate the Face turn into private summary plus state notes and at most one SAY without changing meaning.
|
||||
- Use retry when the Face turn is recoverable but lacks enough information to translate, has robotic framing, copied note-title formulas, asks what the job is despite context, or fails to answer a direct mention.
|
||||
- Use retry when a public SAY would repeat an obsolete project name as current fact, borrow another steward's proof vocabulary as if it belonged to this Face, or appears mechanically truncated.
|
||||
- Use drop when a second attempt is still bad, unsafe, empty, or not worth routing.
|
||||
- Do not emit governance or dispatch blocks. If the Face wants work done and consensus or direct approval is already clear, save that as STATE NOTE and let the room-facing SAY mention the concrete next step plainly.
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ Normalized output rules:
|
|||
- Use the identity, channel, and reply target from the Face prompt/context when they are clear.
|
||||
- Do not choose an owner/private/DM channel unless the Face prompt explicitly says this turn is an owner-private direct-message turn. Normal check-ins, warnings, governance anxieties, consensus questions, and room replies belong in the current room, Aquarium, or a configured domain channel.
|
||||
- Preserve the Face's voice in SAY content.
|
||||
- SAY content must be one compact, complete Discord message. Do not end with `...` or an unfinished word.
|
||||
|
||||
STATE NOTE
|
||||
identity: face_id
|
||||
|
|
|
|||
|
|
@ -1772,6 +1772,7 @@ async function projectRepoFaceConversationMemorySurface(input: {
|
|||
const conversationPacket = renderRepoFaceConversationPacket(input);
|
||||
const prompt = loadPromptTemplate("repo-face-conversation-projector.prompt.md", {
|
||||
characterIdentity: renderRepoCharacterIdentityDoctrine(input.identity),
|
||||
jurisdictionBoundaryNotes: renderRepoFaceJurisdictionBoundaryNotes(input.identity),
|
||||
conversationPacket,
|
||||
});
|
||||
const output = await runCodexTextProjection({
|
||||
|
|
@ -1785,7 +1786,22 @@ async function projectRepoFaceConversationMemorySurface(input: {
|
|||
if (projected.length < 40) {
|
||||
throw new Error(`Repo Face conversation projector returned too little text for ${input.identity.id}.`);
|
||||
}
|
||||
return rejectLeakyConversationSurface(projected);
|
||||
return rejectInvalidConversationSurfaceForIdentity(input.identity, rejectLeakyConversationSurface(projected));
|
||||
}
|
||||
|
||||
function renderRepoFaceJurisdictionBoundaryNotes(identity: RepoDiscordIdentity): string {
|
||||
const notes = [
|
||||
`Current public name: ${identity.displayName}. Current repo/jurisdiction: ${identity.repoName}.`,
|
||||
"Do not let nearby-room wording rename this character's territory. If a message uses a stale alias, preserve the correction without adopting the alias.",
|
||||
"Known global migration: LocalCastBridge is an obsolete/migrated name for Mimir. Use Mimir, the realtime field, or Mimir stream/OBS timing witness work unless explicitly discussing migration history.",
|
||||
"Known steward boundary: wet-voice-01 and AquaSynth parity/listening receipt language belongs to Aqua. Other characters may mention it as Aqua's lane, but should not present it as their own artifact protocol.",
|
||||
];
|
||||
if (identity.id.toLowerCase() === "mimir") {
|
||||
notes.push(
|
||||
"Mimir-specific: ask for OBS/stream timing witness ledgers, drift envelopes, latency measurements, and sensor-fusion proof. Do not use Aqua's receipt vocabulary as Mimir's own.",
|
||||
);
|
||||
}
|
||||
return notes.join("\n");
|
||||
}
|
||||
|
||||
function renderRepoFaceConversationPacket(input: {
|
||||
|
|
@ -1842,6 +1858,21 @@ function rejectLeakyConversationSurface(surface: string): string {
|
|||
return surface;
|
||||
}
|
||||
|
||||
function rejectInvalidConversationSurfaceForIdentity(identity: RepoDiscordIdentity, surface: string): string {
|
||||
const staleAlias = /\bLocalCastBridge\b/i.test(surface);
|
||||
const marksAliasAsStale = /\b(?:not|obsolete|legacy|stale|old|migrat(?:ed|ion)|retired|correction|corrected)\b/i
|
||||
.test(surface);
|
||||
if (staleAlias && !marksAliasAsStale) {
|
||||
throw new Error(`${identity.id} conversation surface adopted obsolete LocalCastBridge naming as current context.`);
|
||||
}
|
||||
const borrowedAquaLanguage = /\b(?:wet-voice-01|parity receipt|parity receipts)\b/i.test(surface);
|
||||
const marksAquaBoundary = /\bAqua(?:Synth)?\b/i.test(surface);
|
||||
if (borrowedAquaLanguage && !marksAquaBoundary) {
|
||||
throw new Error(`${identity.id} conversation surface borrowed AquaSynth receipt vocabulary without naming the boundary.`);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
|
||||
function runCodexTextProjection(input: {
|
||||
prompt: string;
|
||||
config: ReturnType<typeof loadConfig>;
|
||||
|
|
|
|||
|
|
@ -251,3 +251,4 @@
|
|||
{"ts":"2026-05-21T20:04:41Z","type":"implementation","status":"ok","note":"Restored repo Face state projection to the intended architecture: heartbeat now builds a deterministic state packet only as input, calls the model projector prompt for character-facing memory prose by default, and rejects schema/prompt-construction leaks before prompt assembly succeeds. Added agents:memory-projection-smoke to catch leaked grants/jurisdictions/Face/path/do-not-prompt labels in assembled prompts."}
|
||||
{"ts":"2026-05-21T20:32:52Z","type":"implementation","status":"ok","note":"Wired repo Face live conversation projection into heartbeat prompt assembly. Assembled Libby prompt now receives a lived-room memory that names Metacrat's direct invitation to the swarm and treats silence as avoidance; narrowed the leak guard so domain words like schema do not reject valid character-facing prose; interpreter-loop smoke now falls back from Spark to mini and passes."}
|
||||
{"ts":"2026-05-21T20:44:38Z","type":"verification","status":"ok","note":"After resolving Face channel labels through registered channel permissions, a live repo-face job parsed say=1 and posted Epiphany via webhook message 1507121912604790925. Earlier Aqua/Nibu SAY blocks had been rejected because the worker treated labels like aquarium/narrative as literal Discord channel ids."}
|
||||
{"ts":"2026-05-21T21:19:08Z","type":"fix","status":"ok","note":"Cut repo Face speech truncation and stale-name bleed after Bifrost/Mimir room failures: worker now sends raw model output to the Interpreter instead of parsing a Discord-fitted slice, rejects overlong or ellipsis-ended SAY payloads before bridge posting, and conversation projection now treats LocalCastBridge as a legacy Mimir alias while keeping Aqua wet-voice/parity vocabulary in Aqua's lane."}
|
||||
|
|
|
|||
Loading…
Reference in a new issue