feat(all): add --active-session-dir to decouple Active Sessions coordination from --temp - #1520
feat(all): add --active-session-dir to decouple Active Sessions coordination from --temp#1520simtel12 wants to merge 6 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
d7f53d2 to
6a220a6
Compare
|
@simtel12 - I wanted to share my thoughts on a few issues. This includes a local repository coderabbit run. After you correct these, we'll run CR here. [P1] Propagate the parent’s active-session directory to GUI children — session_launcher.rb (line 160) [P2] Correct the claim that the flag writes nothing to disk — help_text.rb (line 199) [P3] Wire up or remove the unused :active_session_dir launch-context path — session_launcher.rb (line 20) [P3] Release the ownership lock before deleting its temporary directory — active_sessions_spec.rb (line 126) [P3] Remove the uncalled spawn_login helper — login_helpers.rb (line 622) |
|
@OSXLich-Doug — thanks, these were all real. Pushed as four commits, one per finding, so any of them can be dropped independently. [P1] Propagate the parent's active-session directory to GUI children ( Rather than have [P2] Correct the "writes nothing to disk" claim ( [P3] Unused [P3] Release the ownership lock before deleting its temp dir ( [P3] Remove the uncalled Full suite green and rubocop clean on all six touched files. One thing I ran into while verifying, unrelated to this branch: running Ready for a CodeRabbit run here whenever you are. Edit: rebased onto latest |
…ination from --temp Active Sessions coordination (the lock + discovery files that let independent Lich processes find each other) previously always lived under TEMP_DIR. Anyone who overrides --temp per-character to keep debug logs separate ended up with an isolated Active Sessions registry per character instead of one shared registry, defeating the point of a cross-process session list. --active-session-dir=PATH lets coordination be pointed at a shared directory independently of --temp. Unset, behavior is unchanged (falls back to TEMP_DIR, or Dir.tmpdir if that's undefined). Also fixes two related gaps caught in review before this landed: - coordination_dir had no boot-time mkdir the way TEMP_DIR does, so pointing --active-session-dir at a path that doesn't exist yet raised Errno::ENOENT, silently swallowed into a plain "service unavailable" with no trace of the real cause. acquire_ownership_lock now creates the directory first. - SessionLauncher's optional-flag forwarding assumed every path flag has a constants.rb default a spawned child re-derives on its own. ACTIVE_SESSION_DIR deliberately has no such default, so that assumption caused the flag to be silently dropped whenever a spawned child requested the same value the parent already had.
…r is passed Passing --active-session-dir=PATH is a clear enough signal of intent that requiring the persisted feature_flag:active_sessions_api row too is just friction. ActiveSessions.enabled? now treats an explicit --active-session-dir as opt-in for that launch only -- it never writes to lich_settings, and omitting the flag on a later launch reverts to whatever the persisted flag says (disabled by default). Split out from the --active-session-dir commit so this specific enable-on-presence behavior can be reverted on its own if it turns out to be the wrong call.
Production launch contexts come from the GUI login tabs and carry account and frontend keys only -- never directory overrides. For path flags backed by a constants.rb default that is harmless, since a child spawned without the flag re-derives the same path. --active-session-dir has no such default by design: an unset child falls back to its own TEMP_DIR. The result was that the flag never reached a child at all. Every session started from the persistent launcher either built an isolated Active Sessions registry under its own TEMP_DIR or stayed untracked, which is exactly the split --active-session-dir exists to prevent. Mark the flag :inherit and fall back to this process's ACTIVE_SESSION_DIR when the launch context does not mention the key. An explicitly empty value remains an opt-out, so a caller can still suppress the flag deliberately.
… claim Enabling the service creates the coordination directory, the ownership lock file, and the discovery record, so "writes nothing to disk" is wrong. The guarantee actually on offer is narrower: the implicit opt-in persists no setting, so lich_settings is untouched and dropping the flag reverts to the persisted default.
…mp dir The coordination_dir example deletes base_dir while acquire_ownership_lock's flocked handle is still open -- the outer after hook releases it, but only after the deletion has already been attempted. Harmless on Linux, but a platform that refuses to remove open locked files leaks the directory.
spawn_login has had no caller since it was added -- only its own unit test exercised it, and nothing in lich-5 or the script repos reaches for it. It is a second child-launch implementation that has already drifted from SessionLauncher: no path flags, no dark-mode propagation, and a --start-scripts flag SessionLauncher does not emit. Keeping two divergent spawn paths around invites fixing one and missing the other. Its require of ruby_executable goes with it; the two remaining RubyExecutable callers require the file themselves.
e1db750 to
64d4d15
Compare
Summary
TEMP_DIR. Anyone overriding--tempper-character to keep debug logs separate ends up with an isolated Active Sessions registry per character instead of one shared one, defeating the point of a cross-process session list.--active-session-dir=PATHto point coordination at a shared directory independently of--temp. Unset, behavior is unchanged (falls back toTEMP_DIR, orDir.tmpdirif that's undefined).coordination_dirhad no boot-timemkdirthe wayTEMP_DIRdoes, so a not-yet-existing--active-session-dirpath silently degraded to "service unavailable" with no trace of the real cause; andSessionLauncher's optional-flag forwarding assumed every path flag has aconstants.rbdefault a spawned child re-derives on its own, which isn't true for this one and caused it to be silently dropped when forwarded value matched the parent's.--active-session-diralso implicitly enables the Active Sessions service for that launch, without persisting anything tolich_settings— removing the flag on a later launch reverts to the persisted default (disabled). Kept as a separate commit in case the "implicit enable" behavior specifically needs to be reverted independently.Review round 2 (@OSXLich-Doug)
Four follow-up commits, one per finding:
OPTIONAL_PATH_FLAGScontext keys, since GUI launch contexts are login entries (account/frontend), not directory overrides. For the other eight that's harmless — a child re-derives them fromconstants.rb.--active-session-dirhas no such default by design, so it was dropped on every GUI-launched child. Marked:inheritand now falls back to this process'sACTIVE_SESSION_DIRwhen the context omits the key; an explicitly empty value stays an opt-out.:active_session_dirlaunch-context path — resolved by the P1 fix, which makes the path reachable from production.ensure, ahead ofrm_rf.spawn_loginhelper — removed, along with its now-unusedruby_executablerequire (both remainingRubyExecutablecallers require it themselves). Predates this branch; folded in here since it's a second child-launch path already drifted fromSessionLauncher. Happy to split it out if you'd rather keep the branch narrow.Test plan
bundle exec rspec(full suite): 6346 examples, 0 failures (rebased ontomainthrough fix(all): terminate preserved quiet-state tags with a newline #1532 / 5.20.1)bundle exec rubocopon all touched files: no offenseslich_settingsrow forced tofalse, confirming it stays untouched on diskACTIVE_SESSION_DIRwhen the context omits it, when no context is passed at all, the explicit-empty opt-out, and the no-constant casemkdir_premoved the same call raisesErrno::ENOENTand degrades to "service unavailable"SessionLauncher, asserting on the child's actualARGV: inherits the parent's--active-session-dirfrom a production-shaped GUI context, still forwards it when the explicit value equals the parent's, honours the explicit-empty opt-out, and emits nothing when the parent has noACTIVE_SESSION_DIR.--datamatching itsconstants.rbdefault is still suppressed in the same run, confirming the suppression logic is live and only bypassed for this flaglich_settingsrow forced tofalse:ActiveSessions.enabled?returns true with the flag set, the row still readsfalse, no rows are added, the db file is byte-identical, and dropping the flag reverts to the persistedfalse