Repository navigation
Fix concurrent session clocks and prepare 0.2.1 - #15
Conversation
|
OpenRouter review posted ( |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: issues
Scope: full-pr (full-pr)
Mode: initial
Commit: a84cfd150c9f3e9099fb5c14e1a7f704cb7478f6
Judge: openai/gpt-5.6-luna
Cost: $0.1749 (lanes $0.1712 + judge $0.0037)
Lanes
openai/gpt-6.1-sol: ok (1 finding(s), 46.0s, 110624+1561 tokens (74863 cached), 4 tool round(s), via Azure, $0.12)z-ai/glm-5.3-flash: ok (7 finding(s), 243.1s, 626296+34984 tokens (527616 cached), 13 tool round(s), via KT, $0.0475)
Findings
🔵 Issue 1 — Stale linked project-plan release status
docs/PROJECT_PLAN.md:5 · nit · identified by openai/gpt-6.1-sol
Readers following the README's project-plan link receive a conflicting release status: the README now identifies 0.2.0 as published and 0.2.1 as the unpublished candidate, while the plan's current-status section still identifies 0.1.1 as published and 0.2.0 as merely prepared.
Update the plan's status paragraph alongside the release metadata so consumers and maintainers can distinguish the published version from the pending patch consistently.
I checked README.md, RELEASE_NOTES.md, and docs/PROJECT_PLAN.md. The conflicting paragraph is under the plan's current Status heading, rather than in its historical release account.
🟠 Issue 2 — Concurrent-touch fix only holds for one monotonic clock; cross-host clock skew still deletes live sessions
packages/sessions/src/index.ts:551 · risk · identified by z-ai/glm-5.3-flash
Host A's clock running 30s fast touches lastSeenAt to 12:00:30 while true time is 12:00:00. Host B (correct clock) then reads that row at 12:00:05: isLive requires lastSeen <= at, so it sees a "future" idle anchor, takes the !isLive branch, and deleteIfUnchanged succeeds because the version is unchanged — a live in-use session is deleted and the user is signed out. The same applies to purgeExpired (line 715). Observing the local clock after the read (this PR's fix) cannot close this, because the skew lives in the stored value, not in when the clock is sampled.
The new guarantee as written is unscoped: README says the candidate fixes reads/sweeps "so concurrent touches do not delete live sessions", and RELEASE_NOTES.md says a concurrent read advancing the anchor no longer causes deletion. Both are true only when every writer shares one monotonic clock; for the realistic multi-host Azure Tables deployment the failure above still exists.
What I checked: isLive (single predicate, lastSeen <= at), both deleteIfUnchanged call sites, and the repo's own skew discussion (REVOCATION_GUARD_LEASE_MS comment, docs/PROJECT_PLAN.md) — that discussion covers the revocation guard only and accepts fail-closed behavior, so this may be an accepted posture rather than a defect; nothing I found documents the skew carve-out for session records, which is the proof gap. Pre-existing behavior, not a regression introduced by this diff, but the new docs overstate the guarantee's scope.
🔵 Issue 3 — Published v0.2.1 release body will verbatim say "Unpublished patch candidate"
RELEASE_NOTES.md:1 · nit · identified by z-ai/glm-5.3-flash
If this file is merged as-is and the release is cut per docs/RELEASING.md, the permanent GitHub release for v0.2.1 will contain the heading "# @pegma/sessions v0.2.1 candidate" and the sentence "Unpublished patch candidate for concurrent session reads and expiry sweeps" — both false the moment the release exists.
docs/RELEASING.md line 143 passes the whole file straight through: gh release create v0.2.1 --verify-tag ... --notes-file RELEASE_NOTES.md, and the procedure calls this the "reviewed release notes" with no editing step at tag time. The body also duplicates the entire v0.2.0 section into the v0.2.1 release notes (the v0.2.0 release's own notes were a single section).
What I checked: RELEASE_NOTES.md content (lines 1–19 are candidate-scoped wording), the --notes-file command in docs/RELEASING.md, and the release scripts/tests — nothing rewrites or sections the notes at publish time.
🔵 Issue 4 — README "unpublished 0.2.1 patch candidate" paragraph has no process step that ever flips it
README.md:20 · nit · identified by z-ai/glm-5.3-flash
After v0.2.1 is tagged and published, README.md will still tell readers the fix is "The unpublished 0.2.1 patch candidate" while npm serves 0.2.1 — the exact class of staleness this PR itself just repaired one paragraph up (the IMPORTANT block previously claimed "published as 0.1.0" throughout the 0.2.0 window, i.e. the published-version line was already one release stale before this change).
The release procedure in docs/RELEASING.md instructs updating "the root, workspace, and lockfile versions together and adds reviewed release notes" — it never mentions the README published-version/unpublished-candidate lines, so nothing in the process reminds the maintainer to update them.
What I checked: README.md (both statements), docs/RELEASING.md's release-procedure checklist, and git-evidenced prior behavior via the diff context showing the 0.1.0→0.2.0 correction happening only now.
🔵 Issue 5 — docs/PROJECT_PLAN.md status section not updated by the 0.2.1 bump
docs/PROJECT_PLAN.md:5 · nit · identified by z-ai/glm-5.3-flash
The plan's Status section still reads "@pegma/sessions@0.1.1 is published; ... 0.2.0 is prepared". After this PR the repository states three different version stories: README says 0.2.0 is published plus a 0.2.1 candidate, the manifests say 0.2.1, and PROJECT_PLAN says 0.1.1 published / 0.2.0 merely prepared.
A reader using the plan (which README explicitly links to as "the model, the design decisions, and the delivery phases") gets the wrong published version, and the drift compounds each release since the version-bump checklist in docs/RELEASING.md doesn't list this file.
What I checked: docs/PROJECT_PLAN.md lines 5–16 (untouched by this diff), README.md, both package.json files, and grep for 0.2.0/0.1.0 across the repo.
🔵 Issue 6 — New pause tests release the suspended storage call outside try/finally, so a future mid-test failure hangs instead of failing
packages/sessions/src/index.test.ts:343 · nit · identified by z-ai/glm-5.3-flash
In "observes expiry at the default clock after the awaited session read" and "preserves explicit read and sweep instants after awaited storage", paused.release() is a plain statement after await paused.entered (lines 342–343 and the matching spot in the explicit-instant test). The two overlapping-read tests above them correctly wrap the interleaving in try { ... } finally { paused.release(); }.
Failure scenario: someone later inserts an assertion between await paused.entered and paused.release() in tests 3 or 4 (a natural place to check intermediate state). If it fails, the armed getVersioned never resumes, the pending get never settles, and the suite reports a 30s testTimeout instead of the real assertion error — on the Azurite backend that also leaves a leaked in-flight request against the shared global Azurite instance.
What I checked: all four new tests' structure in index.test.ts; nothing else in the suite resumes an armed pause.
🔵 Issue 7 — No regression test pinning the sweep's post-list expiry deletion
packages/sessions/src/index.test.ts:303 · nit · identified by z-ai/glm-5.3-flash
Observing the default sweep clock after the list snapshot (packages/sessions/src/index.ts:715) changes two behaviors: the overlap fix the new test pins (live record touched during the awaited list is kept), and a second unpinned behavior — a record that expires during the awaited listVersioned is now purged (observed at >= expiresAt), where the old entry-sampled clock kept it. Nothing exercises that second case: every other purgeExpired call in the suite passes an explicit now, and the only default-clock sweep test uses a record that stays live.
Failure scenario: a future change "fixes" perceived over-deletion by sampling now per record or before the list; the unpinned post-list expiry deletion silently reverts and no test fails, unlike the get side which has the dedicated "observes expiry at the default clock after the awaited session read" case.
What I checked: the full test file — the sweep tests at lines 303–326 and every other purgeExpired usage (all explicit now except the overlap test and the new null case).
🔵 Issue 8 — Default clock is no longer consulted at all on the missing/malformed-record and empty-list paths
packages/sessions/src/index.ts:545 · nit · identified by z-ai/glm-5.3-flash
Previously now = clock.now() ran at get entry unconditionally, so even get of an unknown id, a kind-mismatched row, or purgeExpired over an empty partition cost exactly one clock observation. Now the observation only happens after a versioned record is actually present (line 551) and after a non-empty list snapshot is iterated (line 715).
Concrete cost: a host wrapping Clock for metrics/audit sees zero clock reads for cache-miss reads, and a deliberately throwing test clock no longer throws on those paths — a behavior change the release notes don't mention (they only describe when the observation happens, not that it became conditional). The interface doc "An omitted now is observed after the initial storage read" also reads as unconditional, but for a missing record no observation ever occurs.
What I checked: get (lines 541–551) and purgeExpired (lines 711–715) control flow, the interface JSDoc, and the test suite — no test or doc asserts clock-call counts, so this is unverifiable either way from the repo; reported as an undocumented observable change rather than a defect.
|
Fixed in b317822. r1-1 The project plan records the published 0.2.0 dependency checkpoint and 0.2.1 behavior, with authoritative publication links. r1-5 The same project-plan status correction addresses this duplicate finding. r1-8 The default clock observation now follows getVersioned and precedes the missing-record branch. New tests check missing-record and empty-sweep clock counts, including explicit-time calls. The sweep already observed empty lists. Both Node22 and24 passed83 tests with zero skips, formatting, types, release checks and clean pack/import validation. |
There was a problem hiding this comment.
OpenRouter pull-request review
Verdict: clean
Scope: full-pr (full-pr)
Mode: verify
Commit: b3178224743c8d8f38dab6ca8d53ce6e1604e56f
Judge: openai/gpt-5.6-luna
Cost: $0.1531 (lanes $0.1530 + judge $0.0001) + at least $0.0836 (incomplete)
Lanes
openai/gpt-6.1-sol: ok (0 finding(s), 32.3s, 119176+1273 tokens (71495 cached), 4 tool round(s), via Azure, $0.15)z-ai/glm-5.3-flash: ok (0 finding(s), 858.8s, 1716940+96832 tokens (1609380 cached), 35 tool round(s), 1 retried request(s), salvaged finish, via OpenInference, at least $0.0836 (incomplete))
Round 2 resolution
- 🤝
r1-2disputed — Concurrent-touch fix only holds for one monotonic clock; cross-host clock skew still deletes live sessions: The remaining skew behavior is now an explicitly documented, technically justified fail-closed tradeoff rather than a claimed guarantee of this repair. README.md and RELEASE_NOTES.md scope the ordering fix to a consistent advancing clock and state that clock rollback or cross-host skew can still cause future idle anchors to be conditionally deleted.
The current shared isLive predicate retains `…
- 7 nit finding(s) from earlier rounds retired (severity floor for follow-up rounds is
risk). - Open findings after this round: 0 (0 bug-severity).
No structured findings from the successful lane(s).
Changes
Validation
Real Memory and Azurite barriers reproduced six failures involving two concurrent reads, a sweep overlapping a touch, and expiry during an awaited read. The fixed cases pass alongside explicit-time compatibility cases.
Both Node 22.18 and 24.18 passed all 83 tests with zero skips, formatting, types, release checks and clean pack/import validation. The change uses the existing storage snapshots with no additional query.
The 0.2.1 candidate awaits current-head OpenRouter review, CI and release activation. Hosts supplying explicit captured times require appropriate advancing-clock adoption for ordinary browser reads.
The follow-up restores one default clock observation for a missing record, adds post-list expiry and clock-count regressions over both backends, and ensures paused test operations release their barriers. Documentation scopes the await-ordering repair to a consistent advancing clock and records the existing fail-closed treatment of future timestamps. Release notes use durable behavior wording and the guide extracts the current version section.