# Use the private farm data bank

Reports publishes dataset descriptions. `master_planning` owns private releases
and calculations. For historical Sales without checkout access, use the
[private Sales bundle contract](sales-bundle.md), discovered through
`dataBank.salesBundle` in the public catalog. Current availability is `configured`:
authenticated raw download, trusted hash/source-owned validation and anonymous
denial passed; valid ungranted-identity denial remains pending. The supported
transport is an authenticated Drive binary-file download; Sheets access alone is
insufficient.

The full records and runtime catalog live in the private
`deckfamilyfarm/master_planning` checkout. The local route below requires separately
authorized repository and filesystem access; do not assume a sibling checkout.
Set `FARM_DATA_ROOT` to that checkout when writing local consumers; no token belongs
in a Reports URL. Remote bundle consumers do not need the private runtime catalog.

```sh
cd /path/to/master_planning
python3 scripts/data_bank.py list
python3 scripts/data_bank.py describe local_line.product_orders
python3 scripts/data_bank.py verify
```

The list distinguishes implemented adapters from released datasets. `describe`
returns the row grain, columns, units, calculation limitations and available
release references. `verify` checks the current release, its CSV files, the pinned
configuration, source manifests and captured-file hashes. It performs no network
calls and no operational writes.

## Read a release

1. Read `data/catalog.json` below `FARM_DATA_ROOT`. It is private and generated.
2. Select its explicitly recorded `current_release` or a pinned older release.
   Resolve its manifest path relative to the checkout. Never select files by mtime
   or glob together overlapping captures.
3. Inspect the release's `requested_range`, timezone/date bases, source-as-of and
   extraction times, dataset statuses, known gaps and transformation revision.
4. Verify the release, then read each dataset's named CSV artifact. Money columns
   use integer USD cents, quantities/hours use decimal strings, and empty cells
   mean unknown. IDs are scoped by source and account.
5. Record that release ID and the dataset manifest/hash in your result. A complete
   SELECT or completed collection task establishes extraction coverage, not that
   every real-world activity was entered upstream.

`local_line.product_orders` and `csa_store.order_reference` can describe the same
order. The reference dataset supplies classification/identity, not more revenue.
Square and Local Line sales remain separate until an explicit cross-source mapping
establishes duplication. Do not call their unreviewed sum audited whole-farm sales.

The initial local release provides Local Line product-order values, Square
location/date sales, CSA Store order references, recorded Timesheets entries, and
Layer washroom output. The older egg-washing-only labor archive has its own dataset
ID and cannot represent all enterprise labor. Read the actual runtime catalog:
some datasets may be unavailable or partial on a different checkout.

## Refresh on demand

Private configuration pins source manifest paths and classification rules; copy
the blank `config/data_bank.example.json` only when configuring a new installation.
Do not overwrite an existing configuration or `.env`.

```sh
python3 scripts/data_bank.py build --config config/data_bank.local.json \
  --start 2026-09-07 --end 2026-09-27
python3 scripts/data_bank.py verify
python3 scripts/data_bank.py pilot
```

`build` is offline: it reuses selected captures and writes an immutable release.
Unchanged inputs/code produce the same release ID. A failed build never advances
the current-release pointer. Missing sources produce unavailable datasets and
explicit pilot gaps; they are not fabricated empty tables.
The private pilot retains separate FFCSA definition and Layers rounding bridges,
plus optional hashed comparison evidence. Explained differences do not change the
underlying metric; unresolved source/workbook differences remain visible.

For fresher data, use existing Square/Local Line collectors documented in
`docs/sales-harvest.md`, or the bounded read-only Timesheets collector documented
in `docs/data-bank.md`. Then explicitly update private manifest selections and
rebuild. Source snapshots can have different as-of dates; show those differences.
No automatic collection schedule is added by this gateway.

## Add a dataset

Keep a safe definition in `config/datasets.json`: stable ID, version, source,
grain, keys, columns, units, date basis, adapter and limitations. Add an offline
adapter that validates manifest coverage and hashes, produces stable unique rows,
and preserves source lineage. Use synthetic cases for meaningful joins, refunds,
unknown values and units. Actual releases, mappings, records and report results
stay in ignored private directories and need a separate private backup.

The full bank uses local files; the historical Sales companion can be privately
provisioned on Drive using the bundle contract. Neither introduces a Reports HTTP
query endpoint, MCP server or alternate sales calculation service.
