Repository navigation
feat(profiles): add session profile encoder and active-branch replay - #1919
noxsystems wants to merge 3 commits into
Conversation
Part of Gentleman-Programming#1064 (slice 3b-i, codec). Standalone decoder for the gentle-pi.session-profile/v1 custom entry: closed origin set, own-property checks, one invalid route invalidates the whole snapshot, unknown fields ignored, prototype keys kept as own data. No Pi API, disk access, Enter, startup or routing changes. Chain: main -> [this] decoder -> encoder + active-branch replay (next). Out of scope: encoder, replay, disk-reader corroboration, Enter wiring.
|
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 |
…dicate Export isSafeAgentName from model-routing-authority and use it in the session profile decoder instead of probing normalizeModelConfig. Assert constructor and prototype keys stay own data in the hostile-keys test. Addresses the two CodeRabbit comments on Gentleman-Programming#1918.
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.
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