Move Persona profile adapter into social source
This commit is contained in:
parent
489d06525c
commit
40675f101a
6 changed files with 47 additions and 32 deletions
|
|
@ -47,11 +47,10 @@ import {
|
|||
type PersonaStateObservation,
|
||||
} from "../apps/persona-scheduler/dist/persona-state-source.js";
|
||||
import { projectNativePersonaBody } from "../apps/persona-scheduler/dist/persona-standard-state-projector.js";
|
||||
import type { PersonaHumanPronounGuidance as RepoFaceHumanPronounGuidance } from "../apps/persona-scheduler/dist/persona-social-context-projector.js";
|
||||
import { assemblePersonaTurn } from "../apps/persona-scheduler/dist/persona-turn-assembler.js";
|
||||
import { coordinatePersonaMemoryTurn } from "../apps/persona-scheduler/dist/persona-memory-turn-coordinator.js";
|
||||
import { readGlobalAgentDoctrine } from "../apps/persona-scheduler/dist/global-agent-doctrine-source.js";
|
||||
import { readPersonaHumanPronounGuidance } from "../apps/persona-scheduler/dist/persona-social-context-source.js";
|
||||
import { readStoredPersonaHumanPronounGuidance } from "../apps/persona-scheduler/dist/persona-social-context-source.js";
|
||||
import {
|
||||
readDiscordActivitySnapshot,
|
||||
type IdleCoolingSnapshot,
|
||||
|
|
@ -407,7 +406,7 @@ async function queueRepoFaceTurn(input: {
|
|||
recentMessages,
|
||||
channelSnapshots,
|
||||
};
|
||||
const humanPronounGuidance = await loadRepoFaceHumanPronounGuidance(input.config, roomContext);
|
||||
const humanPronounGuidance = await readStoredPersonaHumanPronounGuidance({ config: input.config, ...roomContext });
|
||||
const memoryContext = await coordinatePersonaMemoryTurn({
|
||||
identity,
|
||||
config: input.config,
|
||||
|
|
@ -534,7 +533,7 @@ async function assembleRepoFaceTurnPrompt(input: {
|
|||
recentMessages,
|
||||
channelSnapshots,
|
||||
};
|
||||
const humanPronounGuidance = await loadRepoFaceHumanPronounGuidance(input.config, roomContext);
|
||||
const humanPronounGuidance = await readStoredPersonaHumanPronounGuidance({ config: input.config, ...roomContext });
|
||||
const personaStateObservation = await readPersonaStateObservation({ identity, storageRoot: input.config.storageRoot });
|
||||
const projectedMemoryOverride = input.memorySurfacePath
|
||||
? await readOptionalMemorySurface(input.memorySurfacePath)
|
||||
|
|
@ -593,32 +592,6 @@ async function assembleRepoFaceTurnPrompt(input: {
|
|||
};
|
||||
}
|
||||
|
||||
async function loadRepoFaceHumanPronounGuidance(
|
||||
config: ReturnType<typeof loadConfig>,
|
||||
roomContext?: {
|
||||
recentMessages: SourceMessage[];
|
||||
channelSnapshots: ChannelSnapshot[];
|
||||
},
|
||||
): Promise<RepoFaceHumanPronounGuidance[]> {
|
||||
return readPersonaHumanPronounGuidance({
|
||||
ownerActorId: config.ownerDiscordId,
|
||||
ownerFallbackName: "Metacrat",
|
||||
recentMessages: roomContext?.recentMessages ?? [],
|
||||
channelSnapshots: roomContext?.channelSnapshots ?? [],
|
||||
openProfiles: async () => {
|
||||
const storage = await createStateStorage({
|
||||
backend: config.stateStorageBackend,
|
||||
databaseDsn: config.databaseDsn,
|
||||
jobsFile: config.jobsFile,
|
||||
auditLogFile: config.auditLogFile,
|
||||
interactionMemoryFile: config.interactionMemoryFile,
|
||||
rateLimitStateFile: config.rateLimitStateFile,
|
||||
});
|
||||
return { getProfile: (actorId) => storage.interactionMemory.getProfile(actorId), close: () => storage.close() };
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function renderRepoActivityObservation(observation: RepoActivityObservation): string {
|
||||
if (observation.status === "unconfigured") {
|
||||
return "- This Persona has no source repository configured; no repo activity was requested.";
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ import { projectGamecultPersonaState } from "../apps/persona-scheduler/dist/pers
|
|||
import { projectPersonaStatePacket } from "../apps/persona-scheduler/dist/persona-state-packet-projector.js";
|
||||
import { extractLastPersonaProjectionMessage, isRetryablePersonaProjectionFailure } from "../apps/persona-scheduler/dist/persona-text-projection-actuator.js";
|
||||
import { observePersonaRoomTexture, projectPersonaSocialContext, renderPersonaHumanClarityPressure, renderPersonaHumanPronounFacts, renderPersonaRoomWeather, renderPersonaSocialGraph } from "../apps/persona-scheduler/dist/persona-social-context-projector.js";
|
||||
import { readPersonaHumanPronounGuidance } from "../apps/persona-scheduler/dist/persona-social-context-source.js";
|
||||
import { readPersonaHumanPronounGuidance, readStoredPersonaHumanPronounGuidance } from "../apps/persona-scheduler/dist/persona-social-context-source.js";
|
||||
|
||||
function participant(identityId: string, nextTurnAt: number): InitiativeParticipant {
|
||||
return {
|
||||
|
|
@ -503,6 +503,19 @@ const pronounGuidance = await readPersonaHumanPronounGuidance({
|
|||
});
|
||||
assert.match(pronounGuidance[0]?.evidenceExcerpt ?? "", /please use they\/them/, "the social-context source owns pronoun evidence precedence rather than favoring merely newer ambient usage");
|
||||
assert.equal(pronounReaderClosed, true, "the social-context source closes its injected interaction-profile reader");
|
||||
let storedProfileReaderClosed = false;
|
||||
const storedPronounGuidance = await readStoredPersonaHumanPronounGuidance({
|
||||
config: { ownerDiscordId: "human" } as never,
|
||||
recentMessages: [{ id: "human-pronouns", authorId: "human", authorName: "Operator", content: "hello", timestamp: "2026-07-15T21:00:00.000Z", isBot: false, channelId: "aquarium" }],
|
||||
channelSnapshots: [],
|
||||
}, {
|
||||
openProfiles: async () => ({
|
||||
getProfile: async () => ({ actorId: "human", actorName: "Operator", pronounPolicy: "explicit", resolvedPronounSet: "they/them", resolvedPronounSets: ["they/them"], pronounGuidance: "use they/them", pronounConfidence: 1, pronounEvidence: [{ pronounSet: "they/them", stance: "prefer", source: "explicit_self_statement", confidence: 1, timestamp: "2026-07-15T20:00:00.000Z", excerpt: "I use they/them" }], traits: [], notes: [], updatedAt: "2026-07-15T20:00:00.000Z" }),
|
||||
close: async () => { storedProfileReaderClosed = true; },
|
||||
}),
|
||||
});
|
||||
assert.equal(storedPronounGuidance[0]?.resolvedPronounSet, "they/them", "the stored-profile adapter feeds the existing social-context source without reimplementing pronoun policy");
|
||||
assert.equal(storedProfileReaderClosed, true, "the stored-profile adapter preserves provider close semantics");
|
||||
const clarityPressure = renderPersonaHumanClarityPressure({
|
||||
identity: routedIdentity,
|
||||
recentMessages: [
|
||||
|
|
|
|||
Loading…
Reference in a new issue