This is a submission for the Hacktoberfest Open-Source AI Challenge Week 1: Touch Grass
What I Built
Solo hikers venturing into the Western Ghats quickly discover where cellular connectivity vanishes. Step into the Netravali river valley and phone status indicators drop immediately to zero reception.
In mountain wilderness, dead zones turn minor mishaps into emergencies. If an explorer twists an ankle on wet basalt, nobody discovers their distress until days later.
Millions of hikers, runners, and nature enthusiasts venture outside alone to touch grass. They deserve dependable protection without carrying heavy satellite gear or paying recurring subscriptions.
TrailSafe is an offline-first safety tool built around a Screen-Zero philosophy. It tracks trail waypoints, calculates physical distress using Prior Labs TabPFN, and runs a durable dead-man switch with Temporal.
sequenceDiagram
autonumber
actor Hiker as π₯Ύ Solo Hiker
participant PWA as π± TrailSafe PWA (Offline)
participant Temporal as β³ Temporal Durable Workflow
participant TabPFN as π§ Prior Labs TabPFN
participant Dispatch as π¨ Multi-Channel Dispatch
Hiker->>PWA: Start Trek (Route: Netravali Ridge, Interval: 45 min)
PWA->>Temporal: Start Workflow (TrailSafetyWorkflow)
Note over Temporal: Durable Timer Starts (45-min countdown)
rect rgb(24, 32, 47)
Note over Hiker, PWA: Trekking Leg (Phone zipped in pack)
Hiker->>PWA: Tap Check-in at Waypoint (GPS + Sensor Telemetry)
PWA->>Temporal: Signal check_in(checkpoint_id, telemetry)
Temporal->>Temporal: Reset Timer & Advance Checkpoint Leg
Temporal->>TabPFN: Execute Activity: evaluate_tabpfn_risk_activity
TabPFN-->>Temporal: Posterior P(hazard)=0.082, Fluid Deficit=0 mL
end
rect rgb(45, 20, 20)
Note over Hiker, Temporal: Severe Hazard: Hiker Injured in Ravine
Note over Temporal: 45-Min Timer Expires with Zero Signal
Temporal->>Temporal: Transition to GRACE_PERIOD (10 minutes)
Note over Temporal: Grace Period Expires (Dead-Man Triggered)
Temporal->>Dispatch: Execute Activity: dispatch_emergency_alert_activity
Dispatch->>Dispatch: Send Telegram Alert + SMS with GPS & TabPFN Risk
end
The Screen-Zero Field Experience
Conventional outdoor software demands continuous attention. Screen-Zero keeps the device hidden inside your backpack:
- Trailhead Launch (30 seconds): Select your trail, set an expected checkpoint interval, and slip the phone into your backpack.
- On the Trail (Screen-Zero): The device stays zipped away while you climb, observe nature, and experience the wilderness uninterrupted.
- At the Landmark (5 seconds): When you reach a designated trail marker, give the device a single tap.
- Autonomous Safeguards: Prior Labs TabPFN evaluates seven physiological signals in under 100 milliseconds. Temporal guarantees the timer continues counting down even if the device restarts.
When an explorer misses a checkpoint and grace period, TrailSafe automatically builds a rescue alert containing GPS coordinates, elevation, and hydration diagnostics.
Demo
(Full HD 1080p demo walkthrough showcasing offline Bayesian inference, time-skipping test suites, and search-and-rescue dispatch).
Interactive Terminal Monitor
For wilderness basecamps, park rangers, and headless workstations, TrailSafe includes an interactive terminal monitor:
Run the autonomous field simulation locally:
# Run the live autonomous dead-man switch simulation
python3 scripts/simulate_emergency.py
# Launch the interactive terminal monitor
python3 src/cli/field_app.py --trail "Netravali Ridge" --timeout 45
Code
Labreo
/
trailsafe
Offline Bayesian Hiker Distress Forecasting & Durable Search-and-Rescue Dead Man's Switch (TabPFN + Temporal)
ποΈ TrailSafe
Offline Solo Hiker Dead-Man's Switch & In-Context Tabular Risk Engine
Autonomous Backcountry Life Safety with Prior Labs TabPFN & Temporal Durable Execution
"Go outside, stay safe, and touch grass."
π¬ Watch the 2-Minute Full HD Video Walkthrough on YouTube π¬
Challenge: Hacktoberfest Open-Source AI Challenge: Week 1 - Touch Grass
Challenge Tag:dev.to/t/hf26challenge
Submissions Due: Sunday, October 11, 2026 at 11:59 PM PDT (October 12, 2026 at 12:29 PM IST)
Targeted Prize Categories:
- Best Use of TabPFN (Featured Category: $200 USD)
- Best Use of Temporal (Partner Category: $100 USD)
- Overall Winner (Touch Grass Theme Champion) Author: Kanak Sanjay Waradkar (@Labreo) Repository: Central Knowledge Hub & Career Systems Engineering (
Labreo/learning)
1. Executive Summary & The "Touch Grass" Philosophy
TrailSafe is an autonomous, privacy-preserving outdoor safety product engineered for solo hikers, trail runners, and field naturalists exploring remote terrain (suchβ¦
βοΈ TrailSafe is open source under the MIT License.
Repository Structure
trailsafe/
βββ src/
β βββ ml/
β β βββ tabpfn_engine.py # Prior Labs TabPFN in-context Bayesian inference
β β βββ benchmark_eval.py # Cross-validation benchmark (TabPFN vs baselines)
β βββ temporal/
β β βββ workflows.py # TrailSafetyWorkflow durable state machine
β β βββ activities.py # TabPFN evaluation and dispatch activities
β βββ dispatch/
β β βββ notifier.py # Multi-channel Telegram and Twilio dispatcher
β βββ server/
β β βββ app.py # FastAPI backend serving offline PWA
β βββ static/ # Offline PWA, service worker, and acoustic siren
βββ tests/ # Pytest suite with Temporal time-skipping
βββ docs/assets/ # Video B-roll, diagrams, and benchmarks
Prior Labs TabPFN In-Context Engine
Here is the core inference implementation from src/ml/tabpfn_engine.py:
class TabPFNRiskEngine:
def __init__(self, data_path: Optional[Path] = None):
self.data_path = data_path or settings.DATA_DIR / "sample_trail_history.csv"
self.classifier = TabPFNClassifier()
self.regressor = TabPFNRegressor()
self._fit_context()
def _fit_context(self) -> None:
df = pd.read_csv(self.data_path)
X = df[FEATURE_COLUMNS].to_numpy(dtype=np.float32)
y_cls = df["hazard_label"].to_numpy(dtype=np.int64)
y_reg = df["water_deficit_ml"].to_numpy(dtype=np.float32)
# In-context fitting in a single forward pass
self.classifier.fit(X, y_cls)
self.regressor.fit(X, y_reg)
def evaluate(self, telemetry: HikerTelemetry) -> RiskAssessmentResult:
X_query = telemetry.to_array()
# Bayesian posterior probability P(hazard)
prob_matrix = self.classifier.predict_proba(X_query)
hazard_prob = float(prob_matrix[0, 1])
# Hydration deficit prediction in milliliters
deficit_pred = self.regressor.predict(X_query)
water_deficit = float(np.maximum(0.0, deficit_pred[0]))
return RiskAssessmentResult(
hazard_probability=round(hazard_prob, 4),
projected_water_deficit_ml=round(water_deficit, 1),
is_hazard=hazard_prob >= settings.HAZARD_PROBABILITY_THRESHOLD,
confidence=round(float(np.abs(hazard_prob - 0.5) * 2.0), 4),
model_mode="Prior Labs TabPFN Bayesian Foundation Model",
recommendation=self._generate_field_guidance(hazard_prob, water_deficit, telemetry),
)
Temporal Durable Workflow State Machine
The durable workflow state machine resides in src/temporal/workflows.py:
@workflow.defn(sandboxed=False)
class TrailSafetyWorkflow:
@workflow.signal
def check_in(self, payload: Dict[str, Any]) -> None:
self._signal_received = True
self.latest_telemetry = payload.get("telemetry", {})
self.current_checkpoint_idx = min(self.current_checkpoint_idx + 1, self.total_checkpoints)
@workflow.signal
def extend_window(self, minutes: int) -> None:
self._extended_seconds += max(1, minutes) * 60
@workflow.signal
def emergency_sos(self, reason: str) -> None:
self._sos_triggered = True
self._sos_reason = reason
@workflow.run
async def run(self, params_dict: Dict[str, Any]) -> Dict[str, Any]:
self.params = TrailSessionParams(**params_dict)
self.status = "ACTIVE"
while self.current_checkpoint_idx < self.total_checkpoints:
target_cp = self.params.checkpoints[self.current_checkpoint_idx]
leg_window = self.params.checkpoint_timeout_seconds + self._extended_seconds
self._extended_seconds = 0
self._signal_received = False
# Wait for hiker check-in signal
try:
await workflow.wait_condition(
lambda: self._signal_received or self._sos_triggered or self._hike_completed,
timeout=timedelta(seconds=leg_window),
)
except TimeoutError:
pass
if self._sos_triggered:
return await self._escalate_emergency(f"SOS: {self._sos_reason}")
if self._signal_received:
await self._process_successful_signal()
continue
# Grace period countdown
self.status = "GRACE_PERIOD"
try:
await workflow.wait_condition(
lambda: self._signal_received or self._sos_triggered or self._hike_completed,
timeout=timedelta(seconds=self.params.grace_period_seconds),
)
except TimeoutError:
return await self._escalate_emergency(
f"Missed checkpoint '{target_cp.get('name')}' beyond timeout and grace period."
)
Automated Test Verification
All integration paths pass using Temporal's time-skipping test server:
pytest tests/ -v
# 10 passed in 1.42s
How I Built It
TrailSafe is constructed on two open-source foundations: Prior Labs TabPFN and Temporal.
| Open-Source Technology | Category | Role |
|---|---|---|
| Prior Labs TabPFN | Foundation Model | In-context Bayesian prediction on small tabular telemetry |
| Temporal SDK | Workflow Engine | Durable execution state machine for countdown timers |
| FastAPI & Uvicorn | Web Framework | Lightweight local server supporting offline PWA clients |
| Web Audio API | Audio Interface | Generates 880Hz-1200Hz acoustic siren in browser sandboxes |
1. In-Context Bayesian Inference with TabPFN
Backcountry hiker distress represents a small-sample tabular problem. Excursions provide at most dozens of historical checkpoints rather than massive corporate datasets.
Deep neural networks overfit on small sample sizes. Standard tree algorithms require manual feature scaling and hyperparameter tuning.
TabPFN resolves this challenge. The foundation model pre-trains synthetic causal priors directly into transformer weights. We supply a seven-dimensional feature vector:
- Total elapsed trekking time in minutes
- Vertical ascent velocity in meters per hour
- Ambient air temperature in degrees Celsius
- Real-time heart rate in beats per minute
- Backpack weight ratio relative to body mass
- Cumulative fluid volume consumed in milliliters
- Total trail distance traversed in kilometers
TabPFN produces posterior probabilities in one forward pass on consumer hardware.
2. Empirical Benchmark Evaluation
I evaluated TabPFN against standard algorithms using 5-fold cross-validation on 40 trail records (src/ml/benchmark_eval.py):
| Model | Brier Score (Lower is Better) | ROC-AUC | Accuracy | Fluid Deficit MAE |
|---|---|---|---|---|
| Prior Labs TabPFN | 0.0050 | 1.0000 | 100.0% | 17.9 mL |
| Random Forest (50 trees) | 0.0114 | 1.0000 | 100.0% | 34.2 mL |
| Linear Regression | 0.0005 | 1.0000 | 100.0% | 44.2 mL |
TabPFN achieved a fluid deficit error of 17.9 mL, cutting error by more than half compared to Random Forest (34.2 mL). It ran zero-shot without hyperparameter searches.
3. Durable Execution with Temporal
Standard countdown timers stored in memory vanish when devices restart or lose power.
Temporal provides durable execution. Every timer, signal, and state transition persists inside an append-only event history.
If a field worker process crashes, Temporal reconstructs the state and resumes the countdown without dropping a second.
4. Engineering Post-Mortem: Three Real Hurdles Solved
Building resilient software requires overcoming unexpected edge cases:
-
The Rest Break False Alarm: Early prototypes used rigid timers. When a hiker paused at a waterfall, alerts fired unintentionally. I introduced an
extend_windowsignal alongside a two-stage grace period. - Brittle Heuristic Thresholds: Simple rules like flagging speed drops failed on steep boulder scrambles. TabPFN evaluates joint distributions, recognizing that reduced speed during steep ascents is normal.
- CPU Activity Deadlines: CPU inference required 20 seconds during initial cold starts. I lengthened activity timeouts to 90 seconds and added non-blocking health checks.
Why Does Open Innovation Matter?
- Backcountry Offline Resilience: When cell towers vanish, proprietary cloud endpoints become useless. Open models run directly on local laptops and consumer phones.
- Biometric Privacy: Heart rate, location coordinates, and emergency contacts are deeply personal. Running open weights on local hardware prevents telemetry harvesting.
- Equitable Safety: Life-saving wilderness protection should never require expensive recurring subscriptions. Open software ensures everyone explores outdoors safely.
My Agent Session
Developing TrailSafe involved fast iteration across Bayesian tabular statistics, durable state machines, and responsive terminal interfaces.
I used Gemini CLI to explore mathematical formulation, write time-skipping test suites, and validate TabPFN benchmarks:
-
Interactive Session Embed:
TrailSafe: Prior Labs TabPFN In-Context Bayesian Inference & Temporal Durable Dead Man's Switch
Prize Categories
Featured Category: Best Use of TabPFN ($200 USD)
- Deploys Prior Labs foundation models (
TabPFNClassifierandTabPFNRegressor) offline on local hardware. - Performs in-context Bayesian inference over seven physiological signals in under 100 milliseconds.
- Demonstrates an empirical benchmark with 17.9 mL fluid deficit error, outperforming Random Forest by more than 2x zero-shot.
Partner Category: Best Use of Temporal ($100 USD)
- Implements
TrailSafetyWorkflowwith durable timers and dynamic signals (check_in,extend_window,emergency_sos). - Manages state transitions across active countdowns, grace periods, and emergency escalations.
- Validated using Temporal's in-memory time-skipping test server to simulate multi-hour trail legs in milliseconds.
Overall Winner: Touch Grass
- Directly addresses the challenge theme by protecting solo adventurers exploring the outdoors.
- Employs a Screen-Zero philosophy that keeps devices tucked away, letting hikers truly touch grass.
Built with passion for solo wilderness explorers everywhere. Step outside, stay safe, and touch grass.







Top comments (2)
One time-skipping fixture I'd add for the rest-break fix: send extend_window(15) halfway through an active leg, then advance past the original deadline. In the snippet, leg_window is calculated before wait_condition, while the signal only increments _extended_seconds. The test should show whether the extension moves the current leg's deadline or only affects the next one, and the UI should say which. I'd pair that with the same check-in arriving twice after a reconnect: the handler shown advances current_checkpoint_idx on every signal, so a checkpoint ID dedup test would check that a retried delivery cannot skip a leg. These are questions from the posted snippet, not a claim that I ran the app.
Nice use of the dead-man switch: it's the same pattern we relied on in vehicle tracking, where the absence of a report is the alarm.
One question from that world: where does the countdown live while the phone is in the dead zone? If the Temporal worker runs on the phone, the alert is ready on time but can't leave until there's signal; if it runs on a server, the check-ins can't reach it. In tracking we ended up doing both: the device stores its positions and resends them when coverage returns, and the server raises the alarm on silence, using the last known position plus the planned route. Curious which side TrailSafe takes, and what the rescue alert carries when the last fix is hours old.
A small note on the benchmark: with 40 records and all three models at 100 % accuracy (even linear regression), the data may be too easy to tell them apart. A harder or real-world set would make the TabPFN advantage more convincing.