ErrorsReads and writes · rule
query.other_domain
A query in one domain reads the records of an entity that belongs to another domain.
Area 6, Reads and writes; not declinable; the next step is usually the human's.
Why Jadpo refuses it
A domain owns its entities, and other domains see its data only through
what it makes public. A query reads its own domain's entities. Here
shelf, in lending, reads Book, which belongs to catalogue. If
that were allowed, catalogue could no longer change how it stores books
without breaking lending, and it would have no say in what it shares.
Jadpo won't choose for you between moving the query and asking
catalogue for the data, because that decides which domain owns the
shelf and what catalogue offers to others.
What it looks like
Book is a public entity in the catalogue domain, and lending uses
it:
domains/lending/queries/shelf.jadpo:
use catalogue/entities { Book }/// Every copy.query shelf() -> List<Book> { from: Book order: [Book.id asc] limit: 20}
error shelf reads Book, an entity of domain catalogue
--> domains/lending/queries/shelf.jadpo:5:11
|5 | from: Book | ^^^^ domain `catalogue`
- reason
- A query reads its own domain's entities only; another domain's data comes from that domain's public queries, so
cataloguedecides what it shares. - next
- Call a public query of
catalogue, or moveshelfintocatalogue(human) - rule
- query.
other_ domain - help
- https://jadpo.
dev/docs/errors/query. other_ 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 which domain owns the shelf, and what catalogue shares with
other domains.
How to fix it
The question is whether the shelf belongs to catalogue or to lending.
If it belongs to catalogue, move the file to
domains/catalogue/queries/shelf.jadpo. Its contents stay the same:
use catalogue/entities { Book }/// Every copy.query shelf() -> List<Book> { from: Book order: [Book.id asc] limit: 20}
shelf reads Book from inside its own domain. Only catalogue's own
code can call it.
If lending needs the list, put the query in catalogue, mark it
public, and call it from lending through the domain's name. In
domains/catalogue/queries/shelf.jadpo:
public query shelf() -> List<Book> { ...}
And in domains/lending/actions/browse_shelf.jadpo:
use catalogue/entities { Book }use catalogue/// The copies a borrower can choose from.action browse_shelf() -> List<Book> { return catalogue.shelf()}
catalogue now offers shelf to other domains, and lending gets the
books by calling catalogue.shelf(). catalogue can change how it
stores books as long as shelf gives the same result.
Related
Markdown for agents: /docs/errors/query.other_domain.md.Built from Jadpo main at aee2e8f.