Metadata-Version: 2.4
Name: askonce
Version: 5.5.2
Summary: Checks the CSV files your pipeline or model writes, against answers you give once. Fails closed, writes offline-reproducible receipts.
Author: Nikhil Ramesh
License-Expression: MIT OR Apache-2.0
Project-URL: Source, https://github.com/Ramesh-35/askonce
Project-URL: Issues, https://github.com/Ramesh-35/askonce/issues
Keywords: csv,data-validation,data-contracts,llm,mcp,receipts,fail-closed
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Dynamic: license-file

# askonce

**Your pipeline or your model changed, and the CSV still parses. askonce tells you whether it still keeps the promises your first batch made.**

askonce asks you a few questions about a folder of CSV files once: the form of each column, the keys, and which files refer to which. After that it checks every later batch against your answers, and gives one of three verdicts.

```
uvx askonce demo                 # real public data, about a second, nothing to set up
uvx askonce check ./out/         # your own folder: first time it asks, after that it checks
```

| Exit | Verdict | Meaning |
|---|---|---|
| 0 | HOLDS | every check held |
| 1 | VIOLATED | a check you confirmed failed, with the file, line and value (this wins over NOT EVALUATED) |
| 4 | NOT EVALUATED | nothing failed, but something could not be checked; it is never a pass |
| 3 | error | askonce could not run; never a verdict |

It is one Python file, standard library only, and it works offline. Status: **alpha**. It has been tested by its author on synthetic fixtures and on the public data below. There is no independent verification yet.

<!-- mcp-name: io.github.Ramesh-35/askonce -->

## The demo

The data is South Africa's National Treasury eTenders, as published by the Open Contracting Partnership (public domain). There are four linked files: tenders, awards, suppliers and contracts.

```
1. First read of Jan to Jun 2026 (1,508 tenders, 369 awards, 61 contracts)
   askonce showed what it read and asked 5 questions; this demo answered yes to each.
   The contract now holds every column's form, the keys, and 7 references between files.

2. Jul to Sep 2026, as published: HOLDS

3. Jul to Sep 2026 again, with 3 changes planted to look like a different model re-extracting it:
   NOT EVALUATED: awards.csv, column 'value_amount' is blank on line 3; the first file had no blank there, so a person must say whether a blank is allowed
   VIOLATED: main.csv, column 'date', line 2 holds '03/07/2026', but the column was confirmed as date-times with a time zone (ISO 8601) by demo (answered yes to every question)
   VIOLATED: contracts.csv line 2: awardID '74332' is not among the id values in awards.csv
   VIOLATED: contracts.csv line 2: awardID '74332' is not among the awards_id values in awards_suppliers.csv
   Verdict: VIOLATED, exit code 1 (VIOLATED wins over NOT EVALUATED)

4. Receipt: /tmp/askonce-demo-…/.invar/receipts/receipt-….json
   Re-checked offline from the exact bytes: HOLDS (the receipt reproduces)
   Signed with a throwaway key made for this demo: signature verifies
   Changed one byte of awards.csv and re-checked: NOT EVALUATED (not the bytes the receipt names)
```

The three changes in step 3 are planted by the demo. They are not in the published data, which HOLDS.

## On your own folder

```
uvx askonce check ./out/
```

**The first time.** askonce prints what it read in each file: whole numbers, money, dates, ISO 8601 date-times, codes or text. It also prints how many cells were blank, the keys it saw, and the references between files that held on every line. It asks once whether to hold later batches to them. Your answers are written to `.invar/layout-contract.json`, so keep that file in git.

**Every later time.** The same command checks the new batch against that contract, and writes a receipt to `.invar/receipts/`.

```
uvx askonce verify .invar/receipts/receipt-….json --in ./out/
```

This re-checks a receipt from the exact bytes, offline.

**Blank cells.** A blank in a checked column that had no blank in the first file is NOT EVALUATED, never a pass. In a terminal, askonce asks once whether a blank is allowed there, or is a mistake. With nobody there to answer, as in CI, it stays NOT EVALUATED, and the rest of the run is still reported. A changed byte, or a different contract, gives NOT EVALUATED, never a quiet pass. `askonce sign` adds a signature with your own SSH key.

**In CI,** fail the job on exit 1 and on exit 4.

## With your coding agent

```
claude mcp add askonce -- uvx askonce mcp
```

The server is local, over stdio, and offers one tool, `check_layout`. The agent can check a folder, but it can never answer the first-read questions for you: a file nobody has confirmed comes back NOT EVALUATED. Its state lives in the folder the agent starts it in.

To have the agent run it after every step that writes data, paste [docs/AGENTS-SNIPPET.md](docs/AGENTS-SNIPPET.md) into your `AGENTS.md` or `CLAUDE.md`.

## Without uv

```
curl -O https://raw.githubusercontent.com/Ramesh-35/askonce/main/askonce.py
python3 askonce.py check ./out/
```

Python 3.8 or later. The single file is the whole engine.

## What it does not do yet

- **Date-time forms.** A date-time with a space instead of `T` (`2026-01-30 00:00:00`) is read as text and not checked.
- **Formats.** CSV only. There is no JSON or JSONL yet.
- **Text columns.** Columns read as text are not checked, and that includes their blanks.
- **What it checks.** It checks form, blanks, keys, arithmetic between columns and references between files. It does not check whether a value is *true*.
- **State across batches.** Uniqueness is checked within a batch, not across batches.

## Exit codes and receipts are a promise

The exit codes above will not change meaning. A receipt states:
- the sha256 of every input file;
- the sha256 of the contract;
- the sha256 of the engine;
- every finding.

## Licence

MIT OR Apache-2.0. The demo data is under the ODC Public Domain Dedication and License; see [src/askonce_kit/demo_data/SOURCE.md](src/askonce_kit/demo_data/SOURCE.md).

Found a wrong verdict? Please open an issue with the files, if you can share them. A wrong HOLDS is the bug that matters most.
