How the ai-memory Auto-Improvement Scheduler Approves Wiki Edits Without Human Review
The ai-memory auto-improvement scheduler bypasses human review when require_approval is set to false, automatically staging proposals and committing them to the wiki using a dedicated system actor.
The ai-memory project implements an autonomous content improvement pipeline that can operate without manual intervention. When the scheduler runs inside the server process (ai-memory serve), it evaluates completed sessions, generates improvement proposals, and can immediately apply them to the wiki. This article explains the exact mechanism that enables automatic approval, with reference to the Rust source code in the akitaonrails/ai-memory repository.
How Auto-Approval Is Configured
The scheduler's behavior is controlled by the require_approval boolean in ScheduledAutoImproveSettings. This flag determines whether proposals enter a pending queue for human review or proceed directly to publication.
When require_approval is false, the scheduler executes the full approval pipeline automatically. When true, it stops after staging and leaves proposals for later manual review.
let settings = ScheduledAutoImproveSettings {
review: AutoImproveReviewConfig::default(),
require_approval: false, // enables auto-approval
min_session_age_secs: 0,
max_sessions_per_tick: 10,
};
The configuration is evaluated per-tick in auto_improve_schedule.rs at lines 344-355.
The Four-Stage Auto-Approval Pipeline
1. Staging Proposals After Session Review
After analyzing a completed session, the scheduler calls stage_auto_improve_run_for_owner on the store. This creates one or more NewAutoImproveProposal records and prepares them for the wiki.
In crates/ai-memory-consolidate/src/auto_improve_schedule.rs (lines 88-120), the staging logic:
- Identifies applicable sessions for the current tick
- Generates improvement proposals via LLM analysis
- Associates each proposal with its owner and session context
Staging does not modify the wiki yet—it only prepares the data structures.
2. Writing Side-Car Files to the Wiki
Each staged proposal receives a side-car file through wiki.write_auto_improve_sidecar. These files contain the pending changes in a structured format that the wiki can later apply.
From auto_improve_schedule.rs (lines 330-337):
// After staging, write side-car for each proposal
for proposal in &proposals {
wiki.write_auto_improve_sidecar(&proposal).await?;
}
Side-cars serve as intermediate storage, allowing the system to track proposals independently of the main content.
3. The Approval Decision Point
Before processing each proposal, the scheduler checks the configuration flag:
if ctx.settings.require_approval {
// proposals stay pending for a human admin
pending += 1;
continue;
}
When require_approval is false, this branch is skipped and execution continues to automatic approval.
4. Executing Auto-Approval via the Wiki Actor
The scheduler calls wiki.approve_auto_improve_proposal with a dedicated system actor: "auto_improve_scheduler_auto_approve". This actor name ensures all automatic changes remain auditable in the project history.
In crates/ai-memory-wiki/src/wiki.rs, the approval method (lines 118-127) performs three critical operations:
- Loads proposal details from the side-car and constructs a complete markdown page with front-matter, body content, and cross-links
- Commits the page through the standard write pipeline using
replace_file_with_rollback_snapshotfor atomic updates - Records approval in the database via the store's
approve_auto_improve_proposaloperation
The core approval logic with rollback protection:
let result = {
let _guard = self.mutation_lock.write().await;
self.ensure_project_workspace(ws, proj).await?;
let abs = self.abs_path(ws, proj, &path);
let installed = replace_file_with_rollback_snapshot(&abs, emitted.as_bytes())?;
self.writer.approve_auto_improve_proposal(ApproveAutoImproveProposal {
workspace_id: ws,
project_id: proj,
proposal_id,
page,
actor, // "auto_improve_scheduler_auto_approve"
author_id,
checkpoint: None,
}).await?
};
This guarantees that wiki edits are atomic—even if the database update fails, the filesystem can be rolled back to its previous state.
Key Implementation Files
| File | Purpose |
|---|---|
crates/ai-memory-consolidate/src/auto_improve_schedule.rs |
Scheduler orchestration; stages proposals and decides auto-approval based on require_approval |
crates/ai-memory-wiki/src/wiki.rs |
approve_auto_improve_proposal implementation; applies proposals to wiki with rollback safety |
crates/ai-memory-store/src/writer.rs |
Persists approval results via ApproveAutoImproveProposal operations |
docs/auto-improvement-loop.md |
Documents the require_approval setting and overall auto-improvement architecture |
Running the Scheduler with Auto-Approval Enabled
To enable fully automatic wiki improvement:
let outcome = run_auto_improve_scheduler_tick(
&reader, &writer, &wiki, &llm, &settings,
).await?;
println!("Approved {} proposals", outcome.approved);
With require_approval: false, the outcome.approved count reflects proposals immediately committed to the wiki. No human operator receives notifications or approval requests.
Summary
require_approval: falseinScheduledAutoImproveSettingsdisables the human review queue- Proposals are staged, written to side-cars, then automatically approved in a single tick
- Atomic commits via
replace_file_with_rollback_snapshotensure data integrity - Dedicated actor name (
auto_improve_scheduler_auto_approve) preserves auditability - All logic resides in
auto_improve_schedule.rsandwiki.rsas implemented inakitaonrails/ai-memory
Frequently Asked Questions
What happens if require_approval is true?
Proposals accumulate as pending side-car files. A human administrator must later review each proposal through the wiki interface and manually trigger approval. The scheduler skips the approve_auto_improve_proposal call and increments a pending counter instead.
Can auto-approved changes be reverted?
Yes. The wiki uses replace_file_with_rollback_snapshot during every commit, which preserves the previous file state. Additionally, the store records the approval with checkpoint metadata, enabling administrative rollback through the standard wiki history features.
Is the auto-approval actor distinguishable from human edits?
Yes. The scheduler explicitly uses the actor string "auto_improve_scheduler_auto_approve" for all automatic approvals. This appears in page metadata and audit logs, making automated changes immediately identifiable compared to human-authored edits.
Does auto-approval work with all content types?
The scheduler evaluates proposals against the review rules defined in AutoImproveReviewConfig. While the approval mechanism itself is content-agnostic, the staging step may filter out proposals that don't meet quality thresholds—regardless of the require_approval setting.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →