# Worked example: a three-statement forecast from a CSV of actuals

Twelve tool calls, including one deliberate diagnostic and its fix.

1. finidb_describe → empty database.
2. finidb_import_csv(table: gl, path: actuals.csv, map: {account: Account, dept: Dept, date: Date, amount: Amount},
   columns: {account: {type: ref, list: account}, dept: {type: ref, list: dept}}, time: {calendar: fy, from: date}, on_unknown_member: create)
   → E100: list 'account' not found. Lists and the calendar must exist first.
3. finidb_apply_spec({calendars: {fy: {granularity: month, start: 2025-01, end: 2028-12}}, constants: {last_actual: 2026-06},
   lists: {account: {members: [revenue, cogs, opex, {id: gross_profit, computed: true}, {id: ebitda, computed: true}]}, dept: {members: []}, scenario: {members: [actual, forecast]}}})
4. finidb_import_csv(... same as step 2 ...) → 1,240 rows; dept members created from the data.
5. finidb_apply_spec({modules: {drivers: {dims: [time:fy], line_items: {rev_growth: {}, cogs_pct: {}, opex_growth: {}}},
   pnl: {dims: [scenario, dept, account, time:fy], line_items: {amount: {formulas: [
     {scope: {scenario: actual}, formula: "SUM(gl.amount MATCHING *)"},
     {scope: {account: gross_profit}, formula: "amount[account = revenue] + amount[account = cogs]"},
     {scope: {account: ebitda}, formula: "amount[account = gross_profit] + amount[account = opex]"},
     {scope: {scenario: forecast, account: revenue, time: "> @last_actual"}, formula: "PREV(amount) * (1 + drivers.rev_growth)"},
     {scope: {scenario: forecast, account: cogs, time: "> @last_actual"}, formula: "amount[account = revenue] * drivers.cogs_pct"},
     {scope: {scenario: forecast, account: opex, time: "> @last_actual"}, formula: "PREV(amount) * (1 + drivers.opex_growth)"},
     {formula: "amount[scenario = actual]"}]}}}}})
6. finidb_set_values(module: drivers, item: rev_growth, cells: [[["2026-07"], 0.02], ...]) and the same for cogs_pct and opex_growth.
7. finidb_query(module: pnl, rows: [account], columns: [time], pages: {scenario: forecast, dept: total}) → the agent reads the grid.
8. finidb_explain(module: pnl, item: amount, coords: [forecast, total, ebitda, 2027-06]) → rule 2, reads, dependents.
9. finidb_list_errors → [].
10. finidb_get_spec → the agent summarises what it built.
11. finidb_export(kind: csv, query: {...}) → the human's grid.
12. Done. The human sees the commands applied, the changed cells and the spec diff, and can restore the run backup.
