AI Assistant & Workbook Safety
In-App AI Plan Validator, Suggest Style Guard & Undo Audit
Audit the client-side validatePlan and applyPlan safety rules in Arte Sheets: <=100 cell changes, <=2,000-char strings, <=10,000-cell range/SEQUENCE caps, suggest-mode style rejection, and local Undo stack recording.
Verify every client-side guardrail before applying or proposing an AI cell plan!
When you send a prompt to the in-app Pro Assistant in Arte Sheets (which requires an active Pro plan and consumes metered monthly Arte AI credits from the 2,000-credit monthly grant—distinct from the external Arte Sheets ChatGPT plugin 0.1.0, which remains In review / Not published and runs 13 scoped OAuth MCP tools at 0 Arte AI credits under a 120 calls/min per-account limiter), client-side validatePlan in js/assistant/actions.js enforces deterministic workbook safety BEFORE a single cell updates: (1) changes.length <= 100 cells and string length <= 2,000 characters; (2) no merged or dynamic-array spill target cells; (3) volatile/unbounded tokens RANDARRAY, MAKEARRAY, INDIRECT, OFFSET, and whole-column/row references (A:A, 1:1) are blocked, while A1:B10 ranges and SEQUENCE(r, c) dimensions are capped at <= 10,000 cells; and (4) allowed style keys (bold, italic, #rrggbb bg/color, numFmt, align) apply ONLY in direct edit mode—in suggest mode (suggester role or proposal review), ch.style is explicitly rejected because cell suggestions carry value/formula proposals only!
Build an interactive Plan Readiness Audit on Planned_Cell_Changes n_chg = 40 (B2, cap 100), Max_Value_Chars n_len = 280 (B3, cap 2,000), Max_Range_or_Sequence_Cells n_rng = 1,200 (B4, cap 10,000), Blocked_Tokens_or_Spill_Targets n_blk = 0 (B5, must be 0), Includes_Style_Patch f_sty = 1 (B6), Suggest_Mode_Active f_sug = 0 (B7, 0 = direct editor/owner apply, 1 = suggest mode), and Shared_Workbook_Active f_shr = 0 (B8, 0 = local browser workbook, 1 = cloud collaboration workbook): Remaining Cell Headroom is 100 - 40 = 60 cells (E2); Remaining Range-Scan Headroom is 10,000 - 1,200 = 8,800 cells (E3); Plan Gate returns "Plan Valid: Direct Apply" (E4); and Undo/Sync Route returns "Local UndoStack Patch Recorded" (E5, whereas on a shared cloud workbook f_shr = 1 live collaboration sync / peer review governs history)! Flip Suggest_Mode_Active f_sug = 1 while keeping Includes_Style_Patch f_sty = 1: E4 immediately catches "Rejected: Styles Blocked in Suggest Mode"!
| Client Plan Validator Rule (js/assistant/actions.js) | Hard Contract Threshold | Verified Baseline State |
|---|---|---|
| Patch Count & String Cap | 1 <= n_chg <= 100; n_len <= 2,000 chars | 40 cells (60 Headroom) |
| Range & SEQUENCE Cell Cap | n_rng <= 10,000; 0 A:A / OFFSET / INDIRECT | 1,200 cells (8,800 Headroom) |
| Suggest-Mode Style Guard | If f_sug = 1, f_sty MUST equal 0 | Plan Valid: Direct Apply |
| Local Undo vs Shared Collab | f_shr = 0 pushes {label:"AI"} to undoStack | Local UndoStack Patch Recorded |
Client-Side validatePlan Gate Status Formula
Check patch size, character length, 10,000-cell range cap, zero blocked volatile/spill targets, and the suggest-mode style restriction in exact priority order!
=LET(n_ch, B2, n_ln, B3, n_rg, B4, n_bk, B5, f_st, B6, f_sg, B7, f_sh, B8, IF(OR(n_ch < 1, n_ln < 0, n_rg < 0, n_bk < 0, NOT(OR(f_st = 0, f_st = 1)), NOT(OR(f_sg = 0, f_sg = 1)), NOT(OR(f_sh = 0, f_sh = 1))), "Invalid Audit Flags", IF(OR(n_ch > 100, n_ln > 2000), "Rejected: Exceeds 100-Cell or 2000-Char Cap", IF(OR(n_rg > 10000, n_bk > 0), "Rejected: Range >10k or Blocked Formula/Spill", IF(AND(f_sg = 1, f_st = 1), "Rejected: Styles Blocked in Suggest Mode", IF(f_sg = 1, "Plan Valid: Route to Cell Suggestions", "Plan Valid: Direct Apply"))))))UndoStack vs Cloud Collaboration Routing Formula
When f_sg = 1 and f_st = 0, proposals route to peer-reviewable cell suggestions (where editors/owners inspect references and test changed inputs before accepting); when f_sg = 0 on a local workbook (f_sh = 0), applyPlan records a single Undo entry!
=IF(LEFT(E4, 10) <> "Plan Valid", "No Mutation Applied", IF(B7 = 1, "Peer-Review Suggestion Queue", IF(B8 = 0, "Local UndoStack Patch Recorded", "Shared Cloud Live Sync Applied")))Try the example
Use the original values or change them to test your understanding.