Skip to main content
Glama

Knock-On

See what a spreadsheet edit knocks on before you, or your AI agent, make it. Knock-On turns an Excel workbook into a dependency graph in Relate (one .rl file) and answers, in Cypher, the questions Excel's arrow-by-arrow tracing cannot: if I change this input, which outputs move, and will the number I care about actually follow?

Change the tax rate in a financial model and report the new net income. If one row of the model types 0.21 instead of reading the tax-rate cell, the edit goes through, nothing errors, and the agent reports the old number. We call that a silent failure. Knock-On's pre-edit gate catches it from the graph, before anything is written:

$ knockon check examples/workbooks/saas_plan.xlsx "tax rate" --expect "net income 2032"
Assumptions!C12 (Tax rate | TaxRate) = 0.21: 1 cell(s) downstream
  -> P&L!H15 (Net income | 2032): NO_EFFECT
  ! changing Assumptions!C12 will not move P&L!H15 (Net income | 2032): P&L!H14 type the input's value instead of reading it
NOT OK

Measured

Result

A real agent (Claude Code) asked to change an input and report the result, on two larger models with a defect each

with plain read/write tools it reported the model's wrong number 6 / 6 times without noticing; with Knock-On it found the defect and told the user 5 / 6 times

Graph-predicted impact vs. real recalculation, 24 public Enron workbooks + 5 demo models (884 edited inputs, 284,689 cells that actually changed)

recall 1.000: every cell that changed was predicted. Excel's one-step "Trace Dependents" view (direct readers only) covers 2.2 % of them

24 scripted edit requests on four models with known defects (knockon gate-eval)

the model gives a wrong answer in 22; the gate flags 22 / 22 before the edit and passes the 2 correct ones

Same 24 requests on the repaired models

0 false alarms (24 / 24 "reaches")

91,000-formula model, one driver feeding 88,623 cells

impact in 1.6 s, pre-edit gate in 4.0 s

Three minutes to a first result:

git clone https://github.com/NL-Hackerton/knockon && cd knockon && uv sync --all-extras
uv run knockon check examples/workbooks/saas_plan.xlsx "tax rate" --expect "net income 2032"
uv run knockon risks examples/workbooks/saas_plan.xlsx

Contents: Use case · How it uses Relate · The questions, in Cypher · Setup and run · For agents (MCP) · Results · Where the data lives · How it compares · Limitations · Third-party software and AI use

Use case

Who: analysts and model reviewers who change assumptions in financial and operational workbooks, and the AI agents that now edit workbooks for them (Excel Agent Mode, Claude for Excel, Gemini in Sheets, or any agent with file access).

Problem: spreadsheets are dependency graphs that nobody can see. Field audits found errors in 94% of the operational spreadsheets they examined (Panko); in the Enron corpus 24% of workbooks with formulas contain Excel error values (Hermans & Murphy-Hill). Agents now edit workbooks too, and on SpreadsheetBench 2 the best model completes 34.9% of real financial-model tasks, failing most often by inspecting too little and changing the wrong cell (arXiv 2606.29955). Excel's own tracing shows one level of arrows per click, drops them on the next edit, cannot follow named constants, and offers nothing an agent can call (Microsoft). Modelling standards ask for consistent formulas, no hardcoded numbers and traceable references (ICAEW Financial Modelling Code), which are exactly the things a graph can check.

Which relationships matter: a cell reads other cells, ranges and named ranges; a range contains cells; a name refers to a range; a formula uses typed constants. "What moves if I change X" is every cell that reaches X by those relationships, at any depth and across sheets. "Will Y follow X" is whether a path exists, and whether something on Y's lineage types X's value instead of reading it, or a range stops one row short of a cell X moves.

What Knock-On gives you:

  • impact, lineage, why (shortest dependency path), find (cells by their row/column headers)

  • a pre-edit gate (check) with verdicts reaches, caution, partial, no_effect and the cells to blame

  • what-if (whatif): try a formula or value; Knock-On applies it inside a Relate transaction, reports inputs gained or lost and findings added or resolved, then rolls back

  • edit review (review): diff two versions of a workbook and trace every changed cell to the outputs it reaches

  • risk rules written as graph queries: typed numbers that shadow an existing input, copies of a formula that break their row/column pattern, values pasted over a run of formulas, ranges that stop one cell short, blank and #REF! references, circular references, unused inputs, dynamic references, external links

  • an MCP server so an agent asks all of the above before it writes, and a one-page HTML report

Related MCP server: GridPath

How it uses Relate

  • Mode: single file. One workbook becomes one .rl store, written next to it (examples/workbooks/saas_plan.xlsx → examples/workbooks/saas_plan.rl).

  • Why this mode: a workbook is a single file that people mail around, and its graph should travel the same way: a reviewer can keep the .rl beside the .xlsx, open it with the relate CLI, or point an agent at it. A file also gives the graph a durable home between an agent's turns (in-memory mode would vanish when the process ends), and Relate's single-owner lock matches one agent working on one workbook. The store records the workbook's SHA-256 and is rebuilt only when the workbook's content changes (or after a Knock-On upgrade that changes the graph layout); a rebuild writes a new file and moves it into place.

  • What the graph models:

graph LR
  Cell -->|READS| Cell
  Cell -->|READS| Range
  Cell -->|READS| Name
  Cell -->|READS| ExternalBook
  Range -->|CONTAINS| Cell
  Name -->|REFERS_TO| Cell
  Name -->|REFERS_TO| Range
  Cell -->|USES_CONSTANT| Constant
  Sheet -->|IN| Workbook
  Cell -->|ROW_HEADER / COL_HEADER| Header

Every dependency relationship points from the consumer to what it consumes, so "everything downstream of X" is one quantified path pattern, (x)<-[:READS|CONTAINS|REFERS_TO]-+(d:Cell). A Cell carries its address, kind (formula, input, text, empty), formula text, cached value, a label built from its row and column headers ("Net income | 2032"), and an R1C1-style signature that copies of the same formula share. Constant nodes hold the numbers typed inside formulas, which is what lets one query find every formula that types 0.21 while an input cell already holds 0.21. Each distinct row or column header becomes a Header node with a vector (hashed character trigrams, no model, no network) in a vector index, so "net incme 2032" or "taxrate" still find the right cells: a vector search over the few hundred headers, then one graph hop to the cells filed under them. find fuses that with full-text search on cell labels.

Relate features in use: single-file store, Cypher 25 quantified path patterns and shortestPath, a vector index with the SEARCH clause and vector.similarity.cosine (hybrid with the full-text index, CREATE FULLTEXT INDEX, db.index.fulltext.queryNodes), explicit transactions with rollback (what-if, and the read_cypher tool of Knock-On's MCP server, which wraps Relate), UNWIND batch loading, property indexes, the Python embedding (relate-db), and the relate CLI. Relate's own MCP endpoint (relate serve --mcp) also serves the committed stores for generic Cypher. For models where one driver feeds tens of thousands of cells, Knock-On expands the same relationships with a breadth-first frontier of batched one-hop Cypher queries instead of one path query (see Limitations); both give the same answer and tests/ checks that they do.

The questions, in Cypher

Run these against the committed store with the relate CLI (or knockon cypher <store> "<query>"). tests/test_readme.py runs every query in this section and compares the output shown.

  1. What moves if the tax rate changes? (impact, a quantified path)

MATCH (x:Cell {key: 'Assumptions!C12'})<-[:READS|CONTAINS|REFERS_TO]-+(d:Cell)
RETURN DISTINCT d.key AS cell, d.label AS label
cell        label
Summary!C9  Net income 2032 after tax

Only one cell. Net income itself does not read the tax rate.

  1. Which formulas type a number that an input cell already holds? (a join through Constant)

MATCH (c:Cell)-[:USES_CONSTANT]->(k:Constant) MATCH (i:Cell {kind: 'input'})
WHERE i.num = k.value OR 1 + i.num = k.value
RETURN i.key AS input, i.label AS label, k.value AS typed, count(c) AS formulas
ORDER BY formulas DESC
input            label               typed  formulas
Assumptions!C12  Tax rate | TaxRate  0.21   6
Assumptions!C10  Cost inflation      1.04   5

Six formulas type the tax rate and five type one plus the cost inflation, so neither input reaches them.

  1. Find a cell by its headers, then every input it is built from (full-text, then a path the other way)

CALL db.index.fulltext.queryNodes('cell_label', 'net income 2032') YIELD node, score
WITH node ORDER BY score DESC LIMIT 1
MATCH (node)-[:READS|CONTAINS|REFERS_TO]->+(i:Cell {kind: 'input'})
RETURN DISTINCT node.key AS target, i.key AS input, i.label AS label ORDER BY input
target   input            label
P&L!H15  Assumptions!C10  Cost inflation
P&L!H15  Assumptions!C11  Headcount cost per FTE
P&L!H15  Assumptions!C14  Customers per support FTE
P&L!H15  Assumptions!C4   Starting customers
P&L!H15  Assumptions!C5   New customers per year
P&L!H15  Assumptions!C6   Annual churn rate | Churn
P&L!H15  Assumptions!C7   Price per customer (ARR)
P&L!H15  Assumptions!C8   Price increase per year
P&L!H15  Assumptions!C9   Hosting cost per customer

Nine inputs, and the tax rate is not one of them.

  1. Why does the price increase reach total revenue? (shortestPath)

MATCH (src:Cell {key: 'Assumptions!C8'}) MATCH (dst:Cell {key: 'Summary!C5'})
MATCH p = shortestPath((dst)-[:READS|CONTAINS|REFERS_TO*]->(src))
RETURN [n IN nodes(p) | n.key] AS path
path
['Summary!C5', 'P&L!C5:H5', 'P&L!H5', 'Revenue!H8', 'Revenue!H7', 'Assumptions!C8']
  1. Which outputs depend on the most inputs?

MATCH (o:Cell {kind: 'formula'}) WHERE NOT (o)<-[:READS|CONTAINS|REFERS_TO]-()
MATCH (o)-[:READS|CONTAINS|REFERS_TO]->+(i:Cell {kind: 'input'})
RETURN o.key AS output, o.label AS label, count(DISTINCT i) AS inputs ORDER BY inputs DESC, output LIMIT 5
output      label                      inputs
Summary!C9  Net income 2032 after tax  10
P&L!D8      Gross margin | 2028        9
P&L!E8      Gross margin | 2029        9
P&L!F8      Gross margin | 2030        9
P&L!G8      Gross margin | 2031        9
  1. Vector search, then the graph: the headers closest to "Net income", and the 2032 cell filed under each

MATCH (q:Header {key: 'net income'})
MATCH (h:Header) SEARCH h IN (VECTOR INDEX header_emb FOR q.emb LIMIT 3)
OPTIONAL MATCH (c:Cell)-[:ROW_HEADER]->(h), (c)-[:COL_HEADER]->(:Header {key: '2032'})
RETURN h.text AS row_header, round(vector.similarity.cosine(h.emb, q.emb), 3) AS similarity,
       coalesce(c.key, '-') AS cell_2032
ORDER BY similarity DESC
row_header                  similarity  cell_2032
Net income                  1.0         P&L!H15
Total net income 2027-2032  0.831       -
Net income 2032 after tax   0.827       -

Relate scales cosine similarity to [0, 1] (0.5 is unrelated). The two summary headers are close to "Net income" but have no 2032 column, so the hop finds no cell under them. knockon find runs this kind of search with the query text's own vector and adds full-text hits on cell labels.

Setup and run

Prerequisites: Python 3.11 or newer on macOS, Linux or Windows, and uv (or pip). No API keys, no server, no network after install. Relate installs from PyPI as relate-db.

git clone https://github.com/NL-Hackerton/knockon
cd knockon
uv sync --all-extras              # or: python -m venv .venv && . .venv/bin/activate && pip install -e ".[verify]"

# 1. index a workbook (the committed examples/workbooks/saas_plan.rl already matches it; --force rebuilds)
uv run knockon index examples/workbooks/saas_plan.xlsx

# 2. ask the gate before editing
uv run knockon check examples/workbooks/saas_plan.xlsx "tax rate" --expect "net income 2032"

# 3. everything the model gets wrong
uv run knockon risks examples/workbooks/saas_plan.xlsx

# 4. try the fix without touching anything (transaction, rolled back)
uv run knockon whatif examples/workbooks/saas_plan.xlsx 'P&L!H14' '=MAX(0,H12*TaxRate)'

# 5. one-page report with the graph (open the .html in a browser)
uv run knockon report examples/workbooks/saas_plan.xlsx -o saas_plan.html

Other commands: impact, lineage, why, find, review <before.xlsx> <after.xlsx>, cypher, mcp, bench, gate-eval. Every command takes --json. Commands accept a .rl store or a workbook (indexed on first use). Cell references are keys like 'P&L!H15' or header text like "net income 2032".

Open the same graph with the Relate CLI (install: https://relatedb.ai/docs/get-started/install):

relate --read-only -d examples/workbooks/saas_plan.rl "MATCH (c:Cell)-[:USES_CONSTANT]->(k:Constant {key: '0.21'}) RETURN c.key"
relate serve --database examples/workbooks/saas_plan.rl --mcp 7475 --read-only   # generic Cypher over MCP

For agents (MCP)

uv run knockon mcp examples/workbooks/saas_plan.xlsx     # stdio

Claude Code: claude mcp add knockon -- uv --directory /path/to/knockon run knockon mcp /path/to/workbook.xlsx. Any MCP client works the same way. Tools: find_cell, impact, lineage, explain_path, check_edit, whatif, risks, review_edit, read_cypher (read-only, always rolled back). The server works on a private copy of the store; review_edit reads workbooks only from the served workbook's folder, compares an in-place edit with the version the server indexed, and then reloads it. Errors come back to the agent with their reason. The server's instructions tell the agent to call check_edit before it changes an input and to tell the user when a target is no_effect or partial. examples/mcp_client.py drives the server with the official MCP client and no LLM:

uv run python examples/mcp_client.py examples/workbooks/saas_plan.xlsx

Results

All results are reproducible with one command each; the outputs are committed in results/.

Does the graph predict what an edit changes? knockon bench

For each workbook, up to 40 numeric inputs that some formula reads are chosen with a fixed seed. Each input is set to three different values in formualizer, a Rust recalculation engine that never sees the graph; every cell whose value differs from the restored workbook counts as changed. Cells that change with no edit at all (NOW(), RAND() and their readers) are excluded. The graph's prediction is the set of cells downstream of the input.

uv run knockon bench corpus/enron/*.xlsx examples/workbooks/*.xlsx --out results/bench.json

Stratum (pooled)

Inputs

Cells that changed

Recall

Precision

One-step recall

All

884

284,689

1.000

0.636

0.022

Dependency depth 1

82

638

1.000

0.225

1.000

Depth 2

14

38

1.000

0.927

0.553

Depth 3 or more

788

284,013

1.000

0.639

0.020

Change crosses sheets

429

257,201

1.000

0.721

0.019

The corpus: 24 workbooks (222,000 formulas) from the CC0 Enron spreadsheet set, converted from .xls once; selection and provenance in corpus/SOURCES.md. Two had no input with a dependent formula and one does not load in the recalculation engine; they are listed in results/bench.json. None of the tested inputs had INDIRECT or OFFSET downstream, so the dynamic-reference stratum is empty.

Does the gate catch wrong answers before the edit? knockon gate-eval

examples/tasks/edit_tasks.json holds 24 requests a user might give an agent ("Raise the tax rate to 25% and show the new 2032 net income"): an input, a new value and the cell expected to move, over four synthetic models with defects of the kinds field audits report (typed copies of an input, a churn term dropped in the last year, a SUM that stops one row short, a value pasted over a formula). Each model has a repaired twin with the intended formulas (examples/repaired/). Ground truth is recalculation of both after the edit.

Variant

Requests

Ground truth

Gate verdict matched

Wrong answers flagged

False alarms

As built (defects)

24

silent 6, partial 14, wrong value 2, correct 2

24 / 24

22 / 22

0

Repaired

24

correct 24

24 / 24

0 / 0

0

These models and their defects were written by the same team that wrote the rules, so this table shows that the gate does what it claims on known defect types, not how often such defects occur. The Enron benchmark above is the independent check of the graph itself. The fourth model was added after the first three, and its first run showed a false alarm (a typed copy of the tax rate raised a caution on an FX question although it distorts nothing until the tax rate changes); the rule was narrowed and the run above is after that change.

Does it change what an agent tells the user? examples/agent_demo/run.sh

Claude Code got the same request three times with plain read/write cell tools and three times with Knock-On added, on two larger models:

  • group_plan.xlsx (19,000 formulas): "Raise the tax rate to 25% and tell me the new group net income." Region 07 types 0.21 instead of reading the tax-rate driver. After the edit the model shows 7,889,348; with Region 07 fixed it is 7,854,829.

  • debt_schedule.xlsx (2,900 formulas): "The base rate goes up 50 basis points ... the new total interest." In one tranche, month 61 holds a pasted number instead of its formula. After the edit the model shows 74,119,531.25; with the formula restored it is 74,174,218.75.

Tools

Runs

Reported the model's number without comment

Found the defect and told the user

Plain read/write

6

6

0

Plain + Knock-On

6

1

5

The one miss with Knock-On: the agent asked the gate about Tranche A's total (Summary!B2), which has no defect, instead of the grand total, got reaches for that cell, and reported the model's number. One agent model (Claude Sonnet), synthetic models with defects we planted, three runs per condition: this shows the mechanism, not how often it happens in the wild. On the 125-formula SaaS plan both variants noticed the typed 0.21, since an agent can read every formula of a model that small. Transcripts and per-run tables: results/agent_demo/.

Scale

uv run python examples/make_large.py && uv run python examples/time_large.py > results/large_timing.json builds a 22-sheet consolidation model (96,780 cells, 91,103 formulas, 633,921 relationships) and times it on a laptop (Apple M-series):

Step

Time

Parse workbook

2.2 s

Load into Relate

16.3 s

Impact of the growth driver (88,623 downstream cells, 23 outputs)

1.6 s

Impact of one product-month (153 cells)

5 ms

why across sheets (8 hops)

< 1 ms

Full risk scan

2.3 s

Pre-edit gate for the growth driver

4.0 s

The risk scan takes at most 4.5 s per Enron workbook (41,734 formulas) and flags candidates in 23 of the 24 (uv run python examples/enron_risks.py, output in results/enron_risks.txt): for example 280 blank references in 19 workbooks, 502 values pasted inside runs of formulas in 10, 368 ranges that stop one cell short of their pattern in 9, and 7 formulas holding #REF! in 6. These are review candidates, not confirmed errors: nobody labelled them, and some are deliberate (a total that excludes a memo row).

Where the data lives

  • examples/workbooks/saas_plan.rl (and headcount_budget.rl, loan_schedule.rl, group_plan.rl, debt_schedule.rl): the persistent Relate stores, single files, committed. examples/workbooks/*.xlsx are the workbooks they were built from; examples/make_demo.py, examples/make_more.py, examples/make_large.py group and examples/make_debt.py regenerate them and the repaired twins in examples/repaired/. Commands open committed stores read-only (what-if and the MCP server work on a private copy), so running the examples leaves them byte-identical.

  • examples/reports/saas_plan.html: the report, self-contained.

  • corpus/enron/: the evaluation workbooks; results/: benchmark and gate outputs.

  • At run time a store sits next to its workbook as <name>.rl.

How it compares

Tool

What it does

What Knock-On adds

Excel Trace Precedents / Dependents

Arrows one level per click; cleared on edit; no closed workbooks or named constants; not callable

Whole downstream or upstream in one query, callable by agents, kept in a file

Excel Inquire, spreadsheet linters

Workbook diagnostics inside Excel

Graph queries anyone can rerun, a pre-edit gate, edit review, MCP

formualizer dependents(), agent-spreadsheet MCP

Dependency info inside a recalculation engine

A persistent graph store judges and agents can query in Cypher; rules that join formulas to inputs; measured against recalculation

xl-marinade, excel-grapher

Extract formula graphs to SQLite or images

Pre-edit verdicts, transactional what-if, review of an agent's edit

"Spreadsheets are Graphs" idea in relate-ideas

Cells as nodes, references as relationships, "what breaks" as a path

Agent tools over MCP, recalculation-checked accuracy, typed-copy and pattern-break rules, gate verdicts, INDIRECT/OFFSET marked as dynamic instead of guessed

Limitations

  • INDIRECT and OFFSET build references at run time. Such cells are marked dynamic and reported; impact past them is not static. 3D references (Sheet1:Sheet3!A1) and some structured-reference forms are reported as unresolved instead of guessed.

  • .xls, macros/VBA, pivot caches, data tables and charts are not read. Convert .xls with LibreOffice first.

  • Ranges larger than 4,096 cells link only to the non-empty cells inside them.

  • A single quantified path query enumerates paths; on a model where one driver feeds tens of thousands of cells that becomes slow, so impact, the gate and the risk rules walk the graph level by level with batched one-hop queries (queries.walk). Both return the same cells.

  • The gate reasons about structure. partial and caution say where a number can go wrong, not by how much.

  • Relate allows one process to own a store; close knockon mcp before opening the same .rl elsewhere.

Troubleshooting

  • storage locked: another process (an MCP server, relate serve) has the store open. Stop it, or copy the .rl.

  • no cell matches '...': use a key ('Sheet!A1', quoted because of ! and &) or more header words.

  • bench and gate-eval need the verify extra: uv sync --all-extras or pip install -e ".[verify]".

  • Windows PowerShell: wrap cell keys in single quotes the same way.

Third-party software and AI use

Software

License

Use

Relate (relate-db 1.5.0, relate CLI)

Apache-2.0

Graph store, Cypher, transactions, full-text and vector indexes

openpyxl 3.1

MIT

Reading .xlsx, formula tokenizer

MCP Python SDK (mcp 2.x)

MIT

MCP server and the example client

formualizer 0.17 (optional, verify)

MIT on PyPI, Apache-2.0 on GitHub

Recalculation ground truth in bench and gate-eval

cytoscape.js 3.33 (bundled in src/knockon/assets)

MIT

Graph view in the HTML report

pytest

MIT

Tests

LibreOffice 24.2 (not distributed)

MPL-2.0

One-time .xls to .xlsx conversion of the corpus

Enron spreadsheets via SheetJS/enron_xls

CC0-1.0

Evaluation corpus

AI use: the code, tests and documentation were written with AI coding assistants (Anthropic Claude models in an agent harness), directed and reviewed by the author, and every number above comes from running the committed commands. Knock-On itself calls no LLM; the agent comparison in results/agent_demo/ runs Claude Code as the agent under test.

This project was started on 2026-12-06 for the Relate by Neo4j Hackathon. It uses the names Relate and Neo4j only to identify the product it is built on; it is not endorsed by Neo4j.

License

Apache-2.0 (see LICENSE).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to perform comprehensive Excel workbook operations with verified, freshness-labeled values and structural edits that preserve formulas, tables, and references, optionally using a private Excel instance for real recalculation and export.
      7
      1
      AGPL 3.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to edit real .xlsx workbooks in place through spreadsheet-native tools like describe, find, read, write, and structural edits, recalculating formulas without Excel, LibreOffice, or Python. Every change comes back as a review link showing changed cells before and after, and nothing is written until the user accepts, while charts, pivots, and VBA data return byte-identical.
      11
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to inspect and safely edit .xlsx workbooks — reading ranges, searching cells, checking formulas, writing values or formulas, appending rows, and converting CSV — while preserving formulas and styles, dry-running edits by default, and refusing any save that would destroy charts, pivots, macros, or other features.
      11
      MIT