Repository navigation
Conversation
Add deny-wins audio admission, immutable correlation handles, bounded provider-owned transfer workers, explicit owned-file leases and session-binding entry points. Keep unqualified retrieval and recording streams fail-closed. Co-Authored-By: Claude Code <noreply@anthropic.com>
…esign The latest-OTel compatibility jobs hung because a test forked the multi-threaded pytest process: OpenTelemetry SDK 1.45's at-fork handler (TracerProvider._handle_fork) deadlocks the child on an inherited ThreadPoolExecutor lock. Fork coverage now runs in separate-interpreter exit probes, so no test forks the runner. Lifecycle (design section 8): a DisabledAttachmentManager null object when attachments are off (no thread, timer, fork hook, wire adapter or schema load), one fork hook per process, lazy daemon workers, bounded waits, and an idempotent shutdown that returns within its timeout. Implements the shared SDK streaming design against F01 f3b0923: preflight tickets evaluated with the F01 privacy table, multi-modal MIME mapping and per-kind caps, segmented PCM recordings with prefix-monotonic manifests, session and capability renewal, owned-file tiers with WAV range segmentation, the completed-recording import seam, consumed single-object streams, idempotency keys, the status-to-reason table and a pacer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker released a recording lane before the writer recorded the segment's result, so the next segment could read a stale index and finish() could build the final manifest early. The lane now stays busy until the writer callback has run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing cap, old-core traceai import - attach_owned_recording: the wav_recording tier admits and re-checks every chunk as `mixed`, matching the wire (every segment is sent as `mixed`), so a hide flag on either side denies the whole file. The caller's label is kept only for the unparseable-header fallback to tier `single`. - RecordingWriter: limits.recording_bytes now caps the cumulative bytes sealed into segments (44-byte headers included), not the bytes still buffered, so a drained recording is truncated at the negotiated total. - traceai: import fi_instrumentation.attachments guarded; on a core without it, `import traceai` and plain init() work, attachment options raise a clear error, and session binding reports unsupported_version. - Regression tests for each, including live stereo with one side hidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of TH-2379 (Linear).
Scope
Python attachment core (P01/P02) and auto plumbing (A01), now implementing the shared SDK streaming design (
sdk-streaming-design.md, sections 0-9) against the frozen F01 contractf3b0923c62(#675). Draft; not merge-ready until the voice/backend lanes integrate.Everything stays OFF by default. Creating new recordings is separately OFF (client
record_audioAND serverpolicy.record_audio). Admission evaluates the vendored F01 privacy table deny-wins: hide flags and PII redaction win (raw media under PII redaction isredaction_unavailablewithout a qualified sanitizer, which v1 does not ship).Review fix pass (c2, head
5a7e1105)An independent review of
7b03f8d3found three blocking defects. Each is fixed here with regression tests, and each test was shown to fail on the pre-fix head.attach_owned_recordingadmitted awav_recording-tier file with the caller'sdirectionlabel, but every segment of that tier goes on the wire asmixed(stereo carries both sides in every byte; segments carry notrack_id; mono maps to themixedlayout). Withhide_outputs=True,direction="input"and stereowav_tracks, the file was uploaded. Now the tier is admitted, re-checked per chunk and re-evaluated on policy updates asmixed, and every segment request saysmixed. The live recording path already evaluated stereo asmixed; it now has a test that a per-track mutation fails.wav_recording-tier file is denied when EITHER side is hidden, whatever label the caller passed (this includes a mono WAV labelledinput, whose wire direction was alreadymixed), and when the server'sallowed_directionslacksmixed. An invalid caller label ispolicy_deniedup front.single, whose wire direction is "as given" (design 4); its checks stay at the strictermixed.traceaicrashed on import with an older core.traceaiimportedfi_instrumentation.attachmentsunconditionally while its floor (fi-instrumentation-otel >=0.1.7) still admits releases without it (1.3.1 is the current release). The import is now guarded: on such a core,import traceaiand plaininit()work,register()gets no new keywords, instrumentors get no attachment keywords,attachment_config/trace_configraise a clearRuntimeError,attachment_status()["runtime"]isunsupported_version, and session binding reportsunsupported_version.python-tests.ymlrunspoetry installinpython/traceai, which resolves the core from PyPI before overlaying the repo core, so a floor above 1.3.1 would fail that job until a core release with attachments exists. The release PR that publishes that core should raise the floor.limits.recording_byteswas not enforced. The writer compared bytes still buffered against the cap, so a drained recording uploaded past it and endedpublished. The writer now keeps a cumulative count of bytes sealed into segments, 44-byte headers included, plus every unsealed run and the headers a new part would start. It truncates (gaptruncated,capture_complete=false, resultpartial) once the total would exceedmin(limits.recording_bytes, 1 GiB).Re-proof on a private GCP VM (
fagi-omega-staging, no external IP, no service account; Debian 12, uv CPython 3.11 / 3.14, OTel SDK 1.45.2):CI blocker: root cause and fix
The 6 latest-OTel tracing compatibility jobs hung at 95% because
test_after_fork_resets_workers_without_parent_replaycalledos.fork()inside the multi-threaded pytest process. OpenTelemetry SDK 1.45.2 registersTracerProvider._handle_forkas anafter_in_childhook; in the child it callsget_aggregated_resources->ThreadPoolExecutor.submit, which deadlocks on an inherited lock. OTel 1.29.0 (floor) has no such hook, so only the latest jobs hung; the stuck child was the orphan process.TracerProvider._handle_fork.TracerProvidercreated beforeconcurrent.futures.threadis imported, thenos.fork()-> the child hangs.python/tests/attachments/exit_probe.py, design 8.5); no test forks the pytest process.create_attachment_managerreturns aDisabledAttachmentManagernull object when OFF (no thread, timer, fork hook, atexit hook, wire-adapter or privacy-table load, span attribute); one fork hook per process over aWeakSetthat resets live managers in the child without touching inherited locks; workers start lazily; every wait is bounded (<= 1 s slices);shutdown(timeout)is idempotent and returns withintimeout + 250 mseven with a blocked transport.What the core now provides
manager.preflight(target, mime_type=, direction=, max_bytes=, operation=, ...)returns a single-useAdmissionTicketafter the full privacy check, without touching the source; it reserves a descriptor and byte budget, expires lazily (no timer), is re-checked at use and can only narrow.attach()is preflight +ticket.attach().Purposeenum includingcomputer_screenshotanddocument; the server'sallowed_modalitiesis the gate. Per-kind caps (50 MiB single, 20 MiB image, in-memory <= owned budget; mutable buffers copied only up tosync_copy_bytes).start_recording(...)->RecordingWriter. Sample-count clock; WAV segments <= 30 s and <= 8 MiB including the 44-byte header (worked vectors asserted: 1 440 044 / 5 760 044 / 8 388 140 bytes); shared cut points across tracks;track_idonly forseparate_tracks; strictly ordered uploads with a moving window; prefix-monotonic manifests PUT with the latest completed segment's capability (BR-7 fallback order implemented);try_writenever does I/O.bs-{sid}-{n}); upload-capability renewal replays the byte-identical init body; a stale capability endsexpiredwithout creating a new upload.RecordingFileScope.identify()(secure open + fstat),attach_owned_recording()with tierssingle(streams from the lease, one slice of memory) andwav_recording(segments synthesized frompreadranges; never materialized); encoded files above the cap aretoo_largewith zero bytes read.await import_completed_recording(target, request, resolver=)with the resolver seam (defaultUnavailableResolver), original credentials only,im-{rid}key, no span projection, one-shotstatus().start_attachment_stream()receives only chunks the application already consumed; over-cap discards everything; the reference is projected only atfinish().UploadRequest; manifest tracks are the authority for recordings.protocol.pyholds every route, the 0.5 status->reason table with in-classError.coderefinement, 0.6 idempotency keys, separate control/content deadlines, a token-bucket pacer, strict JSON, and schema + cross-field validation.AttachmentSpanProcessor.on_startno longer stamps every span.Breaking changes for consumers (voice lane):
statusis a method returningAttachmentStatus; adapters usepreflight()instead ofmanager._session/manager.policy.evaluate;max_attachment_bytesremoved;register()/traceai.init()holdDisabledAttachmentManagerwhen OFF.Evidence
All runs on a temporary private GCP VM (
fagi-omega-staging, no external IP, no service account), synthetic credentials and synthetic audio only; no local tests. Logs are kept with the lane evidence.Commands (VM: e2-standard-8, Ubuntu 24.04, uv-managed CPython 3.11.14 / 3.14, OTel SDK 1.45.2):
Design test IDs covered: T-PF-01..08, 10..15; T-ST-01..20; T-RN-01..08; T-LS-01..03, 06..10 (T-LS-04 via the existing lease position test); T-IM-01..10; T-CS-02..07; T-CH-01..06; T-LC-01, 03..16 (exit probes
disabled,enabled-idle,enabled-blocked,enabled-no-shutdown,fork,mid-recording,import-pendingin separate interpreters); T-TR-01..08 (all F01 wire fixtures for SDK shapes; all 82 F01 privacy fixtures). TS-only rows (T-PF-09, T-CS-01, T-LS-05, T-LC-02) and Windows (T-LS-11) do not apply.GitHub CI on this head is the authority for the wall-clock fi-core suites.
Not in this PR
preflight/start_recording/attach_owned_recordingand the LiveKit Egress resolver (voice lane, design 12.10/12.11).🤖 Generated with Claude Code