oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1# Contracts: Docs templates, Fichas merge, native signing
2
3Status: **proposal, revision 1, 2026-10-25**. Author: GPT-6 / Codex.
4Not an implementation plan or an approved change to suite authority.
5Independent GPT-6 review accepted this as a scoped discovery/design
6proposal, with four clarifications incorporated below. This is not
7approval to implement issuance or native signing. No application code or
8deployed configuration is changed by this document.
9
10## 1. Outcome and authority
11
12Paul requested a contract authored in Docs, personalised from Fichas, and
13sent for signature. On 2026-10-25 Paul confirmed Fichas is live and asked
14to proceed; when asked about the signing implementation, he chose
15**native signing in Oficina**. The narrower implementation choices below
16are this session's proposals, not decisions attributed to Paul.
17
18The first usable milestone is one customer, one template, and a preview.
19The next is one agreement issued to one external signer and returned to
20the customer's card as completed. Batch issuance follows the working
21single-agreement lifecycle. Suite-wide API, CLI and MCP design remains a
22separate workstream; these operations must eventually be usable by those
23clients without recreating business logic in each transport.
24
25Canonical dependencies, read after fetching on 2026-10-25:
26
27| Source | Revision | Relevant boundary |
28|---|---|---|
29| Suite sharing doctrine | revision 8, `094de9c0733e908c944e958d852cc583f5b78ea5` | §4.1–4.3, §5, §7, §7.1, §11 gates 6b and 7 |
30| Docs | `c6602122601d2dcbfcc24ba9b625dda1852d22bc` on `origin/main` | existing editor, encrypted content, access checks, PDF export, Home bridge; Docs design §14 and §14a |
31| Fichas | `714409257562048ad97fb0fc0b4148acfcce9b4b` on `origin/design/rulings-2026-09-19` | card/field/entry implementation, record revisions, sealed values, standalone admission |
32| Suite producer proposal | `design/producer-protocol`, discussion [10](https://amadan.net/oficina/suite/discussions/10) | proposed producer integration; not an implemented service |
33| External sharing requirement | suite discussion [12](https://amadan.net/oficina/suite/discussions/12) | Paul’s document-scoped isolation requirement; architecture remains unresolved |
34
35Those doctrine sections are cited, not replaced by local paraphrases.
36No new sibling credential, private-item transfer, issuance permission or
37external-signing grant is authorised merely by this draft.
38
39## 2. Verified starting point
40
41The public Fichas `/api/version` returned `7144092`; the Docs endpoint
42returned `v0.1.0-40-gce29703`. These are endpoint observations, not an
43authenticated end-to-end test. Docs main is ahead of the observed release.
44Fichas main is still `fab37e4`, a design-only commit; the live code is on
45the branch above. Feature work must explicitly name its base and cannot
46silently treat that branch as main or merge unrelated work into main.
47
48Fichas has card types, configurable fields/layouts, customer records and
49entries. Its configuration still rejects `FICHAS_SHAPE=suite`. Its mounted
50routes do not implement S2/S3 or a contract handoff. Docs has PDF and
51Markdown export but no template fields, personalised preview, handoff
52receipt/commit, provenance enforcement, agreement store or signing flow.
53An app switcher or Home link is not evidence those integrations exist.
54
55## 3. Product flow
56
571. In Docs, mark a document as a template and insert named fields. Bind
58 customer fields using stable Fichas field keys, showing their labels.
59 Contract-specific inputs such as a start date are separate from CRM
60 fields. Changing a field label must not break a binding.
612. From a Fichas customer, choose **Prepare contract**, select a template,
62 and enter any contract-specific values. Selection exposes only templates
63 this person can use. Displaying their titles is itself an authorised read.
643. Docs shows the resolved contract, customer and template revisions,
65 unresolved fields and explicit formatting errors. A separate preview
66 renders the actual PDF bytes. A preview cannot send invitations.
674. Once issuance exists, the sender names the signer, reviews those same
68 bytes, and explicitly issues the agreement. A changed source requires a
69 new preview; issue must not silently re-merge against a newer source.
705. The signer verifies control of their named address, reads the issued
71 document, accepts the displayed signing consent, and confirms signing.
726. Fichas shows agreement status with a link to Docs. Completed document
73 and evidence are available to authorised participants from Docs.
74
75Prepare/preview is a useful release without issue/sign controls. The first
76release must not display a functioning-looking send button backed by a
77stub or ordinary public document link.
78
79## 4. Ownership and records
80
81**Proposal: Docs owns templates and agreements; Fichas owns customer
82records and references to agreements.** No new app is required for this
83first workflow. An agreement is not an editable Doc with a status flag.
84Its access paths, transitions and immutable payload are separate.
85
86Proposed records, not a migration prescription:
87
88- Template definition: document ID, schema version, field bindings and
89 signer-role anchors. Rendering pins the document content revision and
90 the binding revision together.
91- Preparation: owner/actor, customer reference and revision, template
92 reference and revision, selected values and manual inputs, locale,
93 renderer version, provenance, PDF bytes and digest, expiry. Seal content
94 and personal data under the receiving app's normal content protection.
95- Agreement: preparation reference, exact issued payload and digest,
96 issuer, named recipients/roles, issue timestamp and lifecycle state.
97- Agreement events: attributed transitions with server timestamps,
98 previous state/version, payload digest, and reasons where appropriate.
99- Signing evidence: agreement/payload identity, recipient identity,
100 verification method and time, consent text/version and affirmative
101 action. It must identify what was signed without storing bearer secrets.
102- Delivery outbox: invitation/completion jobs with stable deduplication
103 keys, retry state and delivery outcomes. Delivery is not signing.
104- Fichas reference: Docs instance and agreement ID. Any status projection
105 identifies its last observed revision/time and reports unavailable or
106 stale status honestly. It holds no duplicate PDF.
107
108Reference visibility and status retrieval require agreement access, not
109just access to the customer card. Recipients, agreement titles and state
110must not leak to another card reader. Recheck after team departure or
111participant revocation; an obsolete projection cannot preserve access.
112
113Preparation retention is proposed at 24 hours, to let a sender return the
114next day without making abandoned drafts a permanent copy. Reauthorise
115each access; expiry is not permission to serve a revoked source. Purge
116expired payloads on reads and in scheduled maintenance. Define the backup
117retirement bound before deploying this storage. Issued-record retention,
118withdrawal and deletion are separate decisions required before issuance;
119do not inherit temporary-preparation expiry for signed records.
120
121## 5. Template and rendering contract
122
123Use explicit inline field nodes in the document schema, not global string
124replacement on HTML or a PDF. Field IDs are stable; labels are editable.
125Fields cannot execute expressions, fetch URLs or recursively expand
126values that happen to contain field syntax. Rendering treats values as
127text. Rich-text content is not accepted as a customer field in this slice.
128
129Start with text, date and integer-minor-unit money inputs with an explicit
130currency. Preserve numeric zero; distinguish missing from an empty value.
131Required missing values, removed fields, incompatible types and unsupported
132formatting block successful preview. Optional fields have explicit empty
133behaviour. Date-only values never pass through a timezone conversion.
134Locale and currency are selected once and included in the preparation.
135No conditions, repeating tables or formulas in the first slice.
136
137Preview produces a new resolved representation and leaves the original
138template unchanged. The existing PDF exporter is the initial renderer,
139subject to tests for the supported document subset. Unsupported node
140types and missing glyph substitutions must be visible blocking errors for
141issuance; the existing export route's log-only warning is insufficient.
142
143Persist the PDF being reviewed. Issue freezes those bytes; completion
144preserves them and attaches evidence, rather than regenerating the original
145from a changed renderer/template. If a completion PDF adds a signature
146page, it is a separate derivative with both original and final digests.
147This draft does not claim a PDF certificate signature or any particular
148legal assurance level.
149
150## 6. Cross-app preparation prerequisites
151
152The live standalone instances do not yet satisfy the suite integration
153needed for this workflow. Reuse the Home identity/membership contracts and
154the suite's producer/handoff designs; do not derive trust from matching
155email strings, the shared DNS suffix, or an unrestricted service token.
156
157Before preview is enabled for real customer records, the implementation
158must demonstrate all of the following against the actual app middleware:
159
160- A named identity and membership recognised by both apps, with the
161 configured instances belonging to the same authorised team.
162- The Fichas source authorises the precise record/revision and selected
163 values for the relevant operation. An unavailable source cannot become
164 an empty but apparently successful merge.
165- Docs authorises template use and the resulting preparation. Customer
166 visibility and template visibility are independent checks.
167- A concrete transport for the selected data and provenance that satisfies
168 the cited suite sections, including receipt/commit and sign-in resume.
169 S2 alone is not a data-transfer grant, and the current S3 scope must not
170 be widened to private records for convenience.
171- Source revisions and content are read consistently. Receipt stores
172 bounded, expiring pending state; commit is bound to the same authenticated
173 browser/person and to the exact server-held payload.
174- Every preparation disclosure, including PDF/thumbnail/download and
175 resumed tabs, enforces the source rules. No anonymous preview links.
176
177Choosing the precise source transport is gated on the missing producer and
178identity integration; a naked cross-origin form carrying customer values
179is not a substitute. This proposal therefore does not invent routes or
180declare an implementation-ready wire protocol before those dependencies
181are resolved. A local renderer fixture is useful development work but
182does not pass the integrated-preview milestone.
183
184## 7. Native issuance: required suite decision
185
186The proposed new boundary is **explicit issuance of an independent
187agreement**, distinct from a source-dependent preparation. Once issued,
188editing or deleting a customer card must not mutate the bytes a recipient
189was asked to sign. A participant's access to the issued agreement must not
190require access to CRM notes or the source template.
191
192This needs a reviewed extension to the suite doctrine, specifically §7,
193and must satisfy the external-isolation requirement in suite discussion
19412. The proposal is:
195
196- Require an explicit, auditable authority to issue the template body,
197 selected customer values and every transitive source in their provenance.
198 Permission merely to read or internally use them is not permission to release them
199 independently. The first implementation may restrict issue to owners,
200 but must define what ownership means in both apps and verify it there.
201- Record the approved source revisions, fields, payload digest and named
202 recipients at the issuance boundary. A source change or loss of authority
203 before issuance invalidates preparation and demands a fresh review.
204- Issuance creates recipient-scoped access to this agreement only, hosted
205 by its owning Docs instance. It does not grant team membership, general
206 Docs access, or access to the original customer/template.
207- Subsequent source changes do not invalidate this separately authorised
208 record. Agreement withdrawal, participant access revocation and retention
209 are explicit lifecycle actions, not accidental consequences of editing
210 unrelated records.
211
212These are proposed product semantics, not an exception this app can apply
213unilaterally. **No send/sign implementation may ship before the suite
214extension and the external-isolation design are reviewed.** Merely adding
215a database permission flag does not fulfil discussion 12.
216
217The suite design must define the authoritative issuance point and the
218semantics of a concurrent source update/revocation. Revalidation in one
219app followed by a local transaction in another is not atomic cross-app
220authorisation. Define whether the source supplies a bounded, irrevocable
221release authorisation or a coordinated commit mechanism, including crash,
222timeout and retry behaviour, before prescribing an implementation.
223
224## 8. Signing lifecycle and reliability
225
226First-release proposal: one issuer, one named external signer, one fixed
227document. Email verification identifies control of an address; it is not
228represented as proof of corporate signing authority. Signing is a separate
229affirmative action after verification and document review. Opening an
230email link, a scanner fetch, or rendering a page never signs anything.
231
232Proposed agreement states: `issued`, `completed`, `declined`, `voided`,
233`expired`. Preparations have their own lifecycle. Invitation delivery
234status is independent, so a failed email cannot be mistaken for an
235unissued agreement or a completed one. A completed agreement cannot be
236rewritten or reopened; corrections require a new agreement with a link to
237the previous one. Countersigning and signing order are later slices.
238
239Issue commits an immutable payload, recipient set and delivery outbox job
240atomically. Its idempotency key is scoped to actor and operation and bound
241to the request digest; reuse with different input is a conflict. Network
242retries return the existing result. Delivery retries reuse the invitation
243job; no claim of exactly-once email transport.
244
245Sign/decline/void/expire use a conditional state/version transition. A
246concurrent terminal action has one winner; signature, evidence and state
247commit together. Confirmation binds the recipient and exact payload
248digest; it must fail after withdrawal or expiry. Tokens are expiring,
249purpose-bound and stored only as hashes. Invitation and verified session
250secrets are redacted from logs and referrers. Signing-session and document
251access rules require their own adversarial design review before code.
252
253## 9. Acceptance evidence and sequencing
254
255This is a dependency order for design, not an approved implementation plan.
256
257| Milestone | Evidence required |
258|---|---|
259| Template fields | field nodes survive editing/save/reload; rename preserves binding; missing/type errors are actionable; literal markup remains text; source template unchanged |
260| Integrated preview | real Fichas record through the agreed identity/producer/handoff path; real Docs template; actual PDF; sign-in resume; revoked access, wrong team, replay and expired pending state refused; no customer values in URLs/logs |
261| Issue | suite boundary approved; exact reviewed PDF and source revisions frozen; revalidation failures refuse; double-click/retry yields one agreement; outbox survives restart |
262| Sign | verified named recipient; affirmative consent bound to original digest; scanners do nothing; concurrent sign/void safe; recipient cannot enumerate or access unrelated content |
263| Completion | immutable original and evidence retrievable by intended participants; Fichas link/status correct; outages show stale/unavailable; storage/backup and deletion rules tested |
264
265Browser coverage must include JavaScript disabled for preparation forms,
266handoff confirmation and signing, keyboard navigation, and narrow-screen
267review. Native field-node editing/rendering compatibility must be resolved
268before enabling template editing in clients that cannot preserve the new
269schema. Never silently drop fields in an older client or an export.
270
271The review/signing design must also provide an accessible reading path
272for the exact issued content. Keyboard access to a PDF viewer alone is not
273sufficient: specify reading order and assistive-technology support, and
274how any alternative representation is bound to the reviewed PDF so it
275cannot present different contract terms.
276
277Useful independent implementation work after design review is the typed
278field/renderer layer. The integrated milestone still depends on real
279source authorisation and handoff; unit tests and simulated signing cannot
280be reported as the completed workflow.
281
282## 10. Next design outputs
283
2841. Resolve the suite boundary for independently issued agreements,
285 alongside discussion 12's required isolation mechanism and explicit
286 issued-record retention/access policy.
2872. Specify the authenticated Fichas-to-Docs preview transport against the
288 actual Home and producer implementations. State what source rungs the
289 first release supports; do not claim all cards/templates by default.
2903. Review a concrete document-field schema and rendering compatibility
291 design, then produce the implementation plan for the preview slice.
2924. Review the recipient identity, consent and evidence design before
293 shipping native signing. Keep the wider API/CLI/MCP work separate.
294
295## 11. Independent review record
296
297GPT-6 / Codex, separate `contract_design_review` agent, 2026-10-25:
298acceptable as a scoped discovery/design proposal, not approval to implement
299issuance or signing. No blocking factual error found in inspected fetched
300refs. Clarifications incorporated: issuance authority includes template and
301transitive sources; cross-app revocation race needs an authoritative commit
302boundary; card visibility does not grant agreement-status visibility; PDF
303review needs an accessible equivalent tied to the issued content. The
304reviewer did not repeat live endpoint or discussion-12 checks; those remain
305author-session observations.
306
307## 12. Implementation progress, 2026-10-26
308
309Paul asked to proceed. The first implemented unit is the bounded internal
310template renderer specified in `2026-10-26-contract-rendering-design.md`:
311structural fields, typed values, exact integer money, strict validation,
312PDF fidelity checks, byte/digest output and resource limits. Its independent
313GPT-6 code review approved that scope subject to repository gates.
314
315This is not a user-facing template editor or the integrated Fichas preview.
316The live editor schema remains unchanged to avoid dropping fields in older
317native clients. Source authorisation, handoff, preparation persistence,
318authoring UI and native signing are still required. The first renderer uses
319explicit ISO formatting; locale-specific formatting is not yet supported.
320