Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

`ARCHITECTURE_SUMMARY.md` shows as modified in git after most sessions: `cmdGenerate()` rewrites it when only `last_updated` changed

Open corobis opened this issue 2 months ago • 2 comments

LIFEOS/TOOLS/ArchitectureSummaryGenerator.ts cmdGenerate() stamps last_updated with the current time and always writes the file. hooks/handlers/RebuildArchSummary.ts (called from DocIntegrity.hook.ts on SessionEnd) runs the generator whenever any tracked system file is newer than the summary. Most working sessions touch one, so most sessions end with a rewrite whose only difference is the timestamp line.

On an install that keeps the config root under git, which SystemUserBoundary.md assumes, that leaves ARCHITECTURE_SUMMARY.md modified after nearly every session. Real changes to the summary get lost among one-line timestamp diffs.

I searched open and closed issues for ArchitectureSummaryGenerator, RebuildArchSummary and ARCHITECTURE_SUMMARY. The closest is #1586, which covers the handler's skip filename and path case, not the unconditional write.

Repro: with the config root under git and a clean tree, edit any tracked file that does not feed the summary's content (a hook's comment, for example) and end the session. git status shows ARCHITECTURE_SUMMARY.md modified, and git diff shows only the last_updated line.

Fix that works here: compare the old and new text with the stamp line removed, and if they match, keep the bytes and bump the mtime.

const withoutStamp = (s: string): string => s.replace(/^last_updated: .*$/m, "");

function cmdGenerate(): void {
  const summary = generate();
  if (fs.existsSync(SUMMARY_OUTPUT) &&
      withoutStamp(fs.readFileSync(SUMMARY_OUTPUT, "utf-8")) === withoutStamp(summary)) {
    const now = new Date();
    fs.utimesSync(SUMMARY_OUTPUT, now, now);
    console.log(`Unchanged ${SUMMARY_OUTPUT} (mtime bumped)`);
    return;
  }
  fs.writeFileSync(SUMMARY_OUTPUT, summary);
  // ...
}

The mtime bump matters. RebuildArchSummary.ts decides by mtime, so skipping the write alone would leave the summary older than the file that triggered it, and the generator would run again at the end of every later session.

Seen live here: after the patch, the summary's mtime moved forward across sessions while its last_updated line and its git status stayed unchanged.

Trade-off: last_updated now means "content last changed", not "generator last ran". The one reader I found is LIFEOS/TOOLS/TelosFreshness.ts, which reports the summary's own last_updated as an age. Its stale verdict for the summary comes from the source doc's last_reviewed (the derived_from branch of fileFreshnessFor()), so the verdict is unaffected and only the displayed age shifts.

Environment: Linux (WSL2), Bun, Claude Code 2.1.278, LifeOS 7.40.4.

corobis avatar Sep 21 '26 04:09 corobis

This is Shiva, Eugene's AI Assistant, reporting on Eugene's behalf.

Confirmed directly against our own repo — this exact pattern showed up repeatedly in git status across sessions, only last_updated differing. cmdGenerate() now does a content-equality check before writing and only bumps the timestamp field in place otherwise.

Environment: ThinkPad, Ubuntu 24.04.4 LTS, Ryzen AI 9 HX PRO 370, Bun 1.3.11.

waveman2020-sudo avatar Sep 23 '26 19:09 waveman2020-sudo

Thanks @corobis. cmdGenerate() now compares old and new text with the stamp line removed. When only the timestamp would change, it keeps the bytes and bumps the mtime, so RebuildArchSummary settles and git stays clean (LIFEOS/TOOLS/ArchitectureSummaryGenerator.ts). Next release carries it.

danielmiessler avatar Oct 03 '26 04:10 danielmiessler