foley.obs.recorder#
The run-recorder: owns the manifest, drives the OTel mirror, off by default (#11).
This is where the manifest-first design lives. A RunRecorder builds the
RunManifest + its span tree from its own clock +
id-factory — independent of the tracer — so the artifact is complete with a total
no-op tracer. The façades reach it through facade_run() (a get-or-create,
off-by-default context manager) and current_run(); a #7 find() opens an
explicit run() scope so nested façade calls aggregate into one manifest.
Discipline (mirroring the rest of foley): off by default — a plain
import foley + a plain foley.generate(...) is a byte-for-byte no-op that
touches no store and stays dol-only. foley.obs.enable() / $FOLEY_OBS=1 /
with foley.obs.run(...) turn it on. Emitting a manifest needs NO extra (all
stdlib); only the OTel span mirror needs foley[obs]. Recording never raises into a
façade — a store-write failure degrades gracefully.
Functions
|
Apply |
The active |
|
|
Turn observability off process-wide (façades revert to a byte-for-byte no-op). |
|
Turn observability on process-wide (and apply any |
|
The get-or-create seam every façade wraps its body in. |
Whether observability is on (via |
|
|
Restore the default config (test teardown; clears injected store/tracer/clock). |
|
Open an explicit run scope that aggregates nested façade calls into ONE manifest. |
Classes
|
Process-wide observability configuration (flipped by |
|
Builds one |
- class foley.obs.recorder.ObsConfig(enabled=False, force_disabled=False, redaction_mode=RedactionMode.hash, salt='foley-obs-v1', prefer_otel=True, run_store=None, tracer=None, clock=<built-in function time>, id_factory=<function ObsConfig.<lambda>>, now=<function _iso_now>)[source]#
Bases:
objectProcess-wide observability configuration (flipped by
enable()/disable()).- clock()#
time() -> floating-point number
Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.
- class foley.obs.recorder.RunRecorder(manifest, *, tracer, redactor, run_store, clock, id_factory)[source]#
Bases:
objectBuilds one
RunManifest(span tree + composed shapes), tracer-independent.- add_step(step)[source]#
Append a SELECT-stage
Step(#7), deep-redactingdetailat record time.The record-time net (belt over the emit-time sweep): event text carried in
detail(under thequerykey) is hashed here so a manifest read straight offself.manifest.steps— before any emit — never holds raw narration.seqis assigned here (append position) when the caller left itNone.- Return type:
- foley.obs.recorder.configure(**overrides)[source]#
Apply
ObsConfigoverrides WITHOUT flippingenabled(the test-injection seam).- Return type:
- foley.obs.recorder.current_run()[source]#
The active
RunRecorder, or_NULL_RUN(for the shared child span).
- foley.obs.recorder.disable()[source]#
Turn observability off process-wide (façades revert to a byte-for-byte no-op).
- Return type:
- foley.obs.recorder.enable(**overrides)[source]#
Turn observability on process-wide (and apply any
ObsConfigoverrides).- Return type:
- foley.obs.recorder.facade_run(op, *, inputs=None, params=None)[source]#
The get-or-create seam every façade wraps its body in.
Nested (a run is already active) → a child span into the SAME manifest, no emit (the outer owner emits). Enabled + top-level → a new recorder that emits one manifest on exit. Disabled → the zero-cost
_NULL_RUN.
- foley.obs.recorder.is_enabled()[source]#
Whether observability is on (via
enable()or$FOLEY_OBSin {1,true,yes}).force_disabled(set byfoley.runtime.offline_scope()for a telemetry-off posture) and a telemetry-off runtime ($FOLEY_OFFLINE) hard-override both — so offline mode’s “nothing leaves the device” contract holds even when$FOLEY_OBSis exported.- Return type:
- foley.obs.recorder.reset()[source]#
Restore the default config (test teardown; clears injected store/tracer/clock).
- Return type:
- foley.obs.recorder.run(op='run', *, inputs=None, params=None, **overrides)[source]#
Open an explicit run scope that aggregates nested façade calls into ONE manifest.
Forces observability on for the scope even when it is merely disabled (the #7
find()aggregation entrypoint). The one thing it does not override is the hard-offforce_disabledflag:foley.runtime.offline_scope()sets it for a telemetry-off posture, so an explicitrun()inside offline mode records and exports nothing — the “nothing leaves the device” contract holds on thefind()/weave()paths too, not just thefacade_runones. Get-or-create: a nestedrun()reuses the active recorder.overridesare per-scopeObsConfigfields (e.g.run_store,prefer_otel,clock).