Repository navigation
feat(profiles): add session profile encoder and active-branch replay - #1919
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThis change adds a v1 session-profile codec and active-branch replay utility. It validates bind payloads and route snapshots, classifies profile entries, and selects the newest non-absent result. Tests and documentation describe payload, validation, and replay behavior. ChangesSession profile persistence
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Caller
participant replaySessionProfileBranch
participant readSessionProfileEntry
Caller->>replaySessionProfileBranch: Supply entries in oldest-to-newest branch order
replaySessionProfileBranch->>readSessionProfileEntry: Classify each entry
readSessionProfileEntry-->>replaySessionProfileBranch: Return entry status
replaySessionProfileBranch-->>Caller: Return newest non-absent result and branch index
Merge Risk: ⚪ Minimal · up to This adds a standalone session-profile codec and replay utility with tests and documentation. It is not yet wired into runtime behavior, so merge risk is minimal. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Part of Gentleman-Programming#1064 (slice 3b-i, codec). Adds createSessionProfileBind and createSessionProfileClear (explicit user selections only, typed undefined model/thinking omitted, effort stays strict) and replaySessionProfileBranch: the newest profile-family entry on a caller-supplied, already disk-corroborated active branch is terminal, including invalid and unsupported, and never revives an older binding. Still no disk access, Pi API, Enter or routing changes. Chain: main -> decoder (previous) -> [this] encoder + replay. Depends on: feat/1064-3b-i-1-codec-decoder. Out of scope: disk-reader corroboration, Enter wiring, guards.
409ff09 to
732a11f
Compare
Part of Gentleman-Programming#1064 (slice 3b-i, disk reader). readSessionProfileDisk reads the session's public active branch and JSONL file, selects the newest profile-family entry (excluding known failed append IDs) and admits it only when the record on disk is byte-identical; otherwise it returns one indeterminate reason without record contents. No writes, fallback, cache, ancestry repair or fsync; a missing file never restores a memory-only profile. Verified against a real SessionManager session file. Chain: main -> decoder (Gentleman-Programming#1918) -> encoder + replay (Gentleman-Programming#1919) -> [this]. Depends on: Gentleman-Programming#1919. Out of scope: append controller, authority publication, Enter wiring.
barbatdev
left a comment
There was a problem hiding this comment.
Approved. The encoder only emits explicit user selections, rejects invalid input instead of manufacturing an empty snapshot, strips undefined model and thinking, and keeps effort strict so the invalid-effort shape the decoder rejects can never be produced. The replay is terminal including invalid and unsupported, never revives an older binding, excludes sibling entries by the documented caller precondition, and both directions return defensive snapshots. The strict-effort divergence from #1918 stays consistent end to end.
Focused suites pass on my side (18/18 codec, 72/72 neighbors, typecheck at the 186-diagnostic baseline), plus an independent adversarial QA sweep: 23 probes over encoder hostility, replay orderings, revival attempts and defensive copies, all matching the contract.
One carried note from #1918 remains partially open: non-string customType and modelProfiles-level prototype isolation are still untested, and three more branches are only behaviorally covered. Fold them into #1922's suite, where the reader gives them a natural home. Replay input is structural, so #1922 should carry the corroboration enforcement at its own seam.
Summary
Part of #1064, slice 3b-i (persistence codec). Second and last pure PR of the codec: the encoder and the active-branch replay rule. Still no disk access, Pi API, Enter or routing change.
createSessionProfileBind(name, modelProfiles)creates only explicituserselections and rejects invalid input instead of manufacturing an empty snapshot; typed normalized routes may carrymodel/thinkingasundefinedand those are omitted, whileeffortstays strict.createSessionProfileClear()is the minimal{kind:"clear"}.replaySessionProfileBranch(entries): the caller supplies entries already corroborated on disk, oldest to newest, on the active branch. The newest profile-family entry is terminal, includinginvalidandunsupported; an older binding is never revived.entryIndexis the actual branch offset for a later location warning. In-memorygetBranch()alone is not corroboration; a subsequent disk-reader slice supplies it.This is PR 2 of 2.
Issue
Part of #1064
PR type
type:feature)Changes
732a11f1bencoderInputmode in the route/snapshot readers,replaySessionProfileBranch, their tests, and the Replay section ofdocs/session-profile-format.md.Test plan
Verified on top of PR 1,
main9782d26df, Node 25.2.1:tests/session-profile-persistence.test.ts: 18 pass, 0 fail (adds writer fields, undefined handling, defensive copies, terminal newest entry, branch order, sibling exclusion).tests/agent-profiles.test.ts+tests/model-routing-authority.test.ts: 59 pass, 0 fail.node scripts/check-types.mjs: 186 recorded diagnostics, no regressions.f5a42a5): 18/18, 59/59, ratchet 186 on both lanes.Chain Context
main(fork PRs cannot stack bases; rebased as #1918 lands)Summary by CodeRabbit