feat(fleet): official-document drafting skill — bilingual contracts/amendments, checklist-enforced, billing-linked (T18) #67

Open
opened 2026-07-15 19:56:00 +02:00 by arcodange · 2 comments
Owner

Operator ask 2026-07-15: « un skill/agent capable de préparer ce genre de document officiel, en lien avec les services facturés ensuite dans Dolibarr ». Founding example: the KM bilingual signature set produced the same day (kissmetrics_contract_proposal, branch bilingual-signature-set) and the cohort-review checklist corpus (billing_ops/actions_48h/facture_mentions_obligatoires.md + the 16-article amendment).

What the skill does (fleet class: Analyst-writer, with a Deterministic-controller sidekick):

  1. Draft official documents (contrat cadre, avenant, addendum, attestation, courrier légal) as bilingual FR/EN signable markdown (the house table.bil format, French prevailing), from: the client dossier (vault 01-Projects/Clients/<client>/), the ERP thirdparty record (now editable — #65), the fiscal profile (#54), and the house identity block.
  2. Checklist-enforced, deterministically (code, not prompt): parties block complete (SARL, capital 1 000 €, SIREN/SIRET, RCS Évry, TVA FR00…, gérant not Président), eIDAS + arts. 1366-1367 clause, prevailing-language article, L.441-10 penalties where money is involved, signature blocks with correct titles, FR↔EN numeric-token parity per article (the drift-check pattern proven on the KM set), no dead placeholders except explicitly flagged ones (e.g. Launch date).
  3. Billing linkage: each contract's economic clauses map to Dolibarr objects — thirdparty (#65 phase 1 ), contract + services (#65 phase 2), products, then T05 invoicing reads THE CONTRACT (not a template): amounts, currency, cycle, due-date rules. One source of truth, ERP as book of record.
  4. E-signature dispatch via the selected tool's API (leaning Yousign — operator decision in progress; API v3, EU/FR, SES/AES levels): creating + sending an envelope is an outbound action → human-gated approval card, never autonomous. Post-signature: signed PDF archived (GED attach — #43) + contract recorded (#65 phase 2) + vault note deposited (T17).

QA: the deterministic checklist linter blocks non-conform drafts; an independent context-free verifier does the FR↔EN drift pass before any document is presented for signature (no self-grading — same doctrine as the fleet's write path).

Acceptance: the KM set re-produced by the skill byte-comparable on the checklist dimensions; one NEW document (e.g. the W-8BEN-E cover letter or a Darnis avenant) drafted → linted → verified → operator-approved end-to-end; SKILL.md with Use-when/SKIP-for; catalog row added (T18) with 🧪 status.


Execution — Blocked by: #65 phase 2 (contract objects in Dolibarr) for the billing linkage; the e-sign tool decision for step 4 (steps 1–2 unblocked) · Blocks: scaling beyond KM (prospection Mode B conversions will need contracts) · Human gates: every signature dispatch; tool account creation.
Start: claude --worktree official-doc-skill from the erp repo root; read the KM bilingual set + facture_mentions_obligatoires.md first; the FR/EN drift-checker from the bilingual PR is the seed of the linter.
Done means: evidence comment here (linter output on the KM set + the new document's full trail) → PR merged with Closes #67 → PRD catalog/task-inventory updated in a paired factory PR.

Operator ask 2026-07-15: *« un skill/agent capable de préparer ce genre de document officiel, en lien avec les services facturés ensuite dans Dolibarr »*. Founding example: the KM bilingual signature set produced the same day (kissmetrics_contract_proposal, branch `bilingual-signature-set`) and the cohort-review checklist corpus (`billing_ops/actions_48h/facture_mentions_obligatoires.md` + the 16-article amendment). **What the skill does** (fleet class: Analyst-writer, with a Deterministic-controller sidekick): 1. **Draft** official documents (contrat cadre, avenant, addendum, attestation, courrier légal) as **bilingual FR/EN signable markdown** (the house `table.bil` format, French prevailing), from: the client dossier (vault `01-Projects/Clients/<client>/`), the ERP thirdparty record (now editable — #65), the fiscal profile (#54), and the house identity block. 2. **Checklist-enforced, deterministically** (code, not prompt): parties block complete (SARL, capital 1 000 €, SIREN/SIRET, RCS Évry, TVA FR00…, **gérant** not Président), eIDAS + arts. 1366-1367 clause, prevailing-language article, L.441-10 penalties where money is involved, signature blocks with correct titles, FR↔EN numeric-token parity per article (the drift-check pattern proven on the KM set), no dead placeholders except explicitly flagged ones (e.g. Launch date). 3. **Billing linkage**: each contract's economic clauses map to Dolibarr objects — thirdparty (#65 phase 1 ✅), contract + services (#65 phase 2), products, then T05 invoicing reads THE CONTRACT (not a template): amounts, currency, cycle, due-date rules. One source of truth, ERP as book of record. 4. **E-signature dispatch** via the selected tool's API (leaning **Yousign** — operator decision in progress; API v3, EU/FR, SES/AES levels): creating + sending an envelope is an **outbound action → human-gated approval card**, never autonomous. Post-signature: signed PDF archived (GED attach — #43) + contract recorded (#65 phase 2) + vault note deposited (T17). **QA:** the deterministic checklist linter blocks non-conform drafts; an **independent context-free verifier** does the FR↔EN drift pass before any document is presented for signature (no self-grading — same doctrine as the fleet's write path). **Acceptance:** the KM set re-produced by the skill byte-comparable on the checklist dimensions; one NEW document (e.g. the W-8BEN-E cover letter or a Darnis avenant) drafted → linted → verified → operator-approved end-to-end; SKILL.md with Use-when/SKIP-for; catalog row added (T18) with 🧪 status. --- **Execution** — Blocked by: #65 phase 2 (contract objects in Dolibarr) for the billing linkage; the e-sign tool decision for step 4 (steps 1–2 unblocked) · Blocks: scaling beyond KM (prospection Mode B conversions will need contracts) · Human gates: every signature dispatch; tool account creation. **Start:** `claude --worktree official-doc-skill` from the erp repo root; read the KM bilingual set + `facture_mentions_obligatoires.md` first; the FR/EN drift-checker from the bilingual PR is the seed of the linter. **Done means:** evidence comment here (linter output on the KM set + the new document's full trail) → PR merged with `Closes #67` → PRD catalog/task-inventory updated in a paired factory PR.
arcodange added this to the P4 — Money loops milestone 2026-07-15 19:56:00 +02:00
Author
Owner

The render + dispatch halves of this skill now EXIST and are proven — built in kissmetrics_contract_proposal (PRs #2 + #3, merged 2026-07-15/16). Lift them into the skill when this issue starts.

  • Re-executable pipeline scripts/build-pdfs.sh: markdown (bilingual table.bil or plain) → official PDFs in billing_ops/signature/dist/ + MANIFEST.txt (git rev, sha256-src / sha256-pdf / sha256-text — the stable fingerprint, since Chromium embeds CreationDate; documented). GED-ready provenance.
  • Gated e-sign dispatch scripts/yousign-envelope.sh (Yousign API v3): create request → upload PDF → 2 signers with fields on the auto-detected last page → STOPS IN DRAFT; activation double-gated (--activate + YOUSIGN_CONFIRM=I-UNDERSTAND-THIS-SENDS-FOR-SIGNATURE — the dol-prod-write pattern). Sandbox-proven 2026-07-16 with the trial token: request bc543f95… created, document uploaded, signers added, nothing sent. Known caveat: signature-field x/y are calculated placeholders — visual check in the Yousign app before first real send.
  • The QA loop this skill must inherit (proven twice on the amendment): drafter ≠ verifier — the independent context-free FR↔EN legal-drift pass caught a real BLOCKER in the drafter's own new text (defined-term bifurcation « Launch »/« Lancement » in the prevailing language) plus exigibility and trigger seams; all fixed pre-merge. The deterministic checks (numeric-token parity with locale normalization — space/comma thousands, decimal comma/point, ISO-vs-long dates — isolation diff, manifest coherence, rendered-text spot-checks) are scripted in the PR bodies and ready to lift as the linter.
  • Operator-side token convention: trial key lives at erp test/.env as YOUSIGN_SND_TOKEN (gitignored, verified); the script's canonical env is YOUSIGN_API_KEY — bridge at invocation.
**The render + dispatch halves of this skill now EXIST and are proven — built in `kissmetrics_contract_proposal` (PRs [#2](https://gitea.arcodange.lab/arcodange-org/kissmetrics_contract_proposal/pulls/2) + [#3](https://gitea.arcodange.lab/arcodange-org/kissmetrics_contract_proposal/pulls/3), merged 2026-07-15/16). Lift them into the skill when this issue starts.** - **Re-executable pipeline** `scripts/build-pdfs.sh`: markdown (bilingual `table.bil` or plain) → official PDFs in `billing_ops/signature/dist/` + `MANIFEST.txt` (git rev, sha256-src / sha256-pdf / **sha256-text** — the stable fingerprint, since Chromium embeds CreationDate; documented). GED-ready provenance. - **Gated e-sign dispatch** `scripts/yousign-envelope.sh` (Yousign **API v3**): create request → upload PDF → 2 signers with fields on the auto-detected last page → **STOPS IN DRAFT**; activation double-gated (`--activate` + `YOUSIGN_CONFIRM=I-UNDERSTAND-THIS-SENDS-FOR-SIGNATURE` — the dol-prod-write pattern). **Sandbox-proven 2026-07-16** with the trial token: request `bc543f95…` created, document uploaded, signers added, nothing sent. Known caveat: signature-field x/y are calculated placeholders — visual check in the Yousign app before first real send. - **The QA loop this skill must inherit** (proven twice on the amendment): drafter ≠ verifier — the independent context-free FR↔EN legal-drift pass caught a real BLOCKER in the drafter's own new text (defined-term bifurcation « Launch »/« Lancement » in the prevailing language) plus exigibility and trigger seams; all fixed pre-merge. The deterministic checks (numeric-token parity with locale normalization — space/comma thousands, decimal comma/point, ISO-vs-long dates — isolation diff, manifest coherence, rendered-text spot-checks) are scripted in the PR bodies and ready to lift as the linter. - Operator-side token convention: trial key lives at erp `test/.env` as `YOUSIGN_SND_TOKEN` (gitignored, verified); the script's canonical env is `YOUSIGN_API_KEY` — bridge at invocation.
Author
Owner

Automation decisions for the dispatch half (operator direction 2026-07-16: « avoir tout cela automatisé — agents autonomes ») — proven in kissmetrics_contract_proposal PR #4, merged:

  1. Field placement is now ANCHOR-RESOLVED, not calibrated: scripts/pdf-anchors.py reads the PDF's own text layer (pdftotext -bbox-layout) — signature fields land on the table.sig "Signature" cells (left=counterparty, right=Arcodange), fill-in blanks are located by their labels, wrap-tolerant (same line or next line of the same column; last page excluded — the sig table has its own underscore runs). Repagination-proof; zero hand-tuned coordinates. Proven live: multi-doc sandbox draft b794d6ed… (contrat p4 + amendment p11, 2 launch blanks auto-found).
  2. Multi-document envelopes: --pdf repeatable — one signature request carries the whole signable set (one signing journey for the counterparty).
  3. Fill-at-signing data: --launch-date <ISO> pre-fills the contract's « Date de Lancement » blanks as read-only mention fields (both columns, one language-neutral string). Pattern generalizes to any labelled blank.
  4. Notifications: polling + email, NO webhook in v1. Yousign already emails the requester at every lifecycle step (human channel covered); agent-side, a GET /signature_requests/{id} status check joins the fleet's polling/digest cadence (T01-style) — minutes of latency, nothing downstream needs seconds. A webhook would require a public endpoint (tunnel, auth, replay protection) — new attack surface for zero business value at current volume ([challenges C9] posture). Revisit when signature volume justifies it.
  5. Layout rule learned: h1–h3 { break-after: avoid-page } in the print CSS — orphaned headings are the failure mode of page-break-inside: avoid on table rows.
**Automation decisions for the dispatch half (operator direction 2026-07-16: « avoir tout cela automatisé — agents autonomes ») — proven in `kissmetrics_contract_proposal` PR #4, merged:** 1. **Field placement is now ANCHOR-RESOLVED, not calibrated**: `scripts/pdf-anchors.py` reads the PDF's own text layer (`pdftotext -bbox-layout`) — signature fields land on the `table.sig` "Signature" cells (left=counterparty, right=Arcodange), fill-in blanks are located by their labels, wrap-tolerant (same line or next line of the same column; last page excluded — the sig table has its own underscore runs). Repagination-proof; zero hand-tuned coordinates. Proven live: multi-doc sandbox draft `b794d6ed…` (contrat p4 + amendment p11, 2 launch blanks auto-found). 2. **Multi-document envelopes**: `--pdf` repeatable — one signature request carries the whole signable set (one signing journey for the counterparty). 3. **Fill-at-signing data**: `--launch-date <ISO>` pre-fills the contract's « Date de Lancement » blanks as read-only *mention* fields (both columns, one language-neutral string). Pattern generalizes to any labelled blank. 4. **Notifications: polling + email, NO webhook in v1.** Yousign already emails the requester at every lifecycle step (human channel covered); agent-side, a `GET /signature_requests/{id}` status check joins the fleet's polling/digest cadence (T01-style) — minutes of latency, nothing downstream needs seconds. A webhook would require a public endpoint (tunnel, auth, replay protection) — new attack surface for zero business value at current volume ([challenges C9] posture). Revisit when signature volume justifies it. 5. Layout rule learned: `h1–h3 { break-after: avoid-page }` in the print CSS — orphaned headings are the failure mode of `page-break-inside: avoid` on table rows.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: arcodange-org/erp#67