Scan for sentinels¶
scanForSentinels is a built‑in scan rule that detects containment sentinel markers generated during Jane’s safe‑clone process.
It operates on the containment‑produced string representation of the input. When that representation is a sentinel marker, the rule emits a fatal event. If the value’s detected type is not a containment sentinel, no events are emitted.
Signature¶
export const scanForSentinels: ScanRule (raw: unknown, path: FieldPath) => JaneEvent[]
Events¶
| Event code | Description |
|---|---|
value.was.contained |
Unaccepted structural type was converted to a string sentinel representation. |
Design rationale¶
- Detects containment‑layer sentinel markers inserted during safe‑clone operations.
- Ensures structural hazards (e.g., circular references, proxies, getters, non‑cloneable values) are surfaced during the scan stage.
- Prevents downstream stages from operating on placeholder sentinel strings.
- Converts any detected sentinel into a fatal scan event for consistent policy handling.
- Guarantees deterministic pipeline behavior by halting execution when containment has already failed.
- Performs no mutation, transformation, or interpretation beyond sentinel detection.
Invoke¶
scanForSentinels runs automatically whenever the scan stage is enabled.
Activation methods:
- Enable scan explicitly:
jane.value(input).scan(). - Use a mode that enables scan:
strict()enables scan by default.moderate()andlax()do not enable scan unless.scan()is called.- Enable scan with policy:
jane.value(input).withPolicy({ mode: 'strict' }).
If scan is not enabled, scanForSentinels does not run and no sentinel detection occurs.
Examples¶
Sentinel detected¶
const result = scanForSentinels("[Circular]", "$");
// → [ JaneEvent{ kind: "fatal", code: "value.was.contained", ... } ]
Non‑sentinel string¶
const result = scanForSentinels("hello", "$");
// → []
Non‑string value¶
const result = scanForSentinels(42, "$");
// → []