Skip to content

CCTranscript Swift package: swift-bridge bindings for the session-activity oracle - #3

Merged
yasyf merged 11 commits into
mainfrom
swift-package
Jul 8, 2026
Merged

CCTranscript Swift package: swift-bridge bindings for the session-activity oracle#3
yasyf merged 11 commits into
mainfrom
swift-package

Conversation

@yasyf

@yasyf yasyf commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Exposes the Rust session-activity oracle to Swift via swift-bridge (pinned 0.1.59), shipping a committed SPM package at swift/ (library CCTranscript, macOS 14+, macos-arm64 xcframework).

  • rust-swift/ bridge crate + scripts/build-swift-package.sh regeneration pipeline
  • fixture-driven XCTest smoke suite + Examples/probe consumer
  • CI: macOS job building the bridge crate, running swift-feature cargo tests, testing the committed package, and a freshness guard that regenerates the package and fails on any non-binary drift

@socket-security

socket-security Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​swift-bridge-build@​0.1.599810093100100
Addedcargo/​swift-bridge@​0.1.59100100100100100

View full report

yasyf added 11 commits July 7, 2026 19:37
Add a pyo3-free typed model (types.rs: Entry/EntryMeta/ContentBlock/
UserContent/PrintResult) and parse layer (parse.rs: Value -> typed, with
KeyError/ValueError-mapped ParseError). stream_parse now builds typed
entries in the rayon workers, off the GIL; event.rs shrinks to a pure
typed -> Python materializer with byte-identical output. ToolUseBlock
keeps the verbatim input Value plus typed run_in_background /
subagent_type reads, and Entry grows meta/session_id/blocks/tool_uses/
tool_results accessors for the upcoming analysis stages.
mining.rs now consumes typed Entry values instead of raw sonic_rs reads:
the private tool_use_id map is replaced by the shared tool_use_index join,
sidechain/provenance classification reads typed meta, and the typed model
gains the ToolUseBlock file_path/questions input reads mining needs.
session_activity_probe crosses the pyo3 boundary: it reads a transcript,
parses it through the typed layer (whole-file stream_parse semantics), and
returns the oracle verdict as a dict. cc_transcript.activity_probe is the
dual-backend accessor with a Python reference twin, gated on
CC_TRANSCRIPT_DISABLE_RUST like mining and sentiment. Parity tests cover
every oracle case plus a captain-hook is_waiting reference port asserted
against the real corpus.
…atic lib

default = [python] keeps wheel builds identical; --no-default-features
--features swift compiles only the typed core (types, parse, protocol,
value, activity) into a staticlib with pyo3, udpipe-rs, tree-sitter,
rayon, and crossbeam absent. The pyo3 module moves to python.rs,
parse_bytes moves into parse.rs with a keep-predicate instead of a
CompiledSpec so the drop-spec engine stays python-only, and the unused
direct serde dependency is dropped.
cc_transcript_swift is a staticlib-only workspace member that depends on
the parser core with --no-default-features --features swift, keeping
swift-bridge build deps out of maturin wheel builds. It bridges
session_activity(path, waiting_tools, human_facing_tools) where empty
tool lists mean ActivityOpts::default().

SessionActivity and PendingItem cross as opaque Rust types with accessor
methods rather than the preferred shared transparent structs: swift-bridge
0.1.59 generates Swift for Vec<transparent struct> fields without the
required Vectorizable conformance, rejects opaque types inside shared
structs, and emits a broken throwing closure for &str args on
Result-returning functions (hence path: String). All three swift-bridge
crates are pinned to the exact same pre-1.0 version.
The swift staticlib now comes from the dedicated cc_transcript_swift
bridge crate, so the parser core no longer needs to emit one on every
build. Wheel builds (cdylib) and rust-swift (rlib) are unaffected.
scripts/build-swift-package.sh regenerates swift/ end to end: release
staticlib for aarch64-apple-darwin, swift-bridge-cli create-package
(pinned 0.1.59, binaryTarget name RustXcframework), a scripted
Package.swift patch (tools-version 5.9, platforms macOS 14), a
sessionActivity(path:waitingTools:humanFacingTools:) convenience wrapper
over the RustString/RustVec plumbing, and a swift build smoke check.

The generated package is committed, XCFramework included — deliberate
committed-binary distribution so consumers can depend on swift/ by path
or git without a Rust toolchain. Rerun the script and commit the diff
after touching rust-swift/.
…cript

Five synthesized JSONL fixtures mirroring tests/test_activity_parity.py
cases drive an XCTest target (CCTranscriptTests, Bundle.module resources)
asserting exact verdicts, pending kinds, and last_event_epoch, plus a
RustString error-path test. Examples/probe is a runnable consumer built by
the regen script, which now stages create-package output so the committed
Tests/, Examples/, and README.md survive regeneration.
@yasyf
yasyf merged commit 8417d29 into main Jul 8, 2026
7 checks passed
@yasyf
yasyf deleted the swift-package branch July 8, 2026 02:59
@yasyf
yasyf temporarily deployed to github-pages July 8, 2026 03:09 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant