feat(memory): show (fast) in sync output when hash matches

This commit is contained in:
Research Assistant 2026-05-18 22:29:53 +08:00
parent 48b564594c
commit 8fd1018cf2
2 changed files with 3 additions and 1 deletions

View file

@ -83,7 +83,8 @@ def run(args: argparse.Namespace) -> int:
try:
from paperforge.memory.builder import build_from_index
counts = build_from_index(vault)
print(f"memory: {counts.get('papers_indexed', 0)} papers indexed")
tag = " (fast)" if counts.get("hash_match") else ""
print(f"memory: {counts.get('papers_indexed', 0)} papers{tag}")
except Exception as e:
print(f"memory: deferred ({e})")

View file

@ -155,6 +155,7 @@ def build_from_index(vault: Path) -> dict:
if cached and cached[0] == canonical_hash and stored_version == CURRENT_SCHEMA_VERSION:
papers_count = conn.execute("SELECT COUNT(*) FROM papers").fetchone()[0]
conn.close()
logger.info("Index unchanged, skipping memory rebuild (%s papers)", papers_count)
return {
"papers_indexed": papers_count,
"db_path": str(db_path),