daemon: per-job output log, daily dedup, absolute timestamps
- Jobs report progress via ctx.log_line(), building a rolling output trail visible in `poc-memory daemon status` (last 5 lines per task). - consolidate_full_with_progress() takes a callback, so each agent step ([1/7] health, [2/7] replay, etc.) shows up in the status display. - Persist last_daily date in daemon-status.json so daily pipeline isn't re-triggered on daemon restart. - Compute elapsed from absolute started_at timestamps instead of stale relative durations in the status file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cc7943cb50
commit
b6c70c7734
2 changed files with 98 additions and 35 deletions
|
|
@ -23,7 +23,15 @@ fn log_line(buf: &mut String, line: &str) {
|
|||
}
|
||||
|
||||
/// Run the full autonomous consolidation pipeline with logging.
|
||||
/// If `on_progress` is provided, it's called at each significant step.
|
||||
pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
||||
consolidate_full_with_progress(store, &|_| {})
|
||||
}
|
||||
|
||||
pub fn consolidate_full_with_progress(
|
||||
store: &mut Store,
|
||||
on_progress: &dyn Fn(&str),
|
||||
) -> Result<(), String> {
|
||||
let start = std::time::Instant::now();
|
||||
let log_key = format!("_consolidate-log-{}",
|
||||
store::format_datetime(store::now_epoch()).replace([':', '-', 'T'], ""));
|
||||
|
|
@ -36,6 +44,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 1: Plan ---
|
||||
log_line(&mut log_buf, "--- Step 1: Plan ---");
|
||||
on_progress("planning");
|
||||
let plan = neuro::consolidation_plan(store);
|
||||
let plan_text = neuro::format_plan(&plan);
|
||||
log_line(&mut log_buf, &plan_text);
|
||||
|
|
@ -103,6 +112,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
};
|
||||
|
||||
log_line(&mut log_buf, &format!("\n{}", label));
|
||||
on_progress(&label);
|
||||
println!("{}", label);
|
||||
|
||||
// Reload store to pick up changes from previous agents
|
||||
|
|
@ -145,6 +155,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
let msg = format!(" Done: {} lines → {}", response.lines().count(), report_key);
|
||||
log_line(&mut log_buf, &msg);
|
||||
on_progress(&msg);
|
||||
println!("{}", msg);
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +164,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 3: Apply consolidation actions ---
|
||||
log_line(&mut log_buf, "\n--- Step 3: Apply consolidation actions ---");
|
||||
on_progress("applying actions");
|
||||
println!("\n--- Applying consolidation actions ---");
|
||||
*store = Store::load()?;
|
||||
|
||||
|
|
@ -171,6 +183,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 3b: Link orphans ---
|
||||
log_line(&mut log_buf, "\n--- Step 3b: Link orphans ---");
|
||||
on_progress("linking orphans");
|
||||
println!("\n--- Linking orphan nodes ---");
|
||||
*store = Store::load()?;
|
||||
|
||||
|
|
@ -179,6 +192,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 3c: Cap degree ---
|
||||
log_line(&mut log_buf, "\n--- Step 3c: Cap degree ---");
|
||||
on_progress("capping degree");
|
||||
println!("\n--- Capping node degree ---");
|
||||
*store = Store::load()?;
|
||||
|
||||
|
|
@ -192,6 +206,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 4: Digest auto ---
|
||||
log_line(&mut log_buf, "\n--- Step 4: Digest auto ---");
|
||||
on_progress("generating digests");
|
||||
println!("\n--- Generating missing digests ---");
|
||||
*store = Store::load()?;
|
||||
|
||||
|
|
@ -206,6 +221,7 @@ pub fn consolidate_full(store: &mut Store) -> Result<(), String> {
|
|||
|
||||
// --- Step 5: Apply digest links ---
|
||||
log_line(&mut log_buf, "\n--- Step 5: Apply digest links ---");
|
||||
on_progress("applying digest links");
|
||||
println!("\n--- Applying digest links ---");
|
||||
*store = Store::load()?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue