fix: cognix session adopt CLI for orphan sessions #84
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/dashboard-orphan-session-adopt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
cognix session adoptCLI to grant Primary on sessions written before the F-3 registry existed (legitimate never-owned case the server's one-shot repair deliberately cannot handle).Test Plan
cargo test -p cognix-cli— unit tests for adopt (orphan promotion, dry-run, include-closed, nil-UUID rejection, malformed session id, stale-snapshot race, production-migrated schema).session adopt --path … --owner … --include-closed --dry-run.Self-Review Checklist
unwrap()in library codeprintln!/dbg!(CLI binary usesprintln!for user-facing output only)--ownerand seedmax_agentsresolved fromCognixConfigrather than a magic numberNotes
Trust model: any caller with write access to the SQLite file can use
--ownerto grant Primary to an arbitrary UUID; the DB file ACL (0o600) is the only access control on this path. Documented in bothAdoptCommandand the clap--ownerhelp.session.rs reached 1043 lines (>800 hard ceiling), failing CI / Check file lengths and CI / Test (which also runs the gate). Convert to a module directory with three focused files: - session/mod.rs — public API: AdoptCommand, AdoptReport, run() + run-through tests - session/db.rs — DB internals: OrphanSession, find_orphan_sessions, adopt_orphans, AdoptOutcome, try_adopt_one + 2 direct tests - session/resolve.rs — identity resolution: resolve_owner, resolve_max_agents, load_owner_seed All 115 tests pass; clippy clean; file-length gate exits 0.