Expand description
Explicit trace controls (Task 12, spec §5.1 raw-capture clause + §6.1
surfaces): /trace next, /trace next content, /trace status.
§One-shot semantics
Arming (/trace next) enables tracing for exactly the next logical
outgoing provider request — even when the telemetry config level is
Off — and then auto-disarms. The armed ephemeral context carries a
one-shot request gate consumed inside RequestTracer::begin: the first
request wins, all of its retry attempts emit, and subsequent tool-loop
requests through the same context are disabled. It never silently
enables indefinite persistence: when telemetry is Off the one-shot
record rides an ephemeral writer whose handle the runtime retains (in
its one-shot state, off the request path) until it is replaced by a
re-arm or drained by the shutdown_observability* exit epilogue — so
the armed record flushes even when the session exits immediately after
the request. The existing Basic/Full config rule is unchanged — arming
on top of an already-enabled session only adds the (optional) content
capture.
§Content capture (explicit, ephemeral, redacted)
Persisted traces contain no content, so synaps trace export --include-content needs an explicit capture: /trace next content arms
a one-request, bounded, redacted capture of the request body.
Security decisions, deliberately conservative:
-
capture is redacted at capture time (structural media scrub plus recursive credential-key / secret-pattern scrub, see
trace::export::redact_value) — raw media never touches disk; -
plain text remains explicitly authorized content: a text document lowered to ordinary OpenAI
text/input_texthas lost its structural provenance and cannot be distinguished from a typed prompt here. Its text may be captured under this opt-in (subject to the secret scrub); -
the bundle is written with the Phase 1 private-fs helpers (
0600file,0700parent, symlink-refusing, atomic) under<synaps base dir>/trace/capture/; -
the bundle carries its own schema tag (
synaps-trace-content-capture/1) so it can never masquerade as asynaps-request-trace/1record; -
capture is bounded (
CAPTURE_MAX_BYTES) and expires (CAPTURE_TTL):trace export --include-contentconsumes (deletes) it, and an expired bundle is refused and deleted instead of exported;Expiry semantics (documented guarantee): expiry is logical — an expired bundle can never be exported (the export path checks the embedded
expires_unix_msand deletes stale bundles). Physical deletion is a bounded, fail-soft sweep run at Runtime/session startup, in both the sync and async shutdown epilogues, and on every trace interaction (every new capture,/trace status, everysynaps trace exportinvocation). A bundle left behind by a killed process may therefore sit (private0600file, already redacted) on disk past its TTL until the next session startup/shutdown or trace interaction — but it is unreadable through any supported export path from the moment it expires; -
only the request body is captured — headers, cookies, and credentials never enter the capture path by construction (they are attached by the HTTP client after the body is built).
The capture file is how the arm crosses the process boundary to a later
synaps trace export invocation without weakening privacy: the on-disk
artifact is already redacted, private, bounded, and short-lived.
Structs§
- Content
Capture - One-request content capture arm, attached to a
TraceContextwhen the user ran/trace next content. Fires at most once. - Content
Capture Bundle - On-disk shape of the capture bundle. Clearly labeled non-request-trace
schema;
redactedis a hard marker checked again on export. - Trace
Controls - Session trace controls: one-shot arm consumed by the next request.
- Trace
Status Report - Metadata-only status for
/trace status: mode, persistence path, counters. Never secrets, never content.
Enums§
- Trace
Arm - Current arm state.
Constants§
- CAPTURE_
MAX_ BYTES - Upper bound on captured (post-redaction) body bytes.
- CAPTURE_
TTL - Retention window for a capture bundle.
- CONTENT_
CAPTURE_ SCHEMA - Schema tag for the ephemeral content-capture bundle. Distinct from the request-trace schema by design.
Functions§
- capture_
path - Path of the capture bundle for a request ID.
- default_
capture_ dir - Default capture directory:
<synaps base dir>/trace/capture/.