[GH-ISSUE #1977] Restore selective-only secondary key gating for lorebook entries #969

Closed
opened 2026-10-21 05:24:14 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (Jun 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1977

Originally assigned to: @cha1latte on GitHub.

Problem

Target 7 lorebooks parityscan found a refactor runtime regression in selective secondary-key handling.

Legacy lorebook entries only required secondaryKeys when selective was enabled. Refactor currently requires secondary keys whenever the array is non-empty, even when selective is false.

Refactor evidence

  • src/engine/generation-core/lorebooks/keyword-scanner.ts:493-496 applies testSecondaryKeys whenever entry.secondaryKeys.length > 0.
  • src/features/catalog/lorebooks/components/editor/LorebookEditor.tsx:422-423 uses the same preview behavior.
  • src-tauri/src/commands/storage/imports/normalization.rs:272-276 imports secondaryKeys and selective independently, defaulting selective to false.

Legacy behavior

  • packages/server/src/services/lorebook/keyword-scanner.ts:480-482 only checked secondary keys under entry.selective && entry.secondaryKeys.length > 0.
  • packages/client/src/components/lorebooks/LorebookEditor.tsx:636-637 preview matched the same rule.
  • The ST lorebook importer preserved secondary keys without forcing selective on.

Impact

ST and legacy imports can carry secondary keys while selective is off. Those entries used to activate on primary keys alone; refactor can now skip them until secondary keys also match.

Expected behavior

Keep secondaryKeys gated by selective, or explicitly migrate/import such entries with selective enabled if a product decision says secondary keys should always gate.

Suggested fix

Restore entry.selective && entry.secondaryKeys.length > 0 in the runtime scanner and editor preview, then add focused local proof for an entry with a primary key match, secondary key miss, and selective=false.

Parent: #1904 target 7 lorebooks parityscan.

Originally created by @Xelvanis on GitHub (Jun 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1977 Originally assigned to: @cha1latte on GitHub. ## Problem Target 7 lorebooks parityscan found a refactor runtime regression in selective secondary-key handling. Legacy lorebook entries only required `secondaryKeys` when `selective` was enabled. Refactor currently requires secondary keys whenever the array is non-empty, even when `selective` is false. ## Refactor evidence - `src/engine/generation-core/lorebooks/keyword-scanner.ts:493-496` applies `testSecondaryKeys` whenever `entry.secondaryKeys.length > 0`. - `src/features/catalog/lorebooks/components/editor/LorebookEditor.tsx:422-423` uses the same preview behavior. - `src-tauri/src/commands/storage/imports/normalization.rs:272-276` imports `secondaryKeys` and `selective` independently, defaulting `selective` to `false`. ## Legacy behavior - `packages/server/src/services/lorebook/keyword-scanner.ts:480-482` only checked secondary keys under `entry.selective && entry.secondaryKeys.length > 0`. - `packages/client/src/components/lorebooks/LorebookEditor.tsx:636-637` preview matched the same rule. - The ST lorebook importer preserved secondary keys without forcing selective on. ## Impact ST and legacy imports can carry secondary keys while selective is off. Those entries used to activate on primary keys alone; refactor can now skip them until secondary keys also match. ## Expected behavior Keep `secondaryKeys` gated by `selective`, or explicitly migrate/import such entries with selective enabled if a product decision says secondary keys should always gate. ## Suggested fix Restore `entry.selective && entry.secondaryKeys.length > 0` in the runtime scanner and editor preview, then add focused local proof for an entry with a primary key match, secondary key miss, and `selective=false`. Parent: #1904 target 7 lorebooks parityscan.
bsakaguchi 2026-10-21 05:24:14 +07:00
Sign in to join this conversation.
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
Pasta-Devs/Marinara-Engine#969
No description provided.