Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **`dl` and `dla` keep an event log.** Each launch, session end, `stop`, `kill`, `rm`
and `prune` appends one JSON line to `$XDG_STATE_HOME/devlaunch/events.jsonl`
(`~/.local/state/devlaunch/events.jsonl` by default), with the start's seconds,
whether it was cold, and its stages. `dla` adds `aid_start` and `aid_end` lines.
`DEVLAUNCH_EVENTS=0` turns it off. A line that cannot be written never fails the
command. See [The event log](docs/performance.md#the-event-log).

## [0.64.3] - 2026-11-18

### Fixed
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,16 @@ Images are yours: `docker system df` is what shows those.
| `NVIM_SPLIT=1` | In Herdr, open `$VISUAL`, then `$EDITOR`, or `nvim` in a vertical split beside an agent launched with `dla` or `dl`. Off by default. The agent pane keeps focus. Requires the pane shell installed by `dl --herdr-setup`. See [docs/workspace-tools.md](docs/workspace-tools.md) |
| `HERDR_AGENT=<agent>` | Written, not read: a `dla` launch that starts an agent, or a `dl <ws> -- <agent>` whose command is one, names it here so a session manager can see it. See [docs/workspace-tools.md](docs/workspace-tools.md) |
| `DEVLAUNCH_TIMING=1\|json` | Write a timing summary to stderr. See [docs/performance.md](docs/performance.md) |
| `DEVLAUNCH_EVENTS=0` | Do not append to the event log, `$XDG_STATE_HOME/devlaunch/events.jsonl` (`~/.local/state` without it). On by default: one JSON line per launch, stop, kill, remove and prune. See [docs/performance.md](docs/performance.md#the-event-log) |
| `DEVPOD_SSH_CONFIG=<path>` | devpod's own, honoured rather than set: it is where `devpod up` publishes host aliases, so it is where `dl` looks for them. See [docs/cli.md](docs/cli.md) |
| `CLAUDE_CONFIG_DIR=<path>` | Claude Code's own, honoured rather than set: it is where the host keeps its Claude configuration, so it is where `dl` reads the login to forward. It replaces `~/.claude` rather than being tried before it, exactly as Claude Code treats it. See [docs/workspace-tools.md](docs/workspace-tools.md) |
| `DEVLAUNCH_CLAUDE_PROFILES_DIR=<path>` | Where `--claude-profile` looks, and it wins over the row below. For scoping a scratch run away from real credentials |
| `CLAUDE_PROFILES_DIR=<path>` | Honoured rather than set: the profile directory `claude-as` manages. Defaults to `~/.claude-profiles`. Nothing `dl` deletes reaches it |

Every switch here reads the same values: anything but empty, `0`, `false` or `no` counts as
set. On a "no" variable that means turn it off; on an opt-in one it means turn it on. Eight
rows are not switches and do not follow it: `DEVLAUNCH_AID_AGENT`, `DEVPOD_SSH_CONFIG`,
set. On a "no" variable that means turn it off; on an opt-in one it means turn it on. Nine
rows are not switches and do not follow it: `DEVLAUNCH_EVENTS` is on unless it is `0`,
`false`, `no` or `off`, so an empty value keeps the log on, `DEVLAUNCH_AID_AGENT`, `DEVPOD_SSH_CONFIG`,
`CLAUDE_CONFIG_DIR`, `DEVLAUNCH_CLAUDE_PROFILES_DIR` and `CLAUDE_PROFILES_DIR` take a value, `DEVLAUNCH_TIMING` counts only empty and `0` as off, so `false` and `no`
turn it on, `DEVLAUNCH_AID_REMOTE_CONTROL` takes `1`/`true`/`on`/`yes` or
`0`/`false`/`off`/`no` and refuses anything else rather than guessing, and `HERDR_AGENT` is
Expand Down
61 changes: 59 additions & 2 deletions docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ be the cost of starting a bash per stage, which is small. A warm launch makes no
## Measuring launch time

Set `DEVLAUNCH_TIMING=1` and a `dl` command ends with one summary on stderr,
naming each subprocess round trip and the total. Unset (or `0`) records nothing
and prints nothing.
naming each subprocess round trip and the total. Unset (or `0`) prints nothing.
The stages are still recorded for [the event log](#the-event-log) unless
`DEVLAUNCH_EVENTS=0`.

**Every second quoted in this section came off one host on 2026-08-14, over
three sessions that day (`d3b8ffb`, `5510b1e`, `461f740`), and that host was
Expand Down Expand Up @@ -176,6 +177,62 @@ dl-timing: devpod ssh 1.952s
dl-timing: total 2.444s (in-process, excluding interpreter startup)
```

### The event log

`DEVLAUNCH_TIMING` answers a question asked before the launch. The event log
answers one asked afterwards: how long did starts take this week, and how many
were cold. Every `dl` and `dla` appends one JSON object per line to
`$XDG_STATE_HOME/devlaunch/events.jsonl`, or `~/.local/state/devlaunch/events.jsonl`
when `XDG_STATE_HOME` is unset. Nobody has to set anything first.
`DEVLAUNCH_EVENTS=0` turns it off.

A line that cannot be written is dropped and the command goes on. A full disk or
a read-only state directory costs the log and nothing else. Each line is one
append, so two commands at once do not mix their lines.

| `ev` | Written when | Fields beyond `ts`, `ev`, `ws`, `repo`, `branch` |
|---|---|---|
| `launch` | The workspace is ready and the session is about to start, or an `up`, `code` or `dotfiles` has finished | `cold`, `seconds`, `stages`, `verb` |
| `session_end` | The session a `launch` started has ended | `seconds` (of the session), `exit` |
| `stop`, `kill`, `remove`, `prune` | The verb has finished | `seconds`, `exit` |
| `aid_start` | `dla` has handed its start to `dl` and the workspace is ready | `cold`, `seconds`, `stages`, `agent`, `resume` |
| `aid_end` | `dla` has ended | `seconds`, `exit`, `agent` |

`ts` is UTC ISO 8601 to the millisecond. `ws` is the workspace id when the launch
knew it, else the target as typed. `repo` and `branch` are set when the target
is `owner/repo@branch`. `cold` is true when the launch's `devpod up` created the
workspace. `seconds` on a `launch` is the wall time from the top of the command,
and `stages` holds the same named stages as the timing document, in seconds. On
an `aid_start`, `stages` holds `dla`'s own steps (`pick`, `pr_lookup`, `prompt`,
`boot_wait`) and `dl`, the launch inside it. The `aid` names are what `dla` was
called before, and what readers of older logs already look for.

```json
{"ts":"2026-11-21T09:13:05.340Z","ev":"aid_start","ws":"devlaunch-main-3j1t","repo":"blooop/devlaunch","branch":"main","cold":false,"seconds":0.043923,"stages":{"pick":0.00007,"pr_lookup":0.00005,"prompt":1e-6,"dl":0.023009},"agent":"claude","resume":false}
```

A picked workspace logs the same lines as a named one. A picked batch (several
rows marked for one verb) writes one line, not one per workspace: the `launch` of
the first workspace that came up, or the `stop`, `kill` or `remove` of the last
one, timed from that workspace's start.

Three gaps a reader of the log has to allow for:

- **A closed terminal loses the end line.** When the terminal or pane closes,
`dl` gets SIGHUP (SIGTERM does the same) and its signal handler exits at once
with `_exit(129)`. The handler writes nothing, so the `launch` has no
`session_end` after it, and a `dla` start has no `aid_end`.
- **An interactive `dla` start that creates the workspace logs two `launch`
lines.** The background boot (`dla --boot-up <spec> up`) is a process of its
own. It does the create and writes a `launch` with `verb` `up` and `cold`
true. The attach in the foreground then finds the workspace up and writes a
`launch` with `cold` false, and the `aid_start` copies that `false`. Count cold
starts on the interactive path from the boot's `up` line, not from
`aid_start`.
- **`stop`, `kill` and `remove` log the target as typed.** Their `ws` is not
resolved to a workspace id, and `repo` and `branch` are null when the target
is a workspace id rather than `owner/repo`.

### The same launch, machine-readable

`DEVLAUNCH_TIMING=json` swaps that prose for one document on a single
Expand Down
15 changes: 14 additions & 1 deletion rust/devlaunch-core/public-api.rest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3560,5 +3560,18 @@ pub fn devlaunch_core::timing::Report::eq(&self, &devlaunch_core::timing::Report
impl core::fmt::Debug for devlaunch_core::timing::Report
pub fn devlaunch_core::timing::Report::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::marker::StructuralPartialEq for devlaunch_core::timing::Report
pub fn devlaunch_core::timing::begin()
pub struct devlaunch_core::timing::Ready
pub devlaunch_core::timing::Ready::cold: bool
pub devlaunch_core::timing::Ready::seconds: f64
pub devlaunch_core::timing::Ready::stages: alloc::vec::Vec<(&'static str, f64)>
pub devlaunch_core::timing::Ready::workspace_id: core::option::Option<alloc::string::String>
impl core::clone::Clone for devlaunch_core::timing::Ready
pub fn devlaunch_core::timing::Ready::clone(&self) -> devlaunch_core::timing::Ready
impl core::cmp::PartialEq for devlaunch_core::timing::Ready
pub fn devlaunch_core::timing::Ready::eq(&self, &devlaunch_core::timing::Ready) -> bool
impl core::fmt::Debug for devlaunch_core::timing::Ready
pub fn devlaunch_core::timing::Ready::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result
impl core::marker::StructuralPartialEq for devlaunch_core::timing::Ready
pub fn devlaunch_core::timing::begin(core::option::Option<fn(&devlaunch_core::timing::Ready)>)
pub fn devlaunch_core::timing::emit() -> core::option::Option<devlaunch_core::timing::Report>
pub fn devlaunch_core::timing::ready(core::option::Option<&str>)
9 changes: 9 additions & 0 deletions rust/devlaunch-core/src/flows/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,12 @@ fn up_under_stage(
// This launch is the one paying for the `up`, so no prewarm saved it from
// anything — whether or not one was fired.
timing::observe_attach(timing::AttachShape::Miss);
// A create is what the event log calls a cold launch: devpod did not list
// this workspace, so this `up` builds it rather than starting it.
timing::observe_up(
request.naming.identity(),
matches!(request.naming, Naming::Create { .. }),
);
// The build runs for minutes in the foreground; it leads a process group of
// its own so a Ctrl-C (or `kill -INT <pid>`) tears the whole build down with
// `dl` rather than orphaning it holding the launch lock.
Expand Down Expand Up @@ -4189,6 +4195,9 @@ pub(crate) fn attach_workspace(
forward: &mut dyn FnMut(&str),
notices: &mut dyn Notices<LaunchNotice>,
) -> Result<Session, SessionRefused> {
// Ready before the attach stage opens: what follows is the session, which
// lasts as long as somebody works in it and is no part of the start.
timing::ready(Some(workspace_id));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Failed attaches produce session ends

When the workspace becomes ready but the subsequent attach fails before establishing a session, timing::ready sets readied before attach, and events::end writes session_end for every readied non-sessionless command, so the log counts a session that never started.

Write session_end only after a session has been established.

Also at rust/dl/src/events.rs:155-165.

Prompt for AI agents
In `rust/devlaunch-core/src/flows/launch.rs` at line 4200:

**Failed attaches produce session ends**

When the workspace becomes ready but the subsequent attach fails before establishing a session, `timing::ready` sets `readied` before attach, and `events::end` writes `session_end` for every readied non-sessionless command, so the log counts a session that never started.

Write `session_end` only after a session has been established.

Also at `rust/dl/src/events.rs:155-165`.

timing::stage_result(timing::Stage::Attach, || {
// First, and unconditionally on the way to every session: the terminal is
// about to belong to something else, and after that this process may not
Expand Down
Loading
Loading