Repository navigation
Description
Problem
pm-stack/aggregator/scripts/record-claude-launch.ts — the script a Muse session (or its launcher) uses to register itself in the identity registry, the record that makes the dashboard's task ↔ session linkage work for Muse sessions — silently ignores unknown, misspelled, joined, and duplicate arguments. Every flag is probed with indexOf only:
arg()atrecord-claude-launch.ts:47-50—process.argv.indexOf('--' + name), first match wins, no scan of the remaining tokens.taskRefsatrecord-claude-launch.ts:65— aflatMapover exact--tasktokens only.
The flag values were hardened in #3415 (a flag token refused as a value) and #6895 (empty values refused). The unknown-token half was left, exactly as it was for the sibling scripts fixed in #6961/#6967/#7097/#7254/#7289/#7302.
Verified this run (laptop, main @ 36e5b3e, real script run verbatim with bun run, probe ~/git/fleet/probe-claude-launch-unknown-args, script md5 41403504aadfa51193d0de228c9c829d)
Control (documented separated flags) exits 0 and records exactly what it names:
--label Control --model sonnet --status done --id claude-ctrl
-> {"id":"claude-ctrl","label":"Control","parentId":null,"status":"done","model":"sonnet"}
Every one of these exits 0 and appends a record, with the named intent silently dropped or redirected:
Invocation (plus --label X --id <id>) |
Record actually appended |
|---|---|
--modle sonnet (typo) |
no model field |
--stats done (typo) |
"status":"launched" (the default) |
--model=sonnet (joined) |
no model field |
--parnt sess-123 (typo) |
"parentId":null |
--bogus 1 stray (unknown + positional) |
record appended, tokens ignored |
--label First --label Second, --id a --id b (duplicates) |
first value wins, second silently ignored |
--tas developing-today/code#123 (typo) |
no taskRefs — the session↔task linkage the script exists to create is gone |
--task=developing-today/code#123 (joined) |
no taskRefs |
--fil <intended.jsonl> (typo, fake HOME) |
record written to the default registry file under the fake home, not the intended file — in production the record pollutes the default registry and the collector reading the intended file never sees the session |
Why it matters
This script's only job is faithful registration. A typo does not fail the launch — it registers a wrong session: unlinked to its task (--task typo), unparented, with the wrong status/model, or in the wrong file, all with exit 0 and a success line naming the id. The registry merge then folds/dashboards that corrupted record as truth, and there is no signal anywhere that the operator's flag was dropped.
Acceptance criteria
- Before any file is created, read, or appended, the script validates the whole argv against the documented flag set (
--label,--id,--parent,--task,--model,--status,--file— all value-taking;--taskis the only repeatable one). - Unknown, misspelled, joined (
--flag=value), duplicate single-value, and stray positional arguments fail with a usage error naming the offending token and exit 2, with no record appended to any file (including the default file). - The documented invocations in the script header still work verbatim, including multiple
--taskflags, and the aggregator(record-claude-launch): a flag token is accepted as the previous flag's value — '--task --model x' records taskRefs ['--model'], '--label --id x' records a session named '--id', exit 0 #3415/aggregator(record-claude-launch): empty flag values are recorded verbatim — '--id ""' appends a session with no id, '--parent ""' a parent that is not null, exit 0 #6895 value guards keep passing. - Regression tests in the established subprocess style (cf.
test/record-claude-launch-flag-value-3415.test.ts,test/record-claude-launch-empty-value-6895.test.ts) cover typo, joined, unknown, duplicate, and stray cases and assert no file write occurred; the new tests fail on the pre-fix script.
Prior art
Same fix shape as the merged sibling fixes: rejectUnknownArgs() as the first statement of the main flow, exit 2 before any I/O (post-alert #7289/PR #7295, produce-charge-candidates #7302/PR #7304, generate-digest #7097, collect-github-billing #7254).
Activity
developing-today commentedon Nov 8, 2026
CODE-2259
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done