Project
cortex-cli (lock_cmd, run_delete)
Description
General case: Deleting a resource should clear dependent bookkeeping (locks, indexes) or refuse with a clear path to unlock first.
Concrete case: cortex lock add <session-id> appends to ~/.cortex/session_locks.json. cortex delete <session-id> removes only the rollout file. cortex lock list can still show the id after deletion—orphaned lock rows. cortex sessions no longer lists the session, so state is inconsistent.
Root cause (this repo)
run_delete (src/cortex-cli/src/cli/handlers.rs ~687–725) resolves conversation_id, confirms, then remove_file on get_rollout_path (~716–720) only—no load_lock_file / save_lock_file, no call to is_session_locked.
is_session_locked (src/cortex-cli/src/lock_cmd.rs ~154–163) exists but is only defined there (grep shows no other callers)—delete path never consults it.
- Lock persistence:
get_lock_file_path, load_lock_file, save_lock_file (~117–152).
Fix direction (proposed)
- On successful rollout delete, remove matching
session_id entries from session_locks.json (full UUID match + prefix rules aligned with is_session_locked), or
bail! / prompt when locked unless --force, pointing to cortex lock remove.
Code snapshot
src/cortex-cli/src/cli/handlers.rs — run_delete (~687–725)
src/cortex-cli/src/lock_cmd.rs — get_lock_file_path, load_lock_file, save_lock_file (~117–152); is_session_locked (~154–163); run_remove retain + save_lock_file (~256–291)
Error Message
(None — inconsistent on-disk state.)
Debug Logs
System Information
OS: typical reporter
CLI: cortex lock add … then cortex delete … (no manual lock remove)
Screenshots / Media
https://github.com/galuis116/plaftform_51/blob/main/2026-04-09_20h55_48.png
Steps to Reproduce
cortex lock add <session-id>.
cortex lock list — note entry.
cortex delete <session-id> — confirm.
cortex lock list — entry still there.
cortex sessions --all — session gone.
Expected Behavior
Deletion clears the lock entry or blocks until unlocked / --force, with explicit copy.
Actual Behavior
Rollout removed; session_locks.json unchanged.
Duplicate check
Search terms: cortex delete, run_delete, session_locks.json, cortex lock, is_session_locked, get_rollout_path.
Additional Context
Reuse LockFile mutation logic from run_remove (lock_cmd.rs) to avoid duplicating JSON schema rules.
Project
cortex-cli (
lock_cmd,run_delete)Description
General case: Deleting a resource should clear dependent bookkeeping (locks, indexes) or refuse with a clear path to unlock first.
Concrete case:
cortex lock add <session-id>appends to~/.cortex/session_locks.json.cortex delete <session-id>removes only the rollout file.cortex lock listcan still show the id after deletion—orphaned lock rows.cortex sessionsno longer lists the session, so state is inconsistent.Root cause (this repo)
run_delete(src/cortex-cli/src/cli/handlers.rs~687–725) resolvesconversation_id, confirms, thenremove_fileonget_rollout_path(~716–720) only—noload_lock_file/save_lock_file, no call tois_session_locked.is_session_locked(src/cortex-cli/src/lock_cmd.rs~154–163) exists but is only defined there (grep shows no other callers)—delete path never consults it.get_lock_file_path,load_lock_file,save_lock_file(~117–152).Fix direction (proposed)
session_identries fromsession_locks.json(full UUID match + prefix rules aligned withis_session_locked), orbail!/ prompt when locked unless--force, pointing tocortex lock remove.Code snapshot
src/cortex-cli/src/cli/handlers.rs—run_delete(~687–725)src/cortex-cli/src/lock_cmd.rs—get_lock_file_path,load_lock_file,save_lock_file(~117–152);is_session_locked(~154–163);run_removeretain+save_lock_file(~256–291)Error Message
(None — inconsistent on-disk state.)
Debug Logs
System Information
OS: typical reporter CLI: cortex lock add … then cortex delete … (no manual lock remove)Screenshots / Media
https://github.com/galuis116/plaftform_51/blob/main/2026-04-09_20h55_48.png
Steps to Reproduce
cortex lock add <session-id>.cortex lock list— note entry.cortex delete <session-id>— confirm.cortex lock list— entry still there.cortex sessions --all— session gone.Expected Behavior
Deletion clears the lock entry or blocks until unlocked /
--force, with explicit copy.Actual Behavior
Rollout removed;
session_locks.jsonunchanged.Duplicate check
Search terms:
cortex delete,run_delete,session_locks.json,cortex lock,is_session_locked,get_rollout_path.Additional Context
Reuse
LockFilemutation logic fromrun_remove(lock_cmd.rs) to avoid duplicating JSON schema rules.