Extract repo activity projector
This commit is contained in:
parent
40675f101a
commit
be3659e632
6 changed files with 31 additions and 40 deletions
|
|
@ -79,8 +79,8 @@ import {
|
|||
} from "../apps/persona-scheduler/dist/control-source.js";
|
||||
import {
|
||||
readRepoActivity,
|
||||
type RepoActivityObservation,
|
||||
} from "../apps/persona-scheduler/dist/repo-activity-source.js";
|
||||
import { projectRepoActivityObservation } from "../apps/persona-scheduler/dist/repo-activity-projector.js";
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const config = loadConfig();
|
||||
|
|
@ -417,7 +417,7 @@ async function queueRepoFaceTurn(input: {
|
|||
});
|
||||
const repoActivitySurface = identity.identityKind === "native_persona"
|
||||
? projectNativePersonaBody(identity)
|
||||
: renderRepoActivityObservation(readRepoActivity({ identity, storageRoot: input.config.storageRoot }));
|
||||
: projectRepoActivityObservation(readRepoActivity({ identity, storageRoot: input.config.storageRoot }));
|
||||
const globalAgentDoctrine = await readGlobalAgentDoctrine({ codexHome: process.env.CODEX_HOME, userProfile: process.env.USERPROFILE });
|
||||
const assembly = assemblePersonaTurn({
|
||||
identity,
|
||||
|
|
@ -547,7 +547,7 @@ async function assembleRepoFaceTurnPrompt(input: {
|
|||
stateObservation: personaStateObservation,
|
||||
projectedMemoryOverride,
|
||||
});
|
||||
const repoActivitySurface = renderRepoActivityObservation(
|
||||
const repoActivitySurface = projectRepoActivityObservation(
|
||||
readRepoActivity({ identity, storageRoot: input.config.storageRoot }),
|
||||
);
|
||||
const globalAgentDoctrine = await readGlobalAgentDoctrine({ codexHome: process.env.CODEX_HOME, userProfile: process.env.USERPROFILE });
|
||||
|
|
@ -592,27 +592,6 @@ async function assembleRepoFaceTurnPrompt(input: {
|
|||
};
|
||||
}
|
||||
|
||||
function renderRepoActivityObservation(observation: RepoActivityObservation): string {
|
||||
if (observation.status === "unconfigured") {
|
||||
return "- This Persona has no source repository configured; no repo activity was requested.";
|
||||
}
|
||||
if (observation.status === "unavailable") {
|
||||
return [
|
||||
`- Recent ${observation.sourceRepoName} activity could not be read for this turn.`,
|
||||
observation.detail ? `- Reader error: ${collapseWhitespace(observation.detail, 500)}` : "- Reader error: no diagnostic output.",
|
||||
"- Do not claim current repo state from stale memory; use source/history tools before making fresh claims.",
|
||||
].join("\n");
|
||||
}
|
||||
if (observation.status === "malformed") {
|
||||
return [
|
||||
`- Recent ${observation.sourceRepoName} activity output was not parseable.`,
|
||||
`- Raw output: ${collapseWhitespace(observation.raw, 500)}`,
|
||||
"- Do not claim current repo state from stale memory; use source/history tools before making fresh claims.",
|
||||
].join("\n");
|
||||
}
|
||||
return observation.digest || `- No recent ${observation.sourceRepoName} activity was reported.`;
|
||||
}
|
||||
|
||||
async function readOptionalMemorySurface(path: string | undefined): Promise<string | undefined> {
|
||||
if (!path) {
|
||||
return undefined;
|
||||
|
|
@ -656,25 +635,10 @@ function buildInspectionParticipant(
|
|||
};
|
||||
}
|
||||
|
||||
function collapseWhitespace(value: string, maxLength?: number): string {
|
||||
const normalized = value.replace(/\s+/g, " ").trim();
|
||||
return maxLength && normalized.length > maxLength
|
||||
? `${normalized.slice(0, maxLength - 3)}...`
|
||||
: normalized;
|
||||
}
|
||||
|
||||
function normalizeKey(value: string): string {
|
||||
return value.trim().toLowerCase();
|
||||
}
|
||||
|
||||
function clamp(value: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, Number(value.toFixed(3))));
|
||||
}
|
||||
|
||||
function round3(value: number): number {
|
||||
return Math.round(value * 1000) / 1000;
|
||||
}
|
||||
|
||||
function readArgValue(name: string): string | undefined {
|
||||
const index = process.argv.indexOf(name);
|
||||
if (index < 0) {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ import {
|
|||
readSwarmControlState,
|
||||
} from "../apps/persona-scheduler/dist/control-source.js";
|
||||
import { readRepoActivity } from "../apps/persona-scheduler/dist/repo-activity-source.js";
|
||||
import { projectRepoActivityObservation } from "../apps/persona-scheduler/dist/repo-activity-projector.js";
|
||||
import { readPersonaStateObservation } from "../apps/persona-scheduler/dist/persona-state-source.js";
|
||||
import { readPersonaMemoryRecall } from "../apps/persona-scheduler/dist/persona-memory-context-source.js";
|
||||
import { coordinatePersonaMemoryTurn } from "../apps/persona-scheduler/dist/persona-memory-turn-coordinator.js";
|
||||
|
|
@ -858,6 +859,8 @@ const repoActivity = readRepoActivity({
|
|||
},
|
||||
});
|
||||
assert.deepEqual(repoActivity, { status: "ok", sourceRepoName: "AetheriaLore", digest: "- Fresh repo motion." }, "repo activity crosses the source boundary as facts, not prompt prose");
|
||||
assert.equal(projectRepoActivityObservation(repoActivity), "- Fresh repo motion.", "repo activity prompt lowering belongs to the pure projector");
|
||||
assert.match(projectRepoActivityObservation({ status: "unavailable", sourceRepoName: "AetheriaLore", detail: "exporter asleep" }), /could not be read[\s\S]*exporter asleep[\s\S]*Do not claim current repo state/, "repo activity failure remains explicit without moving exporter mechanics into the projector");
|
||||
assert.ok(repoActivityArgs.includes("--read-only"), "Persona turns cannot advance the repo activity cursor while observing body context");
|
||||
assert.deepEqual(repoActivityArgs.slice(-4), ["--hours", "96", "--max-commits", "5"], "the source owns one bounded activity window");
|
||||
const failedRepoActivity = readRepoActivity({
|
||||
|
|
|
|||
Loading…
Reference in a new issue