docs: add canonical session resolution contract - #2922
1 commit merged into
Conversation
|
Read the RFC at Code referenceThe two test cases pin both the linkage and the contract surface: def test_canonical_session_resolution_rfc_is_indexed():
...
assert "canonical-session-resolution.md" in rfc_index
assert rel in contracts
def test_canonical_session_resolution_contract_names_entrypoints_and_outputs():
text = RFC.read_text(encoding="utf-8")
required_terms = [
"URL route", "query parameter", "localStorage", "sidebar",
"pre_compression_snapshot", "canonical_visible_session_id",
"continuation_session_id", "parent_session_id",
"direct session open", "browser boot restore",
]
missing = [term for term in required_terms if term not in text]
assert missing == []The terminology table at the top of the RFC matches existing field names already in use across the codebase (verified One observation about scopeResolution Rule 2 ("snapshot parents defer to visible continuation tips") is exactly what #2913 ( function _resolveSessionIdFromSidebarLineage(sid){
...
// candidates sorted by segment count, then non-snapshot preference, then timestamp
candidates.sort((a,b)=>{
...
const bSnapshot=!!(b&&b.pre_compression_snapshot);
const aSnapshot=!!(a&&a.pre_compression_snapshot);
if(bSnapshot!==aSnapshot) return aSnapshot-bSnapshot;
return _sessionTimestampMs(b)-_sessionTimestampMs(a);
});And Rule 5 ( return qs.get('session')||qs.get('session_id')||null;So the RFC is documenting a contract whose implementations are arriving alongside it. That's a reasonable order — the RFC gives the next round of fixes a shared vocabulary instead of each PR reinventing the rule set. The list at the bottom of the doc ( SuggestionTwo narrow things worth adding before merge, but neither is a blocker:
DiagnosisDocs-only + a guard test. No runtime behavior change. The hygiene scan noted in the PR description ( |
a0ab168
Thinking Path
Recent compression/session-routing bugs keep surfacing the same state-boundary problem: URL routes, query parameters, localStorage, sidebar collapse, and compression lineage can all identify different rows for one logical conversation. The data is usually still present, but the browser can reopen a stale parent snapshot or a non-canonical row and make the session look lost.
Rather than turning that into another broad implementation PR, this adds a narrow public contract so future fixes can point to one review target.
What Changed
docs/rfcs/canonical-session-resolution.md.docs/rfcs/README.mdanddocs/CONTRACTS.md.Why It Matters
This gives future session-routing fixes a shared vocabulary:
canonical_visible_session_idpre_compression_snapshotcontinuation_session_idIt complements #2361 and #1925 without implementing a new backend surface yet.
Verification
uv run --with pytest python -m pytest tests/test_canonical_session_resolution_rfc.py -q -o addopts=''failed before the RFC existed.uv run --with pytest python -m pytest tests/test_canonical_session_resolution_rfc.py -q -o addopts=''->2 passed.0added private/local marker hits,0secret-like added-line hits.Risks / Follow-ups
canonical_visible_session_idif/when the API exposes one.Model Used
OpenAI Codex / GPT-5.5 via Hermes Agent, with terminal/file tools and TDD workflow.