MCP: Staleness, re-rolls and Promotion (#198) #212

Merged
crowmaki merged 2 commits from issue-198-mcp-staleness into main 2026-10-14 06:05:03 +00:00
Owner

Closes #198. Part of #157.

A harness can now keep coverage current and promote it. Each tool wraps an existing ApiImpl command, so edits land in the undo log with their usual labels.

Tools

  • read_take_staleness: a Take's Stale reasons (kind, key, label, accepted, counts) and each of its inputs, as rendered (recorded) and as a re-roll would send it now (current).
  • accept_stale_reasons: accepts one reason by key, or every current one when key is absent. Undoable ("Accept Prompt", "Accept all Stale reasons"). Returns the staleness after.
  • reroll_take: a new Take with a new seed, from the current (default) or original inputs. With sameSeed, it keeps the Take's seed and uses the current inputs, which also brings back a purged Take. sameSeed with original inputs is refused, because the app has no such re-roll.
  • rebuild_take: rebuilds a waiting Take's job from the current inputs and keeps its name and seed.
  • read_stale_reroll_plan / reroll_stale_takes: the stale re-roll for a scope, either {kind: "scene", sceneId} or {kind: "referenceSet", referenceSetId}. It can queue drafts or Single-pass finals (singlePassFinal).
  • promote_takes: promotes one or many drafts. If any one of them can't be promoted, none is. refineSeed is accepted only for a single Take.

The server instructions now cover staleness, re-rolls and Promotion. StaleRerollScopeDto derives JsonSchema, so the tools reuse it as their scope argument.

Tests

src-tauri/tests/mcp_staleness.rs covers each acceptance criterion:

  • A changed prompt makes a circled Take stale. Its reasons and inputs read back, accepting one reason clears it (and undo restores it), accept-all works, and a later change makes the Take stale again.
  • Re-rolls: a new seed, the same seed and the original inputs (whose Take stays stale), and the refused combination.
  • Rebuild with the queue paused, and its refusal once the Take has rendered.
  • The stale re-roll for a Scene: the plan, the queued Take, the queued skip after it, and circles that stay unchanged.
  • The stale re-roll for a Reference set: locking a new snapshot makes the circled Take stale, and the re-roll queues a Single-pass final.
  • Promotion of two drafts: they are listed as final with their refine seed after wait_for_jobs. Also a single Take with a refineSeed, and a batch that is refused as a whole.
  • Every tool refuses when no Project is open.

renderable_shot, rendered_take and takes moved into tests/common/mcp.rs, and mcp_takes.rs uses them too.

Not tested: a Shot that the stale re-roll skips as blocked. The core plans it, and the plan comes back unchanged.

Closes #198. Part of #157. A harness can now keep coverage current and promote it. Each tool wraps an existing `ApiImpl` command, so edits land in the undo log with their usual labels. ## Tools - `read_take_staleness`: a Take's Stale reasons (kind, key, label, `accepted`, `counts`) and each of its inputs, as rendered (`recorded`) and as a re-roll would send it now (`current`). - `accept_stale_reasons`: accepts one reason by `key`, or every current one when `key` is absent. Undoable ("Accept Prompt", "Accept all Stale reasons"). Returns the staleness after. - `reroll_take`: a new Take with a new seed, from the `current` (default) or `original` inputs. With `sameSeed`, it keeps the Take's seed and uses the current inputs, which also brings back a purged Take. `sameSeed` with `original` inputs is refused, because the app has no such re-roll. - `rebuild_take`: rebuilds a waiting Take's job from the current inputs and keeps its name and seed. - `read_stale_reroll_plan` / `reroll_stale_takes`: the stale re-roll for a scope, either `{kind: "scene", sceneId}` or `{kind: "referenceSet", referenceSetId}`. It can queue drafts or Single-pass finals (`singlePassFinal`). - `promote_takes`: promotes one or many drafts. If any one of them can't be promoted, none is. `refineSeed` is accepted only for a single Take. The server instructions now cover staleness, re-rolls and Promotion. `StaleRerollScopeDto` derives `JsonSchema`, so the tools reuse it as their scope argument. ## Tests `src-tauri/tests/mcp_staleness.rs` covers each acceptance criterion: - A changed prompt makes a circled Take stale. Its reasons and inputs read back, accepting one reason clears it (and undo restores it), accept-all works, and a later change makes the Take stale again. - Re-rolls: a new seed, the same seed and the original inputs (whose Take stays stale), and the refused combination. - Rebuild with the queue paused, and its refusal once the Take has rendered. - The stale re-roll for a Scene: the plan, the queued Take, the `queued` skip after it, and circles that stay unchanged. - The stale re-roll for a Reference set: locking a new snapshot makes the circled Take stale, and the re-roll queues a Single-pass final. - Promotion of two drafts: they are listed as `final` with their refine seed after `wait_for_jobs`. Also a single Take with a `refineSeed`, and a batch that is refused as a whole. - Every tool refuses when no Project is open. `renderable_shot`, `rendered_take` and `takes` moved into `tests/common/mcp.rs`, and `mcp_takes.rs` uses them too. Not tested: a Shot that the stale re-roll skips as `blocked`. The core plans it, and the plan comes back unchanged.
read_take_staleness reads a Take's Stale reasons and its inputs against
the current ones; accept_stale_reasons accepts one by key, or all.
reroll_take queues a new Take with a new seed from the current or the
original inputs, or with the same seed; rebuild_take rebuilds a waiting
Take. read_stale_reroll_plan and reroll_stale_takes plan and run the
stale re-roll for a Scene or a Reference set. promote_takes promotes one
or many drafts, with a refine seed for a single Take.

The Shot setup the Take tests share moves into common::mcp.
Test the stale re-roll for a Reference set: locking a new snapshot makes
a circled Take stale, and the re-roll queues a Single-pass final for it.
rendered_take and takes move into common::mcp, and circled_take becomes
circle_new_take, which says it returns the Take's id.
crowmaki deleted branch issue-198-mcp-staleness 2026-10-14 06:05:03 +00:00
Sign in to join this conversation.
No description provided.