A monthly S&OP pack with a one-number plan and reorder points

A year of weekly shipments for 60 SKUs into consensus demand, supply against two capped lines, four priced ways to handle the 18,380-unit gap, safety stock and reorder points with a service-level switch, and a six-slide pack.

Who
Brookhollow Foods' planning agent in Google ADK, on OpenAI gpt-6.1-sol
Runs in
Google ADK
Hands over
.pptxNovember-SOP-Executive-Pack.pptx.xlsxNovember-SOP-Planning.xlsx
6 slides + 16 sheetsin 2 files, opened in Office
25 turns, 5 minone agent run in Google ADK on gpt-6.1-sol, unedited

The ask

Get the November S&OP pack ready for Thursday; what the execs need is in sop_note.md. Sales history, the item master and line capacity are in this folder. Build the planning workbook (consensus demand by family, supply against the capped lines, the gap and the options, and safety stock and reorder points by SKU with a service-level switch) and the S&OP deck. Families have to add up to total demand. Ledger theme.

Brookhollow Foods' planning agent in Google ADK, on OpenAI gpt-6.1-sol

Every month the planning team rebuilds the same workbook before the executive S&OP meeting: demand by family, capacity by line, the gap and how to close it, and which SKUs to reorder. This month two lines are capped, so the options matter more than usual.

This run is a Google ADK agent, built with artiwright's artiwright_agent the way the docs show, on OpenAI's gpt-6.1-sol through LiteLLM. It gets the request, the paths of the shipments, item master and capacity exports, and the planner's note. It imports the exports, builds the plan and the pack, and checks both before saving.

What they handed over

Made-up data in the shape of a real export. Download it and try the ask yourself.

What came out

November-SOP-Executive-Pack.pptxPowerPoint · 6 slides · 43 KB
Download
November-SOP-Planning.xlsxExcel · 16 sheets · 127 KB
Download

Screenshots exported by PowerPoint and Excel.

What the agent noticed

It priced each way to close the gap

Overtime alone, at the 4% cap, adds 8,453 units for $3,550 and leaves 9,927 short. Pre-building in October adds 13,164 units for $872 and leaves 5,216. Pre-building first and using overtime for the rest closes all 18,380 units for $3,062. The agent recommended that, subject to October slots, labor and shelf life, with allocation to the largest SKUs as the fallback.

It tried the switch and said what changed

The agent flipped the service level to 98% and back during the run. At 98%, safety stock rises from 61,605 to 76,912 units, but the same 12 SKUs need reordering. The item master has no open orders, so the deck calls these provisional and asks procurement to check open orders first.

It flagged a one-unit difference

Base supply is shared out across families pro rata, so the family gaps (7,264, 5,509 and 5,608) add up to 18,381, one more than the line gap. The gap slide says so in its footnote.

Build it yourself

Get the November S&OP pack ready for Thursday; what the execs need is in sop_note.md. Sales history, the item master and line capacity are in this folder. Build the planning workbook (consensus demand by family, supply against the capped lines, the gap and the options, and safety stock and reorder points by SKU with a service-level switch) and the S&OP deck. Families have to add up to total demand. Ledger theme.

Set Artiwright up in your app first: Quickstart for AI apps, Google ADK, LangGraph, Node.js.

Inside the workbook

16 sheets, laid out by the agent. In its words, sheet by sheet:

  1. The Sales history sheet
    Sales history

    The imported shipments: 3,120 rows, 52 weeks for 60 SKUs, as a table the formulas read.

  2. The SKU master sheet
    SKU master

    The imported item master: family, line, unit cost, lead time and on-hand stock for each SKU.

  3. The Capacity sheet
    Capacity

    The imported line capacity by month, October 2026 to March 2027.

  4. The Inputs sheet
    Inputs

    The plan month, the 13-week window, the service level on a 95%/98% dropdown, the 4% overtime cap at $0.42 a unit, 24% annual carry, and the family overlays.

Show all 16 sheets
  1. The Weekly stats sheet
    Weekly stats

    Units by SKU for the 13 weeks from Jul 6 to Sep 28, 2026, with the weekly mean, standard deviation and a count of weeks.

  2. The SKU plan sheet
    SKU plan

    All 60 SKUs: November consensus units, safety stock and reorder point at the selected level and at 95% and 98%, a reorder flag, and each SKU's share of base supply, prebuild and overtime.

  3. The Line plan sheet
    Line plan

    The four lines: consensus against November capacity, an 11,676-unit gap on L2 and 6,704 on L4, overtime room, October headroom, prebuild, overtime and cost.

  4. The Family demand sheet
    Family demand

    Statistical demand, overlay and consensus by family, adding up to 366,404 units, with base supply and the gap.

  5. The Family by line sheet
    Family by line

    Every family on every line, so families that run on two lines show their gap on each.

  6. The Options sheet
    Options

    Allocate only, overtime only, prebuild only, and prebuild then overtime: units, what's left unmet and cost for each.

  7. The Checks sheet
    Checks

    Nine controls that should be zero, from families against SKUs to the gap closing exactly. All nine are zero.

  8. The Read me sheet
    Read me

    The method and its limits, line by line, including that there are no open orders in the item master.

  9. The Executive summary sheet
    Executive summary

    The headline figures, the family table, the recommendation and a chart of demand by family.

  10. The Inventory summary sheet
    Inventory summary

    Total safety stock, total reorder points, alerts and the gap to reorder point at 95% and at 98%.

  11. The Deck data sheet
    Deck data

    The figures the slides use, laid out in one place.

  12. The Reorder alerts sheet
    Reorder alerts

    The 12 SKUs at or below their reorder point, filtered live from the SKU plan at the selected service level.

How it got thereSee all 27 calls the agent made, what lint found and the finalize report

The run

One real session in Google ADK (gpt-6.1-sol), with only Artiwright's tools and the paths of the files above. Nothing below is edited: every call the agent made, what came back, and the renders it looked at.

  1. artiwright_help
    {
      "query": "skill spreadsheets, skill presentations",
      "maxChars": 12000
    }
    ---
    name: artiwright-spreadsheets
    description: Build native Excel workbooks (.xlsx) with Artiwright - live formulas that compute as you write them, tables, number formats, conditional formats, data validation and native charts, then render, lint and publish a checked file. Use when a user asks for a spreadsheet, workbook, financial or operating model, budget, tracker, dashboard or data "as Excel".
    ---
    
    # Artiwright spreadsheets
    
    You build workbooks as code against a live document. Formulas compute as you write them, so you
    can read results back, check them, and look at the sheet as an image before you publish.
    Everything you make stays native and editable in Excel: real formulas (not pasted values), tables,
    number formats, conditional formats, validation dropdowns and charts linked to the cells.
    
    ## The loop
    
    1. **Plan the sheets.** Inputs (assumptions the user can change) → calculations → outputs
       (summary, charts). Decide the rows, columns and units before writing. Never invent numbers:
       ask, or label an assumption clearly as one.
    2. **Build** a sheet or a whole section per call: values, then formulas, then formats.
    3. **Look.** Render each sheet (`artiwright_render`) and read key results back (`return` a range,
       or `artiwright_inspect` with kind `formula`).
    4. **Check** with lint: formula errors, cycles, `####` columns, numbers stored as text, typed-in
       numbers in formulas. Fix everything in one call, then look again.
    5. **Publish** with finalize, stating requirements: the sheets, tables and charts that must exist
       and key cells with the values they must hold (`{ cell: "Checks!B2", equals: 0 }`).
    
    ## Work in few calls
    
    Every call resends the whole conversation, so a workbook made in 4 calls costs a fraction of one
    made in 25. When the user gives the data, this is usually enough:
    
    1. **One `artiwright_run` that builds every sheet**: rename `Sheet1`, write inputs, formulas,
       formats, tables, rules and charts, and `return` the key result cells to read them back.
    2. **`artiwright_lint`**. If it reports problems, fix them all in **one** run.
    3. **`artiwright_finalize`** with requirements (sheets, tables, charts, key cell values).
    
    - Don't probe the API with small runs: the calls on this page are enough. Use `help` only for
      something it doesn't show (`help("range.format")`, `help("functions")`).
    - One formula fills a range adjusted per row: `sheet
    …
  2. I’ll build a linked planning workbook and six-slide executive pack in Ledger. I’ll make the demand, capacity and inventory assumptions explicit, reconcile the family totals, and include a 95%/98% service-level switch.

  3. artiwright_importsales_history.csverror
    {
      "document": "plan",
      "path": "./work/sales_history.csv",
      "sheet": "History",
      "table": "Sales",
      "theme": "ledger"
    }
    {
      "ok": false,
      "error": {
        "name": "ArtiwrightError",
        "message": "\"History\" is reserved by Excel."
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sheet1"
      ],
      "version": 0,
      "lint": {
        "errors": 0,
        "warnings": 0
      }
    }
  4. artiwright_importsales_history.csv
    {
      "document": "plan",
      "path": "./work/sales_history.csv",
      "sheet": "Sales history",
      "table": "Sales",
      "theme": "ledger"
    }
    {
      "ok": true,
      "value": {
        "sheet": "Sales history",
        "range": "A1:D3121",
        "rows": 3120,
        "columns": [
          "Week",
          "SKU",
          "Family",
          "Units"
        ],
        "firstRows": [
          [
            45936,
            "BH-HC-101",
            "Hot cereal",
            517
          ],
          [
            45936,
            "BH-HC-102",
            "Hot cereal",
            1484
          ],
          [
            45936,
            "BH-HC-103",
            "Hot cereal",
            3123
          ]
        ],
        "table": "Sales"
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history"
      ],
      "version": 1,
      "lint": {
        "errors": 0,
        "warnings": 25
      },
      "next": "Use the table in formulas, e.g. =SUM(Sales[column]); import the next file the same way."
    }
  5. artiwright_importsku_master.csv
    {
      "document": "plan",
      "path": "./work/sku_master.csv",
      "sheet": "SKU master",
      "table": "Items",
      "theme": "ledger"
    }
    {
      "ok": true,
      "value": {
        "sheet": "SKU master",
        "range": "A1:H61",
        "rows": 60,
        "columns": [
          "SKU",
          "Product name",
          "Family",
          "Line",
          "Unit cost",
          "List price",
          "Lead time (weeks)",
          "On hand"
        ],
        "firstRows": [
          [
            "BH-HC-101",
            "Organic Steel-Cut Oats, Maple & Brown Sugar, 12 x 400 g Family Pack",
            "Hot cereal",
            "L1",
            3.37,
            5.88,
            6,
            2584
          ],
          [
            "BH-HC-102",
            "Rolled Oats Original 1 kg",
            "Hot cereal",
            "L1",
            3.24,
            6.28,
            3,
            6816
          ],
          [
            "BH-HC-103",
            "Instant Oatmeal Apple Cinnamon 10 x 35 g",
            "Hot cereal",
            "L1",
            2.63,
            5.37,
            2,
            11800
          ]
        ],
        "table": "Items"
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master"
      ],
      "version": 2,
      "lint": {
        "errors": 0,
        "warnings": 26
      },
      "next": "Use the table in formulas, e.g. =SUM(Items[column]); import the next file the same way."
    }
  6. artiwright_importcapacity.csv
    {
      "document": "plan",
      "path": "./work/capacity.csv",
      "sheet": "Capacity",
      "table": "Caps",
      "theme": "ledger"
    }
    {
      "ok": true,
      "value": {
        "sheet": "Capacity",
        "range": "A1:D25",
        "rows": 24,
        "columns": [
          "Month",
          "Line",
          "Line name",
          "Capacity (units)"
        ],
        "firstRows": [
          [
            46296,
            "L1",
            "Oats line",
            75300
          ],
          [
            46296,
            "L2",
            "Baking line",
            156100
          ],
          [
            46296,
            "L3",
            "Mill line",
            84200
          ]
        ],
        "table": "Caps"
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master",
        "Capacity"
      ],
      "version": 3,
      "lint": {
        "errors": 0,
        "warnings": 27
      },
      "next": "Use the table in formulas, e.g. =SUM(Caps[column]); import the next file the same way."
    }
  7. artiwright_run
    return {capacity:workbook.sheets.get('Capacity').range('A1:D25').values,items:workbook.sheets.get('SKU master').range('A1:H61').values,first:workbook.sheets.get('Sales history').range('A2:D3').values,last:workbook.sheets.get('Sales history').range('A3062:D3063').values};
    {
      "ok": true,
      "value": {
        "capacity": [
          [
            "Month",
            "Line",
            "Line name",
            "Capacity (units)"
          ],
          [
            46296,
            "L1",
            "Oats line",
            75300
          ],
          [
            46296,
            "L2",
            "Baking line",
            156100
          ],
          [
            46296,
            "L3",
            "Mill line",
            84200
          ],
          [
            46296,
            "L4",
            "Bar line",
            89600
          ],
          [
            46327,
            "L1",
            "Oats line",
            74300
          ],
          [
            46327,
            "L2",
            "Baking line",
            134264
          ],
          [
            46327,
            "L3",
            "Mill line",
            77100
          ],
          [
            46327,
            "L4",
            "Bar line",
            77081
          ],
          [
            46357,
            "L1",
            "Oats line",
            75300
          ],
          [
            46357,
            "L2",
            "Baking line",
            146800
          ],
          [
            46357,
            "L3",
            "Mill line",
            80100
          ],
          [
            46357,
            "L4",
            "Bar line",
            89300
          ],
          [
            46388,
            "L1",
            "Oats line",
            76900
          ],
          [
            46388,
            "L2",
            "Baking line",
            150500
          ],
          [
            46388,
            "L3",
            "Mill line",
            83100
          ],
          [
            46388,
            "L4",
            "Bar line",
            88000
          ],
          [
            46419,
            "L1",
            "Oats line",
            68900
          ],
          [
            46419,
            "L2",
            "Baking line",
            132600
          ],
          [
            46419,
            "L3",
            "Mill line",
            75800
          ],
          [
            46419,
            "L4",
            "Bar line",
            79100
          ],
          [
            46447,
            "L1",
            "Oats line",
            78900
          ],
          [
            46447,
            "L2",
            "Baking line",
            146900
          ],
          [
            46447,
            "L3",
            "Mill line",
            79200
          ],
          [
            46447,
            "L4",
            "Bar line",
            84700
          ]
        ],
        "items": [
          [
            "SKU",
            "Product name",
            "Family",
            "Line",
            "Unit cost",
            "List price",
            "Lead time (weeks)",
            "On hand"
          ],
          [
            "BH-HC-101",
            "Organic Steel-Cut Oats, Maple & Brown Sugar, 12 x 400 g Fami
    …
  8. artiwright_help
    {
      "query": "guide workbook-charts, guide workbook-formatting",
      "maxChars": 6500
    }
    # Workbook charts guide
    
    Charts in a workbook read their data from cells, so they update when the numbers change.
    
    ```js workbook-test
    const s = workbook.sheets.get("Sheet1");
    s.range("A1").values = [
      ["Month", "Revenue", "Margin"],
      ["Jan", 120, 0.21],
      ["Feb", 135, 0.22],
      ["Mar", 150, 0.24],
    ];
    s.range("B2:B4").numberFormat = "currency0";
    s.range("C2:C4").numberFormat = "percent";
    s.charts.add("column", {
      data: "A1:C4",
      at: "E2",
      size: { w: 520, h: 300 },
      title: "Revenue grew while margin widened",
      series: [{}, { type: "line", axis: "secondary" }],
    });
    ```
    
    - `data` is a block with series names in its first row and categories in its first column (text);
      `seriesIn: "rows"` when series run across. Another sheet: `data: "Model!A1:C13"`.
    - Place with `at` (top-left cell) and `size` in px, or `to` (bottom-right cell). Put charts beside
      or below the numbers, not over them. On a summary sheet, below its table at the table's width.
    - To show $M or $K, give the source cells (or `axes.y.format`) a scaled number format like
      `"millions"`; don't copy the numbers into a second table in other units for the chart.
    - Text defaults to Excel's sizes (9 pt labels, 14 pt title); set `style` only for a reason.
    - `series` restyles series by position: `{ type: "line", axis: "secondary" }` for a combo,
      `{ fill: "accent2" }` for a color.
    - Axes and values take the cells' number formats unless you set `axes: { y: { format } }`.
    - Types: column, bar, line, area, pie, doughnut, scatter (x values in the first column), bubble,
      radar, stock; and the Office 2016 types waterfall, funnel, pareto, histogram, boxWhisker,
      treemap and sunburst (leading text columns are the levels).
    - A chart title should say what the chart shows ("Revenue grew 25% in Q1"), not just "Revenue".
    
    
    # Formatting guide
    
    Formatting tells the reader what a number is. Use few styles, consistently.
    
    ## Number formats
    
    | Shortcut | Format | For |
    |---|---|---|
    | `integer` | `#,##0` | counts |
    | `number` | `#,##0.00` | measures |
    | `percent`, `percent1` | `0%`, `0.0%` | rates and shares |
    | `currency`, `currency0` | `$#,##0.00`, `$#,##0` | money |
    | `millions`, `thousands` | `$#,##0.0,,"M"`, `#,##0,"K"` | large money / counts |
    | `date`, `datetime`, `time` | `yyyy-mm-dd`, … | dates (Dates get `date` automatically) |
    | `accounting` | Excel's accounting format | finance statements |
    
    Any Excel cod
    …
  9. artiwright_runerror
    const sh=workbook.sheets.get('Sales history'), ms=workbook.sheets.get('SKU master'), cap=workbook.sheets.get('Capacity'); const items=ms.range('A2:H61').values; const hist=sh.range('A2:D3121').values; const weeks=[...new Set(hist.map(r=>r[0]))].sort((a,b)=>a-b).slice(-13); const fams=['Hot cereal','Granola','Snack bars','Nut butters','Crackers']; const ovs=[.06,0,.04,-.02,.03];
    const inp=workbook.sheets.add('Inputs'); inp.range('A1:C1').values=[['NOVEMBER S&OP | CONTROL PANEL','Value','Basis']]; inp.range('A2:C19').values=[['Plan month',46327,'November 2026 inferred from capacity calendar'],['Lookback weeks',13,'Latest 13 complete weeks in sales export'],['Days per week',7,'Calendar conversion'],['November days',30,'Calendar month'],['October days',31,'Calendar month'],['Service level',.95,'Switch to 98% for cycle-service sensitivity'],['Overtime cap',.04,'On November constrained lines only'],['Overtime cost / unit',.42,'Incremental cost from Ines'],['Annual carry rate',.24,'Applied to unit manufacturing cost'],['Prebuild months held',1,'Assumption: one month average holding'],['Months per year',12,'Annual-to-month conversion'],['Zero',0,'Formula constant'],['One',1,'Formula constant'],['Rounding digits',0,'Whole units'],['95% reference',.95,'Sensitivity'],['98% reference',.98,'Sensitivity'],['Latest history week',weeks[12],'Last weekly observation'],['First history week',weeks[0],'Inclusive lookback start']]; inp.range('A22:C27').values=[['Family','Overlay','Commercial rationale'],...fams.map((f,i)=>[f,ovs[i],['Winter promotion','Unchanged','Club listing','Price increase','Holiday tins'][i]])]; inp.tables.add('A22:C27',{name:'Overlays'}); const names={PlanMonth:2,Lookback:3,DaysWeek:4,NovDays:5,OctDays:6,ServiceLevel:7,OTRate:8,OTCost:9,CarryRate:10,HoldMonths:11,MonthsYear:12,Zero:13,One:14,Digits:15,Ref95:16,Ref98:17,LastWeek:18,FirstWeek:19}; for(const [n,r] of Object.entries(names))workbook.names.add(n,`Inputs!$B$${r}`); inp.validations.add('B7',{type:'list',values:[.95,.98],error:'Choose 95% or 98%.'}); inp.range('B7:B8').numberFormat='percent'; inp.range('B10').numberFormat='percent'; inp.range('B16:B17').numberFormat='percent'; inp.range('B23:B27').numberFormat='percent'; inp.range('B2').numberFormat='mmm yyyy';inp.range('B18:B19').numberFormat='date'; inp.range('B2:B19').format({color:'blue-700',fill:'blue-50'});inp.range('B23:B27').format({color:'blue-700',fill:'blue-50'});
    const wk=workbook.sheets.add('Weekly stats');wk.range('A1:Q1').values=[['SKU',...weeks,'Mean / week','Std dev / week','Observations']];wk.range('A2:A61').values=items.map(r=>[r[0]]);wk.range('B1:N1').numberFormat='date';for(let c=0;c<13;c++){const col=String.fromCharCode(66+c);wk.range(`${col}2:${col}61`).formulas=`=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],${col}$1)`;}wk.range('O2:O61').formulas='=AVERAGE(B2:N2)';wk.range('P2:P61').formulas='=STDEV.S(B2:N2)';wk.range('Q2:Q61').formulas='=COUNTIFS(Sales[SKU],A2,Sales[Week],">="&FirstWeek,Sales[Week],"<="&LastWeek)';
    const sk=workbook.sheets.add('SKU plan');sk.range('A1:AB1').values=[['SKU','Family','Line','Unit cost $','Lead weeks','On hand units','Mean / week','Std dev / week','Overlay','Consensus Nov units','Oct baseline units','Mean with overlay','Std with overlay','Safety stock selected','Reorder point selected','Reorder now?','Shortfall to ROP','SS at 95%','ROP at 95%','SS at 98%','ROP at 98%','Base supply units','Base gap units','Priority allocation units','Priority unmet units','Prebuild units','Carry cost $','OT units']];sk.range('A2:F61').values=items.map(r=>[r[0],r[2],r[3],r[4],r[6],r[7]]);const sf={G:'=\'Weekly stats\'!O2',H:'=\'Weekly stats\'!P2',I:'=SUMIF(Overlays[Family],B2,Overlays[Overlay])',J:'=ROUND(G2*NovDays/DaysWeek*(One+I2),Digits)',K:'=ROUND(G2*OctDays/DaysWeek,Digits)',L:'=G2*(One+I2)',M:'=H2*(One+I2)',N:'=ROUNDUP(NORM.S.INV(ServiceLevel)*M2*SQRT(E2),Digits)',O:'=ROUNDUP(L2*E2+N2,Digits)',P:'=IF(F2<=O2,"REORDER","OK")',Q:'=MAX(Zero,O2-F2)',R:'=ROUNDUP(NORM.S.INV(Ref95)*M2*SQRT(E2),Digits)',S:'=ROUNDUP(L2*E2+R2,Digits)',T:'=ROUNDUP(NORM.S.INV(Ref98)*M2*SQRT(E2),Digits)',U:'=ROUNDUP(L2*E2+T2,Digits)',V:'=J2*SUMIF(Lines[Line],C2,Lines[Base supply])/SUMIF(Lines[Line],C2,Lines[Consensus])',W:'=J2-V2',X:'=MIN(J2,MAX(Zero,SUMIF(Lines[Line],C2,Lines[Base supply])-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,">"&J2)-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,J2,$A$2:$A$61,"<"&A2)))',Y:'=J2-X2',Z:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[Prebuild]),Zero)',AA:'=Z2*D2*CarryRate*HoldMonths/MonthsYear',AB:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[OT units]),Zero)'};
    const ln=workbook.sheets.add('Line plan'); ln.range('A1:P5').values=[['Line','Consensus','November cap','Base supply','Gap','OT max','OT units','OT cost $','Residual after OT','October baseline','October cap','October headroom','Prebuild','Carry cost $','Unresolved','Utilization'],...['L1','L2','L3','L4'].map(l=>[l])];ln.tables.add('A1:P5',{name:'Lines'});const lf={B:'=SUMIF(\'SKU plan\'!$C$2:$C$61,A2,\'SKU plan\'!$J$2:$J$61)',C:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],PlanMonth)',D:'=MIN(B2,C2)',E:'=MAX(Zero,B2-D2)',F:'=IF(E2>Zero,ROUNDDOWN(C2*OTRate,Digits),Zero)',G:'=MIN(E2,F2)',H:'=G2*OTCost',I:'=MAX(Zero,E2-G2)',J:'=SUMIF(\'SKU plan\'!$C$2:$C$61,A2,\'SKU plan\'!$K$2:$K$61)',K:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],EDATE(PlanMonth,-One))',L:'=MAX(Zero,K2-J2)',M:'=MIN(I2,L2)',N:'=SUMIF(\'SKU plan\'!$C$2:$C$61,A2,\'SKU plan\'!$AA$2:$AA$61)',O:'=MAX(Zero,I2-M2)',P:'=B2/C2'};for(const [c,f]of Object.entries(lf))ln.range(`${c}2:${c}5`).formulas=f;for(const [c,f]of Object.entries(sf))sk.range(`${c}2:${c}61`).formulas=f;sk.tables.add('A1:AB61',{name:'SKUPlan'});
    const fa=workbook.sheets.add('Family demand');fa.range('A1:G6').values=[['Family','Statistical Nov','Overlay','Consensus Nov','Base supply','Gap','Mix of total'],...fams.map(f=>[f])];fa.tables.add('A1:G6',{name:'Families'});fa.range('B2:B6').formulas='=SUMIF(\'SKU plan\'!$B$2:$B$61,A2,\'SKU plan\'!$G$2:$G$61)*NovDays/DaysWeek';fa.range('C2:C6').formulas='=SUMIF(Overlays[Family],A2,Overlays[Overlay])';fa.range('D2:D6').formulas='=SUMIF(SKUPlan[Family],A2,SKUPlan[Consensus Nov units])';fa.range('E2:E6').formulas='=SUMIF(SKUPlan[Family],A2,SKUPlan[Base supply units])';fa.range('F2:F6').formulas='=D2-E2';fa.range('G2:G6').formulas='=D2/SUM(SKUPlan[Consensus Nov units])';fa.range('A7').values=[['TOTAL']];for(const c of ['B','D','E','F','G'])fa.range(c+'7').formulas=`=SUM(${c}2:${c}6)`;fa.range('C2:C6').numberFormat='percent';fa.range('G2:G7').numberFormat='percent1';
    const bridge=workbook.sheets.add('Family by line');bridge.range('A1:F21').values=[['Family','Line','Consensus','Base supply','Gap','Gap after OT and prebuild'],...fams.flatMap(f=>['L1','L2','L3','L4'].map(l=>[f,l]))];bridge.range('C2:C21').formulas='=SUMIFS(SKUPlan[Consensus Nov units],SKUPlan[Family],A2,SKUPlan[Line],B2)';bridge.range('D2:D21').formulas='=SUMIFS(SKUPlan[Base supply units],SKUPlan[Family],A2,SKUPlan[Line],B2)';bridge.range('E2:E21').formulas='=C2-D2';bridge.range('F2:F21').formulas='=MAX(Zero,E2-SUMIFS(SKUPlan[Prebuild units],SKUPlan[Family],A2,SKUPlan[Line],B2)-SUMIFS(SKUPlan[OT units],SKUPlan[Family],A2,SKUPlan[Line],B2))';bridge.tables.add('A1:F21',{name:'FamilyLines'});
    const opt=workbook.sheets.add('Options');opt.range('A1:F5').values=[['Scenario','OT units','Prebuild units','Unmet units','Incremental cost $','Caveat'],['Allocate only','=Zero','=Zero','=SUM(Lines[Gap])','=Zero','Priority allocation in SKU plan protects largest November unit demand, then SKU ID. Revenue loss not priced.'],['Overtime only','=SUM(Lines[OT units])','=Zero','=SUM(Lines[Residual after OT])','=SUM(Lines[OT cost $])','4% ceiling on each constrained November line; fractional capacity rounded down.'],['Prebuild only','=Zero','=SUM(B9:B12)','=SUM(Lines[Gap])-C4','=SUM(C9:C12)','October headroom versus unoverlaid run rate only; provisional, schedule and shelf life unverified.'],['OT then prebuild','=SUM(Lines[OT units])','=SUM(Lines[Prebuild])','=SUM(Lines[Unresolved])','=SUM(Lines[OT cost $])+SUM(Lines[Carry cost $])','Recommendation conditional on October slot feasibility; holding cost only, excludes normal production cost.']];opt.range('A8:C12').values=[['Line','Prebuild only units','Carry cost $'],...['L1','L2','L3','L4'].map(l=>[l])];opt.range('B9:B12').formulas='=MIN(SUMIF(Lines[Line],A9,Lines[Gap]),SUMIF(Lines[Line],A9,Lines[October headroom]))';opt.range('C9:C12').formulas='=IFERROR(B9/SUMIF(SKUPlan[Line],A9,SKUPlan[Consensus Nov units])*SUMPRODUCT((\'SKU plan\'!$C$2:$C$61=A9)*\'SKU plan\'!$J$2:$J$61*\'SKU plan\'!$D$2:$D$61)*CarryRate*HoldMonths/MonthsYear,Zero)';
    const ck=workbook.sheets.add('Checks');ck.range('A1:B10').values=[['CONTROL | expected zero','Value'],['Family demand less SKU total','=SUM(Families[Consensus Nov])-SUM(SKUPlan[Consensus Nov units])'],['Lines less SKU total','=SUM(Lines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Demand less base and gap','=SUM(Lines[Consensus])-SUM(Lines[Base supply])-SUM(Lines[Gap])'],['Family-line reconciliation','=SUM(FamilyLines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Weekly count deviations','=SUMPRODUCT(ABS(\'Weekly stats\'!Q2:Q61-Lookback))'],['Priority allocation supply check','=ROUND(SUM(SKUPlan[Priority allocation units])-SUM(Lines[Base supply]),Digits)'],['OT beyond limit','=MAX(Zero,MAX(\'Line plan\'!G2:G5-\'Line plan\'!F2:F5))'],['Base supply beyond cap','=MAX(Zero,MAX(\'Line plan\'!D2:D5-\'Line plan\'!C2:C5))'],['Closure reconciliation','=ROUND(SUM(Lines[Gap])-SUM(Lines[OT units])-SUM(Lines[Prebuild])-SUM(Lines[Unresolved]),Digits)']];
    const read=workbook.sheets.add('Read me');read.range('A1:B12').values=[['BROOKHOLLOW FOODS | NOVEMBER S&OP','Method and limitations'],['Demand','Latest 13 observed weeks; weekly mean x 30/7; family overlays applied to every SKU; round SKU demand to units, then sum families.'],['Capacity','Production requirement is gross demand, not demand net of on hand. Opening inventory not deployed to close production gaps; service-stock adequacy is separate.'],['Base family gaps','November capped line supply apportioned pro rata across SKUs on that line; do not assume a family has only one line.'],['Inventory','Fixed lead time in weeks; independent weekly demand, normal cycle-service approximation; SS = z x sample weekly sigma x sqrt(lead weeks).'],['Reorder point','Overlaid weekly mean x lead weeks + rounded-up safety stock, rounded up to units. Both mean and sigma scaled by commercial overlay.'],['Reorder now','On hand <= ROP. No open orders, backorders or inventory position supplied: provisional alerts, not purchase order quantities. Shortfall is only the gap to ROP.'],['Switch','Inputs B7 selects 95% or 98%; SKU plan retains both sensitivities beside the live selected scenario.'],['October prebuild','October baseline from same history x 31/7, no November overlay. Headroom is indicative; no actual October schedule, labor or shelf-life data.'],['Cost','Overtime incremental $0.42/unit. Prebuild cost = units x SKU cost x 24% x 1/12; assumes one month held. Excludes lost margin, freight and normal conversion cost.'],['Allocation','Standalone allocate-only scenario ranks all SKUs on each line by November unit demand descending; deterministic SKU-ID tie break.'],['Sources','sales_history.csv, sku_master.csv, capacity.csv and sop_note.md. Confirm assumptions at Thursday meeting.']];
    for(const s of [wk,sk,ln,fa,bridge,opt,ck]){s.showGridLines=false;s.freeze(1,1);s.setColumnWidth('A',160);s.setColumnWidth('B:AB',130);s.range('A1:AB1').format({bold:true,fill:'accent1',color:'white',wrap:true});s.setRowHeight(1,46);s.pageSetup({orientation:'landscape',fitTo:{width:1},repeatRows:'1:1'});}wk.range('B2:Q61').numberFormat='integer';sk.range('D2:AB61').numberFormat='integer';sk.range('D2:D61').numberFormat='currency';sk.range('I2:I61').numberFormat='percent';sk.range('AA2:AA61').numberFormat='currency';sk.setColumnWidth('B',145);sk.setColumnWidth('P',120);ln.range('B2:O5').numberFormat='integer';ln.range('H2:H5').numberFormat='currency';ln.range('N2:N5').numberFormat='currency';ln.range('P2:P5').numberFormat='percent1';fa.range('B2:B7').numberFormat='integer';fa.range('D2:F7').numberFormat='integer';fa.range('A7:G7').format({bold:true,borderTop:'double'});bridge.range('C2:F21').numberFormat='integer';opt.range('B2:D5').numberFormat='integer';opt.range('E2:E5').numberFormat='currency';opt.range('C9:C12').numberFormat='currency';opt.setColumnWidth('A',180);opt.setColumnWidth('F',550);opt.range('F2:F5').format({wrap:true});for(let r=2;r<=5;r++)opt.setRowHeight(r,48);sk.conditionalFormats.add('P2:P61',{type:'containsText',text:'REORDER',format:{fill:'red-50',color:'red-700'}});for(const s of [inp,read]){s.showGridLines=false;s.setColumnWidth('A',235);s.setColumnWidth('B',s===read?960:155);s.setColumnWidth('C',480);s.range('A1:C1').format({bold:true,fill:'accent1',color:'white'});s.freeze(1);}read.range('B2:B12').format({wrap:true});for(let r=2;r<=12;r++)read.setRowHeight(r,43);inp.range('A1:C1').format({wrap:true});inp.setRowHeight(1,42);sh.setColumnWidth('A',110);sh.range('A2:A3121').numberFormat='date';ms.setColumnWidth('B',610);ms.setColumnWidth('C:H',135);ms.range('E2:F61').numberFormat='currency';cap.setColumnWidth('A',115);cap.setColumnWidth('C:D',165);cap.range('A2:A25').numberFormat='mmm yyyy';fa.charts.add('column',{data:'A1:B6',at:'A10',size:{w:940,h:330},title:'Statistical November demand by family'});ln.charts.add('column',{data:'A1:C5',at:'A9',size:{w:950,h:330},title:'November consensus demand versus line capacity'});
    return {families:fa.range('A1:G7').values,lines:ln.range('A1:P5').values,options:opt.range('A1:F5').values,checks:ck.range('A1:B10').values};
    {
      "ok": false,
      "error": {
        "name": "ArtiwrightError",
        "message": "names.add: \"Ref95\" can't be a name (start with a letter or _, then letters, digits, _ or .; not a cell address like \"AB12\")."
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master",
        "Capacity"
      ],
      "version": 3,
      "lint": {
        "errors": 0,
        "warnings": 0
      }
    }
  10. artiwright_runerror
    const items=workbook.sheets.get('SKU master').range('A2:H61').values,hist=workbook.sheets.get('Sales history').range('A2:D3121').values,weeks=[...new Set(hist.map(r=>r[0]))].sort((a,b)=>a-b).slice(-13),fams=['Hot cereal','Granola','Snack bars','Nut butters','Crackers']; const add=n=>workbook.sheets.add(n);const inp=add('Inputs');inp.range('A1:C19').values=[['NOVEMBER S&OP | CONTROLS','Value','Basis'],['Plan month',46327,'November 2026, capacity calendar'],['Lookback weeks',13,'Latest complete weeks'],['Days per week',7,'Calendar'],['November days',30,'Calendar'],['October days',31,'Calendar'],['Service level',.95,'Select 95% or 98% cycle service'],['Overtime cap',.04,'Constrained lines only'],['Overtime cost / unit',.42,'Incremental dollars'],['Annual carry rate',.24,'On manufacturing cost'],['Prebuild months held',1,'Assumption: one month held'],['Months per year',12,'Calendar'],['Zero',0,'Constant'],['One',1,'Constant'],['Rounding digits',0,'Whole units'],['95% reference',.95,'Sensitivity'],['98% reference',.98,'Sensitivity'],['Latest history week',weeks[12],'Inclusive end'],['First history week',weeks[0],'Inclusive start']];const names={PlanMonth:2,Lookback:3,DaysWeek:4,NovDays:5,OctDays:6,ServiceLevel:7,OTRate:8,OTCost:9,CarryRate:10,HoldMonths:11,MonthsYear:12,Zero:13,One:14,Digits:15,ServiceLow:16,ServiceHigh:17,LastWeek:18,FirstWeek:19};for(const[n,r]of Object.entries(names))workbook.names.add(n,`Inputs!$B$${r}`);inp.range('A22:C27').values=[['Family','Overlay','Reason'],...fams.map((f,i)=>[f,[.06,0,.04,-.02,.03][i],['Winter promotion','Unchanged','Club listing','Price increase','Holiday tins'][i]])];inp.tables.add('A22:C27',{name:'Overlays'});inp.validations.add('B7',{type:'list',values:[.95,.98],error:'Select 95% or 98%.'});inp.range('B2:B19').format({color:'blue-700',fill:'blue-50'});inp.range('B23:B27').format({color:'blue-700',fill:'blue-50',numberFormat:'percent'});for(const a of ['B7:B8','B10','B16:B17'])inp.range(a).numberFormat='percent';inp.range('B2').numberFormat='mmm yyyy';inp.range('B18:B19').numberFormat='date';
    const wk=add('Weekly stats');wk.range('A1:Q1').values=[['SKU',...weeks,'Mean per week','Std dev per week','Observations']];wk.range('A2:A61').values=items.map(r=>[r[0]]);wk.range('B1:N1').numberFormat='date';for(let c=0;c<13;c++){const l=String.fromCharCode(66+c);wk.range(`${l}2:${l}61`).formulas=`=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],${l}$1)`;}wk.range('O2:O61').formulas='=AVERAGE(B2:N2)';wk.range('P2:P61').formulas='=STDEV.S(B2:N2)';wk.range('Q2:Q61').formulas='=COUNTIFS(Sales[SKU],A2,Sales[Week],">="&FirstWeek,Sales[Week],"<="&LastWeek)';
    const sk=add('SKU plan');sk.range('A1:AB1').values=[['SKU','Family','Line','Unit cost $','Lead weeks','On hand units','Mean per week','Std dev per week','Overlay','Consensus Nov units','Oct baseline units','Mean with overlay','Std with overlay','Safety stock selected','Reorder point selected','Reorder now?','Shortfall to ROP','SS at 95%','ROP at 95%','SS at 98%','ROP at 98%','Base supply units','Base gap units','Priority allocation units','Priority unmet units','Prebuild units','Carry cost $','OT units']];sk.range('A2:F61').values=items.map(r=>[r[0],r[2],r[3],r[4],r[6],r[7]]);sk.tables.add('A1:AB61',{name:'SKUPlan'});
    const ln=add('Line plan');ln.range('A1:P5').values=[['Line','Consensus','November cap','Base supply','Gap','OT max','OT units','OT cost $','Residual after OT','October baseline','October cap','October headroom','Prebuild','Carry cost $','Unresolved','Utilization'],...['L1','L2','L3','L4'].map(l=>[l])];ln.tables.add('A1:P5',{name:'Lines'});
    const sf={G:"='Weekly stats'!O2",H:"='Weekly stats'!P2",I:'=SUMIF(Overlays[Family],B2,Overlays[Overlay])',J:'=ROUND(G2*NovDays/DaysWeek*(One+I2),Digits)',K:'=ROUND(G2*OctDays/DaysWeek,Digits)',L:'=G2*(One+I2)',M:'=H2*(One+I2)',N:'=ROUNDUP(NORM.S.INV(ServiceLevel)*M2*SQRT(E2),Digits)',O:'=ROUNDUP(L2*E2+N2,Digits)',P:'=IF(F2<=O2,"REORDER","OK")',Q:'=MAX(Zero,O2-F2)',R:'=ROUNDUP(NORM.S.INV(ServiceLow)*M2*SQRT(E2),Digits)',S:'=ROUNDUP(L2*E2+R2,Digits)',T:'=ROUNDUP(NORM.S.INV(ServiceHigh)*M2*SQRT(E2),Digits)',U:'=ROUNDUP(L2*E2+T2,Digits)',V:'=J2*SUMIF(Lines[Line],C2,Lines[Base supply])/SUMIF(Lines[Line],C2,Lines[Consensus])',W:'=J2-V2',X:'=MIN(J2,MAX(Zero,SUMIF(Lines[Line],C2,Lines[Base supply])-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,">"&J2)-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,J2,$A$2:$A$61,"<"&A2)))',Y:'=J2-X2',Z:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[Prebuild]),Zero)',AA:'=Z2*D2*CarryRate*HoldMonths/MonthsYear',AB:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[OT units]),Zero)'};for(const[c,f]of Object.entries(sf))sk.range(`${c}2:${c}61`).formulas=f;
    const lf={B:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Consensus Nov units])',C:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],PlanMonth)',D:'=MIN(B2,C2)',E:'=MAX(Zero,B2-D2)',F:'=IF(E2>Zero,ROUNDDOWN(C2*OTRate,Digits),Zero)',G:'=MIN(E2,F2)',H:'=G2*OTCost',I:'=MAX(Zero,E2-G2)',J:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Oct baseline units])',K:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],EDATE(PlanMonth,-One))',L:'=MAX(Zero,K2-J2)',M:'=MIN(I2,L2)',N:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Carry cost $])',O:'=MAX(Zero,I2-M2)',P:'=B2/C2'};for(const[c,f]of Object.entries(lf))ln.range(`${c}2:${c}5`).formulas=f;
    const fa=add('Family demand');fa.range('A1:G6').values=[['Family','Statistical Nov','Overlay','Consensus Nov','Base supply','Gap','Mix of total'],...fams.map(f=>[f])];fa.tables.add('A1:G6',{name:'Families'});const ff={B:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Mean per week])*NovDays/DaysWeek',C:'=SUMIF(Overlays[Family],A2,Overlays[Overlay])',D:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Consensus Nov units])',E:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Base supply units])',F:'=D2-E2',G:'=D2/SUM(SKUPlan[Consensus Nov units])'};for(const[c,f]of Object.entries(ff))fa.range(`${c}2:${c}6`).formulas=f;fa.range('A7').values=[['TOTAL']];for(const c of ['B','D','E','F','G'])fa.range(c+'7').formulas=`=SUM(${c}2:${c}6)`;
    const br=add('Family by line');br.range('A1:F21').values=[['Family','Line','Consensus','Base supply','Gap','Gap after OT and prebuild'],...fams.flatMap(f=>['L1','L2','L3','L4'].map(l=>[f,l]))];const bf={C:'=SUMIFS(SKUPlan[Consensus Nov units],SKUPlan[Family],A2,SKUPlan[Line],B2)',D:'=SUMIFS(SKUPlan[Base supply units],SKUPlan[Family],A2,SKUPlan[Line],B2)',E:'=C2-D2',F:'=MAX(Zero,E2-SUMIFS(SKUPlan[Prebuild units],SKUPlan[Family],A2,SKUPlan[Line],B2)-SUMIFS(SKUPlan[OT units],SKUPlan[Family],A2,SKUPlan[Line],B2))'};for(const[c,f]of Object.entries(bf))br.range(`${c}2:${c}21`).formulas=f;br.tables.add('A1:F21',{name:'FamilyLines'});
    const op=add('Options');op.range('A1:F5').values=[['Scenario','OT units','Prebuild units','Unmet units','Incremental cost $','Caveat'],['Allocate only','=Zero','=Zero','=SUM(Lines[Gap])','=Zero','Largest November unit-demand SKUs first on each line, then SKU ID. Lost margin not priced.'],['Overtime only','=SUM(Lines[OT units])','=Zero','=SUM(Lines[Residual after OT])','=SUM(Lines[OT cost $])','4% ceiling on each constrained line, capacity rounded down.'],['Prebuild only','=Zero','=SUM(B9:B12)','=SUM(Lines[Gap])-C4','=SUM(C9:C12)','Conditional on October headroom and shelf-life feasibility.'],['OT then prebuild','=SUM(Lines[OT units])','=SUM(Lines[Prebuild])','=SUM(Lines[Unresolved])','=SUM(Lines[OT cost $])+SUM(Lines[Carry cost $])','Conditional fallback; holding cost only, excludes normal production cost.']];op.range('A8:C12').values=[['Line','Prebuild only units','Carry cost $'],...['L1','L2','L3','L4'].map(l=>[l])];op.range('B9:B12').formulas='=MIN(SUMIF(Lines[Line],A9,Lines[Gap]),SUMIF(Lines[Line],A9,Lines[October headroom]))';op.range('C9:C12').formulas='=IFERROR(B9/SUMIF(SKUPlan[Line],A9,SKUPlan[Consensus Nov units])*SUMPRODUCT((\'SKU plan\'!$C$2:$C$61=A9)*\'SKU plan\'!$J$2:$J$61*\'SKU plan\'!$D$2:$D$61)*CarryRate*HoldMonths/MonthsYear,Zero)';
    const ck=add('Checks');ck.range('A1:B10').values=[['CONTROL | expected zero','Value'],['Family demand less SKU total','=SUM(Families[Consensus Nov])-SUM(SKUPlan[Consensus Nov units])'],['Lines less SKU total','=SUM(Lines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Demand less base and gap','=SUM(Lines[Consensus])-SUM(Lines[Base supply])-SUM(Lines[Gap])'],['Family-line reconciliation','=SUM(FamilyLines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Weekly count deviations','=SUMPRODUCT(ABS(\'Weekly stats\'!Q2:Q61-Lookback))'],['Priority allocation supply check','=ROUND(SUM(SKUPlan[Priority allocation units])-SUM(Lines[Base supply]),Digits)'],['OT beyond limit','=MAX(Zero,MAX(\'Line plan\'!G2:G5-\'Line plan\'!F2:F5))'],['Base supply beyond cap','=MAX(Zero,MAX(\'Line plan\'!D2:D5-\'Line plan\'!C2:C5))'],['Closure reconciliation','=ROUND(SUM(Lines[Gap])-SUM(Lines[OT units])-SUM(Lines[Prebuild])-SUM(Lines[Unresolved]),Digits)']];
    const re=add('Read me');re.range('A1:B12').values=[['BROOKHOLLOW FOODS | NOVEMBER S&OP','Method and limitations'],['Demand','Latest 13 observed weeks; weekly mean x 30/7; family overlays applied to each SKU. Round SKU demand to whole units, then sum families.'],['Capacity','Gross production requirement; on hand is not netted against demand or deployed to close production gaps. Service-stock adequacy is separate.'],['Family gaps','Base supply apportioned pro rata to SKUs on each constrained line. Families can span lines.'],['Safety stock','Fixed lead times; independent weekly demand; normal cycle-service approximation. SS = z x sample weekly sigma x sqrt(lead weeks).'],['Reorder point','Overlaid weekly mean x lead weeks + rounded-up SS, rounded up. Mean and sigma both scaled by November overlay.'],['Reorder now','On hand <= ROP. No open orders or backorders supplied: provisional alerts, not purchase order quantities. Shortfall is only gap to ROP.'],['Service switch','Inputs B7 selects 95% or 98%; SKU plan retains both sensitivities beside live selected scenario.'],['Prebuild','October baseline from same history x 31/7 without November overlay. Headroom indicative: actual October schedule, shelf life and labor unverified.'],['Costs','OT $0.42/unit; prebuild = units x unit cost x 24% x 1/12. One month held; excludes lost margin, normal production cost and freight.'],['Allocation','Standalone allocate-only plan protects largest November-demand SKUs per line, then SKU ID to break ties. No customer priorities provided.'],['Sources','sales_history.csv, sku_master.csv, capacity.csv, sop_note.md. November 2026 inferred from capacity dates; confirm at meeting.']];
    for(const s of [wk,sk,ln,fa,br,op,ck]){s.showGridLines=false;s.freeze(1,1);s.setColumnWidth('A',160);s.setColumnWidth('B:AB',135);s.range('A1:AB1').format({bold:true,fill:'accent1',color:'white',wrap:true});s.setRowHeight(1,46);s.pageSetup({orientation:'landscape',fitTo:{width:1},repeatRows:'1:1'});}wk.range('B2:Q61').numberFormat='integer';sk.range('D2:AB61').numberFormat='integer';sk.range('D2:D61').numberFormat='currency';sk.range('I2:I61').numberFormat='percent';sk.range('AA2:AA61').numberFormat='currency';sk.setColumnWidth('B',145);ln.range('B2:O5').numberFormat='integer';for(const a of ['H2:H5','N2:N5'])ln.range(a).numberFormat='currency';ln.range('P2:P5').numberFormat='percent1';fa.range('B2:B7').numberFormat='integer';fa.range('D2:F7').numberFormat='integer';fa.range('C2:C6').numberFormat='percent';fa.range('G2:G7').numberFormat='percent1';fa.range('A7:G7').format({bold:true,borderTop:'double'});br.range('C2:F21').numberFormat='integer';op.range('B2:D5').numberFormat='integer';op.range('E2:E5').numberFormat='currency';op.range('C9:C12').numberFormat='currency';op.setColumnWidth('A',180);op.setColumnWidth('F',500);op.range('F2:F5').format({wrap:true});for(let r=2;r<=5;r++)op.setRowHeight(r,48);sk.conditionalFormats.add('P2:P61',{type:'containsText',text:'REORDER',format:{fill:'red-50',color:'red-700'}});for(const s of [inp,re]){s.showGridLines=false;s.setColumnWidth('A',235);s.setColumnWidth('B',s===re?960:155);s.setColumnWidth('C',450);s.range('A1:C1').format({bold:true,fill:'accent1',color:'white'});s.freeze(1);}re.range('B2:B12').format({wrap:true});for(let r=2;r<=12;r++)re.setRowHeight(r,43);inp.range('A1:C1').format({wrap:true});inp.setRowHeight(1,42);ck.setColumnWidth('A',310);const hs=workbook.sheets.get('Sales history');hs.setColumnWidth('A',110);hs.range('A2:A3121').numberFormat='date';const ms=workbook.sheets.get('SKU master');ms.setColumnWidth('B',610);ms.setColumnWidth('C:H',135);ms.range('E2:F61').numberFormat='currency';const cp=workbook.sheets.get('Capacity');cp.setColumnWidth('A',115);cp.setColumnWidth('C:D',165);cp.range('A2:A25').numberFormat='mmm yyyy';fa.charts.add('column',{data:'A1:B6',at:'A10',size:{w:970,h:330},title:'Statistical November demand by family'});ln.charts.add('column',{data:'A1:C5',at:'A9',size:{w:950,h:330},title:'November demand versus line capacity'});return{families:fa.range('A1:G7').values,lines:ln.range('A1:P5').values,options:op.range('A1:F5').values,checks:ck.range('A1:B10').values};
    {
      "ok": false,
      "error": {
        "name": "ArtiwrightError",
        "message": "range.values: every row needs the same number of values (16)."
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master",
        "Capacity"
      ],
      "version": 3,
      "lint": {
        "errors": 0,
        "warnings": 0
      }
    }
  11. artiwright_run
    const items=workbook.sheets.get('SKU master').range('A2:H61').values,hist=workbook.sheets.get('Sales history').range('A2:D3121').values,weeks=[...new Set(hist.map(r=>r[0]))].sort((a,b)=>a-b).slice(-13),fams=['Hot cereal','Granola','Snack bars','Nut butters','Crackers'];const inp=workbook.sheets.add('Inputs');inp.range('A1:C19').values=[['NOVEMBER S&OP | CONTROLS','Value','Basis'],['Plan month',46327,'November 2026, capacity calendar'],['Lookback weeks',13,'Latest complete weeks'],['Days per week',7,'Calendar'],['November days',30,'Calendar'],['October days',31,'Calendar'],['Service level',.95,'Select 95% or 98% cycle service'],['Overtime cap',.04,'Constrained lines only'],['Overtime cost / unit',.42,'Incremental dollars'],['Annual carry rate',.24,'On manufacturing cost'],['Prebuild months held',1,'Assumption: one month held'],['Months per year',12,'Calendar'],['Zero',0,'Constant'],['One',1,'Constant'],['Rounding digits',0,'Whole units'],['95% reference',.95,'Sensitivity'],['98% reference',.98,'Sensitivity'],['Latest history week',weeks[12],'Inclusive end'],['First history week',weeks[0],'Inclusive start']];const names={PlanMonth:2,Lookback:3,DaysWeek:4,NovDays:5,OctDays:6,ServiceLevel:7,OTRate:8,OTCost:9,CarryRate:10,HoldMonths:11,MonthsYear:12,Zero:13,One:14,Digits:15,ServiceLow:16,ServiceHigh:17,LastWeek:18,FirstWeek:19};for(const[n,r]of Object.entries(names))workbook.names.add(n,`Inputs!$B$${r}`);inp.range('A22:C27').values=[['Family','Overlay','Reason'],...fams.map((f,i)=>[f,[.06,0,.04,-.02,.03][i],['Winter promotion','Unchanged','Club listing','Price increase','Holiday tins'][i]])];inp.tables.add('A22:C27',{name:'Overlays'});inp.validations.add('B7',{type:'list',values:[.95,.98],error:'Select 95% or 98%.'});
    const wk=workbook.sheets.add('Weekly stats');wk.range('A1:Q1').values=[['SKU',...weeks,'Mean per week','Std dev per week','Observations']];wk.range('A2:A61').values=items.map(r=>[r[0]]);for(let c=0;c<13;c++){const l=String.fromCharCode(66+c);wk.range(`${l}2:${l}61`).formulas=`=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],${l}$1)`;}wk.range('O2:O61').formulas='=AVERAGE(B2:N2)';wk.range('P2:P61').formulas='=STDEV.S(B2:N2)';wk.range('Q2:Q61').formulas='=COUNTIFS(Sales[SKU],A2,Sales[Week],">="&FirstWeek,Sales[Week],"<="&LastWeek)';
    const sk=workbook.sheets.add('SKU plan');sk.range('A1:AB1').values=[['SKU','Family','Line','Unit cost $','Lead weeks','On hand units','Mean per week','Std dev per week','Overlay','Consensus Nov units','Oct baseline units','Mean with overlay','Std with overlay','Safety stock selected','Reorder point selected','Reorder now?','Shortfall to ROP','SS at 95%','ROP at 95%','SS at 98%','ROP at 98%','Base supply units','Base gap units','Priority allocation units','Priority unmet units','Prebuild units','Carry cost $','OT units']];sk.range('A2:F61').values=items.map(r=>[r[0],r[2],r[3],r[4],r[6],r[7]]);sk.tables.add('A1:AB61',{name:'SKUPlan'});const ln=workbook.sheets.add('Line plan');ln.range('A1:P1').values=[['Line','Consensus','November cap','Base supply','Gap','OT max','OT units','OT cost $','Residual after OT','October baseline','October cap','October headroom','Prebuild','Carry cost $','Unresolved','Utilization']];ln.range('A2:A5').values=['L1','L2','L3','L4'].map(l=>[l]);ln.tables.add('A1:P5',{name:'Lines'});
    const sf={G:"='Weekly stats'!O2",H:"='Weekly stats'!P2",I:'=SUMIF(Overlays[Family],B2,Overlays[Overlay])',J:'=ROUND(G2*NovDays/DaysWeek*(One+I2),Digits)',K:'=ROUND(G2*OctDays/DaysWeek,Digits)',L:'=G2*(One+I2)',M:'=H2*(One+I2)',N:'=ROUNDUP(NORM.S.INV(ServiceLevel)*M2*SQRT(E2),Digits)',O:'=ROUNDUP(L2*E2+N2,Digits)',P:'=IF(F2<=O2,"REORDER","OK")',Q:'=MAX(Zero,O2-F2)',R:'=ROUNDUP(NORM.S.INV(ServiceLow)*M2*SQRT(E2),Digits)',S:'=ROUNDUP(L2*E2+R2,Digits)',T:'=ROUNDUP(NORM.S.INV(ServiceHigh)*M2*SQRT(E2),Digits)',U:'=ROUNDUP(L2*E2+T2,Digits)',V:'=J2*SUMIF(Lines[Line],C2,Lines[Base supply])/SUMIF(Lines[Line],C2,Lines[Consensus])',W:'=J2-V2',X:'=MIN(J2,MAX(Zero,SUMIF(Lines[Line],C2,Lines[Base supply])-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,">"&J2)-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,J2,$A$2:$A$61,"<"&A2)))',Y:'=J2-X2',Z:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[Prebuild]),Zero)',AA:'=Z2*D2*CarryRate*HoldMonths/MonthsYear',AB:'=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[OT units]),Zero)'};for(const[c,f]of Object.entries(sf))sk.range(`${c}2:${c}61`).formulas=f;const lf={B:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Consensus Nov units])',C:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],PlanMonth)',D:'=MIN(B2,C2)',E:'=MAX(Zero,B2-D2)',F:'=IF(E2>Zero,ROUNDDOWN(C2*OTRate,Digits),Zero)',G:'=MIN(E2,F2)',H:'=G2*OTCost',I:'=MAX(Zero,E2-G2)',J:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Oct baseline units])',K:'=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],EDATE(PlanMonth,-One))',L:'=MAX(Zero,K2-J2)',M:'=MIN(I2,L2)',N:'=SUMIF(SKUPlan[Line],A2,SKUPlan[Carry cost $])',O:'=MAX(Zero,I2-M2)',P:'=B2/C2'};for(const[c,f]of Object.entries(lf))ln.range(`${c}2:${c}5`).formulas=f;
    return {sample:sk.range('A2:U2').values,lines:ln.range('A1:P5').values};
    {
      "ok": true,
      "value": {
        "sample": [
          [
            "BH-HC-101",
            "Hot cereal",
            "L1",
            3.37,
            6,
            2584,
            477.9230769230769,
            62.403874797512294,
            0.06,
            2171,
            2117,
            506.59846153846155,
            66.14810728536304,
            267,
            3307,
            "REORDER",
            723,
            267,
            3307,
            333,
            3373
          ]
        ],
        "lines": [
          [
            "Line",
            "Consensus",
            "November cap",
            "Base supply",
            "Gap",
            "OT max",
            "OT units",
            "OT cost $",
            "Residual after OT",
            "October baseline",
            "October cap",
            "October headroom",
            "Prebuild",
            "Carry cost $",
            "Unresolved",
            "Utilization"
          ],
          [
            "L1",
            66029,
            74300,
            66029,
            0,
            0,
            0,
            0,
            0,
            64369,
            75300,
            10931,
            0,
            0,
            0,
            0.8886810228802153
          ],
          [
            "L2",
            145940,
            134264,
            134264,
            11676,
            5370,
            5370,
            2255.4,
            6306,
            148695,
            156100,
            7405,
            6306,
            331.11826871865145,
            0,
            1.086962998272061
          ],
          [
            "L3",
            70650,
            77100,
            70650,
            0,
            0,
            0,
            0,
            0,
            74495,
            84200,
            9705,
            0,
            0,
            0,
            0.9163424124513618
          ],
          [
            "L4",
            83785,
            77081,
            77081,
            6704,
            3083,
            3083,
            1294.86,
            3621,
            83841,
            89600,
            5759,
            3621,
            303.50703819060686,
            0,
            1.0869734435204526
          ]
        ]
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master",
        "Capacity",
        "Inputs",
        "Weekly stats",
        "SKU plan",
        "Line plan"
      ],
      "version": 4,
      "lint": {
        "errors": 0,
        "warnings": 50
      }
    }
  12. artiwright_run
    const fa=workbook.sheets.add('Family demand');fa.range('A1:G1').values=[['Family','Statistical Nov','Overlay','Consensus Nov','Base supply','Gap','Mix of total']];fa.range('A2:A6').values=['Hot cereal','Granola','Snack bars','Nut butters','Crackers'].map(x=>[x]);fa.tables.add('A1:G6',{name:'Families'});const ff={B:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Mean per week])*NovDays/DaysWeek',C:'=SUMIF(Overlays[Family],A2,Overlays[Overlay])',D:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Consensus Nov units])',E:'=SUMIF(SKUPlan[Family],A2,SKUPlan[Base supply units])',F:'=D2-E2',G:'=D2/SUM(SKUPlan[Consensus Nov units])'};for(const[c,f]of Object.entries(ff))fa.range(`${c}2:${c}6`).formulas=f;fa.range('A7').values=[['TOTAL']];for(const c of ['B','D','E','F','G'])fa.range(c+'7').formulas=`=SUM(${c}2:${c}6)`;
    const br=workbook.sheets.add('Family by line');br.range('A1:F1').values=[['Family','Line','Consensus','Base supply','Gap','Gap after OT and prebuild']];br.range('A2:B21').values=['Hot cereal','Granola','Snack bars','Nut butters','Crackers'].flatMap(f=>['L1','L2','L3','L4'].map(l=>[f,l]));const bf={C:'=SUMIFS(SKUPlan[Consensus Nov units],SKUPlan[Family],A2,SKUPlan[Line],B2)',D:'=SUMIFS(SKUPlan[Base supply units],SKUPlan[Family],A2,SKUPlan[Line],B2)',E:'=C2-D2',F:'=MAX(Zero,E2-SUMIFS(SKUPlan[Prebuild units],SKUPlan[Family],A2,SKUPlan[Line],B2)-SUMIFS(SKUPlan[OT units],SKUPlan[Family],A2,SKUPlan[Line],B2))'};for(const[c,f]of Object.entries(bf))br.range(`${c}2:${c}21`).formulas=f;br.tables.add('A1:F21',{name:'FamilyLines'});
    const op=workbook.sheets.add('Options');op.range('A1:F5').values=[['Scenario','OT units','Prebuild units','Unmet units','Incremental cost $','Caveat'],['Allocate only','=Zero','=Zero','=SUM(Lines[Gap])','=Zero','Largest November-demand SKUs first on each line, then SKU ID. Lost margin not priced.'],['Overtime only','=SUM(Lines[OT units])','=Zero','=SUM(Lines[Residual after OT])','=SUM(Lines[OT cost $])','4% ceiling on each constrained line, capacity rounded down.'],['Prebuild only','=Zero','=SUM(B9:B12)','=SUM(Lines[Gap])-C4','=SUM(C9:C12)','Conditional on October headroom, labor and shelf-life feasibility.'],['OT then prebuild','=SUM(Lines[OT units])','=SUM(Lines[Prebuild])','=SUM(Lines[Unresolved])','=SUM(Lines[OT cost $])+SUM(Lines[Carry cost $])','Conditional fallback; holding cost only, excludes normal production cost.']];op.range('A8:C8').values=[['Line','Prebuild only units','Carry cost $']];op.range('A9:A12').values=['L1','L2','L3','L4'].map(l=>[l]);op.range('B9:B12').formulas='=MIN(SUMIF(Lines[Line],A9,Lines[Gap]),SUMIF(Lines[Line],A9,Lines[October headroom]))';op.range('C9:C12').formulas='=IFERROR(B9/SUMIF(SKUPlan[Line],A9,SKUPlan[Consensus Nov units])*SUMPRODUCT((\'SKU plan\'!$C$2:$C$61=A9)*\'SKU plan\'!$J$2:$J$61*\'SKU plan\'!$D$2:$D$61)*CarryRate*HoldMonths/MonthsYear,Zero)';
    const ck=workbook.sheets.add('Checks');ck.range('A1:B10').values=[['CONTROL | expected zero','Value'],['Family demand less SKU total','=SUM(Families[Consensus Nov])-SUM(SKUPlan[Consensus Nov units])'],['Lines less SKU total','=SUM(Lines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Demand less base and gap','=SUM(Lines[Consensus])-SUM(Lines[Base supply])-SUM(Lines[Gap])'],['Family-line reconciliation','=SUM(FamilyLines[Consensus])-SUM(SKUPlan[Consensus Nov units])'],['Weekly count deviations','=SUMPRODUCT(ABS(\'Weekly stats\'!Q2:Q61-Lookback))'],['Priority allocation supply check','=ROUND(SUM(SKUPlan[Priority allocation units])-SUM(Lines[Base supply]),Digits)'],['OT beyond limit','=MAX(Zero,MAX(\'Line plan\'!G2:G5-\'Line plan\'!F2:F5))'],['Base supply beyond cap','=MAX(Zero,MAX(\'Line plan\'!D2:D5-\'Line plan\'!C2:C5))'],['Closure reconciliation','=ROUND(SUM(Lines[Gap])-SUM(Lines[OT units])-SUM(Lines[Prebuild])-SUM(Lines[Unresolved]),Digits)']];
    const re=workbook.sheets.add('Read me');re.range('A1:B12').values=[['BROOKHOLLOW FOODS | NOVEMBER S&OP','Method and limitations'],['Demand','Latest 13 observed weeks; weekly mean x 30/7; family overlays applied to each SKU. Round SKU demand to whole units, then sum families.'],['Capacity','Gross production requirement; on hand not netted against demand or deployed to close production gaps. Service-stock adequacy is separate.'],['Family gaps','Base supply apportioned pro rata to SKUs on constrained lines. Families can span lines.'],['Safety stock','Fixed lead times, independent weekly demand, normal cycle-service approximation. SS = z x sample weekly sigma x sqrt(lead weeks).'],['Reorder point','Overlaid weekly mean x lead weeks + rounded-up SS, rounded up. Mean and sigma both scaled by November overlay.'],['Reorder now','On hand <= ROP. No open orders or backorders supplied: provisional alerts, not purchase-order quantities. Shortfall is only gap to ROP.'],['Service switch','Inputs B7 selects 95% or 98%; SKU plan retains both sensitivities beside live selected scenario.'],['Prebuild','October baseline from same history x 31/7 without November overlay. Headroom indicative: actual October schedule, shelf life and labor unverified.'],['Costs','OT $0.42/unit; prebuild = units x unit cost x 24% x 1/12. One month held; excludes lost margin, normal production cost and freight.'],['Allocation','Standalone allocate-only plan protects largest November-demand SKUs per line, then SKU ID to break ties. No customer priorities provided.'],['Sources','sales_history.csv, sku_master.csv, capacity.csv, sop_note.md. November 2026 inferred from capacity dates; confirm at meeting.']];
    const wk=workbook.sheets.get('Weekly stats'),sk=workbook.sheets.get('SKU plan'),ln=workbook.sheets.get('Line plan'),inp=workbook.sheets.get('Inputs');for(const s of [wk,sk,ln,fa,br,op,ck]){s.showGridLines=false;s.freeze(1,1);s.setColumnWidth('A',160);s.setColumnWidth('B:AB',135);s.range('A1:AB1').format({bold:true,fill:'accent1',color:'white',wrap:true});s.setRowHeight(1,46);s.pageSetup({orientation:'landscape',fitTo:{width:1},repeatRows:'1:1'});}wk.range('B2:Q61').numberFormat='integer';wk.range('B1:N1').numberFormat='date';sk.range('D2:AB61').numberFormat='integer';sk.range('D2:D61').numberFormat='currency';sk.range('I2:I61').numberFormat='percent';sk.range('AA2:AA61').numberFormat='currency';sk.setColumnWidth('B',145);ln.range('B2:O5').numberFormat='integer';for(const a of ['H2:H5','N2:N5'])ln.range(a).numberFormat='currency';ln.range('P2:P5').numberFormat='percent1';fa.range('B2:B7').numberFormat='integer';fa.range('D2:F7').numberFormat='integer';fa.range('C2:C6').numberFormat='percent';fa.range('G2:G7').numberFormat='percent1';fa.range('A7:G7').format({bold:true,borderTop:'double'});br.range('C2:F21').numberFormat='integer';op.range('B2:D5').numberFormat='integer';op.range('E2:E5').numberFormat='currency';op.range('C9:C12').numberFormat='currency';op.setColumnWidth('A',180);op.setColumnWidth('F',500);op.range('F2:F5').format({wrap:true});for(let r=2;r<=5;r++)op.setRowHeight(r,48);sk.conditionalFormats.add('P2:P61',{type:'containsText',text:'REORDER',format:{fill:'red-50',color:'red-700'}});for(const s of [inp,re]){s.showGridLines=false;s.setColumnWidth('A',235);s.setColumnWidth('B',s===re?960:155);s.setColumnWidth('C',450);s.range('A1:C1').format({bold:true,fill:'accent1',color:'white'});s.freeze(1);}re.range('B2:B12').format({wrap:true});for(let r=2;r<=12;r++)re.setRowHeight(r,43);inp.range('A1:C1').format({wrap:true});inp.setRowHeight(1,42);inp.range('B2:B19').format({color:'blue-700',fill:'blue-50'});inp.range('B23:B27').format({color:'blue-700',fill:'blue-50',numberFormat:'percent'});for(const a of ['B7:B8','B10','B16:B17'])inp.range(a).numberFormat='percent';inp.range('B2').numberFormat='mmm yyyy';inp.range('B18:B19').numberFormat='date';ck.setColumnWidth('A',310);const hs=workbook.sheets.get('Sales history');hs.setColumnWidth('A',110);hs.range('A2:A3121').numberFormat='date';const ms=workbook.sheets.get('SKU master');ms.setColumnWidth('B',610);ms.setColumnWidth('C:H',135);ms.range('E2:F61').numberFormat='currency';const cp=workbook.sheets.get('Capacity');cp.setColumnWidth('A',115);cp.setColumnWidth('C:D',165);cp.range('A2:A25').numberFormat='mmm yyyy';fa.charts.add('column',{data:'A1:B6',at:'A10',size:{w:970,h:330},title:'Statistical November demand by family'});ln.charts.add('column',{data:'A1:C5',at:'A9',size:{w:950,h:330},title:'November demand versus line capacity'});return{families:fa.range('A1:G7').values,lines:ln.range('A1:P5').values,options:op.range('A1:F5').values,checks:ck.range('A1:B10').values};
    {
      "ok": true,
      "value": {
        "families": [
          [
            "Family",
            "Statistical Nov",
            "Overlay",
            "Consensus Nov",
            "Base supply",
            "Gap",
            "Mix of total"
          ],
          [
            "Hot cereal",
            62291.538461538454,
            0.06,
            66029,
            66029,
            0,
            0.1802081855001583
          ],
          [
            "Granola",
            90784.94505494504,
            0,
            90786,
            83522.49025836824,
            7263.5097416317585,
            0.2477756793048111
          ],
          [
            "Snack bars",
            66196.48351648352,
            0.04,
            68845,
            63336.41397624873,
            5508.586023751268,
            0.1878936911169092
          ],
          [
            "Nut butters",
            72092.63736263737,
            -0.02,
            70650,
            70650,
            0,
            0.1928199473804871
          ],
          [
            "Crackers",
            68053.18681318681,
            0.03,
            70094,
            64486.09576538304,
            5607.904234616959,
            0.1913024966976343
          ],
          [
            "TOTAL",
            359418.7912087912,
            null,
            366404,
            348024.00000000006,
            18379.999999999985,
            1
          ]
        ],
        "lines": [
          [
            "Line",
            "Consensus",
            "November cap",
            "Base supply",
            "Gap",
            "OT max",
            "OT units",
            "OT cost $",
            "Residual after OT",
            "October baseline",
            "October cap",
            "October headroom",
            "Prebuild",
            "Carry cost $",
            "Unresolved",
            "Utilization"
          ],
          [
            "L1",
            66029,
            74300,
            66029,
            0,
            0,
            0,
            0,
            0,
            64369,
            75300,
            10931,
            0,
            0,
            0,
            0.8886810228802153
          ],
          [
            "L2",
            145940,
            134264,
            134264,
            11676,
            5370,
            5370,
            2255.4,
            6306,
            148695,
            156100,
            7405,
            6306,
            331.11826871865145,
            0,
            1.086962998272061
          ],
          [
            "L3",
            70650,
            77100,
            70650,
            0,
            0,
            0,
            0,
            0,
            74495,
            84200,
            9705,
            0,
            0,
            0,
            0.9163424124513618
          ],
          [
            "L4",
            83785,
            77081,
            77081,
      
    …
  13. artiwright_lint
    {
      "document": "plan"
    }
    {
      "ok": true,
      "errors": 0,
      "warnings": 27,
      "findings": [
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B2",
          "message": "Sales history!B2 is cut off: \"BH-HC-101\" is wider than the column and C2 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B3",
          "message": "Sales history!B3 is cut off: \"BH-HC-102\" is wider than the column and C3 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B4",
          "message": "Sales history!B4 is cut off: \"BH-HC-103\" is wider than the column and C4 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B5",
          "message": "Sales history!B5 is cut off: \"BH-HC-104\" is wider than the column and C5 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B6",
          "message": "Sales history!B6 is cut off: \"BH-HC-105\" is wider than the column and C6 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "Sales history",
          "range": "B7",
          "message": "Sales history!B7 is cut off: \"BH-HC-106\" is wider than the column and C7 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
     
    …
  14. artiwright_run
    const ln=workbook.sheets.get('Line plan'),op=workbook.sheets.get('Options');ln.range('M2:M5').formulas='=MIN(E2,L2)';ln.range('G2:G5').formulas='=MIN(MAX(Zero,E2-M2),F2)';op.range('A5').values=[['Prebuild then OT']];op.range('B3').formulas='=SUM(Lines[OT max])';op.range('D3').formulas='=SUM(Lines[Gap])-B3';op.range('E3').formulas='=B3*OTCost';op.range('F5').values=[['Lowest modeled cost: use cheaper October headroom first, then overtime. Conditional on schedule and shelf life.']];const hs=workbook.sheets.get('Sales history');hs.setColumnWidth('B:C',135);hs.range('D2:D3121').numberFormat='integer';workbook.sheets.get('SKU master').range('G2:H61').numberFormat='integer';workbook.sheets.get('Capacity').range('D2:D25').numberFormat='integer';const sm=workbook.sheets.add('Executive summary');sm.range('A1:F1').values=[['NOVEMBER S&OP | EXECUTIVE PLAN',null,null,null,null,null]];sm.merge('A1:F1');sm.range('A3:B12').values=[['Measure','Units / $'],['Consensus November','=SUM(Families[Consensus Nov])'],['Base production','=SUM(Lines[Base supply])'],['Production gap','=SUM(Lines[Gap])'],['Recommended prebuild','=SUM(Lines[Prebuild])'],['Recommended overtime','=SUM(Lines[OT units])'],['Residual gap','=SUM(Lines[Unresolved])'],['Incremental cost $','=Options!E5'],['Reorder alerts at 95%','=SUMPRODUCT(--(\'SKU plan\'!F2:F61<=\'SKU plan\'!S2:S61))'],['Reorder alerts at 98%','=SUMPRODUCT(--(\'SKU plan\'!F2:F61<=\'SKU plan\'!U2:U61))']];sm.range('A15:F15').values=[['Family','Statistical Nov','Overlay','Consensus Nov','Base supply','Gap']];sm.range('A16:F20').formulas="='Family demand'!A2";sm.range('A22:F23').values=[['Recommendation: prebuild first, then overtime.',null,null,null,null,null],['Conditional on October schedule, shelf life and labor; retain largest-SKU allocation as fallback.',null,null,null,null,null]];sm.merge('A22:F22');sm.merge('A23:F23');sm.range('A23:F23').format({wrap:true});sm.setRowHeight(23,34);sm.showGridLines=false;sm.setColumnWidth('A',230);sm.setColumnWidth('B:F',135);sm.range('A1:F1').format({bold:true,fill:'accent1',color:'white'});sm.setRowHeight(1,34);sm.range('A3:B3').format({bold:true,fill:'slate-100'});sm.range('A15:F15').format({bold:true,fill:'accent1',color:'white',wrap:true});sm.setRowHeight(15,36);sm.range('B4:B12').numberFormat='integer';sm.range('B10').numberFormat='currency';sm.range('B16:F20').numberFormat='integer';sm.range('C16:C20').numberFormat='percent';sm.charts.add('column',{data:'A15:B20',at:'A26',size:{w:905,h:310},title:'November statistical demand by family'});sm.freeze(3);const inv=workbook.sheets.add('Inventory summary');inv.range('A1:E3').values=[['Service','Total safety stock','Total ROP','Reorder alerts','Gap to ROP units'],[.95,'=SUM(SKUPlan[SS at 95%])','=SUM(SKUPlan[ROP at 95%])',"='Executive summary'!B11",'=SUMPRODUCT((\'SKU plan\'!S2:S61>\'SKU plan\'!F2:F61)*(\'SKU plan\'!S2:S61-\'SKU plan\'!F2:F61))'],[.98,'=SUM(SKUPlan[SS at 98%])','=SUM(SKUPlan[ROP at 98%])',"='Executive summary'!B12",'=SUMPRODUCT((\'SKU plan\'!U2:U61>\'SKU plan\'!F2:F61)*(\'SKU plan\'!U2:U61-\'SKU plan\'!F2:F61))']];inv.range('A1:E1').format({bold:true,fill:'accent1',color:'white',wrap:true});inv.setColumnWidth('A:E',165);inv.setRowHeight(1,40);inv.range('A2:A3').numberFormat='percent';inv.range('B2:E3').numberFormat='integer';inv.showGridLines=false;return{summary:sm.range('A3:B12').values,inventory:inv.range('A1:E3').values,lines:ln.range('A1:P5').values,options:op.range('A1:F5').values,topReorders:workbook.sheets.get('SKU plan').range('A2:U61').values.filter(r=>r[15]==='REORDER').sort((a,b)=>b[16]-a[16]).slice(0,5).map(r=>[r[0],r[5],r[14],r[16]]),families:workbook.sheets.get('Family demand').range('A1:G7').values,dates:workbook.sheets.get('Inputs').range('B18:B19').values};
    {
      "ok": true,
      "value": {
        "summary": [
          [
            "Measure",
            "Units / $"
          ],
          [
            "Consensus November",
            366404
          ],
          [
            "Base production",
            348024
          ],
          [
            "Production gap",
            18380
          ],
          [
            "Recommended prebuild",
            13164
          ],
          [
            "Recommended overtime",
            5216
          ],
          [
            "Residual gap",
            0
          ],
          [
            "Incremental cost $",
            3062.256190928252
          ],
          [
            "Reorder alerts at 95%",
            12
          ],
          [
            "Reorder alerts at 98%",
            12
          ]
        ],
        "inventory": [
          [
            "Service",
            "Total safety stock",
            "Total ROP",
            "Reorder alerts",
            "Gap to ROP units"
          ],
          [
            0.95,
            61605,
            467797,
            12,
            35785
          ],
          [
            0.98,
            76912,
            483104,
            12,
            39593
          ]
        ],
        "lines": [
          [
            "Line",
            "Consensus",
            "November cap",
            "Base supply",
            "Gap",
            "OT max",
            "OT units",
            "OT cost $",
            "Residual after OT",
            "October baseline",
            "October cap",
            "October headroom",
            "Prebuild",
            "Carry cost $",
            "Unresolved",
            "Utilization"
          ],
          [
            "L1",
            66029,
            74300,
            66029,
            0,
            0,
            0,
            0,
            0,
            64369,
            75300,
            10931,
            0,
            0,
            0,
            0.8886810228802153
          ],
          [
            "L2",
            145940,
            134264,
            134264,
            11676,
            5370,
            4271,
            1793.82,
            7405,
            148695,
            156100,
            7405,
            7405,
            388.82505230916814,
            0,
            1.086962998272061
          ],
          [
            "L3",
            70650,
            77100,
            70650,
            0,
            0,
            0,
            0,
            0,
            74495,
            84200,
            9705,
            0,
            0,
            0,
            0.9163424124513618
          ],
          [
            "L4",
            83785,
            77081,
            77081,
            6704,
            3083,
            945,
            396.9,
            5759,
            83841,
            89600,
            5759,
            5759,
            482.7111386190844,
            0,
            1.0869734435204526
          ]
    …
  15. artiwright_lint
    {
      "document": "plan"
    }
    {
      "ok": true,
      "errors": 0,
      "warnings": 25,
      "findings": [
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A2",
          "message": "SKU master!A2 is cut off: \"BH-HC-101\" is wider than the column and B2 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A3",
          "message": "SKU master!A3 is cut off: \"BH-HC-102\" is wider than the column and B3 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A4",
          "message": "SKU master!A4 is cut off: \"BH-HC-103\" is wider than the column and B4 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A5",
          "message": "SKU master!A5 is cut off: \"BH-HC-104\" is wider than the column and B5 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A6",
          "message": "SKU master!A6 is cut off: \"BH-HC-105\" is wider than the column and B6 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
          "sheet": "SKU master",
          "range": "A7",
          "message": "SKU master!A7 is cut off: \"BH-HC-106\" is wider than the column and B7 is not empty.",
          "evidence": {
            "needs": 79,
            "width": 74
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        },
        {
          "rule": "text/clipped",
     
    …
  16. artiwright_render
    {
      "document": "plan",
      "sheets": [
        "Executive summary"
      ],
      "range": "A1:F23"
    }
    Sheet Executive summary A1:F231 image(s) rendered; they are attached to your next turn. Look at them before you continue.
  17. The model shows November consensus demand of 366,404 units, with an 18,380-unit production gap on L2 and L4. The lowest modeled-cost option is to prebuild 13,164 units in October and add 5,216 overtime units, for about $3,062 incremental cost—conditional on confirming October slots and shelf life.

    There are 12 provisional reorder alerts at both service levels. Moving to 98% raises safety stock, but does not add any SKUs to the alert list.

  18. artiwright_run
    workbook.sheets.get('SKU master').setColumnWidth('A',125);const ln=workbook.sheets.get('Line plan');ln.range('I1').values=[['Gap after prebuild']];ln.range('I2:I5').formulas='=MAX(Zero,E2-M2)';const inp=workbook.sheets.get('Inputs'),sk=workbook.sheets.get('SKU plan');inp.range('B7').values=[[.98]];const test98=sk.range('N2:O2').values;inp.range('B7').values=[[.95]];const test95=sk.range('N2:O2').values;const dd=workbook.sheets.add('Deck data');const fa=workbook.sheets.get('Family demand').range('A2:G6').values;dd.range('A1:E6').values=[['Family','Consensus units','Overlay','Base gap units','Statistical units'],...fa.map(r=>[r[0],r[3],r[2],Math.round(r[5]),Math.round(r[1])])];dd.range('A9:F13').values=[['Line','Consensus','Cap','Gap','Prebuild','OT'],...ln.range('A2:P5').values.map(r=>[r[0],r[1],r[2],r[4],r[12],r[6]])];dd.range('A16:E20').values=[['Option','OT units','Prebuild units','Unmet units','Cost $'],...workbook.sheets.get('Options').range('A2:F5').values.map(r=>[r[0],r[1],r[2],r[3],Math.round(r[4])])];const alerts=sk.range('A2:U61').values.filter(r=>r[15]==='REORDER').sort((a,b)=>b[16]-a[16]);dd.range('A23:D28').values=[['SKU','On hand','ROP95','Gap to ROP'],...alerts.slice(0,5).map(r=>[r[0],r[5],r[14],r[16]])];dd.range('A31:E33').values=workbook.sheets.get('Inventory summary').range('A1:E3').values;dd.range('A36:B42').values=[['Headline metric','Value'],['Demand',366404],['Base production',348024],['Gap',18380],['Prebuild',13164],['Overtime',5216],['Cost rounded','=ROUND(Options!E5,Digits)']];const alert=workbook.sheets.add('Reorder alerts');alert.range('A1:E1').values=[['SKU','Family','On hand units','ROP selected','Gap to ROP units']];alert.range('A2:E61').formulas='=IF(\'SKU plan\'!P2="REORDER",\'SKU plan\'!A2,"")';alert.clear();alert.range('A1:E1').values=[['SKU','Family','On hand units','ROP selected','Gap to ROP units']];alert.range('A2').formulas='=FILTER(SKUPlan[SKU],SKUPlan[Reorder now?]="REORDER","")';alert.range('B2').formulas='=FILTER(SKUPlan[Family],SKUPlan[Reorder now?]="REORDER","")';alert.range('C2').formulas='=FILTER(SKUPlan[On hand units],SKUPlan[Reorder now?]="REORDER","")';alert.range('D2').formulas='=FILTER(SKUPlan[Reorder point selected],SKUPlan[Reorder now?]="REORDER","")';alert.range('E2').formulas='=FILTER(SKUPlan[Shortfall to ROP],SKUPlan[Reorder now?]="REORDER","")';for(const s of [dd,alert]){s.showGridLines=false;s.setColumnWidth('A:F',160);s.range('A1:F1').format({bold:true,fill:'accent1',color:'white',wrap:true});s.setRowHeight(1,35);s.freeze(1);}alert.range('C2:E61').numberFormat='integer';dd.range('B2:E6').numberFormat='integer';dd.range('C2:C6').numberFormat='percent';dd.range('B10:F13').numberFormat='integer';dd.range('B17:E20').numberFormat='integer';dd.range('B24:D28').numberFormat='integer';dd.range('A32:A33').numberFormat='percent';dd.range('B32:E33').numberFormat='integer';dd.range('B37:B42').numberFormat='integer';return {switchTest:{test98,test95},families:dd.range('A1:E6').values,lines:dd.range('A9:F13').values,options:dd.range('A16:E20').values,topAlerts:dd.range('A23:D28').values,inventory:dd.range('A31:E33').values,headlines:dd.range('A36:B42').values,checks:workbook.sheets.get('Checks').range('B2:B10').values};
    {
      "ok": true,
      "value": {
        "switchTest": {
          "test98": [
            [
              333,
              3373
            ]
          ],
          "test95": [
            [
              267,
              3307
            ]
          ]
        },
        "families": [
          [
            "Family",
            "Consensus units",
            "Overlay",
            "Base gap units",
            "Statistical units"
          ],
          [
            "Hot cereal",
            66029,
            0.06,
            0,
            62292
          ],
          [
            "Granola",
            90786,
            0,
            7264,
            90785
          ],
          [
            "Snack bars",
            68845,
            0.04,
            5509,
            66196
          ],
          [
            "Nut butters",
            70650,
            -0.02,
            0,
            72093
          ],
          [
            "Crackers",
            70094,
            0.03,
            5608,
            68053
          ]
        ],
        "lines": [
          [
            "Line",
            "Consensus",
            "Cap",
            "Gap",
            "Prebuild",
            "OT"
          ],
          [
            "L1",
            66029,
            74300,
            0,
            0,
            0
          ],
          [
            "L2",
            145940,
            134264,
            11676,
            7405,
            4271
          ],
          [
            "L3",
            70650,
            77100,
            0,
            0,
            0
          ],
          [
            "L4",
            83785,
            77081,
            6704,
            5759,
            945
          ]
        ],
        "options": [
          [
            "Option",
            "OT units",
            "Prebuild units",
            "Unmet units",
            "Cost $"
          ],
          [
            "Allocate only",
            0,
            0,
            18380,
            0
          ],
          [
            "Overtime only",
            8453,
            0,
            9927,
            3550
          ],
          [
            "Prebuild only",
            0,
            13164,
            5216,
            872
          ],
          [
            "Prebuild then OT",
            5216,
            13164,
            0,
            3062
          ]
        ],
        "topAlerts": [
          [
            "SKU",
            "On hand",
            "ROP95",
            "Gap to ROP"
          ],
          [
            "BH-NB-112",
            7734,
            16536,
            8802
          ],
          [
            "BH-CR-109",
            23950,
            29802,
            5852
          ],
          [
            "BH-SB-104",
            5340,
            10868,
            5528
          ],
          [
            "BH-CR-110",
            8014,
            12141,
            4127
          ],
          [
            "BH-HC-106",
            10729,
            13603,
            2874
          ]
        ],
    …
  19. artiwright_lint
    {
      "document": "plan"
    }
    {
      "ok": true,
      "errors": 0,
      "warnings": 1,
      "findings": [
        {
          "rule": "text/clipped",
          "sheet": "Read me",
          "range": "A1",
          "message": "Read me!A1 is cut off: \"BROOKHOLLOW FOODS | NOVEMBER S&OP\" is wider than the column and B1 is not empty.",
          "evidence": {
            "needs": 296,
            "width": 235
          },
          "fix": "Widen the column, wrap the text (format({ wrap: true })), or shorten it.",
          "severity": "warn"
        }
      ],
      "next": "No errors: call artiwright_finalize now. You can still improve the workbook afterwards and finalize again under a new name."
    }
  20. artiwright_run
    workbook.sheets.get('Read me').setColumnWidth('A',320);return {skuHeaders:workbook.sheets.get('SKU plan').range('A1:AB1').values,skuFormulas:workbook.sheets.get('SKU plan').range('V2:AB2').formulas,weekly:workbook.sheets.get('Weekly stats').range('A1:Q2').formulas,alerts:workbook.sheets.get('Reorder alerts').range('A1:E14').values,inputs:workbook.sheets.get('Inputs').range('A1:C27').values};
    {
      "ok": true,
      "value": {
        "skuHeaders": [
          [
            "SKU",
            "Family",
            "Line",
            "Unit cost $",
            "Lead weeks",
            "On hand units",
            "Mean per week",
            "Std dev per week",
            "Overlay",
            "Consensus Nov units",
            "Oct baseline units",
            "Mean with overlay",
            "Std with overlay",
            "Safety stock selected",
            "Reorder point selected",
            "Reorder now?",
            "Shortfall to ROP",
            "SS at 95%",
            "ROP at 95%",
            "SS at 98%",
            "ROP at 98%",
            "Base supply units",
            "Base gap units",
            "Priority allocation units",
            "Priority unmet units",
            "Prebuild units",
            "Carry cost $",
            "OT units"
          ]
        ],
        "skuFormulas": [
          [
            "=J2*SUMIF(Lines[Line],C2,Lines[Base supply])/SUMIF(Lines[Line],C2,Lines[Consensus])",
            "=J2-V2",
            "=MIN(J2,MAX(Zero,SUMIF(Lines[Line],C2,Lines[Base supply])-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,\">\"&J2)-SUMIFS($J$2:$J$61,$C$2:$C$61,C2,$J$2:$J$61,J2,$A$2:$A$61,\"<\"&A2)))",
            "=J2-X2",
            "=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[Prebuild]),Zero)",
            "=Z2*D2*CarryRate*HoldMonths/MonthsYear",
            "=IFERROR(W2/SUMIF(Lines[Line],C2,Lines[Gap])*SUMIF(Lines[Line],C2,Lines[OT units]),Zero)"
          ]
        ],
        "weekly": [
          [
            "SKU",
            46209,
            46216,
            46223,
            46230,
            46237,
            46244,
            46251,
            46258,
            46265,
            46272,
            46279,
            46286,
            46293,
            "Mean per week",
            "Std dev per week",
            "Observations"
          ],
          [
            "BH-HC-101",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],B$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],C$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],D$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],E$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],F$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],G$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],H$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],I$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],J$1)",
            "=SUMIFS(Sales[Units],Sales[SKU],$A2,Sales[Week],K$1)",
            "=SUMIFS(S
    …
  21. artiwright_run
    const add=(recipe,props)=>{const s=deck.slides.add();compose(s,h(recipe,props));return s.id;};const ids=[];ids.push(add(TitleSlide,{title:'November S&OP',subtitle:'Brookhollow Foods\nThursday executive decision meeting',figures:[{value:'366,404',label:'units of consensus demand'},{value:'18,380',label:'units above base production'},{value:'12',label:'provisional reorder alerts'}]}));ids.push(add(ChartTakeaway,{title:'November consensus is 366,404 units',chart:{type:'column',categories:['Hot cereal','Granola','Snack bars','Nut butters','Crackers'],series:[{name:'Statistical units',values:[62292,90785,66196,72093,68053]},{name:'Consensus units',values:[66029,90786,68845,70650,70094]}],format:'#,##0'},takeaways:['Hot cereal: winter promotion adds 6%','Snack bars: club listing adds 4%','Nut butters: price increase reduces demand 2%','Crackers add 3%; Granola unchanged'],note:'Source: planning workbook, Family demand. Latest 13 weeks × 30/7, then overlays. Rounded SKU consensus sums exactly to the total.'}));ids.push(add(ChartTakeaway,{title:'L2 and L4 leave an 18,380-unit production gap',chart:{type:'column',categories:['L1','L2','L3','L4'],series:[{name:'Consensus units',values:[66029,145940,70650,83785]},{name:'November cap',values:[74300,134264,77100,77081]}],format:'#,##0'},takeaways:['L2 gap: 11,676 units','L4 gap: 6,704 units','Granola gap: about 7,264 units','Snack bars and Crackers also face shortages'],note:'Source: Line plan and Family demand. Pro rata family gaps: Snack bars 5,509; Crackers 5,608. Family gap rounding differs by one unit. Gross demand is not netted against on hand.'}));ids.push(add(ComparisonTable,{title:'Prebuild then overtime closes the modeled gap',rows:[['Option','Prebuild units','OT units','Unmet units','Cost $'],['Allocate only','0','0','18,380','$0'],['Overtime only','0','8,453','9,927','$3,550'],['Prebuild only','13,164','0','5,216','$872'],['Prebuild then OT','13,164','5,216','0','$3,062']],takeaways:['October headroom is cheaper than overtime in this model.','Allocation fallback protects the largest November-demand SKUs on each line.'],note:'Source: Options. OT capped at 4%, $0.42/unit. Prebuild held one month at 24% annual carry on unit cost. October slots and shelf life unconfirmed. Allocation cost excludes lost margin.'}));ids.push(add(ComparisonTable,{title:'12 SKUs need a provisional reorder review',rows:[['Largest ROP gaps at 95%','On hand','Reorder point','Gap to ROP'],['BH-NB-112','7,734','16,536','8,802'],['BH-CR-109','23,950','29,802','5,852'],['BH-SB-104','5,340','10,868','5,528'],['BH-CR-110','8,014','12,141','4,127'],['BH-HC-106','10,729','13,603','2,874']],takeaways:['At 98%, safety stock rises from 61,605 to 76,912 units.','Alerts remain at 12; confirm open orders before releasing purchases.'],note:'Source: SKU plan and Inventory summary; full list in Reorder alerts. Fixed lead time; sample weekly variability; normal cycle-service model. Gap to ROP is not an order quantity.'}));ids.push(add(TwoColumns,{title:'Approve demand and a conditional supply recovery plan',left:{heading:'Decisions for Thursday',bullets:['Approve consensus demand of 366,404 units.','Authorize 13,164 prebuild units, subject to feasibility.','Authorize 5,216 overtime units and $3,062 incremental cost.','Retain 95% cycle service; review the 98% sensitivity.']},right:{heading:'Owners and release conditions',bullets:['Operations: confirm October slots, labor and shelf life.','L2: prebuild 7,405; overtime 4,271 units.','L4: prebuild 5,759; overtime 945 units.','Procurement: validate open orders for the 12 alerts.','Sales: approve largest-SKU allocation if recovery fails.']}}));return ids;
    {
      "ok": true,
      "value": [
        "sl_P5HYHAAJ",
        "sl_8W5XA930",
        "sl_8ZH29XFZ",
        "sl_7RB44MJS",
        "sl_50YVC670",
        "sl_JZEXZA5W"
      ],
      "logs": [],
      "created": [
        "sl_P5HYHAAJ",
        "sh_YKGJR7AS",
        "sh_P61NTVF9",
        "sh_M9NTPN8T",
        "sh_1S895XXA",
        "sh_6221XKXP",
        "sh_QMFHR5X7",
        "sh_R0E458HY",
        "sh_MYJTX61Z",
        "sh_P79MKHRH",
        "sl_8W5XA930",
        "sh_4MKZKBSW",
        "ch_GPZ3V0HE",
        "sh_HGWT2NKG",
        "sh_JDB7VJD7",
        "sl_8ZH29XFZ",
        "sh_R6A98QMV",
        "ch_SA0BE7FN",
        "sh_X19M6GRK",
        "sh_M35Q2PQ9",
        "sl_7RB44MJS",
        "sh_9WZS1T82",
        "tb_HZ8XJ2CR",
        "sh_ZAZYK7H4",
        "sh_7D3DJ5X5",
        "sl_50YVC670",
        "sh_MD50T1XD",
        "tb_R7S5QZ4J",
        "sh_H8WS639Y",
        "sh_FMEJCHHN",
        "sl_JZEXZA5W",
        "sh_46PES2QJ",
        "sh_HAAMNCW1",
        "sh_8FVPVJ2V",
        "sh_Z0WVNZ27",
        "sh_E8XKBY7C"
      ],
      "removed": [],
      "slides": 6,
      "version": 1,
      "lint": {
        "errors": 0,
        "warnings": 0
      },
      "theme": {
        "theme": "Ledger",
        "source": "requested"
      }
    }
  22. artiwright_render
    {
      "document": "deck"
    }
    Contact sheet of 6 slides.1 image(s) rendered; they are attached to your next turn. Look at them before you continue.
  23. artiwright_lint
    {
      "document": "deck"
    }
    {
      "ok": true,
      "errors": 0,
      "warnings": 0,
      "findings": [],
      "next": "No errors: call artiwright_finalize now. You can still improve the deck afterwards and finalize again under a new name."
    }
  24. artiwright_finalizeNovember-SOP-Planning.xlsxerror
    {
      "document": "plan",
      "file": "November-SOP-Planning.xlsx",
      "requirements": {
        "sheets": [
          "Inputs",
          "SKU plan",
          "Weekly stats",
          "Line plan",
          "Family demand",
          "Family by line",
          "Options",
          "Checks",
          "Read me",
          "Executive summary",
          "Inventory summary",
          "Reorder alerts"
        ],
        "tables": [
          "Sales",
          "Items",
          "Caps",
          "SKUPlan",
          "Lines",
          "Families",
          "FamilyLines"
        ],
        "charts": 3,
        "values": [
          {
            "cell": "Checks!B2",
            "equals": 0
          },
          {
            "cell": "Checks!B3",
            "equals": 0
          },
          {
            "cell": "Checks!B4",
            "equals": 0
          },
          {
            "cell": "Checks!B5",
            "equals": 0
          },
          {
            "cell": "Checks!B6",
            "equals": 0
          },
          {
            "cell": "Checks!B7",
            "equals": 0
          },
          {
            "cell": "Checks!B8",
            "equals": 0
          },
          {
            "cell": "Checks!B9",
            "equals": 0
          },
          {
            "cell": "Checks!B10",
            "equals": 0
          },
          {
            "cell": "Executive summary!B4",
            "equals": 366404
          },
          {
            "cell": "Executive summary!B9",
            "equals": 0
          },
          {
            "cell": "Inputs!B7",
            "equals": 0.95
          }
        ]
      }
    }
    {
      "ok": false,
      "blocking": [
        {
          "step": 2,
          "code": "export/failed",
          "message": "Table \"Lines\": the header cell I1 must hold the column name \"Residual after OT\"."
        }
      ],
      "warnings": [],
      "checks": [
        {
          "step": 1,
          "code": "path",
          "ok": true
        },
        {
          "step": 2,
          "code": "export",
          "ok": false
        }
      ],
      "receiptPath": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/.artiwright/receipts/November-SOP-Planning.failed.1794788113607.receipt.json"
    }
  25. artiwright_run
    workbook.sheets.get('Line plan').range('I1').values=[['Residual after OT']];return {deck:workbook.sheets.get('Deck data').range('A1:F42').values,checks:workbook.sheets.get('Checks').range('A1:B11').values,tables:workbook.sheets.get('Family by line').tables.items,notes:workbook.sheets.get('Read me').range('A1:B13').values};
    {
      "ok": true,
      "value": {
        "deck": [
          [
            "Family",
            "Consensus units",
            "Overlay",
            "Base gap units",
            "Statistical units",
            null
          ],
          [
            "Hot cereal",
            66029,
            0.06,
            0,
            62292,
            null
          ],
          [
            "Granola",
            90786,
            0,
            7264,
            90785,
            null
          ],
          [
            "Snack bars",
            68845,
            0.04,
            5509,
            66196,
            null
          ],
          [
            "Nut butters",
            70650,
            -0.02,
            0,
            72093,
            null
          ],
          [
            "Crackers",
            70094,
            0.03,
            5608,
            68053,
            null
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
          ],
          [
            "Line",
            "Consensus",
            "Cap",
            "Gap",
            "Prebuild",
            "OT"
          ],
          [
            "L1",
            66029,
            74300,
            0,
            0,
            0
          ],
          [
            "L2",
            145940,
            134264,
            11676,
            7405,
            4271
          ],
          [
            "L3",
            70650,
            77100,
            0,
            0,
            0
          ],
          [
            "L4",
            83785,
            77081,
            6704,
            5759,
            945
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
          ],
          [
            "Option",
            "OT units",
            "Prebuild units",
            "Unmet units",
            "Cost $",
            null
          ],
          [
            "Allocate only",
            0,
            0,
            18380,
            0,
            null
          ],
          [
            "Overtime only",
            8453,
            0,
            9927,
            3550,
            null
          ],
          [
            "Prebuild only",
            0,
            13164,
            5216,
            872,
            null
          ],
          [
            "Prebuild then OT",
            5216,
            13164,
            0,
            3062,
            null
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
          ],
          [
            null,
            null,
            null,
            null,
            null,
            null
        
    …
  26. artiwright_run
    return {lineHeaders:workbook.sheets.get('Line plan').range('A1:P1').values,lineFormulas:workbook.sheets.get('Line plan').range('A2:P2').formulas,optionFormulas:workbook.sheets.get('Options').range('A1:F5').formulas};
    {
      "ok": true,
      "value": {
        "lineHeaders": [
          [
            "Line",
            "Consensus",
            "November cap",
            "Base supply",
            "Gap",
            "OT max",
            "OT units",
            "OT cost $",
            "Residual after OT",
            "October baseline",
            "October cap",
            "October headroom",
            "Prebuild",
            "Carry cost $",
            "Unresolved",
            "Utilization"
          ]
        ],
        "lineFormulas": [
          [
            "L1",
            "=SUMIF(SKUPlan[Line],A2,SKUPlan[Consensus Nov units])",
            "=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],PlanMonth)",
            "=MIN(B2,C2)",
            "=MAX(Zero,B2-D2)",
            "=IF(E2>Zero,ROUNDDOWN(C2*OTRate,Digits),Zero)",
            "=MIN(MAX(Zero,E2-M2),F2)",
            "=G2*OTCost",
            "=MAX(Zero,E2-M2)",
            "=SUMIF(SKUPlan[Line],A2,SKUPlan[Oct baseline units])",
            "=SUMIFS(Caps[Capacity (units)],Caps[Line],A2,Caps[Month],EDATE(PlanMonth,-One))",
            "=MAX(Zero,K2-J2)",
            "=MIN(E2,L2)",
            "=SUMIF(SKUPlan[Line],A2,SKUPlan[Carry cost $])",
            "=MAX(Zero,I2-M2)",
            "=B2/C2"
          ]
        ],
        "optionFormulas": [
          [
            "Scenario",
            "OT units",
            "Prebuild units",
            "Unmet units",
            "Incremental cost $",
            "Caveat"
          ],
          [
            "Allocate only",
            "=Zero",
            "=Zero",
            "=SUM(Lines[Gap])",
            "=Zero",
            "Largest November-demand SKUs first on each line, then SKU ID. Lost margin not priced."
          ],
          [
            "Overtime only",
            "=SUM(Lines[OT max])",
            "=Zero",
            "=SUM(Lines[Gap])-B3",
            "=B3*OTCost",
            "4% ceiling on each constrained line, capacity rounded down."
          ],
          [
            "Prebuild only",
            "=Zero",
            "=SUM(B9:B12)",
            "=SUM(Lines[Gap])-C4",
            "=SUM(C9:C12)",
            "Conditional on October headroom, labor and shelf-life feasibility."
          ],
          [
            "Prebuild then OT",
            "=SUM(Lines[OT units])",
            "=SUM(Lines[Prebuild])",
            "=SUM(Lines[Unresolved])",
            "=SUM(Lines[OT cost $])+SUM(Lines[Carry cost $])",
            "Lowest modeled cost: use cheaper October headroom first, then overtime. Conditional on schedule and shelf life."
          ]
        ]
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU m
    …
  27. artiwright_run
    const l=workbook.sheets.get('Line plan');l.range('I2:I5').formulas='=MAX(Zero,E2-G2)';l.range('O2:O5').formulas='=MAX(Zero,E2-G2-M2)';return {unresolved:l.range('O2:O5').values,checks:workbook.sheets.get('Checks').range('B2:B10').values};
    {
      "ok": true,
      "value": {
        "unresolved": [
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ]
        ],
        "checks": [
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ]
        ]
      },
      "logs": [],
      "created": [],
      "removed": [],
      "slides": 0,
      "sheets": [
        "Sales history",
        "SKU master",
        "Capacity",
        "Inputs",
        "Weekly stats",
        "SKU plan",
        "Line plan",
        "Family demand",
        "Family by line",
        "Options",
        "Checks",
        "Read me",
        "Executive summary",
        "Inventory summary",
        "Deck data",
        "Reorder alerts"
      ],
      "version": 10,
      "lint": {
        "errors": 0,
        "warnings": 0
      }
    }
  28. artiwright_finalizeNovember-SOP-Planning.xlsx
    {
      "document": "plan",
      "file": "November-SOP-Planning.xlsx",
      "requirements": {
        "sheets": [
          "Inputs",
          "SKU plan",
          "Weekly stats",
          "Line plan",
          "Family demand",
          "Family by line",
          "Options",
          "Checks",
          "Read me",
          "Executive summary",
          "Inventory summary",
          "Reorder alerts"
        ],
        "tables": [
          "Sales",
          "Items",
          "Caps",
          "SKUPlan",
          "Lines",
          "Families",
          "FamilyLines"
        ],
        "charts": 3,
        "values": [
          {
            "cell": "Checks!B2",
            "equals": 0
          },
          {
            "cell": "Checks!B3",
            "equals": 0
          },
          {
            "cell": "Checks!B4",
            "equals": 0
          },
          {
            "cell": "Checks!B5",
            "equals": 0
          },
          {
            "cell": "Checks!B6",
            "equals": 0
          },
          {
            "cell": "Checks!B7",
            "equals": 0
          },
          {
            "cell": "Checks!B8",
            "equals": 0
          },
          {
            "cell": "Checks!B9",
            "equals": 0
          },
          {
            "cell": "Checks!B10",
            "equals": 0
          },
          {
            "cell": "Executive summary!B4",
            "equals": 366404
          },
          {
            "cell": "Executive summary!B9",
            "equals": 0
          },
          {
            "cell": "Inputs!B7",
            "equals": 0.95
          }
        ]
      }
    }
    {
      "ok": true,
      "blocking": [],
      "warnings": [],
      "checks": [
        {
          "step": 1,
          "code": "path",
          "ok": true
        },
        {
          "step": 2,
          "code": "validate",
          "ok": true
        },
        {
          "step": 3,
          "code": "requirements",
          "ok": true
        },
        {
          "step": 4,
          "code": "lint",
          "ok": true
        },
        {
          "step": 5,
          "code": "publish",
          "ok": true
        }
      ],
      "path": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/outputs/November-SOP-Planning.xlsx",
      "sha256": "c034aa1ed97fb270ff8938dffc2994bc96291847008fc50522ffabe2e7b0470c",
      "bytes": 129922,
      "receiptPath": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/.artiwright/receipts/November-SOP-Planning.c034aa1ed97f.1794788140274.receipt.json"
    }Saved for the user as artifact 'November-SOP-Planning.xlsx' (version 0).
  29. artiwright_finalizeNovember-SOP-Executive-Pack.pptx
    {
      "document": "deck",
      "file": "November-SOP-Executive-Pack.pptx",
      "requirements": {
        "slideCount": 6,
        "nativeCharts": [
          "sl_8W5XA930",
          "sl_8ZH29XFZ"
        ],
        "nativeTables": [
          "sl_7RB44MJS",
          "sl_50YVC670"
        ]
      }
    }
    {
      "ok": true,
      "blocking": [],
      "warnings": [],
      "checks": [
        {
          "step": 1,
          "code": "path",
          "ok": true
        },
        {
          "step": 2,
          "code": "size",
          "ok": true
        },
        {
          "step": 2,
          "code": "validate",
          "ok": true
        },
        {
          "step": 3,
          "code": "package",
          "ok": true
        },
        {
          "step": 4,
          "code": "slideCount",
          "ok": true
        },
        {
          "step": 4,
          "code": "nativeCharts",
          "ok": true
        },
        {
          "step": 4,
          "code": "nativeTables",
          "ok": true
        },
        {
          "step": 4,
          "code": "numbers",
          "ok": true
        },
        {
          "step": 5,
          "code": "chartData",
          "ok": true
        },
        {
          "step": 6,
          "code": "lint",
          "ok": true
        },
        {
          "step": 7,
          "code": "reimport",
          "ok": true
        },
        {
          "step": 8,
          "code": "publish",
          "ok": true
        }
      ],
      "path": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/outputs/November-SOP-Executive-Pack.pptx",
      "sha256": "2037ab9fa5d4c059639a698e1f1c7b319cfd62e5208eeaa96624a0487122b0cc",
      "bytes": 44255,
      "manifestPath": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/outputs/November-SOP-Executive-Pack.pptx.manifest.ndjson",
      "receiptPath": "./sessions/planner-0230c47e-7d77-4e5c-9f13-a4ca5ff2de87/.artiwright/receipts/November-SOP-Executive-Pack.2037ab9fa5d4.1794788144639.receipt.json"
    }Saved for the user as artifact 'November-SOP-Executive-Pack.pptx' (version 0).
The agent's last message

Ready for Thursday, both in Ledger:

  • [Planning workbook](outputs/November-SOP-Planning.xlsx): reconciled family demand, capped-line supply, gap-closing options, SKU allocation fallback, and safety stock/reorder points with a 95%/98% service-level switch.
  • [Six-slide executive pack](outputs/November-SOP-Executive-Pack.pptx): demand, constraints, options, reorder risks and a dedicated decisions slide.

Headline: 366,404 units of consensus demand leaves an 18,380-unit production gap. The recommended modeled option is 13,164 prebuild units plus 5,216 overtime units, costing approximately $3,062, subject to October schedule, labor and shelf-life confirmation.

12 SKUs need provisional reorder review at either service level; confirm open orders before releasing purchases.

Both files passed validation, with family totals reconciled and no lint findings.

Lint during the run

Clipped SKU codes and a renamed table column

Lint's first pass on the workbook found 25 clipped cells and 2 unformatted numbers, mostly SKU codes too wide for their columns in the imported sheets. The agent widened columns and linted again until nothing was left; the deck passed lint the first time. Then finalize refused the workbook: the agent had renamed a column of the Lines table. It put the header back, rewrote the two formulas that depended on that column, and the second finalize passed.

  1. lintplan25 × text/clipped2 × number/unformatted
  2. lintplan25 × text/clipped
  3. lintplan1 × text/clipped
  4. lintdeckNo findings
  5. finalizeNovember-SOP-Planning.xlsxNo findings

Finalize report

Nothing is published until these pass. Finalize checks the real file and never overwrites one.

How this example was made: the request above went to a Google ADK agent on gpt-6.1-sol, built with Artiwright's Python package, using agent-runs/framework_run.py. The files are what it finalized, opened in PowerPoint and Excel for the screenshots. Companies, people and figures are made up.