cadrumo.adapters.outbound.google.calc_sheets_pull module¶
Read operator-edited Sheets cells back into structured records.
Pairs with calc_sheets_apply. The export
side materialises a
SheetExportPlan as a real Google
Sheets workbook; this module reads the operator’s edits back out, validates the
workbook is still bound to the
RegistrySnapshot the engine
compiled it from, and returns typed records the caller can inspect, compute
from, or assemble into ledger / filing inputs.
Two safety gates fire before any value is read:
Drive ownership marker — the spreadsheet must carry the
appProperties.cadrumo_vault_app=cadrumomarker. Reading values from a spreadsheet that lacks the marker would mix operator content with foreign Drive files and break thecadrumo-vault/isolation contract.Registry-SHA and layout-engine metadata match — the spreadsheet’s developer metadata must declare
cadrumo_registry_sha = <snapshot.registry_sha>andcadrumo_modelo_id/cadrumo_revision_id/cadrumo_filing_year/cadrumo_period/cadrumo_engine_versionmatching the caller’s snapshot and live layout compiler. A mismatch means the workbook was compiled against a different registry slice or coordinate layout — casilla identity/layout, formula chains, and bracket tables may have shifted. The pull is refused with a typed error before coordinates are read.
The pull adapter does NOT mutate any local state; it returns a
PullResult and leaves applying the
edits to the caller.
See also
pull_operator_edits() reads the
workbook,
compute_from_pull() maps a matching
pull into
RegistryCalculationResult.
- class CalcSheetsPullPreconditionCondition(*values)[source]¶
Bases:
StrEnumClosed terminal conditions owned by the calculation-sheet pull adapter.
- API_CLIENT_AVAILABLE¶
- SPREADSHEET_ID_VALID¶
- OWNERSHIP_METADATA_VALID¶
- OWNERSHIP_ALIGNED¶
- DEVELOPER_METADATA_LIST_VALID¶
- DEVELOPER_METADATA_ENTRY_VALID¶
- DEVELOPER_METADATA_CONSISTENT¶
- SNAPSHOT_ALIGNED¶
- RELATION_LEGAL_REFS_VALID¶
- RELATION_SOURCE_REFS_VALID¶
- EDIT_VALUE_FINITE¶
- EDIT_CASILLA_DECLARED¶
- EDIT_CASILLA_INPUT¶
- pull_operator_edits(snapshot, *, spreadsheet_id, credentials)[source]¶
Read operator-edited cells back from a workbook into typed records.
This is the readback entrypoint behind
aeat config google sync calc pull. It verifies the Drive ownership marker, reads developer metadata, classifies metadata againstsnapshot, reads operator/binding/relation cells plus Detalle row-set blocks, and returns aPullResult.- Parameters:
snapshot (
RegistrySnapshot) – TheRegistrySnapshotthe workbook was compiled against. Used to derive the layout (cell addresses for every casilla / binding / relation) and to validate the workbook’s developer-metadata stamps.spreadsheet_id (
str) – The Drive file id of the workbook to read. Must already exist and carry theappProperties.cadrumo_vault_app=cadrumoownership marker.credentials (
Credentials) – Agoogle.oauth2.credentials.Credentials-shaped object carrying a refresh + access token with at least thedrive.file+spreadsheetsscopes.
- Return type:
- Returns:
A
PullResultcarrying the operator edits, binding edits, relation edits, and the metadata-match verdict. A non-matching stamp is refused before the live layout is derived, so no operator cells are read under coordinates that may have shifted since export.- Raises:
OutboundStorageValidationError – When
spreadsheet_idis blank.OutboundStorageError – When Drive or Sheets rejects the request, the target is missing, quota is exhausted, or the workbook fails the app-owned marker gate.
- compute_from_pull(snapshot, pull)[source]¶
Run the local Decimal runtime against a
PullResult.Maps each edit family back to the runtime contract:
valueflows into runtimeinputs, withDecimal("0")substituted forNoneso the runtime’s “every non-computed casilla has a value” precondition holds.valueis routed by the binding’styped_enumdeclaration: numeric bindings flow intobinding_valuesas Decimals; enum bindings flow intoenum_binding_valuesas plain strings.valueflows intorelation_valuesas Decimals, withDecimal("0")substituted forNone.
Refuses to compute when the workbook’s metadata stamps do not match the supplied snapshot (
pull.metadata_match != "matches"). The caller is responsible for handling stale workbooks before invoking this helper.- Parameters:
snapshot (
RegistrySnapshot) – TheRegistrySnapshotthe workbook was compiled against. Used to derive input casilla identifiers, active relation periods, and the metadata-match gate.pull (
PullResult) – ThePullResultcarrying the operator-edited cells to compute from.
- Return type:
- Returns:
A
RegistryCalculationResultproduced bycalculate_registry_snapshot().- Raises:
OutboundStorageConflictError – When
pulldoes not bind tosnapshotby metadata verdict and registry-SHA stamp.