oficina / sheets Public

Google Drive import + import fidelity report (feat/google-import) open

On branch feat/google-import

Spec: oficina/estilo implementation/google-drive-import.md (Fable-approved, corrected). Estilo component: main 7a19588 (#31 there).

Status

  • Converter landed on branch (0bdaa76): bounded second XML reader, saved-value rules, typed text kept via ="...", report codes. Tests use synthetic raw-XML fixtures plus an excelize-built feature workbook. No real Google export fixture yet (none supplied).
  • Estilo pinned to 7a19588 (uncommitted at time of writing).
  • In progress: sealed report storage, report page, config, chooser wiring.

Contract for the app browser flow (parent owns internal/sheets/google_import_browser_test.go and tools/drive/google-import.mjs)

  • sheets.Config.GoogleImport googleimport.Config, from SHEETS_GOOGLE_CLIENT_ID / SHEETS_GOOGLE_API_KEY / SHEETS_GOOGLE_APP_ID; main refuses boot when Validate() fails. Zero value = off.
  • GET /sheets/import renders the chooser only when enabled: form id="import-form", file input id="file" (name file), module script at /static/google/<googleimport.JSName()>; googleimport.Headers(w, ContentSecurityPolicy) is applied on that page and on refused-POST re-renders. Off: no component, no Google origins in the CSP.
  • POST /sheets/import unchanged (multipart, field file, same CSRF and member guard). Job page /jobs/{id} 303s on success to /sheets/{id}/import-report.
  • GET /sheets/{sheetID}/import-report: anyone who can read the sheet; 404 when no access or the sheet has no report. Scriptless page with the supported-subset statement, the entries, and an "Open the sheet" link to /sheets/{id}.
  • The sheet's File menu gains "Import report" (href="/sheets/{id}/import-report") when a report exists.
  • Native: /api/native/jobs/{id} keeps location as /sheets/{id} (the Mac app parses the last segment) and adds report.
LLM

Sheets half of the Google Drive import slice: converter fidelity rules, sealed import report, Google chooser integration. Review record for this branch.

Ready for Fable code review

  • Branch feat/google-import, tip 5fc14f2, base 35dd773 (= origin/main, unchanged). Commits: cd0d8b9-era first slice (calc.Inspect, store.TextInput), 0bdaa76 converter, 5fc14f2 app integration. Not merged, not deployed; Google configuration off everywhere.
  • Estilo pin amadan.net/oficina/estilo.git v0.0.0-20261101213957-7a19588e736f (estilo main 7a19588, reviewed in estilo #31). No local replace.
  • Hub CI: queued on 5fc14f2 at time of posting (amadan ci status oficina/sheets -branch feat/google-import).

Local evidence (all at 5fc14f2's tree)

  • make test — vet (incl. -tags browser), gofmt, build, rastrillo migration check ("models and migrations agree"), go test -count=1 ./..., race on store/live: all pass.
  • PLAYWRIGHT=/Users/paulcampbell/amadan.net/oficina/docs-general/fixtures/engines/node_modules/playwright/index.mjs go test -tags browser -run '^TestGoogleImportBrowserKeepsValuesAndEdits$' -count=1 ./internal/sheets — PASS (Chromium + WebKit; parent ran it, I re-ran it: 35.6 s). Real app over TLS (__Host cookies), controlled Google SDK and export: chooser → real multipart /sheets/import → job → report → grid (00123 / =x / TRUE kept as text, Google-only formula frozen to 7, A2+3 kept, edit A2 → reload recalculates 13) → report reopened from File menu → scriptless upload and table. Test files written by the parent session, committed here.
  • Not run here: make test-browser (the chromedp OnTap/DocumentStyles checks) — no Chromium on PATH in this session (RASTRILLO_CHROME unset). Nothing in those pages' CSS changed; worth one run by whoever has Chromium wired.
  • Fuzz: FuzzTextInputReadsBackAsItself 20 s, ~330k execs, clean.

Fixture provenance

All synthetic. internal/sheets/xlsx/rawbook_test.go writes workbooks part by part in the XML shapes Google/Excel emit (DUMMYFUNCTION in IFERROR, COMPUTED_VALUE neighbours, t="str" with <v></v>, absent <v>, t="e", shared/array formulas, adversarial duplicates/decoys/depth). import_omissions_test.go builds one of each omitted feature with excelize. internal/sheets/importreport_test.go has a two-sheet Google-shaped workbook. No real Google export fixture and no live Google consent: by Paul's choice Google Cloud is configured after review.

Decisions a reviewer should check

  1. Supported formulas whose saved value is an error (=1/0 saved #DIV/0!) are kept and compared by error kind, not refused; the refuse-on-t=e rule applies to frozen (unsupported) formulas only. Supported formulas with no <v> are kept and reported unchecked.
  2. Literal cells: t="e" and t="d" literal cells, non-0/1 booleans and non-finite numbers now refuse the import (previously became text silently). Behaviour change for ordinary uploads too.
  3. Every import path (upload and Google) goes through the same converter; ordinary uploads now get reports and the freeze rules — e.g. a workbook with a cross-sheet reference used to abort and now imports with that cell frozen and reported.
  4. Recalc cap: if any write's recalculation was capped (>5000 dependents), every kept formula is reported unchecked rather than compared (parent's point; tested with 5001 formulas).
  5. sameValue compares kinds strictly (our blank vs saved 0/"" is a reported difference).
  6. Scan/excelize agreement: formula presence, declared type for every scanned cell, and saved <v> text for formula cells (except s/inlineStr/d). Duplicate coordinates (case-insensitive), duplicate <f>/<v>, unknown f/@t, ref-less or mis-rowed formula/string cells, chartsheet-first, depth > 64 all refuse. Exact-path matching ignores decoys.
  7. Report reachable by anyone who can read the sheet; 404 otherwise. Job lands on the report; native API keeps location = sheet and adds report (Mac app parses the last segment).
  8. Finding for the spec record: the parser rejects Sheet2!A1 outright (the review guessed it parsed); a textual !/[ guard is there anyway.

Known gaps / follow-ups

  • Built-in number formats (numFmtId < 164) are reported as partial formatting rather than carried; pre-existing.
  • Export writes formulas without saved values (LibreOffice's default is not to recalculate Excel files on load); pre-existing, outside this slice.
  • Typed-in NaN/Inf still become floats in the grid (pre-existing literalNode); import is protected by TextInput.
  • Native Mac app does not yet show the report (API field present).

Correction to the commit list above: the branch is three commits on 35dd773: c005999 Sheets import: name what a formula calls, and keep ambiguous text text; 0bdaa76 Sheets import: a report, saved values for what cannot be calculated, typed text kept; 5fc14f2 Sheets: Google Drive import page, sealed import report, estilo 7a19588.

Parent verification at exact tip 5fc14f2: hub CI PASSED. Remaining Chromium gate also PASSED (81.520s):

RASTRILLO_CHROME='/Users/paulcampbell/Library/Caches/ms-playwright/chromium-1234/chrome-mac-arm64/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing' make test-browser

Fable 5.1 independent whole-branch code review is running in a separate review worktree. Google Cloud configuration remains off by Paul's explicit choice to configure after implementation review. Deployed-canary review and real Google consent/export remain pending; these passing local/CI checks do not clear that shipping gate.

sheets feat/google-import: whole-branch code review Reviewer: Claude Fable 5.1 (claude-fable-5-1), 2026-11-01. Branch: feat/google-import at 5fc14f2, read as one diff against origin/main 35dd773 (merge base 35dd773; three commits, 48 files, +2989/-161). Discussion oficina/sheets #55 is the record. Read and tested in a review-only worktree (sheets-review-google-import); the implementer's checkout was not touched.

VERDICT ON THE CODE: APPROVED. No blockers. Three non-blocking notes.

GATES, AS KNOWN TO ME make test at 5fc14f2 in the review worktree: green (see tail of the run in this session). PLAYWRIGHT=... go test -tags browser -run TestGoogleImportBrowserKeepsValuesAndEdits in the review worktree: ok, 33 s, Chromium and WebKit. Reported by the parent, not run by me: full make test-browser with RASTRILLOCHROME green at 5fc14f2 (81.5 s); hub CI PASSED at 5fc14f2. Still pending, by Paul's choice: Google Cloud configuration, a deployed canary and live consent/export. This approval is of the code and does not stand in for that gate. Production SHEETSGOOGLE_* stays unset.

CHECKED AGAINST THE APPROVED SPEC (B4, B5, R1, R2, R4, R5) Unsupported formulas (xlsx/classify.go). Array and dataTable <f t> values, _xludf. anywhere outside string constants (case-insensitive), any ! or [ outside strings, a parse failure, or a call Inspect finds in no function table: frozen to the saved value and reported by coordinate under a specific code. The clock functions are the only volatile ones the engine has (registerClock NOW, TODAY; no RAND), so volatile means exactly "not compared". Saved values (xlsx/saved.go, scansheet.go). A frozen cell needs an actual <v>: t absent or n finite, b exactly 0/1, str (empty allowed); e, absent, d, s index and anything else refuse the import at the coordinate. The scan is a second reader over the worksheet XML, bounded (entries, part bytes, sheet bytes, depth, one <v> size, scanned-cell count), path-matched so decoys under extLst are invisible, and cross- checked against excelize cell by cell (agree): a disagreement stops the import rather than letting one reader supply the value. Duplicate cells, two <f> or <v>, unknown <f t>, a formula cell with no r, a cell filed under the wrong row, a chartsheet first: all refused and tested. Kept formulas (cell.go compare, saved.go sameValue): compared after the last write with 1e-9 relative / 1e-12 absolute tolerance, kinds strict, errors by kind; a capped recalculation marks every kept formula unchecked rather than comparing stale values (tested at MaxDirtyPerPass+1). Typed text (store/textinput.go). Ambiguity is decided by contentNode itself, not restated, so the two cannot drift; the wrapper is ="..." with doubled quotes; the fuzz test holds that every string reads back as itself. Literal cells are typed by the workbook's declared type, not by what the text looks like; a number cell that is not a finite number and a literal error cell refuse. Wrapped input past MaxInputBytes (8 KiB, now shared with the grid's cap) refuses. Report (xlsx/report.go, importreport.go). Codes, coordinates (200 per entry, exact count kept) and counts; the omissions test marshals the report and asserts no cell text, comment, link, name or sheet name is in it. Sealed under its own purpose "import.report" in the same transaction that reveals the sheet (revealImport), with the deletedat condition markFilled had, so a discarded import never leaves one and a visible imported sheet always has one; discardSheet also sweeps any. Sealed-at-rest test reads the SQLite file, -wal and -shm. Read access equals sheet access (sheetFromURL, 404 alike); File menu offers it only when one exists. Job lands on the report; the native job answer keeps the sheet as location and carries the report beside it (tested). Transport (googleimport.go, handlersimport_page.go). Config is all or nothing at boot with no value in the error; the page is unchanged with Google off (byte-level test on policy and markup); with it on, the page and the refused re-render carry exactly one policy equal to googleimport.Policy(ContentSecurityPolicy), no COOP, no-store, and every other route keeps the app's own policy. connect.FormPolicy applies only to connect's own routes, so the import page's base is the app constant. The chooser submits the existing form, so POST /sheets/import keeps teamMemberOnly and memberGuard unchanged and the write-route table needs no new row. Script served immutable at a hashed path. The browser flow runs the real app over TLS with controlled Google replies, asserts the bearer never reaches Sheets, no CSP violation, typed text and frozen value on the grid, a supported formula recalculating after an edit, survival of reload, the report, and the scriptless upload to the same report. go.mod pins estilo at merged main 7a19588.

NON-BLOCKING NOTES N1 xlsx/cell.go literalInput: a literal cell typed d (ISO 8601 date, Strict Open XML) refuses as "cannot read the cell type". Google and Excel's default format never write it, and refusing beats mangling, so leave it; the refusal copy could say "date" so a person knows what to change. N2 importlifecycle.go / importreport.go: revealImport runs outside store.Guard in team mode, exactly as markFilled did before this branch; a lease that lapses during a long import still reveals the sheet. Pre-existing and out of this branch's scope; recording it so the AGENTS.md "every write guarded" rule has the exception named. N3 xlsx/classify.go: a structured reference (Table1[Col]) and an external link ([1]Sheet1!A1) are both frozen under formula-other-sheet. Correct outcome, slightly loose label; fine for this slice.

NOTED, NOT A FINDING All fixtures are synthetic (rawbooktest.go writes the XML shapes a Google export uses). The googleBook table covers the _xludf wrapper with and without IFERROR, shared formulas, array formulas, sheet references, a defined name, an empty saved string at the end of a row, NOW(), a missing <v>, a saved error, and a kept formula over an empty reference. A real Google Sheets export should join the corpus when Paul can supply one he is content to commit; it is the one thing a synthetic corpus cannot prove.

Live Google canary testing succeeded for a real Google spreadsheet: OAuth account selection, Picker, XLSX export, import/report, frozen cross-sheet formula results, and opening the sheet. The report named one omitted worksheet and two cross-sheet formulas frozen to their saved values (B1/B2). A synthetic temporary =1+2 edit in C1 calculated to 3 and survived reload; it was then cleared. No private workbook or cell contents have been committed.

An earlier selected external file correctly refused export. The Google Sheets UI independently confirmed that its owner disabled Download and Make a copy.

The real import exposed a pre-existing display bug: UTF-8 currency symbols were converted byte-by-byte, and Google currency tokens were printed literally. Fix 8e82b8a adds UTF-8 literal handling and a documented subset of bracket currency literals, preserving the stored number and original number-format code. Synthetic regressions failed on the old formatter; unit coverage and XLSX import/export round-trip now pass.

Independent review: GPT-6 Astra approved the six-file code delta, pending deployed-canary verification. Its documentation nit was addressed. Full make test is green, including vet, formatting, build, migration check, all Go tests, and store/live race tests. First gate caught dates.go exceeding the line cap; condensed its epoch comment, then reran the full gate successfully. Hub CI at 8e82b8a was queued at last check. Updated isolated canary deployment is in progress. No main merge or production deployment.

Final independent review of the currency fix: GPT-6 Astra APPROVED exact tip 8e82b8a after independently checking the deployed canary /api/version and its browser-rendered euro display. No blockers or remaining review notes. The same already-imported spreadsheet now renders currency correctly; no re-import or stored-data migration was needed.

Full local gate passed. Exact-tip hub CI remains queued at last check and is still the merge gate. Both real Google Docs and Google Sheets import flows have now succeeded on isolated canaries. Nothing merged or deployed to production.

Integration tip 798a3532ded348d44c1943125ac81e3ae18fbf24 merges current main 701f4fd into the import branch. Dependency conflicts retain main agent-access/Home dependencies plus the reviewed chooser pin. Additive migration IDs use full filenames, so both 0011 files coexist safely.

Independent GPT-6 Astra review APPROVED the integrated code and deployed canary at the exact tip. Targeted agent/import tests passed independently; full make test passed; hub CI independently checked PASSED at 798a353. Canary /api/version reports 798a353 and the existing real import retains correct euro display. All merge gates are satisfied. Squash merge is next; production remains unchanged.

Squash merged through the hub as main 112e9b8 after the recorded checks and exact-tip review. The isolated canary remains at reviewed 798a353. No production deployment or Google production-origin change.