docs: which app the client picks when other projects' apps run too

The consumer notes tell agents that commands pick their project's app
and how to reach another with -i, the README's discovery row says the
same, and the agent notes describe CRAFTER_DEBUG_PROJECT and how an app
is matched to its project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-01 18:33:59 +01:00
commit 98e92c1976
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 3 additions and 1 deletions

View file

@ -128,6 +128,7 @@ A test's own output appears only when it fails. To see its PASS lines, run the b
- **A consumer's `#ifdef`'d `import Crafter.Debug;`** is harmless in its plain builds. - **A consumer's `#ifdef`'d `import Crafter.Debug;`** is harmless in its plain builds.
- **`project.cpp` regenerates `build/generated/<core variant>/Crafter.Debug.Core-BuildInfo.cpp`** when the sources or the client's path change. `crafter-build clean` removes it, and the next load writes it again. - **`project.cpp` regenerates `build/generated/<core variant>/Crafter.Debug.Core-BuildInfo.cpp`** when the sources or the client's path change. `crafter-build clean` removes it, and the next load writes it again.
- **The launcher is written by `Debug::Use` while crafter-build loads the consumer,** not by the build. A plain build keeps an existing launcher; a fresh plain build writes the stub. - **The launcher is written by `Debug::Use` while crafter-build loads the consumer,** not by the build. A plain build keeps an existing launcher; a fresh plain build writes the stub.
- **The launcher tells the client its project** in `CRAFTER_DEBUG_PROJECT`, which becomes `Cli::Environment::project`. An app is the project's when its executable lies under that directory, as `-r` runs it from `<project>/bin/<variant>/`. With a project set, commands pick only the project's apps unless `-i` says otherwise, and `ls` exits 3 while none of them runs. A client started without the launcher has no project and picks the one app running, as before.
- **A consumer that depends on Crafter.Network itself** must name it exactly as `project.cpp` here does (same URL, no pin, same args). Otherwise the graph holds two Crafter.Network configurations, and crafter-build refuses with "module … built twice". - **A consumer that depends on Crafter.Network itself** must name it exactly as `project.cpp` here does (same URL, no pin, same args). Otherwise the graph holds two Crafter.Network configurations, and crafter-build refuses with "module … built twice".
- **`debug.log`'s `last` of 0 means no backlog**, as `tail -n 0` does. A `TimelineQuery`'s `last` of 0 means all. - **`debug.log`'s `last` of 0 means no backlog**, as `tail -n 0` does. A `TimelineQuery`'s `last` of 0 means all.
- **Answer before you raise a flag the main loop acts on.** The loop may end the Session at once. A reply given before the connections close is delivered; one given after is not. `quit` replies first, then sets `QuitRequested`. - **Answer before you raise a flag the main loop acts on.** The loop may end the Session at once. A reply given before the connections close is delivered; one given after is not. `quit` replies first, then sets `QuitRequested`.

View file

@ -34,7 +34,7 @@ $ ./build/crafter-debug screenshot
|---|---| |---|---|
| **The library**, `Crafter.Debug` | Linked into the app's debug builds only. A `Debug::Session` serves requests on 127.0.0.1 over QUIC, with a random port and a token, and runs the ones that touch the app on the app's own thread, between frames, in `Debug::Pump()`. | | **The library**, `Crafter.Debug` | Linked into the app's debug builds only. A `Debug::Session` serves requests on 127.0.0.1 over QUIC, with a random port and a token, and runs the ones that touch the app on the app's own thread, between frames, in `Debug::Pump()`. |
| **The client**, `crafter-debug` | Built in the same pass as the app, from the same sources. The launcher `build/crafter-debug` runs it inside the CrafterBuild Flatpak sandbox it was built for. Nothing the Flatpak compiles runs on the host. | | **The client**, `crafter-debug` | Built in the same pass as the app, from the same sources. The launcher `build/crafter-debug` runs it inside the CrafterBuild Flatpak sandbox it was built for. Nothing the Flatpak compiles runs on the host. |
| **Discovery** | Each running app writes `$HOME/.cache/crafter-debug/instances/<id>.json` (its user's only) and holds a lock while it lives. The client finds apps there, across Flatpak sandboxes, and forgets the ones that died. | | **Discovery** | Each running app writes `$HOME/.cache/crafter-debug/instances/<id>.json` (its user's only) and holds a lock while it lives. The client finds apps there, across Flatpak sandboxes, and forgets the ones that died. It picks the app of the project whose launcher started it, and leaves other projects' apps to `-i`. |
| **The build helper**, `Crafter.Debug.Build` | Loaded into a consumer's `project.cpp` by `#pragma crafter dependency`. It adds the library under the consumer's own debug flag and writes the launcher. | | **The build helper**, `Crafter.Debug.Build` | Loaded into a consumer's `project.cpp` by `#pragma crafter dependency`. It adds the library under the consumer's own debug flag and writes the launcher. |
## Adding it to a project ## Adding it to a project

View file

@ -19,6 +19,7 @@ This app can be driven while it runs: call its commands, read and set its state,
- Requests run when the app calls `Debug::Pump()`, once per frame; `status` shows when it last did. - Requests run when the app calls `Debug::Pump()`, once per frame; `status` shows when it last did.
- Stopping the background `-r` task can leave the app running. Stop it with `quit`, or `quit --force` if its loop is stuck. - Stopping the background `-r` task can leave the app running. Stop it with `quit`, or `quit --force` if its loop is stuck.
- Run long `wait`s in the background, and chain short steps with `&&`. - Run long `wait`s in the background, and chain short steps with `&&`.
- Other projects' debug apps may be running too. Commands pick this project's app and leave the others alone, and `ls` marks this project's. `-i <name|id>` picks another project's app, or one of two copies of this one.
- `debugger` prints how to attach lldb or gdb for breakpoints and memory. - `debugger` prints how to attach lldb or gdb for breakpoints and memory.
### Coding with it ### Coding with it