Skip to content

fix(mods): migrate legacy session mode constraints - #2359

Merged
vastsa merged 1 commit into
vastsa:mainfrom
new-Beginner:fix/custom-mode-selection-897fe1aa
Nov 15, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
new-Beginner:fix/custom-mode-selection-897fe1aa

Conversation

@new-Beginner

Copy link
Copy Markdown
Contributor

Root cause

A retained sessions.mode CHECK (mode IN ('agent','plan','goal')) can reject a valid custom mode during session.configure or session.create. The current fresh schema already accepts custom ids, but the mode migrations only add snapshot/run storage and do not remove this legacy constraint. A fresh-database test therefore misses the upgraded-user failure.

Reproduced the exact CHECK failure through the real Host RPC path on current main using a schema-31 fixture that actually retains the constraint.

Minimal fix

  • Add a backed-up transactional schema 31-to-32 migration that removes only the builtin-only mode CHECK from the actual sessions definition.
  • Retain session columns/data, other checks, indexes, triggers, dependent views and child records. Check foreign keys before commit and restore connection settings after success or rollback. Already-unconstrained tables are not rebuilt.
  • Keep the existing schema 28/29/30 upgrade chain, immutable snapshots, mode-id validation and permission policy. No UI, runtime, provider, or workflow changes.
  • Add populated migration/rollback tests and real RPC selection, creation, builtin switching, snapshot rejection and restart coverage. Synchronize storage and E2E documentation.

Schema 32 is intentionally refused by older binaries; the retained pi.sqlite.v31.bak supports rollback without deleting user data.

Verification

  • RED: custom selection on the retained-CHECK fixture returned the reported SQLite error before the fix.
  • 122 selected Rust tests passed: 63 database tests, 3 session-creation RPC tests, 2 upgraded custom-mode RPC tests, 9 mode RPC tests and 45 mode-run tests.
  • The complete local database group had one additional Windows path-prefix assertion failure: db::project_path_tests::path_repair_is_atomic_and_can_run_inside_an_import_transaction. The identical failure was independently reproduced on untouched official main 043d11c23d153d9a9088d315bb50d12ebd8283e2; it was not changed or reported as passing.
  • Cargo formatting, host-core Clippy and debug Host build passed; existing warnings remain in untouched modules.
  • All 13 original workspace JS build scripts, including VitePress, passed. Documentation checks verified 625 pages and 89 English/Chinese pairs.
  • Real isolated Host process: reproduce the old CHECK, restart into schema 32, select/create custom modes, reject mismatched snapshots, restart and retain selection; the pre-upgrade backup remains intact.
  • scripts/e2e-mode-definitions.mjs: production Main prompt IPC/coordinator and real Host passed staged artifact/approval/command-gate/completion and catalog edit/removal scenarios. The sidecar boundary is synthetic.
  • Latest-base ancestry and agent-policy synchronization checks passed.

Only isolated data/agents directories were used. No paid provider, running user Desktop, real session database, installer, or release was used or changed.

Task candidate: 524b0265c91bcd367fcdfa1da3e7f71eb3869bca
Base main: 043d11c23d153d9a9088d315bb50d12ebd8283e2

The requester asks to observe all new non-Vercel checks to completion. Vercel preview authorization is excluded from that acceptance scope; no deployment permission or check is bypassed.

Custom mode definitions already pass Host validation, but an older
sessions table can still reject their ids after an upgrade. Repair
that persisted constraint through a backed-up schema 32 migration.

Preserve existing rows, schema objects, and session permission policy.
Cover upgraded selection and creation, restart, rollback, and older
mode schema chains without changing UI or execution contracts.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently reviewed the retained legacy CHECK and upgrade chain. Ran all 6 session_mode_migration SQLite/real Host RPC tests on both head 524b026 and integration 842602c (base 043d11c): passed, including original CHECK rejection, custom mode configure/create, older schemas, persistence, dependent objects, rollback, FK validation and pragma restoration. Diff check passes; all six Actions checks green. No installed-client or paid-provider claim. Backed-up transactional migration is scoped to the retained constraint.

@vastsa
vastsa merged commit 25d57e6 into vastsa:main Nov 15, 2026
6 of 8 checks passed
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.

2 participants