/** * ChangeManager — autonomous code change lifecycle management. * * Manages the full lifecycle of proposed code changes: * PROPOSE → REVIEW (consensus) → APPLY → VERIFY → (ROLLBACK on failure) * * The manager does NOT write files directly — it publishes change nodes to the * KnowledgeGraph and uses the ConsensusProtocol for approvals. File mutations * are performed by agents acting on approved change nodes. * * Quality gates run automatically before approval: * - Tests must pass (or be explicitly waived) * - TypeScript must compile * - No new critical/high security findings * - Lint must pass (or be explicitly ignored) * * Rollback: on failure detection, the manager can propose a rollback change * that reverses the applied change. Rollback changes also go through consensus. * * @module change-manager */ import type { ChangeNode, QualityGateResult } from './knowledge-graph.js'; import type { KnowledgeGraph } from './knowledge-graph.js'; import type { ConsensusProtocol } from './consensus-protocol.js'; import type { FleetBus } from './fleet-bus.js'; export interface ChangeFile { path: string; action: 'create' | 'modify' | 'delete'; /** For modify: unified diff string */ diff?: string; /** For create/modify: full file content */ content?: string; } export interface ChangeProposal { title: string; description: string; files: ChangeFile[]; proposedBy: string; satisfiesGoals: string[]; tags: string[]; /** Quality gate waivers (e.g., ['no-tests', 'lint-errors']) */ waivers?: string[]; /** Skip consensus vote (for automated/internal refactors only) */ skipVote?: boolean; } export interface ApplyResult { changeId: string; success: boolean; appliedAt: string; filesTouched: string[]; verificationResult?: QualityGateResult; rollbackChangeId?: string | undefined; error?: string | undefined; } export interface RollbackResult { originalChangeId: string; rollbackChangeId: string; success: boolean; rolledBackAt: string; error?: string; } /** Quality checks performed before applying a change. */ export interface QualityGateChecks { runTests: boolean; runTypecheck: boolean; runLint: boolean; runSecurityScan: boolean; checkTestCoverage: boolean; minCoveragePercent?: number; } export interface ChangeManagerOptions { graph: KnowledgeGraph; consensus: ConsensusProtocol; fleet?: FleetBus | undefined; checks?: Partial | undefined; } /** * Default quality gate: tests + typecheck + security scan. * Lint and coverage are informational warnings, not blockers. */ export declare const DEFAULT_QUALITY_CHECKS: QualityGateChecks; /** * ChangeManager orchestrates the full change lifecycle. * * ## Workflow * ``` * propose() → knowledge graph (proposed) * → consensus.vote() (approved/rejected) * → apply() → knowledge graph (applied) * → verify() → on failure: proposeRollback() * ``` */ export declare class ChangeManager { private readonly graph; private readonly consensus; private readonly fleet?; private readonly checks; /** Track applied changes for rollback lookup. */ private readonly appliedChanges; constructor(opts: ChangeManagerOptions); /** * Propose a new code change. Creates a ChangeNode in the knowledge graph. * Does NOT automatically initiate voting — call `submitForReview()` for that. */ propose(input: ChangeProposal): Promise; /** * Submit an approved change for application. * Returns the change node — actual file mutations are performed by agents * acting on this node's data from the knowledge graph. */ submitForReview(changeId: string): Promise; /** * Apply an approved change. Updates the change node to 'applied'. * Agents should watch for 'applied' status and perform the actual file mutations. */ markApplied(changeId: string, appliedAt: string): Promise; /** * Mark a change as applied and trigger rollback for any satisfied goal * that turns out to be broken. */ markAppliedWithVerification(changeId: string, verify: () => Promise): Promise; /** * Propose a rollback for an applied change. Creates a new change that * reverses the original. Goes through full consensus. */ proposeRollback(appliedChangeId: string, reason: string): Promise; /** * Mark a change as rolled back. */ markRolledBack(changeId: string, rolledBackAt: string): Promise; getPendingReviews(): ChangeNode[]; getAppliedChanges(): ChangeNode[]; getChange(id: string): ChangeNode | undefined; getChangesForGoal(goalId: string): ChangeNode[]; /** * Run quality gate checks. This is informational — actual test/lint/typecheck * execution is done by agents spawned for this purpose. This method stores * the result in the change node. */ private _runQualityGate; /** * Update quality gate result for a change. Called by verify agents * after running their checks. */ updateQualityGate(changeId: string, checkName: string, result: { passed: boolean; detail?: string; }): Promise; private _emit; } //# sourceMappingURL=change-manager.d.ts.map