devinsession

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package devinsession discovers the identity of the Devin CLI session a hook subprocess belongs to, by walking the process ancestry and looking for the session lock file the devin process holds open.

Why: Devin's UserPromptSubmit hook payload carries only the prompt — no session id (unlike Claude Code's transcript_path or Codex's history.jsonl session_id). Locating the session by "working directory + most recent activity" silently binds to the WRONG conversation whenever several sessions run in the same directory (a real incident: a PPT-writing session's history was injected into an e2e-testing prompt). The hook process, however, is a child of the very devin process it belongs to, and every running devin session holds an open fd on <data-dir>/session_locks/<session-id>.lock — verified against live sessions, including devin-server remote ones. Walking /proc ancestry therefore yields the true session id with zero configuration and zero extra writes.

Linux-only by design (/proc). On other platforms, or on any read failure, Discover returns "" and callers fall back to the heuristic lookup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLockDir

func DefaultLockDir(dbPath string) string

DefaultLockDir derives the session_locks directory from the sessions DB path (they live side by side under the devin CLI data dir), so a DBPath override in config or tests relocates both consistently.

func Discover

func Discover(procRoot string, lockDir string, pid int) string

Discover walks the process ancestry starting at pid (inclusive) and returns the session id of the nearest ancestor holding an open <lockDir>/<session-id>.lock, or "" if none is found within maxDepth. All failures (missing /proc entries, unreadable fd tables, malformed status files) degrade to "" — identity discovery must never break enhancement.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL