Skip to main content

Product · advanced — a legal service

The case. Open a company, then, optionally, subscribe to its accounting. Or subscribe to accounting alone, for a company that already exists.

What the example shows. An item that is a filled-in request, not a product: the guard (form → eligibility → quote) is the service. Two journeys share a skill. Accounting reads the result of the company opening in the same submit.

product-advanced.yaml
# Product · advanced — a legal service: open a company, then (optionally) its accounting.
# The item is a FILLED REQUEST, not a product: the select guard (form → eligibility → quote) is the
# product. Two journeys share one skill; the accounting reads the company the formation opened.
station:
id: statuts-express
name: Statuts Express

global:
language: fr
currency: EUR
locale: fr-FR

domain:
domain_type: legaltech
entity_name: service
entity_name_plural: services

voice:
tone: professional
persona: "un assistant juridique précis qui accompagne les fondateurs"
rules:
- "Ne jamais donner de conseil juridique contraignant : présenter les options, laisser les outils valider et tarifer."
- "Citer le nom et le prix exacts renvoyés par les outils, en euros."

apis:
- name: juridique
openapi_url: https://api.statuts-express.example.fr/openapi.json
base_url: https://api.statuts-express.example.fr
operations:
- {id: recommendLegalStructure, access: read}
- {id: checkFormationEligibility, access: read}
- {id: quoteFormation, access: read}
- {id: openFormationDossier, access: write, reversible: false}
- {id: getAccountingPlans, access: read}
- {id: checkAccountingEligibility, access: read}
- {id: quoteAccounting, access: read}
- {id: subscribeAccounting, access: write, reversible: cancelSubscription}
- {id: cancelSubscription, access: write}
auth: {type: api_key, key_name: Authorization, key_location: header, key_env: STATUTS_KEY}

profiles:
tous:
when: "true"
grants:
- juridique.recommendLegalStructure
- juridique.checkFormationEligibility
- juridique.quoteFormation
- juridique.openFormationDossier
- juridique.getAccountingPlans
- juridique.checkAccountingEligibility
- juridique.quoteAccounting
- juridique.subscribeAccounting

skills:
- name: formation
cognitive:
objective: "recommander la structure juridique adaptée au projet"
diagnose: [l'activité, le nombre d'associés, le capital]
invoke: {method: recommendLegalStructure}
kinds: {company_formation: {}}
present:
fields:
name: {from: label, type: text, role: title}
price: {from: base_fee, type: price, role: billed}
select:
max_items: 1 # one company is being formed
guards:
- form:
activity: {type: text, required: true, label: "Activité de la société"}
capital: {type: number, required: true, label: "Capital social (€)"}
associates: {type: integer, required: true, label: "Nombre d'associés"}
hq_address: {type: text, required: true, label: "Adresse du siège"}
- check: checkFormationEligibility # the tenant says whether this structure fits
- update: {price: quoteFormation} # …and what it costs for THIS request
submit:
- name: open
mode: request
tool: openFormationDossier
args:
body.structure: "$item.fields.code"
body.activity: "$item.fields.activity"
body.capital: "$item.fields.capital"
body.associates: "$item.fields.associates"
body.hq_address: "$item.fields.hq_address"
body.fee: "$item.price"
body.idempotency_key: "$action.key"
output: {company_id: {from: "$output.company_id", type: id}}

render: {component: cards}
- name: accounting
cognitive:
objective: "recommander le plan de comptabilité adapté au chiffre d'affaires"
diagnose: [le chiffre d'affaires estimé, la structure choisie]
invoke: {method: getAccountingPlans}
kinds: {accounting_subscription: {}}
present:
fields:
name: {from: label, type: text, role: title}
price: {from: price, type: price, role: billed}
cadence: {from: cadence, type: text, role: cadence} # monthly: how often the plan is billed
select:
max_items: 1
guards:
- form:
est_revenue: {type: number, required: true, label: "Chiffre d'affaires estimé (€)"}
siren: {type: text, required: false, label: "SIREN (société existante)"}
- check: checkAccountingEligibility
- update: {price: quoteAccounting}
submit:
- name: subscribe
mode: request
tool: subscribeAccounting
args:
body.plan: "$item.fields.code"
body.est_revenue: "$item.fields.est_revenue"
body.siren: "$item.fields.siren"
# Value at submit (ADR-028 §3): filed AFTER the formation, in the same submit, and held
# if the formation failed. Alone, it resolves empty and the SIREN names the company. The
# tenant's operation requires one of the two (`anyOf` in its schema): with neither, the
# call is held, never sent (`submit.held_missing`).
body.company_id: "$submitted[formation.open].company_id"
body.fee: "$item.price"
body.fee_cadence: "$item.price_cadence"
render: {component: cards}

playbooks:
- name: open-company
goal: "ouvrir une société : la structure, puis (option) la comptabilité"
activation: {when: "true"}
tasks:
formation: {skill: formation, required: true, label: "Votre société"}
accounting: {skill: accounting, required: false, label: "Votre comptabilité", after: [formation]}
- name: subscribe-accounting
goal: "souscrire la comptabilité d'une société existante (SIREN)"
tasks:
accounting: {skill: accounting, required: true, label: "Votre comptabilité"}

submit_guard:
form:
accept_terms: {type: boolean, required: true, label: "J'accepte les conditions générales"}
confirm: true

What happens​

stepCoreresult
"I'm creating an SAS with one partner"formation → recommendLegalStructure; a read opens no journeycards for the structures
an accounting plan chosen first, with no journey openfirst_write: accounting is a task of open-company (which declares activation) and of subscribe-accountingadded outside any flow, its notice naming both: "… belongs to several flows (open-company, subscribe-accounting) — it was chosen outside them; start the one meant to follow its steps"
SAS chosenfirst_write: open-company, the only candidate, opens; then form (activity, capital, partners, head office), checkFormationEligibility, quoteFormation"open-company is now open"; the line enters with its own price
an accounting plan chosenstep_open: after: [formation] holds; form, eligibility, quotesecond line, monthly price
"Finalise"accept_terms + confirmopenFormationDossier, then subscribeAccounting with company_id
the opening failsthe next call depends on itaccounting is put on hold, never filed on a missing company
"I already have a SARL, SIREN 812…"the agent calls start_playbook: subscribe-accountingcompany_id empty, the SIREN is used
an accounting plan chosen alone, with no SIRENthe operation requires the SIREN or the company_id (anyOf); neither is giventhe call is held, never sent: it needs "SIREN (société existante)" or "Votre société" (submit.held_missing)

Key points​

  • $submitted[formation.open].company_id is a dependency at execution time: same submit, in order, and nothing is filed if the parent failed.
  • subscribeAccounting requires the SIREN or the company_id: its schema says so (anyOf), and Core holds the call that has neither (What the operation requires).
  • The price comes from the tenant, for this request: update: {price: quoteFormation}, passed on by body.fee.
  • The accounting plan is billed monthly: the role: cadence field says so, beside the billed price, and $item.price_cadence passes it on (body.fee_cadence). Without that field, every price is charged once.
  • openFormationDossier is declared reversible: false: the MCP door announces the submit as destructive. subscribeAccounting names the operation that undoes it (cancelSubscription); nothing calls it yet.
  • In open-company, after: [formation] enforces the order at the choice: accounting opens only once the company is chosen. The target version makes the opening a sub-playbook.