Skip to content

feat(cli): command registration seam, and the flags doctor never received - #98

Merged
AetherAI3 merged 6 commits into
mainfrom
lane/aa-int-05-dispatch-seam
Aug 22, 2026
Merged

AetherAI3 merged 6 commits into
mainfrom
lane/aa-int-05-dispatch-seam

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

What this is

AA-INT-05, the integration lane. It exists so four parallel lanes can add top-level commands without three-way collisions in the same three places, and it lands one real bug that the missing seam had been hiding.

Base: main @ ed094dc8885945e69f66e166e854142005bf1d62 (verified unmoved at branch time).

The problem

CLI_COMMANDS described the CLI; a hand-written switch in main.ts ran it; a regex over main.ts's source was the only thing holding the two together. Adding one command meant three simultaneous edits — a registry entry, a switch case, and new flags appended to main.ts's single parseArgs option literal.

Both kinds of drift are silent, and both are silent in the expensive direction:

  • Registry vs switch. An unmatched name falls through to cmdChat, so a registered-but-unwired aether sessions becomes a billed chat turn about the word "sessions".
  • Flags. main.ts parses with strict: false, so an undeclared flag is captured into values and stripped from the positionals the command is handed. The command never sees it and never errors.

The shipped bug that second one was hiding

doctor has never received most of its own flags. --live, --fix, --dry-run, --no-ui were swallowed before reaching parseDoctorArgs, and --only <id> arrived as a bare positional that failed as unknown. So:

$ aether doctor --live        # documented as the end-to-end proof
                              # ran the fast, configured-only report, exit 0

The live proof reported as done without being performed — unknown rendered as verified. --yes is global and was likewise invisible to doctor's own parse, so aether doctor --fix --yes answered "Re-run with --yes" to a user who had just passed it. That path is now reachable as documented; it still applies nothing without an explicit --yes, and the repair allowlist is unchanged.

COMMANDS.md already documented all of these as working. This makes the docs true rather than changing them.

The seam

src/core/command_dispatch.ts (new). A DispatchedCommand is the help metadata a CommandSpec already carried plus the two things it was missing: its own flags, and a lazy load().

{
  name: "sessions",
  args: "[inspect|continue] [id]",
  summary: "browse and continue project sessions",
  section: "Start",
  flags: { archived: { type: "boolean", default: false } },
  load: async () => {
    const { cmdSessions } = await import("./sessions.js");
    return (ctx, argv, flags) => cmdSessions(ctx, argv, { archived: flags.bool("archived") });
  },
}

Append that to DISPATCH_COMMANDS. That is the whole change for a new command: no case, no edit to the global flag table. Help, aether help <name>, the typo guard and COMMANDS.md parity all read the union already.

Guarantees:

  • Reachability is structural. A table entry is reachable because it is the dispatch, not because a switch case repeats the same string. The test asserts the union is total and that a name is never wired both ways.
  • Flag collisions are load-time errors. One flat parseArgs namespace, so collisions are real. validateDispatchTable rejects, at module load: shadowing a global, two commands disagreeing about one flag name, an invalid name, a short letter already taken, a missing load(). Two commands declaring an identical flag is fine — that is one parseArgs entry.
  • A command reads only what it declared. An undeclared read throws rather than returning undefined; undefined is exactly what a legitimately absent flag looks like, so returning it would hide the wiring bug behind a plausible value. bool() / str() / list() each refuse the wrong type rather than coercing.

doctor moves into the table rather than the table landing empty — an empty table would make every reachability assertion vacuously true.

Third commit: the lane's own near-miss

Moving main.ts's option literal into GLOBAL_FLAGS dropped --scope, --all, --ci, --available, --junit, --out — the flags aether skills and aether capabilities read. Nothing failed; they would simply have been swallowed. That is this lane reintroducing the exact bug it exists to remove, so the fix ships with the test that catches it: every values["x"] main.ts reads must be a flag the parser was told about. Verified by removing scope again — the test names scope.

Evidence

  • npx tsc -p tsconfig.json --noEmit — clean.
  • npm test — 1150 pass, 0 fail, 1 pre-existing skip (1151 total).
  • npm run verify:production — {"ok":true,"packedFiles":527,"workflows":3}.
  • Zero runtime dependencies unchanged; load() is lazy, so no startup cost.
  • Spawn-level canaries, not rendered prose: --live produces mode: "live" from the built CLI; --only reaches the command with its value intact; a hostile --only value ("; rm -rf / #) stays one argv element, is echoed back verbatim as one unknown repair id, and reaches no shell.

Mutation testing of the load-bearing invariant — 8 applied, 8 killed:

mutation result
dispatch lookup never matches 6 tests fail
dispatch table emptied (vacuity check) 7 tests fail
global-shadow check dropped 1 fails
conflicting-flag check dropped 1 fails
globals no longer win the merge 1 fails
undeclared flag read returns undefined 1 fails
doctor stops declaring --live 5 fail
--scope dropped from globals 1 fails, naming scope

Reviewer's attention

The --yes forwarding in the doctor entry is the one behaviour change that makes a previously unreachable mutating path reachable. It is guarded by explicit --yes, matches the documented contract and COMMANDS.md, and the repair allowlist is untouched — but it is the line to look at first.

For the other lanes

docs/specs/2026-08-22-cli-command-registration-seam.md is the how-to. AA-SHIP-02, AA-CONT-04 and AA-SKILLS-03 should register through DISPATCH_COMMANDS rather than adding switch cases; AA-SKILLS-03 in particular should declare --skill / --no-skills on the agent command's own flag table, since main.ts's option literal no longer exists.

Not merging this myself.

AetherAI3 and others added 5 commits August 22, 2026 10:44
…ceived

`CLI_COMMANDS` described the CLI; a hand-written `switch` in main.ts ran it;
a regex over main.ts's source was the only thing holding the two together.
Adding a command therefore meant three simultaneous edits — registry entry,
switch case, and main.ts's `parseArgs` option table — which is three conflict
surfaces for what is conceptually one entry, and four parallel lanes are about
to add commands to exactly those three places.

Drift there is silent in the direction that costs money. An unmatched name
falls through to `cmdChat`, so a registered-but-unwired `aether sessions`
becomes a billed chat turn about the word "sessions".

`DispatchedCommand` carries help metadata, flags, and a lazy loader in one
entry, so reachability is structural rather than asserted by regex, and the
merged flag table is validated at load: shadowing a global, or two commands
disagreeing about one flag name, is a startup error rather than
last-writer-wins. Handlers read flags through an accessor bound to what they
declared — an undeclared read throws rather than returning `undefined`, which
is exactly what a legitimately absent flag looks like.

`doctor` moves into the table rather than the table landing empty: an empty
table would make every reachability assertion vacuously true.

Moving it surfaced that doctor has never received most of its own flags.
main.ts parses non-strictly, so undeclared `--live`, `--fix`, `--dry-run`,
`--no-ui` were captured into `values` and stripped from the argv doctor was
handed, and `--only <id>` arrived as a bare positional that failed as unknown.
`aether doctor --live` silently ran the fast configured-only report and exited
0 — the live end-to-end proof reported as done without being performed. `--yes`
is global and was likewise invisible to doctor's own parse, so `--fix --yes`
answered "re-run with --yes" to a user who had just passed it; that path is now
reachable as documented, and it still applies nothing without an explicit
`--yes`.

Evidence: `--live` produces `mode: "live"` at the spawn level, `--only` reaches
the command with its value intact, and a hostile `--only` value stays one argv
element and reaches no shell.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…t with a test

Moving main.ts's `parseArgs` option literal into `GLOBAL_FLAGS` dropped
`--scope`, `--all`, `--ci`, `--available`, `--junit` and `--out` — the flags
`aether skills` and `aether capabilities` read. Nothing failed: main.ts parses
non-strictly, so those flags would have been swallowed into `values` and
stripped from the argv the commands were handed, exactly the failure this lane
exists to remove, reintroduced by the lane itself.

The new test is the part that matters. Every `values["x"]` main.ts reads must
be a flag the parser was told about; a dropped declaration is now a failing
assertion naming the flag rather than a command quietly ignoring its own
arguments. Verified by removing `scope` again — the test names `scope`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…repair gate asserted on disk

Three findings from an adversarial read of the seam, plus the arbiter's gate.

**Casing divergence.** `findDispatchedCommand` lowercased before matching while
main.ts's `switch` is case-sensitive, so a migrated command answered to
`DOCTOR` and every command still in the switch did not — and a wrong-case token
for those never reaches the typo guard (its pattern is lower-case only), so it
fell through to `cmdChat` and billed a turn. A migration must not change which
strings are commands; the lookup is now exactly as case-sensitive as the switch.

**A short letter belongs to a flag, not to a command.** The collision check was
keyed on the owning command, so one command could declare two different flags
on the same short letter and pass clean; `parseArgs` then silently resolves
`-x` to whichever was declared first and the other short is dead. Keyed on the
flag name it also catches a command spending a letter a global already holds.

**No argv round trip.** doctor's flags are handed over as parsed data rather
than re-rendered into an argv string for it to parse a second time. The round
trip was the whole problem: an `--only` value of `--fix` re-enters as an option
rather than as data, and validating the value first cannot fix an ambiguity the
rebuild itself creates. Nothing today promoted it — doctor's own parser
rejected the dash-leading value and exited first — but the defence was an
ordering accident, and now there is no second parse to be promoted by.

**The mutating path, asserted on disk.** `--fix` had never reached `cmdDoctor`
at all, so this seam does not make an existing mutating path easier to hit — it
makes a never-exercised one reachable for the first time. The only thing
between a printed plan and four real repairs is the `--yes` check, and the only
evidence it held was a printed sentence. Three canaries now assert the file:
`--fix` without `--yes` leaves an abandoned temp file on disk, `--yes` without
`--fix` leaves it, and `--fix --yes` removes it — the positive case being what
keeps the two refusals from passing vacuously. Each runs in a throwaway
directory with the child's own cwd, so no real state is in scope.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ne must not break

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

Copy link
Copy Markdown
Owner Author

Update — adversarial review findings fixed, and the arbiter's disk gate added

Two more commits (f60655b, f6cace7). An adversarial review by a model that did not build this found two confirmed defects; both are fixed with the tests that catch them.

1. Casing divergence (confirmed, user-visible). findDispatchedCommand lowercased before matching while main.ts's switch is case-sensitive. So aether DOCTOR ran doctor, while aether AUDIT — still in the switch — did not reach cmdAudit at all: the typo guard's pattern is lower-case only, so it fell through to cmdChat and billed a turn. A migration must not change which strings are commands. Lookup is now exactly as case-sensitive as the switch, asserted for every table entry.

2. Same-command short-flag collision (confirmed). The collision check was keyed on the owning command, so one command declaring two different flags on the same short letter passed clean; parseArgs then silently resolves -x to whichever was declared first and the other short is dead. Now keyed on the flag name, which also catches a command spending a letter a global already holds.

3. No argv round trip. doctor's flags are handed over as parsed data rather than re-rendered into an argv string for a second parse. Nothing today promoted a flag-shaped --only value — doctor's own parser rejected the dash-leading value and exited first — but that defence was an ordering accident. There is now no second parse for --only=--fix to be promoted by, and DoctorFlagOverrides is additive only, so a forwarded flag can never switch off a mode the user typed.

The mutating path, asserted on disk

The framing in the original description was understated, and the arbiter was right to read the path rather than nod at it: --fix has never reached cmdDoctor at all. strict: false swallowed --fix and --yes alike, so the whole repair path is unreachable today. This PR does not make an existing mutating path easier to hit — it makes a never-exercised one reachable in a user's hands for the first time.

The only thing between a printed plan and four real repairs is the --yes check, and the only evidence it held was a printed sentence. Three canaries now assert the file:

  • doctor --fix without --yes → the abandoned temp file is still on disk
  • doctor --yes without --fix → still on disk
  • doctor --fix --yes → gone

The positive case is what keeps the two refusals from passing vacuously against a repair that could never have fired. Each runs in a throwaway directory with the child's own cwd, so no real state is in scope — state.temp resolves ./aether-output relative to the process, and the repair allowlist is untouched.

Evidence

  • npx tsc -p tsconfig.json --noEmit clean; npm test 1157 pass / 0 fail / 1 pre-existing skip (1158 total); verify:production ok.
  • Mutation testing now 12 applied, 12 killed. The four new ones: --yes gate removed from runFix (disk canary fails), lookup lowercases again (2 fail), short keyed on command again (1 fail), doctor ignores forwarded flags (6 fail).

Review also confirmed, field by field, that the current merged CLI_PARSE_OPTIONS is identical to the pre-migration 33-key options literal in type, short and default — the six dropped globals were caught by this branch's own third commit and its regression test.

Still not merging this myself.

A migration must not change which strings are commands. The failure the rule
prevents is not cosmetic: a lookup that lowercases while the switch does not
sends a wrong-case token for every unmigrated command through to cmdChat,
because the typo guard's pattern is lower-case only — a misspelling that
silently becomes a paid model call.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@AetherAI3
AetherAI3 merged commit 426b124 into main Aug 22, 2026
5 checks passed
@AetherAI3
AetherAI3 deleted the lane/aa-int-05-dispatch-seam branch August 22, 2026 15:12
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
#98 moved main.ts's flag table into cli_registry.GLOBAL_FLAGS and added a
dispatch-table check ahead of the switch. Resolved by taking main's structure
whole and relocating this lane's two flags (`--skill`, `--no-skills`) into
GLOBAL_FLAGS beside the other `aether agent` flags — they are global rather than
command-owned because `aether agent`, `aether chat` and the REPL all open the
same run session. The dispatch-table check runs before the switch, unchanged.

Both lanes verified together after the merge: `aether agent --skill fix-ci`
renders and enforces its policy, and `aether doctor --only <id>` still reaches
the dispatched command. 1164 pass, 0 fail.
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
`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]>
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
#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]>
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
…ional

The ground moved while PR #96 was open. #98 squash-merged to main, main became
426b124, and the v0.3.0 notes said nothing about it — which is this lane's own
defect arriving from the direction the lane did not gate.

WORK A: the notes now cover #98
-------------------------------
Its user-visible half is three fixes, and the first is the exact failure class
this codebase forbids:

- `aether doctor --live` never received --live. main.ts parses non-strictly, so
  a flag the command had not declared was captured globally and stripped from
  what the command was handed. --live ran the fast configured-only report and
  EXITED 0, presenting a live end-to-end verification that was never performed.
  Unknown rendered as verified. --deep, --dry-run, --no-ui and --only were lost
  the same way, and the whole --fix repair path was unreachable.
- `aether doctor --fix --yes` answered "re-run with --yes" to someone who had
  just passed it, because the global --yes never arrived either.
- Command lookup lowercased the token while dispatch was case-sensitive, so
  `aether Vault` fell past the typo guard into a chat turn and billed a paid
  model call.

The seam itself is announced too: a command now carries its own help metadata,
flag table and loader in one entry, flag collisions are load-time errors, and
reachability is structural rather than a regex over main.ts's source.

Range moves 477f0fc..ed094dc -> 477f0fc..426b124, 16 commits -> 17, across
RELEASE_NOTES.md, docs/releases/2026-08-22.md and the operator packet. Fixed a
miscount while re-deriving: the packet said "9 user-visible fixes" over a list of
ten.

WORK B: the gate now runs both directions
-----------------------------------------
Gate B ran notes -> package: a claim with no code behind it fails. It could not
see the inverse — a user-visible command that ships with NO claim anywhere — and
the inverse is what actually keeps happening, once per lane that lands between
the note being written and the tag being cut.

Gate C: every non-hidden command in the CLI registry must be announced by some
release note, or named in SHIPPED_WITHOUT_A_NOTE with a reason. An explicit list
is fine; silence is not. It is enforced in both directions — a stale entry fails,
and an entry that IS announced fails — so it cannot rot into a permanent bypass
that quietly absorbs the next unannounced command. Every entry must also appear
in the operator packet, because the founder cutting the tag is the person who
needs to know what goes out unannounced. 15 commands are on it today; all predate
the release log or were announced by capability in the June 2026 entry, and none
is new in this release.

Mutation-checked, per the controller's instruction. Added to the registry:

  { name: "teleport", args: "<dest>",
    summary: "beam the working tree somewhere", section: "System" }

  verify:production  -> {"ok":true, ... "packedFiles":527}        MISSED IT
  release_coherence  -> FAIL: no user-visible command ships without either a
                        release note or a named exemption
                        + [ 'teleport — beam the working tree somewhere' ]
                        - []

Registry restored byte-identical (md5 37b3f944…, `git status src/` empty),
10/10 pass. cli_registry.ts is read-only for this lane: it was mutated only in
the working tree, never committed, and the restore is verified by digest.

Also: Gate B now reads the registry by IMPORTING it instead of by regex over its
source. #98 replaced "reachability asserted by a regex over main.ts" for exactly
this reason, and it immediately split the commands across CLI_COMMANDS and
DISPATCH_COMMANDS — a source regex keyed on one array would have silently
stopped covering the other. doctor is in the second one.

Gates at this commit:
  npm run typecheck            exit 0
  release_coherence            10 pass / 0 fail

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

The base moved to 426b124 (#98), so every number in the packet was taken against
a tree that no longer exists. Re-run, commit-bound, at 22aa021:

  commitBound true, ok true, exit 0
  aether-agents-0.3.0.tgz
  sha256 8c5c119d93cabf49af0c49c97addb055308d508af93f8675a26b6f5c8ecba307
  527 entries, 597,400 packed / 2,459,474 unpacked

The digest CHANGED from the a63e1c6 run (25f33524…, 524 entries), and the packet
now says why that is the correct outcome rather than a discrepancy: #98 added
dist/src/core/command_dispatch.* and rewrote main.js, so the packed content is
genuinely different. A digest that had survived that change would have meant the
pack was not reading the tree.

Both mutation checks were re-measured against this base rather than carried
forward:

  skills drop   verify:production {"ok":true, ... "packedFiles":526}  MISSED IT
                release_coherence FAIL: dist/src/commands/skills.js
                restored -> 527 files, 10/10 pass

  teleport      verify:production {"ok":true, ... "packedFiles":527}  MISSED IT
                release_coherence FAIL: 'teleport — beam the working tree
                somewhere'
                restored -> registry byte-identical, 10/10 pass

I had initially edited the skills figure from 523 to 526 by inference. That is a
number nobody measured, so it was re-run before being written down.

Release-owned suite at this commit: 24 pass / 0 fail.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
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.
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
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.
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
…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.
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
AetherAI3 added a commit that referenced this pull request Aug 22, 2026
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]>
AetherAI3 added a commit that referenced this pull request Aug 23, 2026
…notes claim (#96)

* release: cut v0.3.0, and make the package prove it contains what the notes claim

On 2026-08-20 this repository described five different releases at once.
package.json said 0.2.0. package-lock.json still said 0.1.0 — the #81 bump never
touched it. RELEASE_NOTES.md's top entry described a 0.2.0 whose feature list was
written at 477f0fc, before #72 added `aether skills`, `aether capabilities` and
`aether support-bundle`. The npm registry served 0.1.0 and nothing else. And a
packed aether-agents-0.2.0.tgz sat in the repo root from #83 until #90 deleted
it, containing a build with no skills runtime in it at all.

Nothing was lying on purpose. The four statements drifted apart because nothing
compared them.

0.2.0 -> 0.3.0, not 0.2.1
-------------------------
#72 is a backwards-compatible feature addition — a skills runtime, three new CLI
commands, six built-in skills shipped inside the package — that the v0.2.0 notes
never mentioned. Semver makes that a minor bump.

Reusing 0.2.0 was rejected on identity grounds. 0.2.0 already names a specific
dated artifact: the August 19 notes entry, the README availability paragraph,
install.sh's pin example, and that committed tarball. Publishing different
contents under the same version would make two materially different artifacts
answer to one name, which is the defect this release exists to close. 0.2.0 is
retired unused; it will never be published.

Reconciled
----------
- package.json, package-lock.json (both version fields) and src/version.ts all
  say 0.3.0.
- RELEASE_NOTES.md leads with v0.3.0 covering 477f0fc..ed094dc: one feature,
  nine user-visible fixes, three test-only commits, one unwired module (#86 ship
  rail, which no command invokes), one docs commit. The v0.2.0 entry is marked
  superseded rather than rewritten — it is the record of what was written that
  day, not an install instruction.
- README and the release log name 0.3.0, and both still say plainly that
  `npm i -g aether-agents` gives you 0.1.0, because it does.

New gate: test/release_coherence.test.ts
----------------------------------------
Gate A asserts every place that names the release names the same one — including
both package-lock version fields, which is the drift nothing was watching.

Gate B is the load-bearing one: for every feature the release notes claim, the
code behind it must be present in the file list `npm pack` would actually ship,
and the command exposing it must be in the CLI registry. The source checkout's
dist/ is NOT the package — the allowlist is dist/src plus four docs.

Mutation-checked. Adding "!dist/src/commands/skills.js" to the files allowlist
silently drops `aether skills` from the tarball:

  verify:production  ->  {"ok":true, ... "packedFiles":523}   MISSED IT
  release_coherence  ->  FAIL: dist/src/commands/skills.js
                              (agent skills runtime — `aether skills`)

Restored: 7/7 pass, 524 packed files.

New: npm run release:candidate
------------------------------
release.yml only runs after a founder has already tagged and published, so
everything it checks is checked too late to change the decision. This runs the
same sequence, in the same order, before the tag exists — against a detached
git worktree of a specific commit, never the dirty checkout. A dirty tree is
refused unless --allow-dirty, which marks the report commitBound:false rather
than pretending.

Every CLI proof runs the binary npm installed from the packed tarball into a
clean prefix: --version, --help, `skills list`, `capabilities`, and the handoff
demo (the demo harness is not shipped, so it is placed beside the installed
package and resolves the CLI and its imports from the tarball's own dist/src).

Skipped steps are recorded as "not-run" with a reason and can never read as a
green tick — the full npm test suite is release.yml's gate and says so in the
report. No string is handed to a shell: npm is reached through its own JS
entrypoint under node, so every argument stays an argument.

Also
----
- scripts/verify-production.ts exports createPackReport, so a gate reasoning
  about what a user receives asks npm instead of reading the build directory.
- test/release_canaries.test.ts's coverage map said canaries 5 and 7 were
  unwritable. #86 and #87 wrote them two commits later; the excuse outlived the
  condition. The map is now enforced by a test that reads the delegated files.
- docs/releases/OPERATOR-PACKET-v0.3.0.md: the founder-owned publish sequence,
  with what is proven and what is explicitly not.

Gates at this commit:
  npm run typecheck                      exit 0
  release + production test files        21 pass / 0 fail
  npm run verify:production --tag v0.3.0 ok

Full npm test NOT run locally (a tool_executor test does not return on this
Windows box); CI is the authority.

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

* docs(release): fill the operator packet with the commit-bound candidate evidence

Run against a63e1c6 in a detached worktree: commitBound true, ok true, exit 0.
Tarball aether-agents-0.3.0.tgz, 524 entries, 589,829 bytes packed / 2,435,029
unpacked, sha256 25f33524bd866275674eccbf8cfe5706f14e925cb0ba35861dc6bc21a9245a2d.

The digest came out identical from an uncommitted tree and from the detached
worktree, which is recorded as content stability across a docs-only commit and
explicitly NOT as a cross-machine reproducibility claim.

Also records the mutation check: dropping dist/src/commands/skills.js from the
files allowlist leaves verify:production reporting ok:true at 523 files, and
fails release_coherence by name.

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

* release: cover #98 in the notes, and make the coherence gate bidirectional

The ground moved while PR #96 was open. #98 squash-merged to main, main became
426b124, and the v0.3.0 notes said nothing about it — which is this lane's own
defect arriving from the direction the lane did not gate.

WORK A: the notes now cover #98
-------------------------------
Its user-visible half is three fixes, and the first is the exact failure class
this codebase forbids:

- `aether doctor --live` never received --live. main.ts parses non-strictly, so
  a flag the command had not declared was captured globally and stripped from
  what the command was handed. --live ran the fast configured-only report and
  EXITED 0, presenting a live end-to-end verification that was never performed.
  Unknown rendered as verified. --deep, --dry-run, --no-ui and --only were lost
  the same way, and the whole --fix repair path was unreachable.
- `aether doctor --fix --yes` answered "re-run with --yes" to someone who had
  just passed it, because the global --yes never arrived either.
- Command lookup lowercased the token while dispatch was case-sensitive, so
  `aether Vault` fell past the typo guard into a chat turn and billed a paid
  model call.

The seam itself is announced too: a command now carries its own help metadata,
flag table and loader in one entry, flag collisions are load-time errors, and
reachability is structural rather than a regex over main.ts's source.

Range moves 477f0fc..ed094dc -> 477f0fc..426b124, 16 commits -> 17, across
RELEASE_NOTES.md, docs/releases/2026-08-22.md and the operator packet. Fixed a
miscount while re-deriving: the packet said "9 user-visible fixes" over a list of
ten.

WORK B: the gate now runs both directions
-----------------------------------------
Gate B ran notes -> package: a claim with no code behind it fails. It could not
see the inverse — a user-visible command that ships with NO claim anywhere — and
the inverse is what actually keeps happening, once per lane that lands between
the note being written and the tag being cut.

Gate C: every non-hidden command in the CLI registry must be announced by some
release note, or named in SHIPPED_WITHOUT_A_NOTE with a reason. An explicit list
is fine; silence is not. It is enforced in both directions — a stale entry fails,
and an entry that IS announced fails — so it cannot rot into a permanent bypass
that quietly absorbs the next unannounced command. Every entry must also appear
in the operator packet, because the founder cutting the tag is the person who
needs to know what goes out unannounced. 15 commands are on it today; all predate
the release log or were announced by capability in the June 2026 entry, and none
is new in this release.

Mutation-checked, per the controller's instruction. Added to the registry:

  { name: "teleport", args: "<dest>",
    summary: "beam the working tree somewhere", section: "System" }

  verify:production  -> {"ok":true, ... "packedFiles":527}        MISSED IT
  release_coherence  -> FAIL: no user-visible command ships without either a
                        release note or a named exemption
                        + [ 'teleport — beam the working tree somewhere' ]
                        - []

Registry restored byte-identical (md5 37b3f944…, `git status src/` empty),
10/10 pass. cli_registry.ts is read-only for this lane: it was mutated only in
the working tree, never committed, and the restore is verified by digest.

Also: Gate B now reads the registry by IMPORTING it instead of by regex over its
source. #98 replaced "reachability asserted by a regex over main.ts" for exactly
this reason, and it immediately split the commands across CLI_COMMANDS and
DISPATCH_COMMANDS — a source regex keyed on one array would have silently
stopped covering the other. doctor is in the second one.

Gates at this commit:
  npm run typecheck            exit 0
  release_coherence            10 pass / 0 fail

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

* docs(release): re-cut the candidate on the new base, and record the digest change

The base moved to 426b124 (#98), so every number in the packet was taken against
a tree that no longer exists. Re-run, commit-bound, at 22aa021:

  commitBound true, ok true, exit 0
  aether-agents-0.3.0.tgz
  sha256 8c5c119d93cabf49af0c49c97addb055308d508af93f8675a26b6f5c8ecba307
  527 entries, 597,400 packed / 2,459,474 unpacked

The digest CHANGED from the a63e1c6 run (25f33524…, 524 entries), and the packet
now says why that is the correct outcome rather than a discrepancy: #98 added
dist/src/core/command_dispatch.* and rewrote main.js, so the packed content is
genuinely different. A digest that had survived that change would have meant the
pack was not reading the tree.

Both mutation checks were re-measured against this base rather than carried
forward:

  skills drop   verify:production {"ok":true, ... "packedFiles":526}  MISSED IT
                release_coherence FAIL: dist/src/commands/skills.js
                restored -> 527 files, 10/10 pass

  teleport      verify:production {"ok":true, ... "packedFiles":527}  MISSED IT
                release_coherence FAIL: 'teleport — beam the working tree
                somewhere'
                restored -> registry byte-identical, 10/10 pass

I had initially edited the skills figure from 523 to 526 by inference. That is a
number nobody measured, so it was re-run before being written down.

Release-owned suite at this commit: 24 pass / 0 fail.

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

* release: regenerate the v0.3.0 truth against the merged main

* release: cover #105 in the v0.3.0 notes

* release: bind the v0.3.0 operator packet to the head that carries #105

Regenerates the packet against a845479 (origin/main after #105): base SHA,
evidence commit, tarball digest, packed entry count, the recorded
release-candidate run, and the coverage breakdown.

Two corrections rather than refreshes:

- Section 5 no longer lists the full test suite as unproven. It was run at
  the evidence commit (1464 tests, 1460 pass, 0 fail, 4 skipped); what is
  genuinely unproven is the suite INSIDE the candidate run, which reports
  npm-test as not-run by design.
- Two new unproven entries name the deployed API. The notes' Authentication
  claims are about a server this repository cannot test, and #105 exists
  precisely because `aether agent` does not work end to end against
  production today. Both are marked rather than implied.

* release: record the measured tarball size, not a rounded one

The packed size in the packet header was written from npm's rounded
"740.0 kB" notice rather than measured. The tarball is 739,977 bytes.
A digest and a byte count that disagree are the same class of defect
this packet exists to close.

---------

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