oficina / docs Public

Contracts: Fichas merge preview and native signing design open

On branch feat/contract-workflow

Paul asked to proceed with the Docs → Fichas mail merge → signature workflow and explicitly chose native signing in Oficina on 2026-10-25.

Design proposal committed as 0dd6259 on feat/contract-workflow: docs/superpowers/specs/2026-10-25-contract-workflow-design.md.

First milestone: one customer, one template, a personalised preview of the actual PDF. Proposed ownership: Docs holds templates and agreements; Fichas holds customer records and authorised references/status. Native signing follows with fixed issued bytes, named recipients, explicit consent, attributed evidence, and retry-safe transitions.

Verified baseline: live Fichas /api/version returned 7144092 (origin/design/rulings-2026-09-19); main is still design-only fab37e4. Live Docs returned v0.1.0-40-gce29703; design inspected fetched main c660212. Fichas still rejects suite shape. Source authorisation/producer routes and the Docs receipt/commit integration are missing. Public version checks are not authenticated workflow tests.

Independent GPT-6 review accepted this as a scoped discovery/design proposal, NOT implementation approval for issuance or signing. Four findings incorporated: release authority includes template and transitive sources; cross-app source-revocation races require a defined authoritative issuance point; seeing a card does not grant agreement/status access; actual-document review needs an accessible equivalent bound to its content.

The source-dependent draft → independently issued agreement boundary needs a suite amendment and must satisfy suite discussion 12's isolation requirement. Precise preview transport and document-field schema need separate concrete designs before implementation. API/CLI/MCP remains the user's separate workstream, with business operations shared later.

Validation: git diff --check; independent design review and source inspection. No application code changed, no runtime tests claimed, nothing deployed or merged. The proposal records unresolved dependencies explicitly.

Implementation checkpoint: 2f38033 (base incorporates main 29b6dea) adds the reviewed internal rendering foundation. The final scope of this branch is the workflow design plus bounded typed rendering, not the integrated Fichas/UI/signing milestone.

New internal/contract package: strict versioned template parsing, structural merge fields, typed text/date/integer-minor-unit money, literal substitution, preserved multiline values, stable bindings independent of labels, fresh resolved trees and PDF bytes with SHA-256. Unknown/contradictory structure or formatting, missing required values, glyph substitutions and layout overflow refuse with no partial artifact. ISO formatting only in v1. No live editor schema, HTTP route, storage, credential or signing capability is added.

Independent GPT-6 design review identified cumulative indentation overflow. Independent code review additionally identified quadratic shaping of unbroken runs. Both addressed: exporter overflow report; word/text/expanded-node limits; 100-page PDFBounded cap returning no truncated PDF. Final independent GPT-6 review approved the isolated foundation subject to remaining CI gates and independently ran the contract/export tests successfully.

Validation completed: focused contract/export tests; race-enabled contract tests; real PDF text extraction via Poppler; visual page inspection; overlay mutation disabling field substitution failed the intended contract-term assertion without touching the working tree. Longest permitted word in a 12pt column and single oversized glyph refusal are tested.

Full local gate passed Rust, bundle/wire checks and all Go packages except the release-binary test's macOS Unix-socket temporary-path limit. That test passed after setting a short TMPDIR. A subsequent full gate encountered an unchanged save-queue timer assertion (which passed in the first run); another full run with short TMPDIR is underway. Remote CI must pass for this exact head before any merge. No deployment has occurred.

Remaining product work: authoring/persistence and native compatibility, authenticated Fichas source transport and provenance, then the independently issued agreement boundary and native signing. Those are not represented as complete by this foundation.

Landed as 1f75224 after independent GPT-6 review and remote CI passed for 2f38033. The full local gate also passed using a short TMPDIR path for macOS Unix socket limits. Shared main is synced, existing NOTES.md preserved, and the feature worktree removed. This completes the isolated typed template renderer and PDF fidelity checks only. Template UI, Fichas handoff, issuance authority, and native signing remain unfinished; suite discussion #14 remains open.