Skip to content

fix(mods): retire legacy Goal turn snapshot triggers - #2378

Merged
vastsa merged 2 commits into
vastsa:mainfrom
new-Beginner:fix/legacy-goal-migration-897fe1aa
Nov 16, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
new-Beginner:fix/legacy-goal-migration-897fe1aa

Conversation

@new-Beginner

@new-Beginner new-Beginner commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Databases previously opened by the withdrawn independent Goal candidate (#2141, c150b817002df2a28d88d81043a8cf7fbcced8cc) can retain turn_execution_snapshot, an AFTER INSERT ON turns trigger. It copies sessions.mode into the old turn_execution ledger, whose mode CHECK accepts only agent, plan, and goal.

#2359 correctly repairs the legacy sessions.mode constraint. It does not retire this separate writer: selecting a validated custom mode can succeed, but session.beginTurn then fails with:

CHECK constraint failed: mode IN ('agent','plan','goal')

This is a compatibility defect for databases carrying the experimental schema, not a failure of custom-mode definition parsing or a claim that all current databases are affected. The withdrawn candidate also stamped schema 32, so a database already marked 32 may still contain either or both old constraints.

Fix

  • Add a backed-up schema-32-to-33 migration, so already-marked-32 databases receive the repair.
  • Retire only the obsolete turn_execution_snapshot trigger. Preserve historical turn_execution, goal_turns, and session_goals tables and records, indexes, and unrelated triggers; the archived ledger no longer receives new turns.
  • Reuse the actual-schema sessions.mode repair if its builtin-only CHECK remains. Do not rebuild an already-unconstrained sessions table.
  • Keep trigger retirement, conditional table replacement, foreign-key validation, and version advancement in one transaction. Reuse the existing connection-PRAGMA lifecycle for both migrations and restore both settings on success or failure.
  • Cover populated history, custom-mode turn start/completion, backup refusal, rollback, unrelated triggers, schema-version collisions, and restart/idempotence. Document the storage change and E2E scenario.

The Host verifies pi.sqlite.v32.bak before migrating. Older schema-32 Hosts cannot open schema 33; rollback requires the compatible backup, not deleting data or lowering user_version. Mode snapshots, permissions, RPC contracts, and the staged Goal architecture are unchanged. This PR does not revive the withdrawn Goal backend or include local installer/version changes.

Verification

Candidate: 9253fa12de19d1899f4754e7f7f4446f0ac6d967 (repair commit 733b753883e584b38ecf9cd8828e25d22f9cdd82), based on 29043af3371122e256bf265db31651da125d38e3.

  • RED: the new populated-legacy regression on the unmodified base reproduces the exact turn-start CHECK failure above.
  • Rust: session_mode_migration 11 passed; mode_runs:: 45 passed; rpc::modes_rpc::tests 9 passed; rpc::session_mode_create_tests 3 passed. These groups are not all disjoint.
  • db::: 63 passed with the previously reproduced local Windows path_repair_is_atomic_and_can_run_inside_an_import_transaction path-prefix baseline failure explicitly excluded. The unchanged base fails that same case (D:/... versus //?/D:/...); no test was altered to suppress it.
  • cargo fmt --all -- --check, locked/offline all-target Clippy, and Host build passed. Clippy retains five existing warnings in untouched code.
  • All 13 workspace JS build scripts, including VitePress, passed using provisioned dependencies; Desktop typecheck, configured Biome lint, style tokens, policy sync, docs checks (521 pages), script syntax, and latest-base ancestry passed.
  • node scripts/e2e-legacy-goal-migration.mjs: all three isolated real-Host scenarios passed (schema 31, schema 32 with unconstrained sessions, and schema 32 with the old sessions CHECK). Each verifies a staged goal-3 turn, retained ledger history, a verified backup, and restart.
  • node scripts/e2e-mode-definitions.mjs: both existing staged workflow and production IPC/coordinator-to-Host paths passed against the candidate Host.

No live provider or running user Desktop was used, and no real user database was modified. The general smoke suite is not claimed green: an earlier isolated comparison reproduced its unrelated revision not found failure on the unchanged installed baseline as well.

CI follow-up: the initial JS run exposed an existing source-contract contradiction: main 438a1a364 restored the installed-card Open panel button, while extensions-page.test.mjs still required its label to be absent. Maintainer commit 9253fa12d aligns the assertion with the supported-panel guard and callback. Both relevant test files pass (30 tests); no production plugin UI was changed. The three migration scenarios and existing mode-definition E2E paths were rerun successfully at this PR head.

new-Beginner and others added 2 commits November 16, 2026 19:53
Databases touched by the withdrawn independent Goal candidate can retain
a builtin-only execution ledger at schema 32. Valid custom modes then
fail when a turn starts even after sessions.mode has been widened.

Add a backed-up schema-33 compatibility migration that retires only the
obsolete writer, preserves historical data, and repairs schema-version
collisions atomically.
The installed rows already expose supported plugin panels. Replace the\nstale absence assertion so the integration gate checks the current action\nand its handler without changing product behavior.
@vastsa

vastsa commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Independent review: confirmed the compatibility defect with an isolated baseline Host: selecting the custom mode succeeds but session.beginTurn fails with the builtin-only mode CHECK. The candidate retires the obsolete writer in a backed-up transaction and retains the historical ledger.

Local verification: 11/11 session-mode migration tests, 66/66 database tests, all three real-Host legacy migration scenarios (31, unconstrained 32, constrained 32), and both existing staged-mode / production IPC coordinator scenarios passed. cargo build --locked, cargo fmt --all -- --check and diff checks passed. JS artifacts/dependencies were reused from the primary checkout; no live provider or user database was used.

I added a minimal landing repair in 9253fa1: the existing extension-row source contract incorrectly forbade the already-restored open-panel action. It now checks the supported panel action and handler. That suite reproduced 15/16 before and passes 16/16 after; no product behavior changed. Waiting for the refreshed CI and latest integration candidate before merging.

@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.

Root cause independently reproduced on the baseline Host; candidate migration, database regressions and real Host workflows pass. The stale plugin action contract was minimally repaired in 9253fa1. All six CI checks are green on 9253fa1. Latest main is unchanged and integration tree matches the tested candidate. Approved for merge.

@vastsa
vastsa merged commit 3f0c9de into vastsa:main Nov 16, 2026
6 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