ErrorsProject layout and modules · rule
visibility.private_cross_domain
Code in one domain uses an action, type or other declaration that another domain keeps private, because it isn't marked public.
Area 1, Project layout and modules; not declinable; the next step is usually the human's.
Why Jadpo refuses it
A domain is the boundary of what other code can see. Everything in it is
private unless it is marked public, so a domain can change its private
code without breaking another domain. A public action is how other
domains change its data; anything else stays its own.
Jadpo won't mark the declaration public for you. Making it public is
the owning domain's promise to keep offering it to every other domain.
What it looks like
domains/inventory/actions/reserve_stock.jadpo:
use shared/types { Quantity }action reserve_stock(quantity: Quantity) -> Unit {}
domains/ordering/actions/checkout.jadpo:
use shared/types { Quantity }use inventoryaction checkout(quantity: Quantity) -> Unit { inventory.reserve_stock(quantity)}
error reserve_stock is private to domain inventory
--> domains/ordering/actions/checkout.jadpo:5:15
|5 | inventory.reserve_stock(quantity) | ^^^^^^^^^^^^^ private
- reason
- Another domain may use only what a domain marks
public;reserve_stockis an action indomains/inventory/actions/reserve_stock.jadpo. - next
- Mark
reserve_stockpublicifinventoryshould offer it to other domains (human) - rule
- visibility.
private_ cross_ domain - help
- https://jadpo.
dev/docs/errors/visibility. private_ cross_ domain
(human) at the end of the next: line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides whether inventory offers reserve_stock to other domains.
A fixture is private to its domain too. Another domain's tests call it
only when it is public:
domains/reminders/actions/send_reminders.test.jadpo:
use planningtest "reminders start from planning's open todos" { send_reminders() assert planning.two_open_todos() == 2}
error two_open_todos is private to domain planning
--> domains/reminders/actions/send_reminders.test.jadpo:5:21
|5 | assert planning.two_open_todos() == 2 | ^^^^^^^^^^^^^^ private
- reason
- Another domain may use only what a domain marks
public;two_open_todosis a fixture indomains/planning/fixtures/two_open_todos.jadpo. - next
- Mark
two_open_todospublicifplanningshould offer it to other domains' tests (human) - rule
- visibility.
private_ cross_ domain - help
- https://jadpo.
dev/docs/errors/visibility. private_ cross_ domain
How to fix it
The question is whether the owning domain should offer the declaration to other domains.
If inventory should offer reserve_stock, mark it public. In
domains/inventory/actions/reserve_stock.jadpo:
public action reserve_stock(quantity: Quantity) -> Unit {}checkout can now call inventory.reserve_stock(quantity), and both
domains' changes commit or roll back together, in one database
transaction. Every type in a public action's signature must be public or
shared too; Quantity is shared.
If planning should offer two_open_todos to other domains' tests,
mark the fixture public, and the type it returns as well. In
domains/planning/fixtures/two_open_todos.jadpo:
public fixture two_open_todos() -> TodoCount { ...}
The reminders test can now call planning.two_open_todos(). A public
fixture is still offered to tests, fixtures and seeds only, never to
application code.
When the declaration should stay private, the other domain stops using it: it calls a public action of the owning domain instead, or keeps a declaration of its own.
Related
Markdown for agents: /docs/errors/visibility.private_cross_domain.md.Built from Jadpo main at aee2e8f.