Skip to content

chore-shared-helper-duplication-hooks-services-2026-06-10: extract shared helpers#74

Merged
emp3thy merged 1 commit into
mainfrom
ralph/chore-shared-helper-duplication-hooks-services-2026-06-10
Jun 13, 2026
Merged

chore-shared-helper-duplication-hooks-services-2026-06-10: extract shared helpers#74
emp3thy merged 1 commit into
mainfrom
ralph/chore-shared-helper-duplication-hooks-services-2026-06-10

Conversation

@emp3thy

@emp3thy emp3thy commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Extracts the session-ID fallback, default clock, spool-dir, and safe-timestamp helpers — previously copy-pasted across hooks, services, storage, and the MCP layer (7 session-ID copies, 8 clock copies) — into a new lightweight better_memory/_common.py. The module is pure stdlib with no intra-package imports so hooks can import it without paying for SQLite/boto3/config at invocation time; a test guards that property. All copies replaced with imports; the 'duplicated to avoid cross-module import' workaround in session_close.py is gone.

Closes chore-shared-helper-duplication-hooks-services-2026-06-10.

Test plan:

  • pytest --ignore=tests/ui (playwright not installed): 946 passed, 17 skipped
  • New tests/test_common.py: helper behaviour + lightweight-import guard
  • ruff check on changed files: only 6 pre-existing E501s also present on HEAD

PBI: .ralph/current/chore-shared-helper-duplication-hooks-services-2026-06-10 on ralph-queue.

🤖 Generated with Claude Code

…-06-10 — extract shared session-id/clock/spool/timestamp helpers

Create better_memory/_common.py (pure stdlib, no intra-package imports so
hooks can import it cheaply) housing env_session_id, get_session_id,
default_clock, resolve_home, default_spool_dir, and safe_timestamp.
Replace the 7 drifting session-ID fallback copies, 8 _default_clock
copies, and the duplicated _default_spool_dir/_safe_timestamp helpers in
hooks with imports; delete the 'duplicated to avoid cross-module import'
workaround in session_close.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Claude BugBot Analysis

No bugs found. The PR is a clean refactoring that centralizes duplicated utility functions (_default_clock, _default_spool_dir, _safe_timestamp, session-ID resolution) into a new better_memory._common module. All call sites are correctly updated, removed import os/import uuid/from pathlib import Path statements have no remaining usages in the affected files, the test monkeypatch target was correctly renamed from _default_spool_dir to default_spool_dir, and the extracted functions are behaviorally equivalent to the originals they replace.

No bugs were detected in this PR.

@emp3thy
emp3thy merged commit 2653a2d into main Jun 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant