# `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](/docs/project-layout-and-modules.md); 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:

```jadpo
use shared/types { Quantity }

action reserve_stock(quantity: Quantity) -> Unit {}
```

domains/ordering/actions/checkout.jadpo:

```jadpo
use shared/types { Quantity }
use inventory

action checkout(quantity: Quantity) -> Unit {
    inventory.reserve_stock(quantity)
}
```

```text
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_stock` is an action in `domains/inventory/actions/reserve_stock.jadpo`.
  next: Mark `reserve_stock` `public` if `inventory` should offer it to other domains (human)
  rule: visibility.private_cross_domain
  help: https://jadpo.dev/docs/errors/visibility.private_cross_domain

check failed: 1 error, 4 files
```

`(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:

```jadpo
use planning

test "reminders start from planning's open todos" {
    send_reminders()
    assert planning.two_open_todos() == 2
}
```

```text
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_todos` is a fixture in `domains/planning/fixtures/two_open_todos.jadpo`.
  next: Mark `two_open_todos` `public` if `planning` should offer it to other domains' tests (human)
  rule: visibility.private_cross_domain
  help: https://jadpo.dev/docs/errors/visibility.private_cross_domain

check failed: 1 error, 5 files
```

## 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`:

```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`:

```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

- [Ownership and calls replace modules](/docs/ownership-and-calls-replace-modules.md)
- [What can be public](/docs/ownership-and-calls-replace-modules.md#what-can-be-public)
- [Changing another domain's data](/docs/ownership-and-calls-replace-modules.md#changing-another-domains-data)
- [A fixture for other domains: `public`](/docs/shared-test-data-fixtures.md#a-fixture-for-other-domains-public)
