Files
projax/mcp
mAi 63efc23843 refactor(mcp): validate item writes via internal/itemwrite/
Phase 5c slice C. createItemTool and updateItemTool now pre-validate
through internal/itemwrite/ before the store.Create / Update call.

- itemWriteError wraps a *ValidationError into an error whose
  message embeds the JSON shape {kind, path, detail} — the JSON-RPC
  envelope carries that as .error.message, and clients can parse the
  bracketed JSON suffix to extract a typed object. (A future Slice D
  could promote this to .error.data with native typed-error support
  in the mcp server; out of scope here.)
- createItemTool: ValidateFormat + ValidateAgainstStore on
  (title, slug, status, parent_ids) before store.Create. The old
  "slug and title are required" inline check is removed — the
  validator's missing-required kind covers it with a structured
  reject.
- updateItemTool: same pair on the patched-item shape (the item's
  existing fields plus whatever the input overrides). Catches
  cycle / self-parent / slug-collision before the txn opens.

No mcp test source touched — assertions are on observable behaviour
(tool result shape, error presence) and the validator preserves both
for valid AND invalid inputs the SQL trigger would have rejected.

Task: t-projax-5c-itemwrite
2026-05-22 00:37:24 +02:00
..