Metadata-Version: 2.5
Name: rowspec
Version: 0.7.0
Summary: A specification and conformance suite for tabular data that must survive version control
Project-URL: Homepage, https://github.com/kindspec/rowspec
Project-URL: Source, https://github.com/kindspec/rowspec
Project-URL: Issues, https://github.com/kindspec/rowspec/issues
Project-URL: Specification, https://github.com/kindspec/rowspec/blob/main/SPEC.md
Author: Cameron Brooks
License-Expression: Apache-2.0 OR MIT
License-File: LICENSE
License-File: LICENSES/Apache-2.0.txt
License-File: LICENSES/CC-BY-4.0.txt
License-File: LICENSES/CC0-1.0.txt
License-File: LICENSES/MIT.txt
License-File: export/LICENSE
License-File: reference/LICENSE
Keywords: conformance,csv,git,markdown,merge,specification
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Version Control :: Git
Classifier: Topic :: Text Processing :: Markup
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: conformance
Requires-Dist: kindkit<0.3,>=0.2.0; extra == 'conformance'
Provides-Extra: xlsx
Requires-Dist: openpyxl<3.2,>=3.1; extra == 'xlsx'
Description-Content-Type: text/markdown

# rowspec

A file format and test suite for tables that must survive version control.

A `.mdtbl` file is a markdown table where a computed column carries its formula
in the header, rows have opaque ids, and nothing is addressed by position. The
point is that **stock git merges it correctly, or refuses — never quietly
wrong**, with none of this project's tooling installed.

```
| id     | item   | qty | unit  | total = qty * unit |
| ------ | ------ | --: | ----: | -----------------: |
| r_0001 | widget |  10 | 12.00 |                    |

key   := id
grand := sum(total)
```

Two branches insert a row far apart. Stock `git merge` — no driver, no
`.gitattributes`, nothing installed — merges cleanly, and `grand` is correct.
The same table with `A1`-style references merges just as cleanly and reports a
number that is 27% wrong, with no marker anywhere. That difference is the entire
project.

## Quick start

```sh
pip install rowspec
rowspec check .    # will this table survive being edited by several people?
rowspec eval  .    # does it currently say anything false?
```

Run both. `check` finds structural problems, and `eval` computes every table
and fails on an unresolved value. A misspelled column name passes `check` and
leaves a wrong total, so `check` alone is not enough.

Already have CSV files? `rowspec check data/` works on them with no migration.
See [CSV mode](https://github.com/kindspec/rowspec/blob/main/docs/csv.md).

## In CI

```yaml
- uses: actions/checkout@v7
- uses: kindspec/rowspec@v0.7.0
  with:
    paths: data
```

The action runs both commands.

## Edit a table

```sh
rowspec add-row parts.mdtbl bolt 4 0.10
rowspec rename-column parts.mdtbl qty quantity
rowspec add-column parts.mdtbl note --after item
```

Each edit changes only the lines it is about, so edits on two branches merge
wherever they don't touch neighbouring lines. Programs can call `rowspec.edit`;
see the [editing API](https://github.com/kindspec/rowspec/blob/main/docs/editing-api.md).

## Do you need it?

**If your table is a list of facts, you probably do not need this.** Across 7,446 real commits
from four public CSV-in-git registries, including 528 real three-way merges,
neither `.mdtbl` nor plain CSV ever merged silently wrong.

It earns its keep when a table **computes**, and a merge can leave a total that
is quietly wrong. It doesn't help when two branches each add a column, which
conflicts as badly as it does in CSV. It isn't a data-quality tool either; for
that, use [Frictionless](https://frictionlessdata.io/).

## How it is tested

The test suite is the main deliverable. It checks out two branches, runs stock
`git merge`, evaluates the merged file and asserts on the computed number. A
second implementation, written from `SPEC.md` alone, runs against the same
cases, and a mutation gate breaks the code on purpose to prove the suite
notices.

    703 conformance cases          two implementations, both passing
    122 mutants, all distinct      119 killed, 3 equivalent
                                     0 survived, 0 stale, 0 broken

## Documentation

| | |
|---|---|
| [SPEC.md](https://github.com/kindspec/rowspec/blob/main/SPEC.md) | the format |
| [Using rowspec](https://github.com/kindspec/rowspec/blob/main/docs/usage.md) | CSV files, CI, editing and the two commands in full |
| [Export to xlsx](https://github.com/kindspec/rowspec/blob/main/docs/xlsx.md) | `pip install 'rowspec[xlsx]'`, formulas or values |
| [What has been measured](https://github.com/kindspec/rowspec/blob/main/docs/evidence.md) | what it does not do, and how the suite is built |
| [Rationale](https://github.com/kindspec/rowspec/blob/main/docs/rationale.md) | why the format is this way |

## Develop

A real `git` binary is required, because the suite's central claim is about
what stock git does.

```sh
just setup      # uv sync
just check      # fmt-check + lint
just test       # everything under tests/
just conform    # the suite alone, against a stock git binary
just mutants    # break the implementation; the suite must notice
```

See [CONTRIBUTING](https://github.com/kindspec/rowspec/blob/main/CONTRIBUTING.md) and `just --list`.

## Licensing

Per directory, deliberately. See [LICENSE](https://github.com/kindspec/rowspec/blob/main/LICENSE). The fixtures are CC0 so
they can be vendored into an implementation in any language under any licence.

## Credit

Standing on Coopy/daff, ClassSheets, Object Spreadsheets, Lotus Improv and
org-mode. See [NOTICE](https://github.com/kindspec/rowspec/blob/main/NOTICE).
