Skip to content

fix(cli)!: rename mm session start --json key stale_ended → auto_ended#545

Merged
memtomem merged 2 commits intorelease/v0.1.33from
feat/session-json-auto-ended-rename
Apr 29, 2026
Merged

fix(cli)!: rename mm session start --json key stale_ended → auto_ended#545
memtomem merged 2 commits intorelease/v0.1.33from
feat/session-json-auto-ended-rename

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented Apr 29, 2026

Summary

  • Rename mm session start --json output key stale_endedauto_ended so the CLI surface matches the DB metadata's existing auto_ended flag and stops calling cross-agent forced-ends "stale".
  • The list groups two reason classes — cutoff-based stale cleanup (--auto-end-stale) and cross-agent forced-end inside --idempotent. Per-row distinction stays on sessions.metadata.reason (stale or cross_agent).
  • Text mode preserves the per-reason split that JSON intentionally drops: Auto-ended N session(s) (X stale, Y cross-agent). Pinned by a new test_text_mode_breakdown_by_reason.

Why this is safe to land as-is — base retargeted to release/v0.1.33

The stale_ended shape only appeared on main after v0.1.32 (PR #543, b8a5673, 2026-04-29) and was never tagged into a published PyPI release. Base retargeted from main to release/v0.1.33 so the rename ships as part of the v0.1.33 cut — stale_ended therefore never reaches PyPI and there is no published API to break. Plugin's own hooks.json calls the CLI in text mode, not --json, so the rename has zero impact on the shipped Claude Code SessionStart recipe.

Followup tracker

RFC memtomem-docs#24 listed two open questions deferred to "telemetry-then-decide":

  • Item 3 (this PR) — JSON / DB key vocabulary alignment. Decided semantically: rename now, costs are bounded.
  • Item 2 (still deferred) — JSON entry shape (flat list vs split arrays vs [{id, reason}]). Needs a distribution measurement on sessions.metadata.reason after a few weeks of hook usage to know whether cross-agent ends are common enough to justify schema enrichment. The reason field is already persisted on every auto-end (session_cmd.py:215, 245), so no extra telemetry plumbing is required when the data window is up.

Review polish addressed

  • Text-mode information loss (called out in review): the rename initially dropped the "stale" hint from the human-mode print line. Polish commit b511dcf adds per-reason counters at the two append sites and renders (N stale, M cross-agent) whenever either fired. JSON shape unchanged.

Test plan

  • uv run pytest packages/memtomem/tests/test_session_cli.py -m "not ollama" — 27 passed (26 prior + new breakdown test).
  • uv run pytest packages/memtomem/tests -m "not ollama" -k "session or hook" — all pass.
  • uv run ruff check and uv run ruff format --check clean.
  • Manual: mm session start --idempotent --auto-end-stale 24h --agent-id claude-code --json returns auto_ended key.

🤖 Generated with Claude Code

pandas-studio and others added 2 commits April 29, 2026 14:16
The JSON list returned by `mm session start --json` carries UUIDs from
two distinct paths: cutoff-based stale cleanup driven by
`--auto-end-stale`, and the cross-agent forced-end inside `--idempotent`
when the active session belongs to a different `--agent-id`. The
previous key `stale_ended` only describes the first; cross-agent ends
are not stale, just superseded.

The DB metadata already disambiguates them via `metadata.reason`
(`stale` vs `cross_agent`) — this commit aligns the JSON key with the
metadata's existing `auto_ended` flag so the CLI surface and the
storage record use one vocabulary. Drops the misleading "stale" word
from the text-mode print line for the same reason. The shape only
shipped post-v0.1.32 (PR #543, b8a5673) and never went out in a tagged
release, so no released hook caller depends on the old key.

Followup item 2 from RFC `memtomem-docs#24` (per-entry `reason` shape:
flat vs split vs dict-enriched) stays deferred — that decision needs a
distribution measurement on `sessions.metadata.reason` after a few
weeks of real hook usage. The per-row `reason` is already on disk, so
no telemetry plumbing is required for that future analysis.

Co-Authored-By: Claude <[email protected]>
Per PR review: ``mm session start`` text mode previously printed
``Auto-ended N session(s)`` after the rename, dropping the "stale"
hint that the prior wording carried. JSON consumers don't lose
anything (``sessions.metadata.reason`` carries the per-row split),
but a human running the command by hand can't tell whether the
auto-ends came from cutoff age or from cross-agent forced-ends.

Track per-reason counters at the two append sites — both code paths
already know which reason they're handling — and emit a
``(N stale, M cross-agent)`` suffix when either is non-zero. The
JSON shape (flat list of UUIDs) is untouched so the existing
``test_json_output_shape`` pin still holds.

New test ``test_text_mode_breakdown_by_reason`` exercises both
paths firing in the same call and pins the two count fragments,
since this is the only place the per-reason split is now surfaced
without going through SQL.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem changed the base branch from main to release/v0.1.33 April 29, 2026 05:30
@memtomem memtomem merged commit 146eaed into release/v0.1.33 Apr 29, 2026
7 checks passed
@memtomem memtomem deleted the feat/session-json-auto-ended-rename branch April 29, 2026 05:33
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants