[GH-ISSUE #7999] [Issue]: Mari tools: an unreadable apply on a create writes, and bad numeric args are silently replaced #7512

Closed
opened 2026-10-24 04:03:44 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @ylli-selmani on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7999

Originally assigned to: @ylli-selmani on GitHub.

Summary

Two of Professor Mari's structured-tool arguments are coerced without a word. If a create gets an apply value it
cannot read, the create writes. A numeric argument that is not a number, or is out of range, gets replaced by
the default or the limit. In both cases the call "succeeds", so a model never finds out it was misread. These are
behaviour bugs, not wording, so they were split out of #7949.

Expected behavior

  • If a create gets an apply that is neither a boolean nor a recognised string (true/false/yes/no/1/0/on/off),
    it refuses and names the accepted values, as badEnum already does for other enums. Leaving apply out still
    creates, which is the documented default.
  • A non-numeric limit/offset ("ten") is refused, naming the key and the range. When an out-of-range
    value gets clamped, the result says so (e.g. limit clamped to 2000), so a truncated page cannot pass for a
    complete one.

Actual behavior

  • Q2. appDataCreateApply (packages/server/src/services/mari-db/mari-db.service.ts) is
    firstBoolean(source, ["apply"]) !== false. firstBoolean only reads booleans and a fixed set of strings,
    and returns undefined for anything else, including the number 0, "preview" and "dry-run". So
    apply: 0 or apply: "dry-run" on any of the 14 create sites (character.create, persona.create,
    instruction.remember, folder creates, lorebook.create/createEntry, theme.create,
    personal_extension.create, agent/tool creates, preset.addSection/addGroup/addChoiceBlock) writes.
    Updates and deletes are not affected: they use === true, so an unreadable value previews.
  • Q1. In workspace-agent.service.ts, numberArg returns the fallback for a non-finite value and clamps
    everything else to [min, max] without a message. read with limit: 5000 returns 2,000 lines and says
    (truncated), but never mentions that the limit was lowered. normalizeLimit/normalizeOffset in
    mari-db.service.ts do the same for list reads (limit: "ten" → default page, limit: 9999 → the max).

Steps to reproduce

  1. Call app_data with {"action":"theme.create","data":{"name":"Probe","css":"body{}"},"apply":0}, then
    theme.list. The theme exists.
  2. Call it again with "apply":"dry-run". It is created again.
  3. Call app_data {"action":"character.list","limit":"ten"}. The default page comes back, with no word about
    limit.

Environment

  • Marinara Engine version: 2.5.1 (staging 32499a440) + feat/mari-builtin-skills
  • Install type: source (dev worktree)
  • OS + version: Windows 11
  • Browser or app shell: n/a (server-side tool arguments)

Logs, screenshots, or video

Found by reading the source during the #7949 audit. No live model has been seen sending apply: 0 yet; steps
1–3 are the direct repro.

Additional context

  • The audit's original wording ("apply: "no" is treated as true") was wrong: firstBoolean reads "no" as
    false. Only values it cannot read at all fall through to "write".
  • The fix belongs in firstBoolean's callers, not in firstBoolean itself, because other fields rely on its
    undefined.
  • Related: #7949 (wording, fixed in #7908).

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @ylli-selmani on GitHub (Oct 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7999 Originally assigned to: @ylli-selmani on GitHub. ## Summary Two of Professor Mari's structured-tool arguments are coerced without a word. If a create gets an `apply` value it cannot read, the create **writes**. A numeric argument that is not a number, or is out of range, gets replaced by the default or the limit. In both cases the call "succeeds", so a model never finds out it was misread. These are behaviour bugs, not wording, so they were split out of #7949. ## Expected behavior - If a create gets an `apply` that is neither a boolean nor a recognised string (`true/false/yes/no/1/0/on/off`), it refuses and names the accepted values, as `badEnum` already does for other enums. Leaving `apply` out still creates, which is the documented default. - A non-numeric `limit`/`offset` (`"ten"`) is refused, naming the key and the range. When an out-of-range value gets clamped, the result says so (e.g. `limit clamped to 2000`), so a truncated page cannot pass for a complete one. ## Actual behavior - **Q2.** `appDataCreateApply` (`packages/server/src/services/mari-db/mari-db.service.ts`) is `firstBoolean(source, ["apply"]) !== false`. `firstBoolean` only reads booleans and a fixed set of strings, and returns `undefined` for anything else, including the number `0`, `"preview"` and `"dry-run"`. So `apply: 0` or `apply: "dry-run"` on any of the 14 create sites (`character.create`, `persona.create`, `instruction.remember`, folder creates, `lorebook.create`/`createEntry`, `theme.create`, `personal_extension.create`, agent/tool creates, `preset.addSection`/`addGroup`/`addChoiceBlock`) **writes**. Updates and deletes are not affected: they use `=== true`, so an unreadable value previews. - **Q1.** In `workspace-agent.service.ts`, `numberArg` returns the fallback for a non-finite value and clamps everything else to `[min, max]` without a message. `read` with `limit: 5000` returns 2,000 lines and says `(truncated)`, but never mentions that the limit was lowered. `normalizeLimit`/`normalizeOffset` in `mari-db.service.ts` do the same for list reads (`limit: "ten"` → default page, `limit: 9999` → the max). ## Steps to reproduce 1. Call `app_data` with `{"action":"theme.create","data":{"name":"Probe","css":"body{}"},"apply":0}`, then `theme.list`. The theme exists. 2. Call it again with `"apply":"dry-run"`. It is created again. 3. Call `app_data` `{"action":"character.list","limit":"ten"}`. The default page comes back, with no word about `limit`. ## Environment - Marinara Engine version: 2.5.1 (`staging` `32499a440`) + `feat/mari-builtin-skills` - Install type: source (dev worktree) - OS + version: Windows 11 - Browser or app shell: n/a (server-side tool arguments) ## Logs, screenshots, or video Found by reading the source during the #7949 audit. No live model has been seen sending `apply: 0` yet; steps 1–3 are the direct repro. ## Additional context - The audit's original wording ("`apply: "no"` is treated as true") was wrong: `firstBoolean` reads `"no"` as false. Only values it cannot read at all fall through to "write". - The fix belongs in `firstBoolean`'s callers, not in `firstBoolean` itself, because other fields rely on its `undefined`. - Related: #7949 (wording, fixed in #7908). ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-24 04:03:44 +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#7512
No description provided.