Skip to content

feat: add per-party disclosure for enclave job logs and traceback frames - #9519

Open
pjwerneck wants to merge 5 commits into
devfrom
pjwerneck/improve-enclave-introspection
Open

pjwerneck wants to merge 5 commits into
devfrom
pjwerneck/improve-enclave-introspection

Conversation

@pjwerneck

Copy link
Copy Markdown
Collaborator

Summary

The job runner writes stdout and stderr to a new staging folder, not to the review folder that the submitter reads. For an enclave job, the enclave moves an artifact to the review folder only when every data owner released that item.

Changes

  • A new staging folder, at app_data/job/staging/<ds>/v<n>/<job>/. The runner writes stdout.txt and stderr.txt there. returncode.txt and outputs/ still go to the review folder. The submitter holds a read grant on the folder review/<ds>/, and every file under that folder inherits the grant. A write to the review folder is therefore the disclosure. The staging folder carries no grant.
  • JobInfo.release_artifacts() and JobInfo.release_logs() move a staged file to the review folder. JobInfo.artifact_path() finds the file in either folder, so StdoutViewer, StderrViewer and the syft-bg stderr notifier still read a log that no party released.
  • DisclosureItem names two items: logs and traceback_frames. approved_disclosures() returns the items that every party released. approve_job(job, disclosures) records the grant of one data owner. update_disclosures() changes that grant after the run, and _forward_new_releases() sends the artifact that a late grant covers.
  • traceback_capture writes traceback_frames.json from the staged stderr. The record holds the file and the line of each frame, and the exception type. It never holds the exception message. Job execution does not change: there is no wrapper script and no new environment variable, and run.sh keeps its current form. A job submitted before this branch therefore also gets a record.

Testing

  • 46 new tests in test_staging.py, test_traceback_capture.py and test_disclosures.py. test_full_job_lifecycle() and test_truncated_logs.py follow the new paths.
  • uv run pytest packages/syft-job/tests packages/syft-enclave/tests/test_disclosures.py tests/unit/test_truncated_logs.py — 99 passed.
  • uv run pytest packages/syft-enclave/tests/test_enclave_jobs.py packages/syft-rds/tests/test_job_auto_approval.py tests/unit/syft_bg/test_email_approve.py — 45 passed.
  • test_no_sync_runs_while_an_ungranted_artifact_sits_in_review() watches the sync engine and checks that no gated file sits in the review folder at any sync. That test proves the gate, and not only the move.
  • ruff check and ruff format report no problem. An old client reads a new approval file, because pydantic drops the extra disclosures key.

Asana task

https://app.asana.com/1/1185126988600652/project/1210542925864934/task/1217980407095932?focus=true

- Updated StderrViewer and StdoutViewer to use artifact_path for accessing stderr and stdout files.
- Introduced staging directory for job outputs, separating them from review directory.
- Enhanced SyftJobRunner to manage stdout and stderr in staging, with options for sharing logs with submitters.
- Implemented traceback capture functionality to sanitize and record job errors securely.
- Added tests to verify the behavior of staged logs and their release process.
- Adjusted job processing methods to ensure logs are only shared when explicitly released.
- Drop a traceback block with no frames and read the type only after the last
  frame, so job output cannot land in the record as the exception type.
- Match frames behind an ExceptionGroup gutter.
- Keep the innermost frames when the frame cap truncates.
- Reject a non-enclave job in approve_job, which took disclosures as approve's
  reason and granted nothing.
- Honour a False value in a map passed to normalize_disclosures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants