Repository navigation
feat(events): Append one JSON line per launch to an event log - #723
Conversation
dl and dla now write ${XDG_STATE_HOME:-~/.local/state}/devlaunch/events.jsonl,
always on, off with DEVLAUNCH_EVENTS=0. dl writes launch, session_end, stop,
kill, remove and prune; dla adds aid_start (its own stages plus dl's launch)
and aid_end. A write error is dropped and never fails the command.
Core hands the launch over through a hook on timing::begin and a new
timing::ready, so core still renders nothing. The public-API rows for
timing::Ready, begin and ready are hand-written; CI's public-api job checks
them. The Python suite now scopes XDG_STATE_HOME so a test run does not
write into the developer's own log.
Reviewer's GuideAPIExtend the timing interface with a launch-ready snapshot and one-shot hook, while retaining the optional stderr timing report; include the hand-maintained public-API record for these changes.
Uses of the APIRecord readiness and cold-start information in the launch flow, and trigger readiness for sessionless verbs and lifecycle commands at dispatch.
Install the event hook for each command and bracket command execution with event-log lifecycle handling.
ImplementationImplement event construction, timing and workspace association,
ConfigurationIsolate the Python test suite's event log by setting a scratch
DocumentationExplain the event-log format, semantics, limitations and configuration, and announce the feature to users.
TestsCover event records across launches, lifecycle verbs, picker paths and
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Each line read the clock on its own, so the two writes could straddle a millisecond and give launch a ts before aid_start. The usage review pairs them with an ASOF JOIN on l.ts >= a.ts, which then dropped or mispaired the start. One ready now reads the clock once and both lines carry it.
Dla's target was filled only when the launch was ready, so a start that failed first (an unknown workspace) wrote aid_end with ws null. aid_end now takes the target from the verb dl dispatched, which is known before ready. The copy of the target on dla's record goes, since the verb already holds it.
code and dotfiles start no session, so they reached neither attach_workspace nor the up-only ready call: no launch line was written. A Verb now says whether it is ready without a session; the dispatch fires the ready for all three, and the event state writes no session_end after them.
The verb was recorded only on the named-target route; the picker went straight to render_workspace. The record and the sessionless ready now live in render_workspace, so both routes go through them. A picked batch still writes one line, and docs/performance.md says which.
With the event log on by default, the timing registry records a launch's stages even when DEVLAUNCH_TIMING is unset; only DEVLAUNCH_EVENTS=0 as well leaves it off. DEVLAUNCH_TIMING now controls only the stderr report.
…ot lose A SIGHUP _exits dl before session_end or aid_end is written. An interactive dla start that creates the workspace logs the cold start on the boot's up line, and aid_start copies cold:false from the attach. stop, kill and remove log the target as typed, with repo null for a workspace id.
|
A five-axis self-review (defects, types, spec, tests, one mutant) ran on this branch and landed its findings as commits 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Hey - I've found 14 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="rust/dl/src/events.rs" line_range="381-386" />
<code_context>
+ };
+ line.push('\n');
+ if let Some(parent) = path.parent() {
+ let _ = std::fs::create_dir_all(parent);
+ }
+ let Ok(mut file) = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open(&path)
+ else {
+ return;
</code_context>
<issue_to_address>
**Private workspace activity is readable**
When `dl` writes the default log under a traversable home with a typical Unix umask such as 022, another local user can read workspace IDs, private repository and branch names, and launch history from the event log because the directory and file use permissive default creation modes.
Create the log directory and file with owner-only permissions (for example, 0700 and 0600).
</issue_to_address>
### Comment 2
<location path="rust/dl/src/events.rs" line_range="391" />
<code_context>
+ /// Whether [`ready`] has already been heard this command: a launch is ready
+ /// once, however many arms call it.
+ readied: bool,
}
impl Registry {
</code_context>
<issue_to_address>
**Concurrent appends corrupt event lines**
When a write to the log file completes partially while another process appends, `append` uses `write_all` without a record-level lock, so another process can append between writes and interleave JSON fragments, leaving malformed event lines.
Make each complete event-line append indivisible across processes.
Also at `rust/dl/src/events.rs:390`.
</issue_to_address>
### Comment 3
<location path="rust/dl/src/events.rs" line_range="390" />
<code_context>
+ else {
+ return;
+ };
+ let _ = file.write_all(line.as_bytes());
+}
+
</code_context>
<issue_to_address>
**Failed writes corrupt event lines**
When the filesystem accepts only part of a line before returning an error, `append` ignores the `write_all` error and leaves the written prefix in the log, so the next event follows that fragment and readers encounter malformed JSONL.
Roll back a partial line after a failed write, or otherwise ensure failed appends leave no fragment.
Also at `rust/dl/src/events.rs:391`.
</issue_to_address>
### Comment 4
<location path="rust/dl/src/events.rs" line_range="381-390" />
<code_context>
+ };
+ line.push('\n');
+ if let Some(parent) = path.parent() {
+ let _ = std::fs::create_dir_all(parent);
+ }
+ let Ok(mut file) = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open(&path)
+ else {
+ return;
+ };
+ let _ = file.write_all(line.as_bytes());
+}
+
</code_context>
<issue_to_address>
**State storage stalls launches**
When `XDG_STATE_HOME` is on a filesystem whose operation stalls, `on_ready` calls `append` synchronously before the launch continues, and `create_dir_all`, `open` and `write_all` have no timeout. A stalled network or FUSE state mount therefore blocks the launch instead of letting it proceed without telemetry.
Move event writes off the launch path or otherwise bound their latency so an unavailable state filesystem cannot hold up a launch.
</issue_to_address>
### Comment 5
<location path="rust/dl/src/events.rs" line_range="381-390" />
<code_context>
+ };
+ line.push('\n');
+ if let Some(parent) = path.parent() {
+ let _ = std::fs::create_dir_all(parent);
+ }
+ let Ok(mut file) = std::fs::OpenOptions::new()
+ .create(true)
+ .append(true)
+ .open(&path)
+ else {
+ return;
+ };
+ let _ = file.write_all(line.as_bytes());
+}
+
</code_context>
<issue_to_address>
**Dropped events go unnoticed**
When the state directory cannot be created or the log cannot be opened or written, the directory-creation, open and write errors are discarded without a diagnostic, metric or alert, so launches and lifecycle actions silently disappear from the log and usage reviews undercount them.
Keep telemetry failures non-fatal but provide a rate-limited diagnostic or another observable signal that event recording is unavailable.
</issue_to_address>
### Comment 6
<location path="rust/dl/src/commands.rs" line_range="864" />
<code_context>
+ // logged alike. A picked batch is several calls; the event state keeps the
+ // last verb, and the first ready.
+ let sessionless = verb.ready_without_a_session();
+ crate::events::workspace(Some(target), word, sessionless);
+ let ending = render_verb(
+ runner,
</code_context>
<issue_to_address>
**Workspace removals disappear from log**
When a user removes a workspace with `--rm` or `rmt`, `--rm` keeps the `attach` or `--` verb, so `events::end` writes only `session_end`; `rmt` bypasses `render_workspace` and does not register a workspace verb. Neither path writes a `remove` event, so usage reviews miss these removals.
Record a removal lifecycle event for both `--rm` and `rmt` paths.
Also at `rust/dl/src/events.rs:141-143`.
</issue_to_address>
### Comment 7
<location path="rust/dl/src/commands.rs" line_range="864" />
<code_context>
+ // logged alike. A picked batch is several calls; the event state keeps the
+ // last verb, and the first ready.
+ let sessionless = verb.ready_without_a_session();
+ crate::events::workspace(Some(target), word, sessionless);
+ let ending = render_verb(
+ runner,
</code_context>
<issue_to_address>
**Refused targets disappear from aid_end**
When `dla` hands `dl` a pull-request target that resolution refuses before workspace dispatch, `events::workspace` has not recorded the target when `dla_end` runs, so it writes `aid_end` with `ws: null` instead of the target the user supplied.
Record the target before pull-request resolution can refuse the command.
Also at `rust/dl/src/events.rs:305`.
</issue_to_address>
### Comment 8
<location path="rust/dl/src/commands.rs" line_range="864" />
<code_context>
+ // logged alike. A picked batch is several calls; the event state keeps the
+ // last verb, and the first ready.
+ let sessionless = verb.ready_without_a_session();
+ crate::events::workspace(Some(target), word, sessionless);
+ let ending = render_verb(
+ runner,
</code_context>
<issue_to_address>
**Lifecycle logs rewritten targets**
When A lifecycle verb is given a pull-request spec that resolves to a branch, `dispatch` has already rewritten a pull-request target before `render_workspace` passes it to the event logger. A `stop`, `kill` or `remove` given a pull-request spec therefore logs the resolved branch rather than the target as typed, contrary to the documented event fields and obscuring what the user requested.
Preserve the original command-line target for event logging while continuing to use the resolved target for the operation.
</issue_to_address>
### Comment 9
<location path="rust/dla/src/main.rs" line_range="257" />
<code_context>
}
name_agent_for_session_manager(parsed.agent());
- match launch.resume {
+ start.hand_over(parsed.agent(), parsed.resumes());
+ let code = match launch.resume {
Some(resume) => dl::run_resumable(&launch.dl_args, resume),
</code_context>
<issue_to_address>
**Early failures omit end lines**
When A `dla` attempt is canceled or refused before it hands the start to `dl`, `DlaStart` is handed to the event state only at `hand_over`, and earlier `dla` exits return without calling `dla_end`. A start canceled during prompt collection or refused during pre-launch lookup therefore produces no `aid_end`, despite the documented end event for a `dla` start.
Finalize and log the `DlaStart` on every post-start exit, including failures before handover.
</issue_to_address>
### Comment 10
<location path="rust/dl/src/events.rs" line_range="347-352" />
<code_context>
+ _ => (None, None),
+ };
+ let mut event = Map::new();
+ event.insert("ts".into(), iso8601(at).into());
+ event.insert("ev".into(), ev.into());
+ event.insert("ws".into(), workspace_id.or(target).into());
+ event.insert("repo".into(), repo.into());
+ event.insert("branch".into(), branch.into());
+ event
+}
+
</code_context>
<issue_to_address>
**Concurrent starts are misattributed**
When two starts for the same workspace become ready within one millisecond, the event records use millisecond timestamps and have no unique start identifier, so both starts can have the same `ts` and `ws`; the usage-review ASOF join can pair an `aid_start` with the other launch and skew metrics.
Give each start a unique identifier shared by its related event records.
Also at `rust/dl/src/events.rs:404`.
</issue_to_address>
### Comment 11
<location path="rust/devlaunch-core/src/flows/launch.rs" line_range="4200" />
<code_context>
) -> 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));
timing::stage_result(timing::Stage::Attach, || {
// First, and unconditionally on the way to every session: the terminal is
</code_context>
<issue_to_address>
**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`.
</issue_to_address>
### Comment 12
<location path="rust/dl/src/commands.rs" line_range="864" />
<code_context>
+ // logged alike. A picked batch is several calls; the event state keeps the
+ // last verb, and the first ready.
+ let sessionless = verb.ready_without_a_session();
+ crate::events::workspace(Some(target), word, sessionless);
+ let ending = render_verb(
+ runner,
</code_context>
<issue_to_address>
**Picked launches lose repository attribution**
When a user launches a workspace by picking it rather than typing its owner/repo target, a picker selection passes only its workspace ID to the event logger, so `base()` cannot derive `repo` or `branch` from the selected row and writes both as null; usage reviews cannot attribute those launches to a repository or branch.
Pass the selected workspace’s known repository and branch metadata to the event logger and use it when building the event fields.
Also at `rust/dl/src/events.rs:338-345`.
</issue_to_address>
### Comment 13
<location path="rust/dl/tests/launch.rs" line_range="2819-2821" />
<code_context>
+ assert_eq!(launch["branch"], "main");
+ assert_eq!(launch["cold"], false);
+ assert!(
+ launch["seconds"].as_f64().is_some_and(|s| s >= 0.0),
+ "{launch}"
+ );
+ assert!(launch["stages"].is_object(), "{launch}");
+ let ts = launch["ts"].as_str().expect("a timestamp");
</code_context>
<issue_to_address>
**Zero durations pass launch test**
When the ready hook supplies zero seconds for a real launch, the launch event reports `seconds: 0` for a real, nonzero launch, but `a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session` accepts any nonnegative number at this assertion, so the bad duration passes.
Assert a meaningful lower bound for this nonzero launch, or compare the emitted duration with an independently measured elapsed interval.
</issue_to_address>
### Comment 14
<location path="rust/dl/tests/launch.rs" line_range="2825-2827" />
<code_context>
+ assert!(launch["stages"].is_object(), "{launch}");
+ let ts = launch["ts"].as_str().expect("a timestamp");
+ assert!(
+ ts.ends_with('Z') && ts.len() == "2026-11-21T09:30:05.250Z".len(),
+ "{ts}"
+ );
+ assert_eq!(lines[1]["ws"], MAIN);
+ assert_eq!(lines[1]["exit"], 0);
</code_context>
<issue_to_address>
**Malformed timestamps pass launch test**
When the emitted launch timestamp has the expected length and ends in `Z` but encodes an invalid date or time, the launch event contains an invalid date or time with the expected string length and a trailing `Z`, but `a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session` checks only those two properties, so the malformed timestamp passes.
Parse the emitted timestamp as UTC ISO 8601, or assert its components against a controlled-clock value.
</issue_to_address>| let _ = std::fs::create_dir_all(parent); | ||
| } | ||
| let Ok(mut file) = std::fs::OpenOptions::new() | ||
| .create(true) | ||
| .append(true) | ||
| .open(&path) |
There was a problem hiding this comment.
🟡 Medium · Private workspace activity is readable
When dl writes the default log under a traversable home with a typical Unix umask such as 022, another local user can read workspace IDs, private repository and branch names, and launch history from the event log because the directory and file use permissive default creation modes.
Create the log directory and file with owner-only permissions (for example, 0700 and 0600).
Prompt for AI agents
In `rust/dl/src/events.rs` at lines 381-386:
**Private workspace activity is readable**
When `dl` writes the default log under a traversable home with a typical Unix umask such as 022, another local user can read workspace IDs, private repository and branch names, and launch history from the event log because the directory and file use permissive default creation modes.
Create the log directory and file with owner-only permissions (for example, 0700 and 0600).| return; | ||
| }; | ||
| let _ = file.write_all(line.as_bytes()); | ||
| } |
There was a problem hiding this comment.
🟡 Medium · Concurrent appends corrupt event lines
When a write to the log file completes partially while another process appends, append uses write_all without a record-level lock, so another process can append between writes and interleave JSON fragments, leaving malformed event lines.
Make each complete event-line append indivisible across processes.
Also at rust/dl/src/events.rs:390.
Prompt for AI agents
In `rust/dl/src/events.rs` at line 391:
**Concurrent appends corrupt event lines**
When a write to the log file completes partially while another process appends, `append` uses `write_all` without a record-level lock, so another process can append between writes and interleave JSON fragments, leaving malformed event lines.
Make each complete event-line append indivisible across processes.
Also at `rust/dl/src/events.rs:390`.| else { | ||
| return; | ||
| }; | ||
| let _ = file.write_all(line.as_bytes()); |
There was a problem hiding this comment.
🟡 Medium · Failed writes corrupt event lines
When the filesystem accepts only part of a line before returning an error, append ignores the write_all error and leaves the written prefix in the log, so the next event follows that fragment and readers encounter malformed JSONL.
Roll back a partial line after a failed write, or otherwise ensure failed appends leave no fragment.
Also at rust/dl/src/events.rs:391.
Prompt for AI agents
In `rust/dl/src/events.rs` at line 390:
**Failed writes corrupt event lines**
When the filesystem accepts only part of a line before returning an error, `append` ignores the `write_all` error and leaves the written prefix in the log, so the next event follows that fragment and readers encounter malformed JSONL.
Roll back a partial line after a failed write, or otherwise ensure failed appends leave no fragment.
Also at `rust/dl/src/events.rs:391`.| let _ = std::fs::create_dir_all(parent); | ||
| } | ||
| let Ok(mut file) = std::fs::OpenOptions::new() | ||
| .create(true) | ||
| .append(true) | ||
| .open(&path) | ||
| else { | ||
| return; | ||
| }; | ||
| let _ = file.write_all(line.as_bytes()); |
There was a problem hiding this comment.
🟡 Medium · State storage stalls launches
When XDG_STATE_HOME is on a filesystem whose operation stalls, on_ready calls append synchronously before the launch continues, and create_dir_all, open and write_all have no timeout. A stalled network or FUSE state mount therefore blocks the launch instead of letting it proceed without telemetry.
Move event writes off the launch path or otherwise bound their latency so an unavailable state filesystem cannot hold up a launch.
Prompt for AI agents
In `rust/dl/src/events.rs` at lines 381-390:
**State storage stalls launches**
When `XDG_STATE_HOME` is on a filesystem whose operation stalls, `on_ready` calls `append` synchronously before the launch continues, and `create_dir_all`, `open` and `write_all` have no timeout. A stalled network or FUSE state mount therefore blocks the launch instead of letting it proceed without telemetry.
Move event writes off the launch path or otherwise bound their latency so an unavailable state filesystem cannot hold up a launch.| let _ = std::fs::create_dir_all(parent); | ||
| } | ||
| let Ok(mut file) = std::fs::OpenOptions::new() | ||
| .create(true) | ||
| .append(true) | ||
| .open(&path) | ||
| else { | ||
| return; | ||
| }; | ||
| let _ = file.write_all(line.as_bytes()); |
There was a problem hiding this comment.
🟡 Medium · Dropped events go unnoticed
When the state directory cannot be created or the log cannot be opened or written, the directory-creation, open and write errors are discarded without a diagnostic, metric or alert, so launches and lifecycle actions silently disappear from the log and usage reviews undercount them.
Keep telemetry failures non-fatal but provide a rate-limited diagnostic or another observable signal that event recording is unavailable.
Prompt for AI agents
In `rust/dl/src/events.rs` at lines 381-390:
**Dropped events go unnoticed**
When the state directory cannot be created or the log cannot be opened or written, the directory-creation, open and write errors are discarded without a diagnostic, metric or alert, so launches and lifecycle actions silently disappear from the log and usage reviews undercount them.
Keep telemetry failures non-fatal but provide a rate-limited diagnostic or another observable signal that event recording is unavailable.| event.insert("ts".into(), iso8601(at).into()); | ||
| event.insert("ev".into(), ev.into()); | ||
| event.insert("ws".into(), workspace_id.or(target).into()); | ||
| event.insert("repo".into(), repo.into()); | ||
| event.insert("branch".into(), branch.into()); | ||
| event |
There was a problem hiding this comment.
🟡 Medium · Concurrent starts are misattributed
When two starts for the same workspace become ready within one millisecond, the event records use millisecond timestamps and have no unique start identifier, so both starts can have the same ts and ws; the usage-review ASOF join can pair an aid_start with the other launch and skew metrics.
Give each start a unique identifier shared by its related event records.
Also at rust/dl/src/events.rs:404.
Prompt for AI agents
In `rust/dl/src/events.rs` at lines 347-352:
**Concurrent starts are misattributed**
When two starts for the same workspace become ready within one millisecond, the event records use millisecond timestamps and have no unique start identifier, so both starts can have the same `ts` and `ws`; the usage-review ASOF join can pair an `aid_start` with the other launch and skew metrics.
Give each start a unique identifier shared by its related event records.
Also at `rust/dl/src/events.rs:404`.| ) -> 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)); |
There was a problem hiding this comment.
🟡 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`.| // logged alike. A picked batch is several calls; the event state keeps the | ||
| // last verb, and the first ready. | ||
| let sessionless = verb.ready_without_a_session(); | ||
| crate::events::workspace(Some(target), word, sessionless); |
There was a problem hiding this comment.
🟡 Medium · Picked launches lose repository attribution
When a user launches a workspace by picking it rather than typing its owner/repo target, a picker selection passes only its workspace ID to the event logger, so base() cannot derive repo or branch from the selected row and writes both as null; usage reviews cannot attribute those launches to a repository or branch.
Pass the selected workspace’s known repository and branch metadata to the event logger and use it when building the event fields.
Also at rust/dl/src/events.rs:338-345.
Prompt for AI agents
In `rust/dl/src/commands.rs` at line 864:
**Picked launches lose repository attribution**
When a user launches a workspace by picking it rather than typing its owner/repo target, a picker selection passes only its workspace ID to the event logger, so `base()` cannot derive `repo` or `branch` from the selected row and writes both as null; usage reviews cannot attribute those launches to a repository or branch.
Pass the selected workspace’s known repository and branch metadata to the event logger and use it when building the event fields.
Also at `rust/dl/src/events.rs:338-345`.| launch["seconds"].as_f64().is_some_and(|s| s >= 0.0), | ||
| "{launch}" | ||
| ); |
There was a problem hiding this comment.
🟡 Medium · Zero durations pass launch test
When the ready hook supplies zero seconds for a real launch, the launch event reports seconds: 0 for a real, nonzero launch, but a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session accepts any nonnegative number at this assertion, so the bad duration passes.
Assert a meaningful lower bound for this nonzero launch, or compare the emitted duration with an independently measured elapsed interval.
Prompt for AI agents
In `rust/dl/tests/launch.rs` at lines 2819-2821:
**Zero durations pass launch test**
When the ready hook supplies zero seconds for a real launch, the launch event reports `seconds: 0` for a real, nonzero launch, but `a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session` accepts any nonnegative number at this assertion, so the bad duration passes.
Assert a meaningful lower bound for this nonzero launch, or compare the emitted duration with an independently measured elapsed interval.| ts.ends_with('Z') && ts.len() == "2026-11-21T09:30:05.250Z".len(), | ||
| "{ts}" | ||
| ); |
There was a problem hiding this comment.
🟡 Medium · Malformed timestamps pass launch test
When the emitted launch timestamp has the expected length and ends in Z but encodes an invalid date or time, the launch event contains an invalid date or time with the expected string length and a trailing Z, but a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session checks only those two properties, so the malformed timestamp passes.
Parse the emitted timestamp as UTC ISO 8601, or assert its components against a controlled-clock value.
Prompt for AI agents
In `rust/dl/tests/launch.rs` at lines 2825-2827:
**Malformed timestamps pass launch test**
When the emitted launch timestamp has the expected length and ends in `Z` but encodes an invalid date or time, the launch event contains an invalid date or time with the expected string length and a trailing `Z`, but `a_warm_attach_logs_a_warm_launch_and_then_the_end_of_its_session` checks only those two properties, so the malformed timestamp passes.
Parse the emitted timestamp as UTC ISO 8601, or assert its components against a controlled-clock value.
dlanddlanow write one JSON line for each launch to a log file. A usage review can then measure how long a start takes, and nobody has to setDEVLAUNCH_TIMINGfirst.In short
Before this change,
dlmeasured a start only when the user setDEVLAUNCH_TIMINGbefore the command. Nothing kept a record of past starts. So nobody could say how long starts took last week, or how many were cold.Now every
dlanddlacommand appends to an event log. The event log is the file${XDG_STATE_HOME:-~/.local/state}/devlaunch/events.jsonl, one JSON object on each line. It is on by default.DEVLAUNCH_EVENTS=0turns it off.A write to the event log never stops a command. If the write fails,
dldrops the line and continues. Each line goes out in one append, so two commands at the same time do not mix their lines.The field names and the
evvalues match what the usage-review queries read:sources.sqland thedl_*,dla_*andaid_*metrics.Evidence
The built
dlanddlaran against the test world (the fakedevpodthat the integration tests use). They wrote this file:{"ts":"2026-11-21T09:13:05.122Z","ev":"launch","ws":"devlaunch-main-3j1t","repo":null,"branch":null,"cold":false,"seconds":0.017482,"stages":{"devpod-up":0.016424},"verb":"attach"} {"ts":"2026-11-21T09:13:05.140Z","ev":"session_end","ws":"devlaunch-main-3j1t","repo":null,"branch":null,"seconds":0.017801,"exit":0} {"ts":"2026-11-21T09:13:05.178Z","ev":"stop","ws":"devlaunch-main-3j1t","repo":null,"branch":null,"seconds":0.033327,"exit":0} {"ts":"2026-11-21T09:13:05.292Z","ev":"launch","ws":"devlaunch-main-3j1t","repo":null,"branch":null,"cold":false,"seconds":0.109264,"stages":{"devpod-up":0.072553,"tools":0.035113},"verb":"up"} {"ts":"2026-11-21T09:13:05.340Z","ev":"launch","ws":"devlaunch-main-3j1t","repo":"blooop/devlaunch","branch":"main","cold":false,"seconds":0.023009,"stages":{"devpod-up":0.016812},"verb":"--"} {"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} {"ts":"2026-11-21T09:13:05.357Z","ev":"session_end","ws":"devlaunch-main-3j1t","repo":"blooop/devlaunch","branch":"main","seconds":0.016222,"exit":0} {"ts":"2026-11-21T09:13:05.357Z","ev":"aid_end","ws":"devlaunch-main-3j1t","repo":"blooop/devlaunch","branch":"main","seconds":0.060187,"exit":0,"agent":"claude"}DuckDB reads the file:
read_json_autoreadstsasTIMESTAMP WITH TIME ZONE,coldasBOOLEAN,secondsasDOUBLE.sources.sql, withSET VARIABLE dl_eventson this file, loads all 8 lines intodl_eventswith every column filled.dl_start_seconds_p50= 0.023009,dla_start_seconds_p50= 0.043923,aid_start_seconds_p90= 0.043923,dl_cold_starts_per_day= 0.0.The lines
evdlwrites it whents,ev,ws,repo,branchlaunchuphas finishedcold,seconds,stages,verbsession_endlaunchstarted has endedseconds(of the session),exitstop,kill,remove,pruneseconds,exitaid_startdlagave its start todland the workspace is readycold,seconds,stages,agent,resumeaid_enddlahas endedseconds,exit,agenttsis UTC ISO 8601 to the millisecond.wsis the workspace id when the launch knows it. Otherwise it is the target as the user typed it.coldis true when thedevpod upof the launch created the workspace.stageson alaunchholds the same named stages as the timing document, in seconds.stageson anaid_startholds the steps ofdla(pick,pr_lookup,prompt,boot_wait) anddl, the launch inside it.aidnames are the old name ofdla. The usage-review queries already filter on them.What changes
rust/devlaunch-core/src/timing.rs:timing::beginnow takes a hook,Option<fn(&Ready)>. The newtiming::readycalls the hook one time for each command, with a newReadystruct: workspace id, seconds,cold, stages. Core still prints and writes nothing (devlaunch-core module architecture and data model #251).rust/devlaunch-core/src/flows/launch.rs: the launch records whether itsdevpod upcreates the workspace, and callstiming::readybefore the attach.rust/dl/src/events.rs(new): the hook, the file path, and the lines.run_withstarts it and ends it.render_workspacetells it the verb, so a named workspace and a picked workspace give the same lines. Theprunearm tells itprune. Anup, acodeor adotfilesthat ends with code 0 callstiming::readyitself, because these verbs start no session.launchline and theaid_startline of one start take one timestamp, so thetsof theaid_startis never later than thetsof itslaunch. The usage-review join (l.ts >= a.ts) needs this.aid_endafter adlastart that failed before ready names the target the user typed. Before, itswswas null.rust/dla/src/main.rs:dlacharges its own steps as stages, then gives the start todl, then writesaid_end.test/conftest.py: the Python suite now setsXDG_STATE_HOMEto a scratch directory. Without this, one suite run wrote two lines into the real~/.local/state/devlaunch/events.jsonl.README.md,docs/performance.md(new section "The event log"),CHANGELOG.md.Limits
docs/performance.md("The event log") states each of these:dlgets SIGHUP and its signal handler exits with_exit(129). The handler writes nothing, so thelaunchhas nosession_end, and adlastart has noaid_end.dlaboot (dla --boot-up <spec> up) is a separate process. It creates the workspace and writes its ownlaunchwithverbupandcoldtrue. The attach in the foreground then writes alaunchwithcoldfalse, andaid_startcopiescoldfalse. So one interactive start gives twolaunchlines, and a cold start shows on theupline, not onaid_start.stop,killandremovewrite the target as the user typed it inws.repoandbranchare null when the target is a workspace id.launchline too.--refresh-stale(the unattended recreate) writes no line.Merge danger
The public-API rows for
timing::Ready,timing::beginandtiming::readyinrust/devlaunch-core/public-api.rest.txtare hand-written. This host has no nightly toolchain and nocargo-public-api. Thepublic-apijob in CI must confirm the rows.timing::beginchanges its signature, so this is a change to the public API ofdevlaunch-core.Tests
cargo fmt --check: clean.cargo clippy --locked --all-targets -- -D warnings: clean.cargo test --workspace --locked: 3342 passed, 0 failed, 1 ignored.pixi run test(pytest): 888 passed, 7 skipped.prek run --from-ref origin/main --to-ref HEAD: passed.New tests:
rust/dl/tests/launch.rs:launchthensession_end.cold: truewith stages. A stopped workspace that itsupstarts writescold: false.upwrites onelaunchand nosession_end. Acodeor adotfilesdoes the same. Anupthat devpod refuses writes nolaunch.XDG_STATE_HOME. A relativeXDG_STATE_HOMEis ignored.DEVLAUNCH_EVENTS=0writes no file. A log that cannot be written does not change the exit code or stderr.rust/dl/tests/lifecycle.rs:stop,kill,rm,rmeanddl --prune -yeach write one line with theirev. A refusedrmwritesexit: 3.rust/dl/tests/picker.rs: a pickedstopand a pickedupwrite the same lines as a named one.rust/dla/tests/rewrite.rs: adlastart writeslaunch,aid_start,session_end,aid_end, with thedlastages andwsonaid_end. A resume writesresume: true. A start that fails before ready writes anaid_endthat names its target.events.rs(the off switch, the timestamp, the line fields, onetsforlaunchandaid_start) and intiming.rs(theReadysnapshot, one call only, the hook).🤖 Generated with Claude Code
Summary by Sourcery
Record command usage in a resilient JSONL event log so launch performance and lifecycle activity can be reviewed after the fact.
New Features:
dlanddlalaunches, sessions, and lifecycle operations, including timing, cold-start status, stages, and exit details.Bug Fixes:
Enhancements:
DEVLAUNCH_EVENTS=0and locating logs throughXDG_STATE_HOME.Documentation:
Tests:
dlaevent records, configuration, failure handling, and timing metadata.Chores: