Skip to content

fix(agent): stop blocking CLI startup on an unbounded git status - #89

Merged
AetherAI3 merged 1 commit into
mainfrom
fix/lazy-git-commit-guard
Aug 20, 2026
Merged

AetherAI3 merged 1 commit into
mainfrom
fix/lazy-git-commit-guard

Conversation

@AetherAI3

@AetherAI3 AetherAI3 commented Aug 20, 2026 •

Copy link
Copy Markdown
Owner

The defect

new ToolExecutor(cwd) unconditionally constructed a GitCommitGuard, and the guard's constructor ran two synchronous spawnSync git calls:

git status --porcelain=v1 -z --untracked-files=all
git diff --cached --name-only -z

Those ran on every aether agent and every aether chat start — before the first turn, on the main thread, whether or not the run ever called git_commit. Two properties make that expensive rather than merely wasteful:

  • git status reports the whole repository, not the directory it is invoked from. If the workspace is a small directory inside a large repository, the probe still walks the large repository.
  • --untracked-files=all enumerates every untracked path individually rather than collapsing untracked directories.

With no pathspec, the cost is O(entire worktree) and the event loop is frozen for its duration, so the CLI shows nothing at all while it runs. The same pair of calls repeated on every git_commit.

Measured, on this machine

Windows 11, Git Bash, %TEMP% = C:\Users\lilbe\AppData\Local\Temp, which sits inside a version-controlled home directory (C:\Users\lilbe\.git). From an empty temp workspace inside that ambient repository:

probe result
git status --porcelain=v1 -z --untracked-files=all (as shipped) did not finish inside a 120s cap — timeout returned 124
git --no-optional-locks -c core.literalPathspecs=true status --porcelain=v1 -z --untracked-files=all -- . (this PR) 0.51s

The unbounded run spent its two minutes enumerating AppData/Local/Microsoft/Windows/INetCache, .codex/visualizations/..., and similar — none of which could ever have produced a commit candidate for a workspace elsewhere on disk.

Why CI never caught this

The same code path is exercised on every CI run and has always been green, because a hosted runner's temp directory is not inside a git repository. Repository discovery from a temp workspace fails immediately there, git status returns an error in milliseconds, and the guard records "not a usable git repository". The pathology only appears when the temp root — or the workspace — happens to live inside a repository, which is the normal situation for a Windows developer whose home directory is under version control. The green matrix was accurate about the runner and silent about everybody else.

This is also the root cause of the standing "npm test hangs on this machine" hazard in this repo. Every mkdtempSync-based test that built a ToolExecutor walked the entire home tree. On the pre-fix tree the suite was killed at 300s with ToolExecutor writes then reads a file in the workspace (199518ms) still running.

What changed

1. The guard is built lazily, on the first mutating tool call.

ToolExecutor no longer constructs GitCommitGuard in its constructor. It constructs it on the first call to a tool that can change the workspace — write_file, run_shell, run_tests, git_commit. Startup runs no git at all, and a session that only reads never runs any.

Decision I was asked to make explicitly: why not defer all the way to the first git_commit. Constructing the guard is what captures the "already dirty before the agent started" baseline, and planGitCommit computes candidates as currentDirty − baseline. A baseline captured at commit time is by definition equal to the current state, so the difference is empty for every commit and git_commit becomes an unconditional no-op. The first mutating tool call is the latest moment that is still provably before the run's first mutation, so that is where the baseline is taken.

Behaviour change this implies, stated plainly: a change made to the workspace behind the executor's back — by the user, another process, or a test writing with fs directly — between process start and the agent's first mutating action is now part of the baseline and will not be a commit candidate. The baseline is now "the workspace immediately before the agent first touched it" rather than "the workspace when the process started". For a guard whose entire purpose is to avoid committing work the agent did not do, that is a tightening, not a loosening. Two tests in tool_executor.test.ts wrote their fixture file with writeFileSync and then asked for a commit; they now write through exec.execute("write_file", …), which is how the agent actually mutates a workspace, and a new test pins the ordering directly.

2. The probes are bounded and no longer take locks.

Both probes carry a -- . pathspec (STATUS_PROBE / STAGED_PROBE), bounding the walk to the workspace subtree. The guard only ever stages paths inside the workspace, so this removes work that could never have produced a candidate. Every git invocation from SpawnGitRunner now carries --no-optional-locks, so a plain git status no longer rewrites the user's index as a side effect of the agent starting — a side effect the CLI should never have had, and one that can lose a race with the user's own git process in the same worktree.

3. Test workspaces can no longer be held hostage by where os.tmpdir() lives.

New test/tmp_workspace.ts exports tmpWorkspace(prefix) and TEMP_ROOT, and pins GIT_CEILING_DIRECTORIES at the canonical temp root at import time. Every test that builds a ToolExecutor now allocates through it: bridge, process_tree, release_canaries, tool_executor, tool_registry, web.

Decision I was asked to make explicitly: GIT_CEILING_DIRECTORIES rather than git init. The ceiling stops repository discovery at the temp root, so a temp workspace is "not a git repository" on every machine — exactly what CI has always seen. It changes nothing about what the tests exercise. git init-ing each workspace would do the opposite: it would silently convert the non-repository code paths these tests cover into live-repository paths, spawn an extra git process per test, and leave the underlying accident (git discovery escaping the temp directory) in place for any future code that shells out to git from a temp directory. The ceiling is inherited by child processes through process.env, so it covers spawnSync calls the executor makes without any change to the executor.

Test evidence

Environment: worktree ~/agent-w4core-wt (a clean worktree off origin/main @ c165be0), Windows 11, Git Bash, default TEMP=C:\Users\lilbe\AppData\Local\Temp — not redirected. No git stash was used at any point in producing this branch.

$ cd ~/agent-w4core-wt && npm run typecheck
> tsc -p tsconfig.json --noEmit
(clean)

$ cd ~/agent-w4core-wt && echo "TEMP=$TEMP" && time npm test        # run 2 of 2
TEMP=C:\Users\lilbe\AppData\Local\Temp
...
ℹ tests 1119
ℹ suites 0
ℹ pass 1118
ℹ fail 0
ℹ cancelled 0
ℹ skipped 1
ℹ todo 0
ℹ duration_ms 199320.7096

real    3m45.106s

The suite completes, green. That is the proof: on the pre-fix tree, with the same default TEMP, it did not — it was killed at 300s with a single test 199s in. duration_ms is the node --test phase; the wall clock is the full npm test, which is npm run build (a tsc compile) followed by the test phase. Both numbers move with machine load; the first of the two runs reported duration_ms 137027.5677 with a 5m23.252s wall clock, so read the shape (it finishes at all, in minutes rather than never) rather than the exact seconds.

That first run had one failure — a pre-existing load-dependent flake in process_tree.test.ts, which passed on the second run and is not a regression from this branch:

✖ a timed-out command kills its whole tree, not just the shell (5269.7584ms)
  AssertionError: no grandchild pid in output: [timeout after 2s]\nCHILD:37196

The test starts a child which spawns a grandchild and asserts the grandchild printed its pid before a 1500 ms timeout fires. Under full-suite CPU pressure the grandchild's Node cold start did not print in time, so the assertion had no pid to read — it is a race against a fixed 1500 ms budget, and it fails before reaching anything this branch touches. It passed in the second full-suite run, and run in isolation on this same branch it passes 3/3:

$ node --test --test-isolation=none dist/test/process_tree.test.js   # x3
✔ a timed-out command kills its whole tree, not just the shell (3002.2269ms)
✔ a timed-out command kills its whole tree, not just the shell (2880.3981ms)
✔ a timed-out command kills its whole tree, not just the shell (3260.1267ms)
ℹ pass 4 / fail 0   (each run)

Nothing in this branch touches process spawning, timeouts, or reaping. I have left it alone rather than widening a timeout in a file whose whole subject is timing; see "found but not fixed".

New tests added here:

  • test/tool_executor.test.ts — "the commit guard is armed by the first mutating tool, not by construction": asserts the full ordering in one go. Construction does not arm the guard, a read_file does not arm it, a write_file does; an edit made out of band before that point lands in the baseline, and the resulting commit contains the agent's file and only the agent's file.
  • test/git_commit_guard.test.ts — "repository probes are bounded to the workspace and take no optional locks": pins the pathspec on both probes and --no-optional-locks in the global arg prefix.

Blast radius

  • GitCommitGuard's public shape is unchanged; the constructor still takes the baseline. Only its call site moved, plus the flags on the git invocations.
  • src/commands/slash_git_tools.ts also uses SpawnGitRunner and therefore inherits --no-optional-locks. That is intended — those are read-side git helpers too — and no behaviour of theirs depends on the index being refreshed.
  • git_commit semantics change only for edits made outside the executor before the agent's first mutating action, as described above.
  • The GIT_CEILING_DIRECTORIES pin is test-only, set from a test module, and additive: it appends to any existing value rather than overwriting it.
  • .github workflows, package.json, and the CI matrix are untouched.

This also unblocks local testing for every future contributor whose temp directory happens to sit inside a repository. Until now, npm test on such a machine hung with no diagnostic — the suite simply stopped making progress inside a ToolExecutor test — and the only workaround was to know to point TEMP somewhere else. After this branch the default TEMP works, and the mechanism that made it fail is documented at the top of test/tmp_workspace.ts so the next person does not have to rediscover it.

Found but not fixed

  • process_tree.test.ts is timing-fragile under load. The 1500 ms budget in "a timed-out command kills its whole tree" has to cover two Node cold starts on Windows. Its sibling test gives itself 900 ms of settle time before asserting and did not flake. Out of lease for this PR, and worth fixing deliberately rather than by nudging a constant.
  • GitCommitGuard is wrong when the workspace is a subdirectory of the repository. git status --porcelain emits paths relative to the repository root, but the guard feeds them back to git add -- <path> / git reset -- <path> with cwd set to the workspace root. When those differ, the pathspecs do not resolve. This is pre-existing and unchanged by this PR — the -- . pathspec bounds which paths are reported, not how they are spelled. Fixing it means either resolving candidates against the repository root or emitting :(top)-anchored pathspecs, which is a separate change with its own tests.

Constructing a ToolExecutor built a GitCommitGuard unconditionally, and the
guard's constructor ran two synchronous git calls — `git status
--porcelain=v1 -z --untracked-files=all` and `git diff --cached`. Both ran on
every `aether agent` and `aether chat` start, before the first turn, whether
or not the run ever called git_commit. `git status` reports the whole
repository regardless of where it runs, and `-uall` enumerates every untracked
path individually, so the cost was O(entire repository) with the event loop
frozen for the duration.

Three changes:

1. The guard is now built by ToolExecutor on the first MUTATING tool call
   (write_file, run_shell, run_tests, git_commit) instead of in the
   constructor. Startup runs no git at all, and a read-only session never
   runs any. It is not deferred as far as the first git_commit: constructing
   the guard is what takes the "already dirty" baseline, and a baseline taken
   at commit time equals the current state, which would make git_commit an
   unconditional no-op.

2. Both probes are bounded to the workspace subtree with a `-- .` pathspec,
   and every git invocation now carries `--no-optional-locks` so inspecting
   a repository no longer rewrites the user's index as a side effect.

3. Test workspaces route through test/tmp_workspace.ts, which pins
   GIT_CEILING_DIRECTORIES at the temp root. On a machine whose temp
   directory sits inside a repository, repository discovery previously walked
   out of the temp workspace into that ambient repository and every probe
   became O(entire home directory); the suite hung there. CI never saw it
   because hosted runners' temp roots are not inside a repository.

Measured on Windows from a temp workspace inside a version-controlled home
directory: the unbounded probe did not finish inside a 120s cap (exit 124);
the same probe with the pathspec returns in 0.51s. Full suite with the default
TEMP now completes: 1119 tests, 137.0s of test time.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@AetherAI3
AetherAI3 merged commit ac64236 into main Aug 20, 2026
5 checks passed
@AetherAI3
AetherAI3 deleted the fix/lazy-git-commit-guard branch August 20, 2026 10:15
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
The library had columns for these and nothing to put in them: `branch`,
`repoRemote`, `headRev` and `skills` existed on SessionMeta, but the only
caller that builds a SessionLog (commands/code.ts, another lane's file) passes
none of them, so every real session rendered `unknown` for all four. Honest,
and useless — two of the questions the library exists to answer could never be
answered for a session this build actually wrote.

Both are now taken from what the session already has:

  branch / repoRemote / headRev — probed from the workspace ONCE, in close().
    Not in the constructor: `aether agent` startup must spawn no git, which is
    what #89 cleared off that path, and a test asserts the probe has not been
    called after construction. The run is over by close(), so three
    `git rev-parse`-class calls cost nothing anyone waits on. The probe is
    injected, so every branch of it is testable without a checkout. A probe
    that finds nothing, or throws, leaves the fields ABSENT — the library then
    says "unknown", which is the truth, rather than an empty string that
    renders as a blank cell.

  skills — accumulated from the `skill` events already streaming through
    event(). Deduplicated (one entry per skill, not per event) and bounded at
    32, so a looping brain cannot grow the manifest without limit. The
    alternative was re-reading the transcript at listing time, which is exactly
    the cost the index exists to remove.

What the caller declares still wins over what was probed: a caller that made
the branch knows better than a probe of the launch directory.

readRepoIdentity and repoFrom move from handoff.ts to session_log.ts, because
the identity is now STORED here — handoff.ts already imports this module, so
the other direction would be a cycle. handoff.ts re-exports readRepoIdentity
and HandoffRepo is now an alias of RepoIdentity, so a handoff and a library row
cannot describe a repository in two different shapes. No caller changed.

1144 pass / 0 fail / 1 skipped across 132 test files.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
AetherAI3 added a commit that referenced this pull request Aug 23, 2026
…4) (#99)

* feat(sessions): a real project session library

Durable sessions existed but were not operable: finding one meant knowing an
opaque id or browsing ~/.aether-agent by hand, and every "what was I doing
here" question cost a walk of every session directory plus a parse of every
manifest. This adds the library that makes them first class.

core/session_index.ts is one small document beside the session directories:
{schemaVersion, entries}. It is a CACHE with an authority rule — the
per-session manifest.json is the truth — so a lost, corrupt, or forward-version
index costs time, never information. Writes go through durable_store.ts's
existing transaction (lock -> read -> mutate -> temp -> flush -> backup ->
rename), read inside the lock, so two runs closing in the same second both
land. A future-schema index is refused and never overwritten, and the write
path reports whether it actually persisted so a caller cannot print "archived"
for a change that is not on disk.

commands/sessions.ts is the screen: list / inspect / continue / export /
archive / clean, an interactive-width table on a TTY and tab-separated columns
with a fixed field order when piped. ui/continuity.ts computes where a session
can be continued and keeps the six answers apart — ready, stale-branch, moved
checkout, another workspace, missing checkout, archived — because the remedies
differ and collapsing any two of them misleads. ui/splash.ts shows the same
facts as a PROJECT CONTINUITY block on entry.

Nothing on the listing path opens events.jsonl; that file is the transcript and
`aether resume` is what replays it. Nothing here deletes: archive sets a flag,
clean drops index rows for sessions already gone, and neither touches a session
directory, a worktree, a branch, or a file a run wrote.

Unknown is never rendered as zero. A count nobody recorded prints "unknown"; a
run whose manifest never closed prints "never finished (running or interrupted
— unknown which)" rather than guessing; a branch the record does not name is
not assumed to be the branch you are on.

core/logs_root.ts exists only so session_log.ts and session_index.ts do not
import each other; session_log.ts re-exports logsRoot, so no caller changed.

Proven by 24 new tests: four separate processes writing concurrently lose no
row, an interrupted write leaves the previous generation byte-identical, a
corrupt index rebuilds visibly and its unreadable copy is preserved, a
future-schema index is refused and left intact, twenty-five sessions with
malformed transcripts list without a parse error, a shared timestamp prefix
never resolves across workspaces, and ESC/OSC sequences in a task never reach
a terminal. Four mutants of the load-bearing invariant were killed.

* feat(cli): reach the session library from the command line

The library in the previous commit is complete but unreachable: this is the
whole wiring, and it is deliberately separate so it can be dropped or reordered
without touching the feature.

Four additive edits to files this lane shares with others: one row in the CLI
registry, one `case "sessions"` in main.ts that lazily imports the command, a
`resume list` alias so the listing is reachable from the command people already
know, and one field passed to the splash so the PROJECT CONTINUITY block can
render. Nothing existing changes behaviour: omit the field and the splash reads
nothing from disk and renders exactly as before.

The registry spec is mirrored by SESSIONS_CLI_COMMAND next to the
implementation and pinned equal by test, so the help text and the behaviour
cannot drift. COMMANDS.md documents the surface, including the piped field
order, which is part of the contract.

* test(sessions): pin the library's cost and its honesty, and stop inventing repo names

The cost claims were prose. These tests make them a property of the run: every
session's manifest.json and events.jsonl is replaced by a DIRECTORY of the same
name, so anything that opens one throws EISDIR. A warm listing of 300 sessions
answers correctly with all 600 files unopenable, which is the claim "the
listing reads the index, not the transcripts" stated in a form that can fail.

shortRemote also turned a local path into something that reads like a
repository: "/srv/git/bare-repo" rendered as "git/bare-repo", a GitHub-shaped
identity for a directory. It now shortens only what is actually an https or
scp-style git URL and returns anything else whole.

* fix(sessions): say "never finished", "unknown", and "no pull request recorded" as three different things

`inspect` had three ways of quietly claiming more than the record supports.

  ended:  "still running" is a claim nobody can back. A manifest with no `ended`
          is a manifest that was never closed, and a run that was killed leaves
          exactly the same bytes on disk as one that is still going. It now says
          the run may still be live or may have been interrupted, and does not
          pick.

  status: a bare "running" reads like a state the verify gate signed off on. It
          now carries "(never verified — the run did not finish)".

  pr:     the line was printed only when a pull request URL existed, so its
          absence read as "no pull request was opened". Nothing in this build
          records a pull request against a session, so silence there was the
          wrong fact. It now always prints, and says the record cannot answer.

Also pins the CLI registry row against SESSIONS_CLI_COMMAND. The previous test
asserted the spec's own fields, which cannot fail if the row is never copied
into the shared registry at all — the command would simply be unreachable with
a green test. And both confirmation prompts now end in "[y/N] " so the cursor
does not sit against the question mark.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(sessions): record the branch a run was on, and the skills it used

The library had columns for these and nothing to put in them: `branch`,
`repoRemote`, `headRev` and `skills` existed on SessionMeta, but the only
caller that builds a SessionLog (commands/code.ts, another lane's file) passes
none of them, so every real session rendered `unknown` for all four. Honest,
and useless — two of the questions the library exists to answer could never be
answered for a session this build actually wrote.

Both are now taken from what the session already has:

  branch / repoRemote / headRev — probed from the workspace ONCE, in close().
    Not in the constructor: `aether agent` startup must spawn no git, which is
    what #89 cleared off that path, and a test asserts the probe has not been
    called after construction. The run is over by close(), so three
    `git rev-parse`-class calls cost nothing anyone waits on. The probe is
    injected, so every branch of it is testable without a checkout. A probe
    that finds nothing, or throws, leaves the fields ABSENT — the library then
    says "unknown", which is the truth, rather than an empty string that
    renders as a blank cell.

  skills — accumulated from the `skill` events already streaming through
    event(). Deduplicated (one entry per skill, not per event) and bounded at
    32, so a looping brain cannot grow the manifest without limit. The
    alternative was re-reading the transcript at listing time, which is exactly
    the cost the index exists to remove.

What the caller declares still wins over what was probed: a caller that made
the branch knows better than a probe of the launch directory.

readRepoIdentity and repoFrom move from handoff.ts to session_log.ts, because
the identity is now STORED here — handoff.ts already imports this module, so
the other direction would be a cycle. handoff.ts re-exports readRepoIdentity
and HandoffRepo is now an alias of RepoIdentity, so a handoff and a library row
cannot describe a repository in two different shapes. No caller changed.

1144 pass / 0 fail / 1 skipped across 132 test files.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* feat(sessions): pick a session with the arrow keys

The charter asks for "an interactive selector for TTY and a stable flat table
for pipes". The table existed; this is the other half.

ui/session_picker.ts follows the shape logs_viewer.ts already established: a
PURE reducer (pickerReduce) that a test drives with no terminal at all, plus a
thin driver that owns raw mode, the alternate screen and restoration. Movement
clamps rather than wrapping, `/` filters incrementally over the sanitized
session id, task, branch and state, Enter chooses, Esc inside a filter restores
the previous query without abandoning the picker, and q/Esc/Ctrl+C leave.

It is wired as a convenience that can always decline: an empty library, a
non-TTY stdin, `--json`, `--no-select`, or any failure inside the picker falls
back to the flat listing. That is what makes it safe as the default — the
listing is never lost, only sometimes replaced by something better. Choosing a
row opens `sessions inspect` for it, so there is one detail screen rather than
two that can drift.

35 tests cover the reducer, the scrolling window, and the driver against fake
streams — including that ESC/OSC in a task never reaches the screen and that a
row with no recorded file count renders "unknown", not 0.

* feat(resume): say when you are holding a handoff, not a local session

The charter requires local session continuation and portable handoff import to
be clearly distinguished. They were not: `continuityHeader` had a `kind` field
that nothing ever set to "handoff", and `aether resume` only understood a local
session id, so the file form had no screen of its own at all.

`aether resume <file.json>` now shows what an imported handoff carries — the
same Project Continuity header, then the files the prior run wrote and the
steps it took, then the exact command to continue. The branch is chosen by the
loader's own rule (isHandoffPath), the same one resolveResume uses, so a value
can never fall through both.

The two are said differently because they behave differently. A local session
is keyed to one absolute directory and carries a transcript to replay. A
handoff is keyed to NONE — that is what makes it portable — so handoffEntry
leaves the workspace empty and the header renders no continuity state for it at
all. "ready" or "elsewhere" would be a confident answer about a checkout the
file was never keyed to.

Eight tests, including: the two provenance lines are never both claimed, an
imported handoff is never given a state it cannot have, a bare session id still
takes the local path, a newer schema is refused rather than half-read, and
terminal escapes inside a handoff never reach the screen.

* fix(sessions): record the checkout the work actually happened in

A run redirected into a worktree executes somewhere other than where it was
launched, and the record said nothing about it. Worse, the repository identity
was probed against the LAUNCH directory, so the branch stored for such a run was
the branch the user happened to be standing on — not the branch the commits
landed on. That is the exact failure this library exists to avoid: a confident
wrong answer where "unknown" was available.

SessionMeta gains `worktree`, cmdCode passes it when the executing directory
differs from the launch directory, and the identity probe now asks the checkout
the work ran in. The session stays SCOPED to the launch directory, because that
is where the user will be standing when they resume.

The code.ts change is one conditional field, kept in the same additive spirit as
the CLI wiring commit. Two tests drive SessionLog with an injected probe and
assert on the manifest and the index row: the worktree run reports the worktree's
branch and path, and a run with no worktree and no checkout reports neither
rather than inventing either.

COMMANDS.md documents the picker, --no-select, and `aether resume <file.json>`.

* fix(sessions): declare --undo and --no-select, so they reach the command

#98's declared-flag assertion caught its first real case, and it is not a merge
artifact: neither flag was EVER declared, on this lane or before it. main.ts
parses with strict:false, so an undeclared `--undo` was captured into `values`
and stripped from the positionals sessions.ts re-parses. `aether sessions
archive <id> --undo` therefore archived instead of un-archiving and reported
success, and `--no-select` — the documented escape hatch out of the TTY picker
— never reached the command at all, which left a scripted caller on a TTY with
no way out of an interactive selector.

Declaring both in GLOBAL_FLAGS is what makes them arrive; `--no-select` is
forwarded in the sessions case alongside `--all`/`--undo`, so the read and the
declaration stay in step and the assertion covers it from now on.

The old parser would have swallowed this silently and shipped it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor(sessions): move the library onto the command registration seam

main advanced with #98, which replaced main.ts's hand-written switch and its
regex-guarded flag table with a dispatch table where a command carries its own
help metadata, its own flags and its own loader. This lane's wiring predated it,
and the merge exposed exactly the failure that seam was built to end: main.ts
parsed with strict:false, so `--all` and `--undo` were captured into `values`
and stripped from the positionals the command received. `aether sessions --all`
silently listed one project. CI caught it as an undeclared-flag violation.

`sessions` is now one entry in DISPATCH_COMMANDS: the registry row, the flags
and the handler in one place, reachability structural rather than asserted. The
switch case in main.ts is gone.

`--all` and `--out` are NOT declared here. They are global — other commands
already answer to those spellings — and the table refuses a command that
shadows a global, because the merged parseArgs namespace is flat and the shadow
would change what the flag means elsewhere. They reach the command on
ctx.flags, which now carries them the way it already carried --yes.

Adversarial review of the picker/handoff/worktree commits also found two real
defects, fixed here:

- cmdCode decided "was this run redirected into a worktree?" by comparing the
  RAW `--cwd` string to the resolved executing path, so `aether agent --cwd .`
  recorded a worktree for a plain in-place run and `sessions inspect` reported
  a checkout that did not exist. The comparison is normalized now.
- handoffEntry called its file count exact. It is not: summarizeEvents stops
  adding at MAX_FILES and parseHandoff slices to it again, so a run that wrote
  200 files arrives carrying 60. At the bound the count is omitted and renders
  "unknown" rather than confidently reporting the cap as the total.

* refactor(sessions): hand parsed flags over as data, not as a rebuilt argv

#98's spec is explicit that a dispatched command receives its flags as a typed
object and never as tokens re-rendered for a second parse. The sessions entry
was rebuilding `["--all"]`, `["--undo"]` and handing them back for the command's
own parser to read — an array rather than a shell string, so not a hole today,
but exactly the shape the seam exists to remove: a second parse is where a value
can be promoted into a flag nobody typed.

`cmdSessions` now takes a fourth parameter, `SessionsFlags`. The dispatch entry
passes `{all, undo, noSelect, out}` and `argv` carries only the positionals the
host already separated out.

The argv fallback stays for callers that never went through the CLI parse — the
tests, and `aether resume list` — but typed values take PRECEDENCE over tokens,
and a test pins that: an argv `--all` loses to `{all: false}`. Without that test
the fallback quietly becomes a second parse again the first time someone
reorders the function.

Raised by the lane that owns the seam; their objection was correct.

---------

Co-authored-by: DBarr3 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant