# Discovery-to-dashboard Sales pilot

Given only the Reports URL and “prototype an automated Sales dashboard,” follow
`llms.txt` to the [entrypoint](../README.md) and [catalog](../../catalog.json).
Resolve the Sales enterprise, its recipe and the recipe's `workbookUrl`; do not
guess a workbook from its title. Read the existing [Sales definition](sales.md),
[dashboard playbook](../dashboard.md), [private data-bank guide](../data-bank.md)
and [testing guide](../testing.md). Those guides own calculation and access rules.

## Discover, verify and reproduce

1. Write the discovery/access receipt from the testing guide. Discover the private
   bank through `dataBank` in the public catalog. Without checkout access, use
   `dataBank.salesBundle` and the [private bundle contract](../sales-bundle.md).
   Its `configured` status reflects successful authenticated retrieval, validation
   and anonymous denial; valid ungranted-identity denial remains pending.
   Record bundle access separately from reference-workbook read and Sheets
   creation access. Missing access is a documented blocker, not permission to
   use public substitutes or make up totals.
2. **Remote bundle route:** obtain the file ID and trusted expected hash privately,
   download the original bytes with the intended Google identity via authenticated
   Drive `alt=media`, verify SHA-256 before parsing, then validate the source-owned
   schema, release `20260907-20260927-29aba3d42a411b8a`, dates and provenance.
   Follow the bundle and testing guides; do not invent validator flags. Consume
   the exported shared Sales pilot results and comparison evidence. No sibling
   repository or private runtime catalog is required for this route.
   **Local checkout route:** inspect the private `data/catalog.json` and select the verified immutable
   release covering **September 7–27, 2026 inclusive**. Pin its manifest and release
   ID. Verify with `python3 scripts/data_bank.py verify --manifest "$RELEASE_MANIFEST"`
   from the private checkout. Do not assume the current release still has this
   range. Record requested range, America/Los_Angeles date basis, source-as-of and
   extraction dates, schema versions, input hashes, transformation revision,
   classification mapping and known gaps. If no suitable release verifies, stop
   numeric claims and report the missing evidence.
3. For a local checkout, reuse `python3 scripts/data_bank.py pilot --manifest "$RELEASE_MANIFEST"`.
   This verifies inputs and writes a private report under `reports/data_bank/`;
   retain its output privately rather than printing business totals in chat.
   Consult the checkout's `docs/data-bank.md` for its existing implementation and
   comparison-evidence contract. Do not rebuild simply to replace a pinned release.
   The bundle route already carries the shared aggregation output from
   `scripts/data_bank_pilot.py`; preserve it rather than building another normalizer.
4. Reproduce `square.market_events` market sales for the three complete weeks
   September 7–13, 14–20 and 21–27. Use the existing normalizer and reviewed channel
   rules from the Sales recipe. Sum exact integer cents by week and source
   account/location, then reconcile location subtotals to each eligible weekly
   total and the period total. Preserve unknown sales/refund reconciliation and
   unknown channel counts; an incomplete subtotal must be labelled incomplete.
   Keep account IDs scoped and retain event dates for venue comparisons.
   The selected export has no verified dated venue mapping. Workbook market labels
   are not verified Square location identities. Known subtotals are not necessarily
   complete totals; missing data is not zero. Never add payments to sales or fill
   gaps from workbook values. Preserve original pilot integer strings alongside
   exact cents, all partial/unknown/refund/classification states and the two
   unresolved Sales workbook differences.
5. Inspect the reference workbook read-only: relevant tabs, layout, labels,
   formulas, number formats, charts, manual inputs and generated areas. Record
   inspection evidence and template selection under the reporting SOP. Read its
   relevant net-sales cells and formulas for
   those dates. Prefer pinned dated workbook-reference/comparison captures when
   present. Record workbook/tab/cell, observed value/formula, capture time, date
   window and metric definition in private evidence. Current cells are a new
   observation, not proof of what the workbook showed at release time.

## Map metrics and reconcile

Create a private metric-to-source table with stable metric ID, question,
dataset/fields, grain, filters, date basis, unit, exact calculation, release/hash,
workbook range, evidence status and missing-data behavior. At minimum include:

| Metric | Evidence and automation decision |
| --- | --- |
| Weekly eligible market net sales | `square.market_events`, reviewed market classification, exact cents; reproducible now for verified historical coverage |
| Weekly location subtotals and period total | Same eligible events, source account/location/date; automate historical aggregation and subtotal checks now |
| Physical market/venue totals | Require dated reviewed event mapping; location alone cannot establish venue |
| Category sales | Require line-item identity and historical category mapping beyond location/date aggregates |
| Goals/prior-year comparisons | Require dated workbook/manual inputs and compatible definitions/windows |
| COGS, overhead, labor and profit | Require reviewed cost scope, allocation rules and corresponding source evidence; do not infer from sales |

“Automatable now” means deterministic calculation over the pinned evidence. A
live refresh additionally needs supported fresh collectors, access and coverage
checks. Do not label every workbook row automated because one subtotal matches.

Reconciliation must show source value, workbook value, exact delta, aligned date
and scope, and evidence for each explanation. Check refund timing, discounts,
deposits, trades, manual entries, venue assignment and capture-date differences.
Reuse the existing pilot comparison bridges/evidence where suitable. Retain
unresolved differences with affected metric/cells and the next evidence needed.
An archived orders/payments match supports a source subtotal; it does not explain
a different workbook cell. Do not force agreement with balancing adjustments or
silently copy suspected workbook formula errors.

## Build a private Google Sheets dashboard

Create a private native Google Sheets workbook following the Sales example's
layout, formatting and presentation and the dashboard authoring SOP. Use a native
private workbook copy where appropriate. Never modify the reference workbook.
Define generated tabs/ranges, preserve manual inputs and verify formulas, formats,
charts, external references and private sharing. Populate supported metrics from
the pinned pilot outputs; keep unsupported category, goals and cost actuals
unknown or visibly unavailable. Include reconciliation deltas and coverage.

If source access is blocked, still create a clearly labelled private Sheets
mockup following the example; remove or visibly mark sample actuals, never invent
figures. Include source dates, provenance and unresolved differences. If Sheets
creation is also unavailable, report that separate capability gap explicitly and
label any HTML/local artifact as a fallback; acceptance remains incomplete.
Existing publishers are deployment references, usable only for demonstrably owned
ranges. A local renderer may support review but cannot replace the workbook.

Display **Historical prototype: September 7–27, 2026**, source-as-of/extraction
dates per input, release ID, definitions and unresolved differences. Do not call
it a live automated dashboard. Keep business artifacts, workbook captures,
metric mappings, test receipts and results outside public docs and tracked public
files. Never publish publicly, email, modify operational records, or add schedules.
Private workbook creation is part of this task; do not enable public sharing.

## Completion and refresh handoff

Completion requires all five private artifacts, with paths and reproduction
instructions in a private handoff:

1. Discovery/access test receipt, including blocked/skipped checks and actual
   coverage rather than assumed access.
2. Metric-to-source mapping with exact definitions and lineage.
3. Private native Google Sheets dashboard and final workbook link, with example
   inspection evidence, SOP compliance, generated ranges, preserved manual inputs,
   verified formulas/formatting and reference protection. Include reproducible
   script/command, dependencies, pinned manifest or verified bundle release/hash,
   and deterministic source-owned calculations.
4. Reconciliation with evidenced explanations and explicitly unresolved deltas.
5. Proposed refresh command and deployment requirements, without enabling a
   recurring export or adding a schedule.

The prepared bundle is historical, not a live refresh. New exports and their
trusted hashes must come from `master_planning`; provision and verify each private
handoff. Bundle remote acceptance requires actual authorized download and
unauthorized denial, independently of dashboard completion. Authenticated download,
hash/source-owned validation and anonymous denial passed; denial to a valid
ungranted identity remains pending. For a configured private checkout installation, propose
the existing offline refresh:

```sh
cd "${FARM_DATA_ROOT:?authorized checkout required}"
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
```

This rebuilds from explicitly selected captures; it does not fetch fresh data.
For later periods, propose explicit dates, existing read-only collectors from
`docs/sales-harvest.md`, reviewed private manifest selections and the same checks.
Deployment needs owner-provisioned source access, private capture storage/backup,
classification maintenance, schema/coverage failure handling, a reproducible
runtime, destination ownership and approved private transport. Reuse the existing
publisher only for ranges it demonstrably owns; no single publisher is verified
for the whole Sales workbook. Future public publication or scheduling needs a separate
request. Verify all dashboard SOP acceptance criteria before claiming completion.

Acceptance exercise: give a fresh agent only the Reports URL and the dashboard
request above. It should discover the private bank, preserve these historical
dates, produce the private Sheets workbook and five traceable artifacts, and report
access/evidence and Sheets-creation blockers separately
without needing a repository-layout explanation. Record the observed outcome
privately; writing this recipe alone does not constitute a passed exercise.
