feat/modes #1

Merged
jd merged 16 commits from feat/modes into main 2026-10-10 23:33:59 -04:00
Owner

Summary

Adds user-defined agent modes as the central preset mechanism (prompt fragment, identity/guidance overrides, tool allowlist) and wires them through the whole stack: a mode JSON-RPC domain, per-session mode pinning, an Auto picker that routes a prompt to a mode and a reasoning effort in one decision call, and a settings UI to create/customize modes. Alongside it, this branch reworks the subagent lifecycle, adds session archive/trash, hardens the branch shell sandbox, and moves the web toolchain from Deno to Bun.

184 files, +21.7k / −2.9k.

What's in it

Modes

  • agents.Mode preset: fragment, optional identity/guidance, tool allowlist of base names (["*"] = all). Subagent tools are exempt from allowlisting and are injected per build, so the allowlist is the capability set a child may be granted.
  • New internal/api/mode.go (+533 tests): catalog of built-ins + the caller's custom modes stored in the modes UserConfigs row; upsert/delete/default-mode verbs.
  • Web: ModesView, ModesSection, ModeEditor, ModeSelect; custom modes are user-editable in settings, and there is a default_mode per user.
  • A session's mode is pinned on the session row (SetSessionMode); Auto is a synthetic picker id that is never a real mode, is hidden in-session, and never resolves through resolveMode (a stray value falls back to the built-in chat).

Auto routing

  • One decision call answers both the mode and the reasoning-effort questions, bounded by a 10 s UX timeout; any failure (including a cancel) degrades both picks to chat + the model's default effort — all or nothing, by design. This replaces the old separate 30 s, client-detached reasoning call.
  • Reasoning routing is score-based: the model returns a score, which is nudged (ReasoningScoreModifier), rounded and clamped into the levels the model actually advertises. The tuner exposes per-level gloss overrides (auto_reasoning_gloss, never read by the server).
  • Auto mode pinning happens at each successful handoff, so a cached agent running a different mode can't record the synthetic id.
  • Providers gain a Decision feature flag; providers without it are surfaced as unsupported for the Auto decider.

Subagents

  • Parent-side tools subagent / subagent_wait / subagent_message, plus the child-side ask_parent, in a dedicated package with narrow seam interfaces (no agents import). Children are multi-turn: subagent_message extends a running child or starts a follow-up on the same context.
  • Hardening: live children capped at 16 with finished-entry eviction, staleQuestion tracking so answers to timed-out questions are dropped, paused children (gated on core.ErrUserInputRequested) driven through the rebuild arm so a waiting turn stays resumable, and SpawnSubagent no longer takes the redundant prompt (it's already persisted on the session row).
  • Parent-supplied spawn naming replaces async title generation; the web gets ActiveSubagents, SubagentTool and TurnStateBadge.

Sessions

  • Archive/trash/restore operate on a session family (a session plus its subagent descendants): ArchiveSessionFamily, TrashSessionFamily, RestoreSessionFamily, with a ListArchivePage and an ArchiveView + SessionMenu in the SPA. Stopping a family now stops every running member, not just direct children.
  • Overview queries become paged (ListOverviewPage), and a janitor handles lifecycle cleanup.

Branch sandbox + tooling

  • Fixes sandbox escapes: the worktree .git pointer file is bound read-only, and absent git hooks/config are replaced with tmpfs and /dev/null rather than silent --ro-bind-try no-ops. Mise dirs (data/cache/installs) are auto-derived so mise-installed toolchains need no ro_paths entry.
  • Diff parser handles ***-framed patches and re-indents from the attachment point instead of the whole matched span (fixes column-0 context stripping).
  • Web toolchain: Deno → Bun (deno.lock removed, bun.lock added), vue-tsc typecheck task, and a hardened CDP smoke walk that asserts each route's document title and captures full-page + tiled screenshots.

Behavior changes

  • Tool config comment/format cleanup in example.config.yaml / example.branch.config.yaml — same keys, clearer docs; ro_paths no longer needs ~/.local/share/mise/installs.
  • Session migrations are consolidated into the init schema; pre-existing dev DBs from the old migration chain may need a recreate.
  • Prompt/approval/answer APIs now take userID and modeID, since routing and mode resolution are per-user.

Testing

  • mise run test-web — store unit tests (bun test) + server build + full headless-Chromium walk (/setup, /login, /, /overview, /archive, /settings, /settings/modes, /admin/*, /session/{id}).
  • mise run check — template-aware vue-tsc over the SPA.
  • go test ./... — large additions across agents/auto, agents/subagent, agents/modes, api/mode, api/session, db/session.
## Summary Adds user-defined **agent modes** as the central preset mechanism (prompt fragment, identity/guidance overrides, tool allowlist) and wires them through the whole stack: a `mode` JSON-RPC domain, per-session mode pinning, an **Auto** picker that routes a prompt to a mode and a reasoning effort in one decision call, and a settings UI to create/customize modes. Alongside it, this branch reworks the subagent lifecycle, adds session archive/trash, hardens the branch shell sandbox, and moves the web toolchain from Deno to Bun. 184 files, +21.7k / −2.9k. ## What's in it **Modes** - `agents.Mode` preset: fragment, optional identity/guidance, tool allowlist of base names (`["*"]` = all). Subagent tools are exempt from allowlisting and are injected per build, so the allowlist is the capability set a child may be granted. - New `internal/api/mode.go` (+533 tests): catalog of built-ins + the caller's custom modes stored in the `modes` UserConfigs row; upsert/delete/default-mode verbs. - Web: `ModesView`, `ModesSection`, `ModeEditor`, `ModeSelect`; custom modes are user-editable in settings, and there is a `default_mode` per user. - A session's mode is pinned on the session row (`SetSessionMode`); Auto is a synthetic picker id that is never a real mode, is hidden in-session, and never resolves through `resolveMode` (a stray value falls back to the built-in `chat`). **Auto routing** - One decision call answers **both** the mode and the reasoning-effort questions, bounded by a 10 s UX timeout; any failure (including a cancel) degrades both picks to `chat` + the model's default effort — all or nothing, by design. This replaces the old separate 30 s, client-detached reasoning call. - Reasoning routing is score-based: the model returns a score, which is nudged (`ReasoningScoreModifier`), rounded and clamped into the levels the model actually advertises. The tuner exposes per-level gloss overrides (`auto_reasoning_gloss`, never read by the server). - Auto mode pinning happens at each successful handoff, so a cached agent running a different mode can't record the synthetic id. - Providers gain a `Decision` feature flag; providers without it are surfaced as unsupported for the Auto decider. **Subagents** - Parent-side tools `subagent` / `subagent_wait` / `subagent_message`, plus the child-side `ask_parent`, in a dedicated package with narrow seam interfaces (no `agents` import). Children are multi-turn: `subagent_message` extends a running child or starts a follow-up on the same context. - Hardening: live children capped at 16 with finished-entry eviction, `staleQuestion` tracking so answers to timed-out questions are dropped, paused children (gated on `core.ErrUserInputRequested`) driven through the rebuild arm so a `waiting` turn stays resumable, and `SpawnSubagent` no longer takes the redundant prompt (it's already persisted on the session row). - Parent-supplied spawn naming replaces async title generation; the web gets `ActiveSubagents`, `SubagentTool` and `TurnStateBadge`. **Sessions** - Archive/trash/restore operate on a **session family** (a session plus its subagent descendants): `ArchiveSessionFamily`, `TrashSessionFamily`, `RestoreSessionFamily`, with a `ListArchivePage` and an `ArchiveView` + `SessionMenu` in the SPA. Stopping a family now stops every running member, not just direct children. - Overview queries become paged (`ListOverviewPage`), and a janitor handles lifecycle cleanup. **Branch sandbox + tooling** - Fixes sandbox escapes: the worktree `.git` pointer file is bound read-only, and absent git hooks/config are replaced with tmpfs and `/dev/null` rather than silent `--ro-bind-try` no-ops. Mise dirs (data/cache/installs) are auto-derived so mise-installed toolchains need no `ro_paths` entry. - Diff parser handles `***`-framed patches and re-indents from the attachment point instead of the whole matched span (fixes column-0 context stripping). - Web toolchain: Deno → Bun (`deno.lock` removed, `bun.lock` added), `vue-tsc` typecheck task, and a hardened CDP smoke walk that asserts each route's document title and captures full-page + tiled screenshots. ## Behavior changes - **Tool config comment/format cleanup** in `example.config.yaml` / `example.branch.config.yaml` — same keys, clearer docs; `ro_paths` no longer needs `~/.local/share/mise/installs`. - Session migrations are consolidated into the init schema; pre-existing dev DBs from the old migration chain may need a recreate. - Prompt/approval/answer APIs now take `userID` and `modeID`, since routing and mode resolution are per-user. ## Testing - `mise run test-web` — store unit tests (`bun test`) + server build + full headless-Chromium walk (`/setup`, `/login`, `/`, `/overview`, `/archive`, `/settings`, `/settings/modes`, `/admin/*`, `/session/{id}`). - `mise run check` — template-aware `vue-tsc` over the SPA. - `go test ./...` — large additions across `agents/auto`, `agents/subagent`, `agents/modes`, `api/mode`, `api/session`, `db/session`.
jd added 10 commits 2026-10-10 04:45:08 -04:00
- Define the Mode type (prompt fragment, identity/guidance overrides, tool
  allowlist) with four built-in presets: default, plan, code, and ask.
- Add mode/list, mode/upsert, and mode/delete RPC verbs for managing custom
  modes stored as a JSON array in the user's UserConfigs row; slugify labels
  to ids with collision suffixes.
- Thread modeID through SendPrompt, AnswerQuestion, and AnswerApprovals so
  the agent manager resolves the mode before building or reusing a cached
  agent; a behavior hash (blake2b of the resolved mode) triggers rebuilds on
  mode edits without rebuilding on renames.
- Persist the active mode on the Sessions table (migration 20261003000000)
  and seed the composer from it via session/get; a dangling recorded mode
  falls back to default and sets mode_missing so the UI can warn.
- Add settings/mode verb to store the user's default mode, validated against
  the caller's catalog; settings/get now returns the mode catalog and
  default_mode alongside providers and model defaults.
- Introduce session/notice event (distinct from session/error) for non-fatal
  run degradations like mode fallback; wire OnModeFallback on the agent
  manager to push a notice to the session owner.
- Add ModeSelect component to the composer, ModeEditor and ModesSection for
  the settings page, and a /settings/modes route; the home and session
  prompt forms seed and submit the mode selection.
- Update the system prompt builder to accept a Mode parameter, injecting
  identity/guidance overrides and the mode fragment as a labeled section.
- Fail fast when the port is already taken (e.g. a leftover --keep-server
  run) instead of walking a stale instance and reporting setup/complete
  -32004; the probe runs before the scratch dir is wiped.
- Make readiness waits exit-aware: if the server dies while waiting, throw
  with the server log tail (the bind error) instead of a bare timeout.
- Bound CDP.connect with a timeout and reject on close-before-open.
- Launch Chromium on about:blank so no page load can happen before the
  Runtime/Log listeners are wired: any console.error now fails the run.
- Cancel polled response bodies in getStatus; validate ERSA_TEST_PORT at
  startup with a clear error.
- On FAIL with --keep-server, print an unmissable "server left running"
  warning (the instance stays up for debugging).
- Narrow CDP frame decoding to CDPMessage, keeping any only at the
  event-fanout boundary.
- internal/branch/tools/sandbox.go: derive mise data/cache dirs (MISE_*_DIR, XDG, home fallback) and bind read-only; pin MISE_*_DIR into sandbox env when relocated; document trust-store exclusion
- internal/branch/tools/diff.go: treat *** Begin/End Patch and per-file headers as structural markers so they never fold into hunk bodies; stop parse at second file header
- internal/server/agents/modes.go: add debug and review built-in modes, extract askChoice constant, tighten plan/code fragments for self-contained handoffs
- internal/server/agents/system.go: append conciseness directive to defaultGuidance
- internal/server/agents/manager.go: document that prompts sent during an active run join that run at next completion
- internal/api/mode_test.go, settings_test.go: update built-in mode counts from 4 to 5
- docs/THREATMODEL.md, example.branch.config.yaml: document mise auto-derivation and trust-store sandbox isolation
- go.mod: bump agent, oidc, otel dependencies
- Bump `border-muted/30` to `border-muted/50` across all form fields,
  dividers, buttons, and markdown rules for improved visibility
- Update STYLE.md to document the new half-alpha hairline standard
- Redesign PromptComposer with a unified toolbar: mode picker in a top
  strip, compact chip selects for model/reasoning in a bottom bar,
  and a `status` slot for session usage totals
- Add `compact` prop to ModeSelect and ModelReasoningSelects for the
  chip variant (sr-only labels, tooltips, composer-chip styling)
- Add CSS rules for `select.composer-chip option` to ensure readable
  native dropdown popups
- Move session usage totals from above the composer into the mode
  picker's right side via the new status slot
- Track pending message IDs in the session store so queued prompts
  survive transcript reloads while awaiting their own run
- Add `--page <name>` flag to the e2e smoke test for single-page
  screenshot capture
- Collapse "New mode" editor behind a toggle button in ModesSection
- Consolidate built-in modes into a single divided panel
The changes are:
1. `internal/server/agents/system.go` - Added a new instruction paragraph to the system prompt about shell command working directory behavior (use relative paths, chain with `&&`/`;` since each call is a fresh shell)
2. `internal/server/agents/system_test.go` - Added test assertions to verify the new instructions appear in the generated prompt

This is a change to the agent's system prompt/instructions. The primary nature is adding guidance to the agent about how to handle shell commands relative to the working directory. This is a feature enhancement to the agent's behavior/instructions.

Let me craft the commit message:

```
feat(agents): instruct agent to use relative paths and chain commands in fresh shells

Add a paragraph to the branch section of the system prompt telling the
agent that shell commands start in the companion's working directory,
so it should prefer relative paths and avoid repeating the working
directory as an absolute path. Also clarify that each shell call is
stateless, so multi-step commands must be chained with && or ; within
a single call rather than relying on a prior cd to persist.

Extend TestBranchSection to assert the new instructions are present in
the rendered prompt.
Let me look at the key changes to understand the scope:

1. **New subagent system** - A major feature allowing agents to spawn child sessions:
   - `internal/server/agents/subagent.go` - Core subagent management
   - `internal/server/agents/tools/subagent/` - New tools: `subagent`, `subagent_wait`, `subagent_message`, `ask_parent`
   - `internal/server/agents/subagent_test.go` - Extensive tests

2. **Turn state tracking** - New `turn_state` field on sessions:
   - `internal/session/session.go` - TurnState type and constants
   - `internal/server/db/migrations/20261005000000_turn_state.sql` - DB migration
   - `internal/server/db/session.go` - DB operations for turn state
   - `internal/server/agents/manager.go` - Turn state management in agent manager

3. **Overview with nested children** - Sessions now show subagent children:
   - `internal/api/overview.go` - Nested children in overview
   - `web/src/views/overview/OverviewView.vue` - UI for nested sessions

4. **Web UI updates**:
   - `web/src/components/session/SubagentTool.vue` - New component
   - `web/src/components/session/TurnStateBadge.vue` - New component
   - `web/src/stores/session.ts` - Subagent notification handling
   - `web/src/views/session/SessionView.vue` - Turn state badge, parent link

5. **Mode updates** - Plan mode now structured for parallel execution:
   - `internal/server/agents/modes.go` - Updated mode fragments

This is a significant feature addition. The primary type is `feat` with scope `agents` (or possibly a broader scope since it touches multiple areas).

```
feat(agents): add subagent spawning with turn state tracking and nested overview

Introduce the subagent system: parent agents can spawn child sessions
that run concurrently with their own mode, model, and context. Children
can ask their parent questions via ask_parent, and parents can steer or
message running children via subagent_message.

Key additions:
- Subagent tools: subagent (spawn), subagent_wait, subagent_message,
  ask_parent (child→parent question)
- Turn state (idle/running/done/failed/stopped) persisted per session
  with a DB migration; drives the running indicator in both the session
  view and overview list
- Overview now nests subagent sessions under their parent with
  fold/unfold UI and per-row turn state badges
- Session view shows a turn state badge and a link back to the parent
  for child sessions
- Plan mode fragment updated to structure output into parallel batches
  that map directly onto subagent spawns
- System prompt gains Subagents and Parent sections for spawner and
  child builds respectively
- Push invalidation: turn state changes push both session/updated and
  overview/updated so live clients refresh the running indicator
Subagent sessions no longer generate their own title/summary via a
one-shot LLM call at creation. The parent now supplies a short title
(3-8 words) and optional one-line summary through the spawn tool, and
these are persisted with the session row so the user's session list
names the child from its first paint.

A new "waiting" turn state marks a session whose turn paused for user
input (open question or approval). The state settles when the run stops
on core.ErrUserInputRequested and resumes when the pending input is
answered. A paused child is excluded from the parent-orphan wake list
so a restart does not pre-empt the answer.

Key changes:
- Spawn tool gains required title and optional summary params with
  rune-length validation; SubagentInfo struct threads through
  SpawnSubagent, CreateSubagentSession, and claimTask
- generateSubagentInfo and subagentInfo removed from the manager;
  child builds no longer carry an info modifier
- Turn state "waiting" added to session.TurnState, DB, and wire type;
  ResetInterruptedTurns preserves waiting rows across restarts
- subagentFailedHeading replaced by subagentResultHeading returning
  finished/failed/paused; result payloads and notification headings
  carry the paused variant
- ActiveSubagents component lists direct children in flight or paused
  above the prompt form in the session view
- TurnStateBadge renders waiting as "needs input" with a still accent
  dot; STYLE.md documents the new state
- findSession exported from the overview store for nested child lookup
Auto routing runs on the caller's request context with a 10s bound (was 30s on
the manager's background ctx): the RPC acknowledgement no longer waits on the
routing model, and a client disconnect cancels the call while the prompt still
queues — a routing failure or cancel falls back to Chat and surfaces the
notice as before.

The pin now lands after resolution and names the mode that actually ran; the
synthetic "auto" id is never recorded on the session row (session/create and
session/message both queue through queuePrompt) and session/get never seeds it.
The session/mode push and its OnModeRouted hook are deleted end-to-end —
clients adopt the pin through the session/get refetch, which replaces an
"auto" pick or one missing from the catalog but never a concrete user pick.
The in-session composer offers no Auto option; settings/get still does (the
home composer keeps it as the one entry point).

Catalog robustness: stored custom rows carrying the reserved id "auto" are
filtered in both readers (no migration); LoadModeCatalog swallows and logs an
auto_mode row failure while modes-row failures still propagate (settings/mode
fails closed); mode/upsert and mode/delete answer with the full catalog via
LoadModeCatalog so a right-after-edit render keeps the Auto option; modeGloss
truncates by runes. settings/auto compensates a failed default-mode write by
deleting the just-written auto_mode row (best effort), and documents that
enabling overwrites the previous default.

Also: the legacy "default" id stays deliberately unaliased (comment only);
hardcoded catalog sizes derive from agents.BuiltinModes(); SendPrompt,
SessionDeps.QueuePrompt and Server.queuePrompt thread the caller's ctx.
internal/api/overview.go's session mode field ships without a renderer here —
the overview/session restyle lands separately.
- Add session archive/trash lifecycle: `archived_at`/`trashed_at` columns, a
  trigger that skips `updated_at` on lifecycle-only writes, and a janitor that
  hard-purges trashed families after a 7-day grace period.
- Add an auto-reasoning router that picks a reasoning effort level per prompt
  from a model's advertised capabilities, with a built-in level catalog and
  per-level gloss overrides.
- Add the web Archive view, archive store, and a per-session kebab menu with
  Stop/Resume/Archive/Delete actions.
- Migrate the web SPA toolchain from Deno to Bun: install/build/test/e2e tasks,
  `bun:test` imports with a `bun-test.d.ts` shim, `@types/node`, and a `@`
  path alias in tsconfig and vite.
- Add tests for the auto-reasoning router, the archive store, and the
  auto-reasoning level surfaced on session reads.
```bash
git status
```

```bash
git diff --staged
```

Based on the provided diffs and the branch name `feat/modes`, the changes include:
1.  **Auto Reasoning Router**:
    *   Backend: `internal/server/agents/automode.go` adds `AutoReasoningCfg` and `loadAutoReasoningConfig`. `internal/server/agents/manager.go` adds `AutoReasoningSentinel` and routing logic in `SendPrompt`.
    *   API: `internal/api/mode.go` adds `loadAutoReasoning` and `loadAutoReasoningGlosses`. `internal/api/settings.go` exposes `auto_reasoning_model` and `auto_reasoning_glosses`.
    *   DB: New migration `20261008010000_auto_reasoning_level.sql` adds `auto_reasoning_level` to `Sessions`. `internal/server/db/session.go` updates `sessionColumns` and adds `SetSessionAutoReasoningLevel`.
    *   Web: `web/src/components/settings/ModesSection.vue` adds UI for configuring the auto reasoning model and glosses. `web/src/composables/modelSelection.ts` adds `newSessionEffort` and `AUTO_REASONING`. `web/src/components/composer/PromptComposer.vue` and `ModelReasoningSelects.vue` support the "auto" option.

2.  **Session Lifecycle (Archive/Trash)**:
    *   API: `internal/api/session.go` adds `SessionArchiveRow`, `SessionArchiveListResult`, and params for `resume`, `archive`, `delete`, `restore`, `archive.list`. `internal/api/registry.go` registers these new methods.
    *   DB: `internal/server/db/session.go` adds `familyIDs`, `familyLifecycleStamp`, `ArchiveSessionFamily`, `TrashSessionFamily`, `RestoreSessionFamily`, `ListArchivePage`.
    *   Web: `web/src/views/overview/ArchiveView.vue` (implied by router change), `web/src/router.ts` adds `/archive` route. `web/src/components/overview/SessionMenu.vue` likely has actions. `web/src/stores/session.ts` adds lifecycle actions.

3.  **Subagent Kick Logic Fix**:
    *   `internal/server/agents/subagent.go`: `kickParent` is modified to deliver only *one* message (either a note or a result) to an idle parent, restoring the rest. This prevents driving a run on a paused transcript.
    *   `internal/server/agents/subagent_test.go`: Adds `TestRebuiltParentNeverDrivesARunOnItsPausedTranscript`.

4.  **UI/UX Improvements**:
    *   `web/src/components/session/TurnStateBadge.vue`: Updates state colors (moss for done, ochre for waiting).
    *   `web/src/style.css`: Adds `--moss` and `--ochre` variables.
    *   `web/src/components/chrome/AppHeader.vue`: Makes header sticky.
    *   `web/src/views/overview/OverviewView.vue`: Adds "Archive" link and SessionMenu.

The previous commit message was `feat(sessions): add archive/trash lifecycle, auto-reasoning router, and migrate web toolchain to Bun`.
The instruction asks for a **completely different** commit message. I should focus on a different aspect or use a different type/scope.
The changes are a mix of `feat` (auto reasoning, archive), `fix` (subagent kick), and `style`/`refactor` (UI colors, sticky header).
Since `feat` is the dominant change, I will stick with `feat` but change the scope and description.
Scope: `agents` or `core`? The auto-reasoning is in `agents`, archive is in `sessions`/`db`.
Let's try scope `agents` focusing on the reasoning router, or `ui` focusing on the visual updates?
Actually, the subagent fix is significant.
Let's try a `feat` with scope `agents` focusing on the auto-reasoning capability, as it's a new feature. Or `feat` with scope `sessions` focusing on the lifecycle.
The previous message covered "archive/trash lifecycle, auto-reasoning router".
I will focus on the **auto-reasoning** aspect primarily, or the **subagent fix**.
Let's go with `feat(agents): implement auto-reasoning router and fix subagent kick delivery`.
Wait, "fix" is a different type.
Let's try `feat(agents): add auto-reasoning router and refine subagent delivery`.

Let's look at the "different type, scope, or description approach" constraint.
Previous: `feat(sessions): ...`
New: `feat(agents): ...`

Description: `add auto-reasoning router and fix subagent kick delivery`

Body:
- Implement auto-reasoning routing that selects effort levels based on prompt content and model capabilities.
- Add `auto_reasoning_level` column to sessions to track the last routed level.
- Update `kickParent` to deliver only one message to idle parents, preventing runs on paused transcripts.
- Add UI controls for configuring auto-reasoning models and glosses in settings.
- Introduce `moss` and `ochre` theme colors for turn state badges.

This looks good.

```
feat(agents): add auto-reasoning router and fix subagent kick delivery

- Implement auto-reasoning routing in `SendPrompt` to select effort levels
  based on prompt content, with fallback to model defaults.
- Add `auto_reasoning_level` column to `Sessions` and expose it via
  `session/get` for composer labeling.
- Modify `kickParent` to deliver only a single message to idle parents,
  preventing the driver from running on paused transcripts.
- Add settings UI for configuring the auto-reasoning model and level glosses.
- Update turn state badge colors to use `moss` for done and `ochre` for waiting.
Merge the four incremental migrations (session_mode, turn_state,
session_lifecycle, auto_reasoning_level) into the init migration so
new databases are created with the full Sessions schema in one step.
The updated_at trigger now carries the WHEN clause that skips
lifecycle-only writes, and a comment typo is fixed.
jd added 2 commits 2026-10-10 05:46:41 -04:00
Rewrite doc comments, test descriptions, and inline annotations
across the Go backend, web frontend, and build configuration for
conciseness and consistency. No behavioral changes.

- Go: tighten package-level and function-level doc comments in
  internal/branch, internal/server, internal/session, internal/user,
  and pkg/jsonrpc
- Web: condense Vue component, store, and composable documentation
  in web/src
- Config: simplify example YAML files and mise.toml task descriptions
- Tests: shorten test case descriptions while preserving intent
jd added 2 commits 2026-10-10 19:29:00 -04:00
Remove the user-configurable reasoning level glosses feature from the
API, backend, and frontend. Switch the auto-reasoning router from
choice-based selection to score-based index mapping. Fix a bug where
answering questions in an auto-reasoning session failed due to a
mismatch between the sentinel marker and the cached agent's resolved
reasoning value.
Auto asked two questions against two separately configured models: which
mode to run, and how much reasoning to spend. Each call had its own
timeout, its own failure path and its own picker-only sentinel. One model
now answers both in a single systemone Decision call, and the two
UserConfigs rows collapse into one.

Config:
- auto_mode and auto_reasoning become one auto_decision row
  (agents.AutoDecisionCfg): the model, plus the reasoning-score modifier
  that used to be a bare float32 whose zero the handler had to read as
  "keep the stored/default value".
- No migration: Auto never shipped, so no deployed DB can hold the legacy
  rows. The legacy names are unreachable and now undeletable through the
  API, which is fine because they cannot exist. The gloss row remains a
  declaration only - the server never read it.
- The modifier is a sentinel in both the wire param and the row field
  (*float32, json omitzero): omitted or null leaves the field out of the
  row, so the package default (ReasoningScoreModifier) applies; an
  explicit 0..1 is stored as-is, with 0 meaning "no nudge"; and a
  model-only save no longer carries a previously stored modifier forward.
  Out-of-range values are rejected, not clamped.
- The handler's rollback after a failed default_mode write now restores
  the previously stored model and modifier instead of always deleting the
  row.

Semantics:
- All or nothing: one malformed half answers ErrAutoDecision for both
  picks, including when the other half was answered correctly.
- One budget, one cancellation: both answers share the single 10s bound
  on the caller's ctx, so a client disconnect degrades both picks, and
  per-pick detachment - HEAD's separate 30s, client-detached reasoning
  call - is no longer possible by design. The bound covers the prompt's
  acknowledgement: a UX bound, not a model bound.
- The decision judges text, not emptiness: an image-only or
  whitespace-only queued message falls back to the session's last user
  message, and a missing one reports "no user message to judge" rather
  than sending an empty State.
- A failed decision no longer rewrites the session's mode row, so "the row
  names what ran" holds only for successful decisions; the failure still
  fires both fallback hooks and clears the recorded reasoning level.

Cleanups (C6/C7/C8): the decision response is value-typed; the decision
trace carries the answered score and the offered level count the deleted
reasoning route used to log; the client's new-session seed drops its dead
default-effort parameter and applies the mount-time offered-effort guard
on a settings re-seed; loadAutoModel becomes loadAutoDecisionModel, and
ReasoningLevelIDs and two unread test-helper fields go.

cmd/tuner (untracked local tooling) is untouched and no longer predicts
the server: its ParamSet still carries the old split budgets
(lab.go:30-31: 10s mode / 30s reasoning), and its reasoning route still
nudges by the package 0.25 default instead of a row-set modifier.
- Promote loadCustomModes to LoadCustomModes and route all mode reads
  through it, removing the duplicate customModes helper in the API layer.
- Move Auto mode pinning into pinAutoMode at each successful handoff so a
  cached agent running a different mode does not record the synthetic id.
- Add lastUserPrompt to skip machine-injected subagent notifications when
  Auto judges an empty queued message.
- Cap live subagent children at 16 with eviction of finished entries, add
  staleQuestion tracking to drop answers to timed-out questions, and drive
  paused children through the rebuild arm in dispatchChildPrompt.
- Remove the prompt parameter from SpawnSubagent; the task is already
  persisted on the session row.
- Add attachIndent to resolve re-indent depth from the attachment point
  rather than the whole matched span, fixing column-0 context stripping.
- Bind the worktree .git pointer file read-only in the write sandbox and
  replace absent git hooks/config with tmpfs and /dev/null instead of
  silent --ro-bind-try no-ops.
- Consolidate mise directory resolution into miseDirs, pinning only
  relocated paths in the sandbox environment.
- Extract chunkedOREqualities for the expression-tree depth cap and use it
  in familyIDs.
- Preserve the prior reasoning_score_modifier when the settings request
  omits the key, matching the web save shape.
- Add vue-tsc typecheck task, shared controls.ts select classes, and
  useTemplateRef-based dismissable composable.
- Update e2e smoke walk to assert document titles and use node:path.
jd merged commit 410b9bbba2 into main 2026-10-10 23:33:59 -04:00
jd deleted branch feat/modes 2026-10-10 23:33:59 -04:00
jd referenced this pull request from a commit 2026-10-10 23:33:59 -04:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ersyne/ersa-agent!1
No description provided.