Skip to content

feat(sessions): project continuity and the session library (AA-CONT-04) - #99

Merged
AetherAI3 merged 15 commits into
mainfrom
lane/aa-cont-04-sessions
Aug 23, 2026
Merged

AetherAI3 merged 15 commits into
mainfrom
lane/aa-cont-04-sessions

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

What this is

Lane AA-CONT-04. The agent already kept durable session records; they 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 makes the sessions a first-class screen.

aether sessions                        # this project, newest first
aether sessions --all                  # every project on this machine
aether sessions inspect <id>
aether sessions continue <id>
aether sessions export <id>
aether sessions archive <id> [--undo]
aether sessions clean
aether resume list                     # alias for the same listing

Design

The index is a cache; the manifest is the authority. core/session_index.ts
keeps one small {schemaVersion, entries} document beside the session
directories. Anything the index cannot answer is answered by rebuilding from
the manifests — never by rendering an empty list. That rule is what makes it
safe to delete, corrupt, or lose. Writes go through the transaction
durable_store.ts already implements (lock → read → mutate → temp → flush →
backup → rename), with the 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 now reports whether it actually persisted, so no caller can
print "archived" for a change that is not on disk.

Nothing on the listing path opens events.jsonl. That file is the
transcript and aether resume is what replays it.

Where a session can be continued is computed, not assumed. Six states kept
apart because the remedies differ: ready, stale-branch, moved,
elsewhere, missing, archived. A session that cannot be continued here is
refused with the reason and pointed at export, which is the form that crosses
machines.

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)
, because nothing on this machine can tell those
apart. A branch the record does not name is not assumed to be the branch you
are on.

Nothing here deletes. archive sets a flag and --undo reverses it.
clean removes index rows for sessions already gone from disk, after printing
every row and asking. Neither touches a session directory, a worktree, a
branch, or a file a run wrote.

Evidence

  • npm run typecheck — clean
  • npm test — 1169 pass / 0 fail / 1 skipped; the skip is pre-existing
    (symlink creation not permitted on this host)
  • npm run verify:production — {"ok":true,"packedFiles":536,"packedBytes":2561364}
  • 38 new tests. The load-bearing ones:
    • four separate processes writing concurrently lose no row
    • a fault injected at before-rename leaves the previous generation
      byte-identical and still readable
    • a corrupt index rebuilds visibly and its unreadable copy is preserved
    • a future-schema index is refused, preserved, and not overwritten, and
      archive reports failure rather than success against it
    • a warm listing of 300 sessions answers correctly with all 600
      manifest.json/events.jsonl files replaced by directories, so opening any
      one of them would throw
    • a shared timestamp prefix never resolves across workspaces
    • ESC/OSC sequences in a task never reach the terminal
  • Mutation testing on the invariant (index is a cache, manifest is authority):
    4 mutants — empty-on-corrupt, future-schema clobber, unconditional field
    overwrite, missing-checkout→other-workspace collapse — all 4 killed.
  • End-to-end from the built binary against a seeded log root: list, inspect,
    continue, archive, resume list, help sessions.

Adversarial review by a model that did not write it raised two real defects,
both fixed here: archive reported success when the index write had been
refused, and filesTouched double-counted paths differing only by case on
Windows (it is also now labelled as what it measures — files written via
write_file).

Shape of the commits

  1. feat(sessions) — the library. Only files this lane owns.
  2. feat(cli) — the wiring. Four additive edits to shared files
    (cli_registry.ts, main.ts, chat.ts, COMMANDS.md). Kept separate so
    the merge controller can drop or reorder it without touching the feature —
    cli_registry.ts is AA-SKILLS-03's lease and main.ts/chat.ts are the
    integration lane's.
  3. test(sessions) — the cost/honesty tests and the shortRemote fix.

Notes for review

  • Base: main @ ed094dc8885945e69f66e166e854142005bf1d62, verified against
    origin/main before branching.
  • core/logs_root.ts is a new leaf module that exists only so session_log.ts
    and session_index.ts do not import each other. session_log.ts re-exports
    logsRoot, so no existing caller changed.
  • npm run smoke reports one failure on this machine — local turn: Ollama model 'qwen2.5-coder:7b' not found (404). Environmental, untouched by this
    branch.
  • Not merging this myself.

🤖 Generated with Claude Code

AetherAI3 and others added 4 commits August 22, 2026 10:53
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.
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.
…nting 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.
…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]>
@AetherAI3

Copy link
Copy Markdown
Owner Author

Follow-up: the bounded-cost numbers, and the third unknown

Pushed f19dcd0 on top of aee11a0.

Bounded cost, measured

Both runs use the same fixture: 200 sessions, each with a 400-line
events.jsonl (~100 KB) beside a ~500-byte manifest.json. Counters wrap
node:fs and are installed before the modules under test are imported, and
count only paths under the log root.

Answering "which session was last here" — latestSession, what every
aether resume and now every REPL launch calls:

files read bytes read existsSync wall
before (ed094dc) 405 20,090,185 1,201 445 ms
after, warm 3 192,485 207 65 ms

3 = the index, plus the manifest and transcript of the one session it actually
returns. Before, it fully loaded and JSON-parsed every session's
events.jsonl to compare timestamps: 2 file reads per session, 20 MB, growing
without bound with the user's history.

Listing the library — aether sessions. No prior number exists; the
surface did not exist.

files read bytes read readdirSync wall
warm 1 92,134 1 21 ms

One read of the index, one directory listing to reconcile it against the disk.
Independent of the number of sessions.

The one-time migration — the first read after upgrading, when sessions
exist and no index does:

files read bytes read wall
cold, 200 pre-existing sessions 400 140,180 250 ms

Manifests only. Even the cold path never opens a transcript: 140 KB against
the 20 MB the old code read on every single invocation
. It is written back,
so it is paid once. (400 = 200 manifests read twice — once by the rebuild, once
by the re-read inside the write lock. Not optimised; it happens once per
machine.)

f19dcd0 also carries the reconciliation this depends on: syncSessionIndex
lists the session directories and backfills any id the stored index lacks.
Without it, the first session written after an upgrade produces an index that
parses cleanly and is short, and the user's older sessions disappear from both
the listing and aether resume. Test: "sessions recorded before the index
existed are reconciled into it, not lost"
.

Mutation test: unknown is not zero

The PR's four mutants cover index-is-a-cache. This is the other invariant.

Two deliberate mutations, applied together:

-  if (usage.status !== "observed" || usage.observed == null) return `${UNKNOWN} spent · ${cap}`;
+  if (usage.status !== "observed" || usage.observed == null) return `${uvt(usage.observed ?? 0)} / ${cap}`;
-  return typeof value === "number" ? String(value) : UNKNOWN;
+  return String(value ?? 0);

Result — 4 failures, both mutants killed:

dist/test/session_library.test.js
  ✖ an unmeasured budget reads as unknown, never as zero spent
  ✖ the splash continuity block prints unknowns as unknown
dist/test/sessions_cmd.test.js
  ✖ the piped listing is tab separated with a stable field order
  ✖ classification separates the five ways a session can be elsewhere

Reverted; 16/16 and 14/14 green again.

The third unknown

inspect had three ways of claiming more than the record supports. All three
now print distinctly:

  ended     never — this run may still be live, or may have been interrupted
  status    running (never verified — the run did not finish)
  verify    unknown
  branch    unknown
  written   unknown file(s) via write_file
  pr        unknown — this build does not record pull requests

pr is the one worth calling out: it was printed only when a URL existed, so
its absence read as "no pull request was opened". Nothing in this build records
a pull request against a session, so that silence was the wrong fact. "No PR"
and "unknown whether a PR was opened" are different, and only the second one is
true here.
It is unknown by construction, and named as such — not a gap to
fix quietly later.

Registry parity was not actually pinned

The existing test asserted SESSIONS_CLI_COMMAND's own fields. That cannot
fail if the row is never copied into CLI_COMMANDS at all — the command would
be unreachable with a green suite. f19dcd0 adds the assertion that compares
the two.

Verification of this commit

  • npm run typecheck — clean
  • 132 test files (all but tool_executor*, long_running*, process_tree,
    smoke, release_canaries, which hang or are slow on this Windows box):
    1141 pass / 0 fail / 1 skipped
  • dist/test/session_library.test.js 16/16, sessions_cmd 14/14,
    session_index 10/10, resume_cmd 7/7, session_resume 5/5, ui 7/7,
    command_docs_parity 1/1

Lane note

Two agents were live in ~/aa-cont-04-wt on this branch at the same time and
converged on the same design; commits 8bc5cc7/73a982e/aee11a0 and this
one are the interleaved result. Worth checking before another lane is
dispatched to the same worktree. Not merging this myself.

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

Copy link
Copy Markdown
Owner Author

fee9cb5 — the four columns that had nothing to put in them

branch, repoRemote, headRev and skills existed on SessionMeta, but the
only caller that constructs a SessionLog — commands/code.ts, another lane's
file — passes none of them. Every session this build actually wrote rendered
unknown for all four. Honest, and useless: two of the questions the library
exists to answer could not be answered for any real session.

Both are now taken from what the session already has, without touching
code.ts:

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. By close() the run is over, so three
git rev-parse-class calls cost nothing anyone waits on. The probe is
injected, so every branch of it is tested without a checkout. A probe that
finds nothing — or throws — leaves the fields absent, so the library says
unknown rather than rendering an empty string 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.
The alternative was re-reading the transcript at listing time, which is the
cost the index exists to remove.

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

readRepoIdentity/repoFrom move from handoff.ts to session_log.ts,
because the identity is now stored there and handoff.ts already imports that
module — the other direction is 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.

End to end, from the built binary

A session written by this build in this checkout, then read back through the
CLI:

▚ 2026-08-22T15-09-40-576Z-cloud-29220
  task      record the branch a run was on
  started   2026-08-22T15:09:40.576Z
  ended     2026-08-22T15:09:40.599Z
  status    ok
  brain     cloud · gpt56_sol
  verify    npm test
  workspace c:\users\lilbe\aa-cont-04-wt
  repo      https://github.com/AetherAI3/aether-agent.git
  branch    lane/aa-cont-04-sessions @ fee9cb5379dc
  written   1 file(s) via write_file
  events    4
  tools     1
  skills    review-pr, ship
  pr        unknown — this build does not record pull requests
  where     ready — continues here

Every line above except pr is now real recorded data. pr stays unknown by
construction and says so.

Where the nine continuity questions stand

question answered from
what projects did I work on manifest.cwd, always recorded
which session is running or incomplete finalStatus + ended; running-vs-interrupted is unknown by design and named
which model and brain recorded
which branch / worktree branch, remote and HEAD now recorded; worktree still unknown — only code.ts knows the isolated directory
did verification pass finalStatus + testCmd + remaining, from the host's verify gate
was a PR opened unknown by construction, printed as such
which skills / project instructions skills now recorded; instructionsDigest still unknown — nothing computes it
how much UVT was spent current session only, from checkUvtCap(), as unknown / observed / not-metered. No per-session UVT is recorded anywhere, so a past session's spend is not shown at all rather than shown as 0
can I continue / export / archive / clean all four, with the six-state continuability classification

Three remain unknown and are named as unknown rather than defaulted:
worktree, instructionsDigest, and historical per-session UVT. Each needs a
field set by a file this lane does not own (code.ts) or a meter this lane does
not own (AA-USAGE-06).

Verification

  • npm run typecheck — clean
  • 132 test files: 1144 pass / 0 fail / 1 skipped (skip is pre-existing:
    symlink creation not permitted on this host)
  • dist/test/session_library.test.js 18/18

Not merging this myself.

AetherAI3 and others added 7 commits August 22, 2026 11:21
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.
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.
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>`.
`main` replaced main.ts's inline parseArgs literal with CLI_PARSE_OPTIONS and
a DISPATCH_COMMANDS lookup. This lane's `sessions` case merges cleanly onto the
new structure; the declarations it needs move to GLOBAL_FLAGS in the next
commit, which is what #98's declared-flag assertion is asking for.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#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]>
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.
Both sides of this branch fixed the same thing and disagreed on where the fix
belongs. The other side declared `--undo` and `--no-select` in GLOBAL_FLAGS and
kept the `case "sessions"` in main.ts; this side moved the whole command onto
the dispatch table #98 introduced.

Resolved toward the table, because that is what #98 argued for and what makes
the fix structural: the registry row, the flags and the loader are one entry,
so the next flag cannot be read without being declared. `--undo` and
`--no-select` are `sessions`' OWN flags there — nothing else answers to either
spelling, and making them global would hand every command a flag that means
nothing to it. `--all` and `--out` stay global, because other commands do
answer to those, and reach the command on ctx.flags.

The other side's finding stands and is preserved in the comment: neither flag
was ever declared, on this lane or before it, so `aether sessions archive <id>
--undo` archived instead of un-archiving and said it had restored, and
`--no-select` never reached the command at all.

Verified end to end on the built binary: `--all` crosses workspaces, and
archive/--undo round-trips.
…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.
Five conflicts, all resolved toward the seam main established:

- src/commands/cli_registry.ts — union of dispatch entries. The lane's
  `sessions` entry (own `flags`: --undo, --no-select; --all/--out read off
  ctx.flags because they are globals) sits beside main's `review`/`ship`
  entries. No entry redeclares a global.
- src/main.ts — GlobalFlags now carries `all`, `testCmd` (main) and `out`
  (lane). No inline options literal and no `case "sessions"`: the lane had
  already moved onto CLI_PARSE_OPTIONS in d1dc8c4/a6c6f7b.
- src/core/context.ts — GlobalFlags is the union: all, out, testCmd.
- src/core/session_log.ts — both provenance sets kept. #99's
  manifestBody()/indexSelf() structure survives (the session index is built
  only from manifestBody), and #100's `context` field is carried into that
  body alongside the lane's `skills`/`instructionsDigest`: they record
  different things — what the caller declared, and what the host loop saw.
  `homedir` dropped from the imports; the lane resolves the log root through
  logs_root.ts, so main's import had no remaining use.
- COMMANDS.md — every command row kept; the CLI registry index is the union
  (sessions + review + ship).

typecheck clean; npm test 1440 tests, 1436 pass, 0 fail, 4 skipped.
@AetherAI3

Copy link
Copy Markdown
Owner Author

Merged origin/main (bffb40a) into the lane as a plain merge commit — 7e357b5. No rebase, no force-push.

git merge conflicted in the five files merge-tree predicted. Resolutions, all toward the seam main established:

  • src/commands/cli_registry.ts — union of DISPATCH_COMMANDS. The lane's sessions entry (its own flags: --undo, --no-select) sits beside main's review/ship entries. --all and --out stay GLOBAL and are read off ctx.flags the way doctor reads --yes; no entry shadows a global, so the registry load validator stays quiet.
  • src/main.ts — GlobalFlags construction is the union: all, testCmd (main) and out (lane). Nothing else needed: the lane had already moved onto CLI_PARSE_OPTIONS and dropped its case "sessions" in d1dc8c4/a6c6f7b, so there was no inline options literal left to remove.
  • src/core/context.ts — GlobalFlags interface is the same union: all, out, testCmd.
  • src/core/session_log.ts — both provenance sets kept. feat(sessions): project continuity and the session library (AA-CONT-04) #99's manifestBody()/indexSelf() structure survives (the session index is only ever built from manifestBody), and feat(skills): put skills and AGENTS.md inside real runs, and enforce their policy #100's context field is carried into that body next to the lane's skills/instructionsDigest — they record different things (what the caller declared vs. what the host loop observed), so neither replaces the other.
  • COMMANDS.md — every command row kept; the CLI-COMMANDS marker is the union (sessions + review + ship).

Edited beyond the automatic merge: one line only —

  • src/core/session_log.ts: dropped import { homedir } from "node:os". Main used it to compute the log root inline; the lane resolves that through logs_root.ts, so after the merge it was an unused import and noUnusedLocals would have failed typecheck.

No test needed rewriting: the lane already asserts parsed argv through CLI_PARSE_OPTIONS rather than scraping main.ts source.

Gates (local, Windows):

  • npm ci — 0 vulnerabilities
  • npm run typecheck — clean
  • npm test — 1440 tests, 1436 pass, 0 fail, 4 skipped
  • npm run smoke — 5 pass / 1 skip / 1 fail. The failure is environmental on this box (local turn: Ollama model qwen2.5-coder:7b not pulled) and the skip is web_search returning no results. Both are pre-existing on a clean origin/main here and unrelated to this merge.

@AetherAI3
AetherAI3 merged commit 2769778 into main Aug 23, 2026
5 checks passed
@AetherAI3
AetherAI3 deleted the lane/aa-cont-04-sessions branch August 23, 2026 01:30
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