fix(session-cursor): trySave + set guard + temp-mode hardening (v1.4.1) #31

Merged
hongming merged 2 commits from chore/cursor-store-nits into main 2026-05-29 00:26:15 +00:00
Owner

Non-blocking review follow-ups from #30 (session-cursor). Additive, v1.4.1.

  • trySave(onError?) — never-throwing save() wrapper for poll-tick callers; future adapters use this instead of re-implementing the channel's try/catch.
  • set() empty/non-string guard — matches load()'s filter so in-memory state can't diverge from what survives save→load.
  • temp-mode hardening — save() clears a stale same-PID temp before writing, so a leftover temp's mode can't leak through rename (always a fresh 0o600 create).

Tests added for each (trySave true/false+onError, set-throws round-trip, stale-temp mode). npm test = 202 passed / 1 skipped. Build clean.

Non-blocking review follow-ups from #30 (session-cursor). Additive, v1.4.1. - **trySave(onError?)** — never-throwing save() wrapper for poll-tick callers; future adapters use this instead of re-implementing the channel's try/catch. - **set() empty/non-string guard** — matches load()'s filter so in-memory state can't diverge from what survives save→load. - **temp-mode hardening** — save() clears a stale same-PID temp before writing, so a leftover temp's mode can't leak through rename (always a fresh 0o600 create). Tests added for each (trySave true/false+onError, set-throws round-trip, stale-temp mode). `npm test` = 202 passed / 1 skipped. Build clean.
hongming added 1 commit 2026-05-29 00:17:26 +00:00
Non-blocking review follow-ups from molecule-mcp-server#30:
- trySave(onError?): never-throwing save() wrapper for poll-tick callers, so
  each adapter doesn't re-implement the try/catch (SSOT for the next adapter).
- set() rejects empty/non-string activityId, matching load()'s filter so the
  in-memory state can't diverge from what survives a save→load round-trip.
- save() clears a stale same-PID temp before writing: writeFileSync only
  applies `mode` on create, so writing over a leftover temp could leak a 0o644
  mode through the rename. Now always a fresh 0o600 create.

Additive; tests added for each. v1.4.1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hongming added the tier:low label 2026-05-29 00:17:27 +00:00
hongming added 1 commit 2026-05-29 00:24:43 +00:00
Adversarial review of this PR found two issues:
- The 1.4.0→1.4.1 version bump was a blind text replace that also flipped the
  `version` of two unrelated transitive deps (natural-compare, once) to a
  nonexistent 1.4.1, leaving the lockfile internally inconsistent. Redone as a
  precise JSON edit of only the root self-version.
- set() throwing on empty/non-string, combined with the channel's
  `void pollWorkspace` call site, could turn a (platform-pathological) empty
  activity id into a stuck-cursor replay loop. Changed to a silent no-op skip:
  same round-trip-consistency goal, no exception/abort path.
core-be approved these changes 2026-05-29 00:26:05 +00:00
core-be left a comment
Member

Reviewed. trySave + temp-mode-hardening are clean wins. Adversarial review caught two issues in the first cut (a blind version-bump corrupting natural-compare/once in the lockfile, and set() throwing being turned into a replay loop by the channel's void poll call site) — both fixed: lockfile is now a precise JSON root-only bump, set() is a silent skip-empty (no throw). npm ci consistent. Approve.

Reviewed. trySave + temp-mode-hardening are clean wins. Adversarial review caught two issues in the first cut (a blind version-bump corrupting natural-compare/once in the lockfile, and set() throwing being turned into a replay loop by the channel's void poll call site) — both fixed: lockfile is now a precise JSON root-only bump, set() is a silent skip-empty (no throw). npm ci consistent. Approve.
core-lead approved these changes 2026-05-29 00:26:06 +00:00
core-lead left a comment
Member

Confirmed the lockfile no longer mis-syncs transitive deps and skip-empty set() removes the abort-before-save risk while keeping the load round-trip total. Additive v1.4.1. Approve.

Confirmed the lockfile no longer mis-syncs transitive deps and skip-empty set() removes the abort-before-save risk while keeping the load round-trip total. Additive v1.4.1. Approve.
hongming merged commit 6673d4692d into main 2026-05-29 00:26:15 +00:00
Sign in to join this conversation.
No Reviewers
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-mcp-server#31