# `PtcRunner.Kernel.PrivateDiagnostic`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/kernel/private_diagnostic.ex#L1)

Diagnostic projection policy for analysis sessions whose results are private.

A session over private records may not forward evaluator-produced message
text: that text can quote a captured record, and a host may route diagnostics
somewhere the result itself never goes. It may still tell the operator what
went wrong, because the fault often describes nothing but the operator's own
submitted source — or, for a narrower class, nothing private that this
evaluation itself captured.

Three admission rules apply, all **rebuild-or-bound, never raw forward** of
untrusted evaluator prose outside their footing:

1. **Source-derived structured detail** (today `:unbound_var`). A message is
   rebuilt only when every name appears verbatim in the submitted source.
   Every other byte is a literal in this module.

2. **Allowlisted compile/analyze kinds with no capability activity.** Several
   of these kinds (`:invalid_arity`, `:invalid_form`, `:unknown_tool`,
   `:private_tool_unauthorized`) also have runtime constructors. Admission
   therefore requires `details.capability_activity? == false` — measured for
   this evaluation — and a byte/UTF-8 bound at this boundary. The allowlist
   names which kinds may be considered; the activity flag is the load-bearing
   gate. Messages are a function of the submitted source, prelude surface, and
   installed tool names, not of values read from private records.

3. **Code-owned structured selectors with no capability activity.** The
   private prelude boundary may replace an evaluator message with a closed
   `:safe_diagnostic` shape. This module admits only exact selector shapes it
   knows and emits only fixed literals. The current selector explains that
   `analysis/counters` expects a named-argument map and uses `run_id` in its
   remediation example; arbitrary `:invalid_tool_args` messages never enter
   the kind allowlist above.

`details` is evaluator output and remains untrusted even when it contains a
code-owned selector: it can only select among exact fixed shapes and never
contributes rendered bytes. Anything outside those rules collapses to
`redacted_message/0`.

# `project`

```elixir
@spec project(term(), term(), term()) :: {binary(), boolean()}
```

Projects one private-session diagnostic as `{message, redacted?}`.

`redacted?` is true when anything the evaluator reported was withheld,
including a name dropped because it is absent from `source`, or a
pre-execution message clipped at the admission bound. A partially rebuilt or
clipped message also says so in its own text, so a consumer that renders the
message alone still cannot mistake a short list for the whole cause.

# `redacted_message`

```elixir
@spec redacted_message() :: binary()
```

The fixed message used whenever no source-derived message can be rebuilt.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
