refactor: remove self-learning and the optimizer package (P1.4)
Self-learning is excluded from the community edition (ADR-0004); the project owner reworks it separately. Cost tracking stays. - agent: delete behaviour evolution (evolve-schema, iterative GEPA, compose-evolution, evolution gates, orchestrator and deploy), improvement and correction detection, AgentLearning, the eval-dataset builder, optimization-capture and the agent_insights tool. Secret detection moves from eval-dataset to secret-patterns. The LLM wiring keeps only the Haiku adapter and judge call used by skill audit and hygiene, so @ax-llm/ax is now declared by agent instead of server. - server: delete /api/evolution/*, the evolution and optimizer services, GEPA expansion of the first chat message, the prompt_optimization and monthly_assessment jobs, the idle-session reviewer and its session-reviewer persona, prompt injection of past corrections and thumbs-down recorded as correction signals. Existing job rows of the removed types are ignored, not deleted. - core: delete OptimizationLogStore; stop re-exporting the improvement signal and evolution run stores. - web: delete the Evolution screen and the two job types in the automation editor. - delete packages/optimizer. Also logs UF-027 (self-learning loops read data nothing collects) and UF-028 (the Settings prompt-shape choice is ignored by chat).
This commit is contained in:
@@ -5,7 +5,6 @@ import { buildActiveBehavioralSpec } from './behavioral-spec.js';
|
||||
|
||||
/** The resolved behavioral-spec shape returned by `buildActiveBehavioralSpec`. */
|
||||
export type BehavioralSpec = ReturnType<typeof buildActiveBehavioralSpec>;
|
||||
import { loadBehavioralSpecOverrides } from './evolution-deploy.js';
|
||||
import { loadCustomPersonas } from './custom-personas.js';
|
||||
import type { AgentPersona } from './personas.js';
|
||||
|
||||
@@ -16,16 +15,8 @@ export interface LoadedSkill {
|
||||
|
||||
/**
|
||||
* Raw disk read of `{waggleDir}/system-prompt.md`. Returns null if missing
|
||||
* or empty.
|
||||
*
|
||||
* **Prefer `loadSystemPromptWithOverrides(waggleDir)` for runtime use.** This
|
||||
* bare reader exists for tools that legitimately need the unmerged file
|
||||
* content (editor views, migration scripts). Runtime agent code that loads
|
||||
* just this and nothing else will silently miss any deployed
|
||||
* behavioral-spec or persona evolution, since those are stored in separate
|
||||
* override files under the same `waggleDir`.
|
||||
*
|
||||
* H-09 G2 — see `loadSystemPromptWithOverrides` for the composed path.
|
||||
* or empty. Runtime code should prefer `loadSystemPromptWithOverrides`, which
|
||||
* also returns the behavioral spec and custom personas.
|
||||
*/
|
||||
export function loadSystemPrompt(waggleDir: string): string | null {
|
||||
const filePath = path.join(waggleDir, 'system-prompt.md');
|
||||
@@ -34,22 +25,19 @@ export function loadSystemPrompt(waggleDir: string): string | null {
|
||||
return content || null;
|
||||
}
|
||||
|
||||
/** Bundle of every override-aware input the agent runtime needs. */
|
||||
/** Bundle of every prompt input the agent runtime needs. */
|
||||
export interface ComposedSystemPrompt {
|
||||
/** User's literal system-prompt.md content, or null if absent. */
|
||||
userPromptMd: string | null;
|
||||
/** The active behavioral spec — base + any deployed section overrides. */
|
||||
/** The active behavioral spec. */
|
||||
behavioralSpec: BehavioralSpec;
|
||||
/** Custom personas discovered in `waggleDir/personas/*.json`. */
|
||||
customPersonas: AgentPersona[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Override-aware composition: reads `system-prompt.md`, merges deployed
|
||||
* behavioral-spec section overrides from
|
||||
* `{waggleDir}/evolution-deploy/behavioral-spec/*.md`, and surfaces any
|
||||
* custom personas the user has added. Use this at agent startup so
|
||||
* deployed evolutions take effect at the next run.
|
||||
* Composes the runtime prompt inputs: reads `system-prompt.md`, builds the
|
||||
* behavioral spec and surfaces any custom personas the user has added.
|
||||
*
|
||||
* Callers typically pass the bundle to their orchestrator:
|
||||
*
|
||||
@@ -65,44 +53,11 @@ export interface ComposedSystemPrompt {
|
||||
*/
|
||||
export function loadSystemPromptWithOverrides(waggleDir: string): ComposedSystemPrompt {
|
||||
const userPromptMd = loadSystemPrompt(waggleDir);
|
||||
// loadBehavioralSpecOverrides is no-op on missing dir / malformed files.
|
||||
const overrides = loadBehavioralSpecOverrides(waggleDir);
|
||||
const behavioralSpec = buildActiveBehavioralSpec(overrides);
|
||||
const behavioralSpec = buildActiveBehavioralSpec();
|
||||
const customPersonas = loadCustomPersonas(waggleDir);
|
||||
return { userPromptMd, behavioralSpec, customPersonas };
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup-time self-check. Call after composing the override-aware prompt
|
||||
* bundle to verify that deployed overrides on disk actually appear in the
|
||||
* active spec. Emits a structured console warning (never throws) if a
|
||||
* deployed section is present on disk but missing from the active spec —
|
||||
* that would indicate the caller is using the bare `loadSystemPrompt`
|
||||
* instead of the composed loader.
|
||||
*/
|
||||
export function assertOverridesReachActiveSpec(
|
||||
waggleDir: string,
|
||||
activeSpec: BehavioralSpec,
|
||||
): void {
|
||||
const overrides = loadBehavioralSpecOverrides(waggleDir);
|
||||
const missing: string[] = [];
|
||||
for (const [section, overrideText] of Object.entries(overrides)) {
|
||||
const live = (activeSpec as unknown as Record<string, string | undefined>)[section];
|
||||
if (!live || !live.includes(overrideText.slice(0, 24))) {
|
||||
missing.push(section);
|
||||
}
|
||||
}
|
||||
if (missing.length > 0) {
|
||||
|
||||
console.warn(
|
||||
`[prompt-loader] override-reach check failed — deployed sections on disk ` +
|
||||
`not present in active behavioral spec: ${missing.join(', ')}. ` +
|
||||
`This usually means the runtime is using loadSystemPrompt() instead of ` +
|
||||
`loadSystemPromptWithOverrides(). See prompt-loader.ts.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function loadSkills(waggleDir: string): LoadedSkill[] {
|
||||
const skillsDir = path.join(waggleDir, 'skills');
|
||||
if (!fs.existsSync(skillsDir)) return [];
|
||||
|
||||
Reference in New Issue
Block a user