straw/rust/strawcore/src/lib.rs
Cobb 4d3ddf502f
All checks were successful
build-apk / build-and-publish (push) Successful in 8m2s
diag: expand dogfood logging — lighter scrub + always-log failures + wrapper catch-all
Pairs with strawcore's new extractor instrumentation to make "Send logs to Kayos"
actually diagnosable. Today's bot-wall outage produced a log dump that was 90%
framework noise, one mangled strawcore line, and zero failure signal.

- LogDump: split the scrubber into a FULL profile (share-sheet export + on-screen
  error strings — unchanged, still over-redacts) and a lighter DOGFOOD profile
  (the logs.sulkta.com ingest path, our own infra) that KEEPS bare YouTube ids
  (video/channel/playlist/youtu.be — the triage signal) while still scrubbing
  every real credential: signed googlevideo URLs, bearer/cookie/token headers,
  sig/pot/n/cpn params, URL queries, emails, high-entropy tokens (visitorData),
  and IPs. LogShipper uses the dogfood profile.
- Fixed the IPv6-compressed regex that mangled Rust module paths
  (`strawcore::stream` -> `strawcor<ip>stream`) and, as a bonus, a latent
  false-negative where `::1` was never scrubbed.
- Always-log extraction + playback failures (strawLogI) so a user-visible failure
  always lands in the ring.
- Wrapper (rust/strawcore): one catch-all WARN in run_extract that traces EVERY
  extraction failure system-wide, and raise android_logger Info->Debug so the
  extractor's DEBUG tier is live in the dogfood build.
- Added a JVM unit test for the scrubber (not yet wired into CI — the repo has no
  test source set; follow-up).
2026-08-06 08:17:15 -07:00

62 lines
2.3 KiB
Rust

// strawcore (wrapper) — UniFFI surface for the Straw Android app.
//
// Thin layer over the new Sulkta-OSS/strawcore-core crate. All extractor
// logic (InnerTube, JS deobf, stream parsing, search, channel, playlist)
// lives in core. This file:
// * re-exports the DTOs Kotlin expects under their familiar names
// * exposes #[uniffi::export] async fns that bridge Kotlin suspend funs
// to the core's blocking calls via tokio::task::spawn_blocking
// * owns init_logging() — also initializes the core Downloader
use std::sync::Once;
mod channel;
mod error;
mod feed;
mod net;
mod runtime;
mod search;
mod stream;
// Re-exports so UniFFI sees the types at the crate root for macro discovery.
pub use channel::ChannelInfo;
pub use error::StrawcoreError;
pub use net::{RydVotes, SponsorSegment};
pub use search::{Page, SearchItem};
pub use stream::{AudioStreamItem, ResolvedStreams, StreamInfo, VideoStreamItem};
/// Initialize Android logging + the strawcore-core HTTP downloader.
/// Kotlin calls this from StrawApp.onCreate(). Idempotent.
#[uniffi::export]
pub fn init_logging() {
static ONCE: Once = Once::new();
ONCE.call_once(|| {
android_logger::init_once(
android_logger::Config::default()
// Debug (not Info) so the extractor's DEBUG tier — per-request
// HTTP breadcrumbs, cache/lexer-fallback internals — is live in
// this dogfood/debug build. WARN/INFO were already emitted; this
// unlocks the chatty diagnostics behind them.
.with_max_level(log::LevelFilter::Debug)
.with_tag("strawcore"),
);
log::info!("strawcore initialized");
});
runtime::ensure_initialized();
}
/// Smoke-test entry point — round-trip a string through JNI.
/// Used during the initial UniFFI bring-up; kept for future smoke
/// debugging. Logs shape only — the `name` value never hits logcat
/// because a future caller might pass a real user-supplied string.
#[uniffi::export]
pub fn hello_from_rust(name: String) -> String {
log::info!("hello_from_rust called name_len={}", name.len());
format!(
"hello {} from rust 🦀 (strawcore v{})",
name,
env!("CARGO_PKG_VERSION")
)
}
uniffi::setup_scaffolding!();