aeat.application.storage.calc_sheets._workbook_export module

Offline XLSX materializer for SheetExportPlan records.

This module serializes the shared workbook plan into operator-directed plaintext export bytes: an XLSX workbook and an adjacent machine-readable JSON evidence sidecar. It returns bytes and digests to the caller; it does not choose paths, persist secure-object state, or make the export file canonical.

See also

SheetExportPlan

Renderer-neutral workbook contract emitted by the calc-sheets engine.

SheetEvidenceFacet

Evidence facet rendered into the Evidencia tab and JSON sidecar.

class OfflineWorkbookEvidenceSidecar(**data)[source]

Bases: BaseModel

Machine-readable evidence sidecar emitted beside an offline workbook.

The sidecar binds SheetExportMetadata, the workbook SHA-256, and SheetEvidenceFacet so external review can inspect the fact basis without parsing XLSX cells.

Parameters:
schema_version: Literal['calc-sheets-evidence-sidecar/v1']
metadata: SheetExportMetadata
workbook_sha256: str
evidence: SheetEvidenceFacet
class OfflineWorkbookExportResult(**data)[source]

Bases: BaseModel

Serialized offline workbook plus its machine-readable evidence sidecar.

The payloads are operator-directed export bytes. Callers decide where to write them and remain responsible for protecting the plaintext files after export.

Parameters:
  • workbook_payload (bytes)

  • workbook_media_type (Literal['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])

  • workbook_filename_extension (Literal['xlsx'])

  • workbook_sha256 (str)

  • evidence_sidecar_payload (bytes)

  • evidence_sidecar_media_type (Literal['application/json'])

  • evidence_sidecar_filename_extension (Literal['evidence.json'])

  • evidence_sidecar_sha256 (str)

workbook_payload: bytes
workbook_media_type: Literal['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
workbook_filename_extension: Literal['xlsx']
workbook_sha256: str
evidence_sidecar_payload: bytes
evidence_sidecar_media_type: Literal['application/json']
evidence_sidecar_filename_extension: Literal['evidence.json']
evidence_sidecar_sha256: str
evidence_table(plan)[source]

Return (snapshot_fingerprint, header_row, body_rows) for the Evidencia surface.

The single source of truth both transports render: the offline openpyxl workbook and the online Google-Sheets apply adapter consume this so the Evidencia surface is byte-identical across offline and online exports (modelo-export-evidence-parity ADR). Every cell is a string — contributor facts are pre-formatted by the same helpers _write_evidence uses.

Return type:

tuple[str, tuple[str, ...], tuple[tuple[str, ...], ...]]

Parameters:

plan (SheetExportPlan)

build_offline_workbook(plan)[source]

Materialise a SheetExportPlan as an offline openpyxl workbook.

Return type:

Workbook

Parameters:

plan (SheetExportPlan)

build_evidence_sidecar(plan, *, workbook_sha256)[source]

Build the machine-readable evidence sidecar for one workbook export.

The sidecar is keyed to the workbook payload digest, so a reviewer can pair the JSON evidence with the exact XLSX bytes produced by serialize_offline_workbook().

Returns:

The evidence sidecar.

Return type:

OfflineWorkbookEvidenceSidecar

Parameters:
serialize_evidence_sidecar(sidecar)[source]

Serialize an evidence sidecar as canonical UTF-8 JSON bytes.

Return type:

bytes

Parameters:

sidecar (OfflineWorkbookEvidenceSidecar)

serialize_offline_workbook(plan)[source]

Serialize an offline workbook plan to XLSX bytes.

Return type:

bytes

Parameters:

plan (SheetExportPlan)

serialize_offline_export(plan)[source]

Serialize an offline workbook and its adjacent evidence sidecar.

The return value is a pure byte payload plus integrity metadata. No file is written here; this keeps the plaintext-export exception at the caller’s explicit output path boundary.

Returns:

The export result.

Return type:

OfflineWorkbookExportResult

Parameters:

plan (SheetExportPlan)