Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
test:
name: Test & Lint Suite
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
with:
persist-credentials: false

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Cache Cargo Dependencies
uses: Swatinem/rust-cache@v2

- name: Verify Code Formatting
run: cargo fmt --check

- name: Run Clippy Linter
run: cargo clippy --all-targets -- -D warnings

- name: Run Cargo Test Suite
run: cargo test --all

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install Bun Dependencies
run: bun install --frozen-lockfile

- name: Run TypeScript Typecheck
run: bun run typecheck

- name: Run Bun Test Suite
run: bun test

- name: Run Oxlint Anti-Slop Linter
run: bunx oxlint src/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ browser_profiles/
# Logs & Debug
logs/
*.log
*.dump
erl_crash.dump
npm-debug.log*
yarn-debug.log*
pnpm-debug.log*
Expand Down
4 changes: 1 addition & 3 deletions src/agents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ pub use opportunity::{
pub use orchestrator::{MasterOrchestrator, OrchestrationReport};
pub use reddit_2_skill::{GeneratedSkillPackage, Reddit2SkillEngine};
pub use router::{DagStep, DagWave, DynamicRouter, ExecutionDag, IntentCategory};
pub use tool_agents::{
DiggerAgent, DrafterAgent, MinerAgent, OrchestrationContext, ToolAgent,
};
pub use tool_agents::{DiggerAgent, DrafterAgent, MinerAgent, OrchestrationContext, ToolAgent};
pub use velocity::{InteractionVerdict, VelocityGovernor};
50 changes: 38 additions & 12 deletions src/agents/opportunity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ impl RedditThread {
if !self.url.is_empty() {
self.url.clone()
} else {
format!("https://reddit.com/r/{}/comments/{}/", self.subreddit, self.id)
format!(
"https://reddit.com/r/{}/comments/{}/",
self.subreddit, self.id
)
}
}
}
Expand Down Expand Up @@ -204,7 +207,10 @@ impl OpportunityWorker {
id: s.id.clone(),
subreddit: s.subreddit.clone(),
title: s.title.clone(),
body: s.full_body.clone().unwrap_or_else(|| s.body_snippet.clone()),
body: s
.full_body
.clone()
.unwrap_or_else(|| s.body_snippet.clone()),
author: s.author.clone(),
created_utc: s.created_utc,
num_comments: s.num_comments,
Expand Down Expand Up @@ -423,10 +429,14 @@ impl OpportunityWorker {
// Drop off-topic threads that have no grounding in the community ontology
continue;
}
crate::ontology::EngagementVerdict::CertifiedSafe { alignment_score, .. } => {
crate::ontology::EngagementVerdict::CertifiedSafe {
alignment_score, ..
} => {
// Boost product fit and composite score with certified grounding
opp.product_fit_score = (opp.product_fit_score * (1.0 + *alignment_score as f64 * 0.25)).min(1.0);
opp.composite_score = (opp.composite_score * (1.0 + *alignment_score as f64 * 0.2)).min(1.0);
opp.product_fit_score =
(opp.product_fit_score * (1.0 + *alignment_score as f64 * 0.25)).min(1.0);
opp.composite_score =
(opp.composite_score * (1.0 + *alignment_score as f64 * 0.2)).min(1.0);
opp.preflight_verdict = Some(verdict);
final_ranked.push(opp);
}
Expand Down Expand Up @@ -505,7 +515,11 @@ impl OpportunityWorker {
.contains(&OpportunitySignal::UrgentWorkflow))
&& opportunity.product_fit_score >= 0.65;

let (draft_text, review_status, product_named, affiliation_disclosed) = if let Some(crate::ontology::EngagementVerdict::CertifiedSafe { angle, .. }) = &opportunity.preflight_verdict {
let (draft_text, review_status, product_named, affiliation_disclosed) = if let Some(
crate::ontology::EngagementVerdict::CertifiedSafe { angle, .. },
) =
&opportunity.preflight_verdict
{
let disclosure = if !angle.mandatory_disclosure.is_empty() {
format!("{}, ", angle.mandatory_disclosure)
} else {
Expand Down Expand Up @@ -706,15 +720,22 @@ mod tests {
);
assert_eq!(digger_res.total_sources, 1);
assert_eq!(digger_res.sources[0].id, "d1");
assert_eq!(digger_res.sources[0].canonical_url, "https://reddit.com/r/SaaS/comments/d1/");
assert_eq!(
digger_res.sources[0].canonical_url,
"https://reddit.com/r/SaaS/comments/d1/"
);

// 2. Miner analyzes content, intent signals, and ranks
let miner_res = OpportunityWorker::mine_content(&digger_res.sources, &product, 1500);
assert_eq!(miner_res.analyzed_count, 1);
let opp = &miner_res.opportunities[0];
assert_eq!(opp.thread.id, "d1");
assert!(opp.detected_signals.contains(&OpportunitySignal::RecommendationAsk));
assert!(opp.detected_signals.contains(&OpportunitySignal::CompetitorFrustration));
assert!(opp
.detected_signals
.contains(&OpportunitySignal::RecommendationAsk));
assert!(opp
.detected_signals
.contains(&OpportunitySignal::CompetitorFrustration));
assert!(opp.composite_score > 0.70);
}

Expand All @@ -726,7 +747,8 @@ mod tests {
id: "t_safe".to_string(),
subreddit: "SaaS".to_string(),
title: "Need recommendations for customer outreach tools".to_string(),
body: "Tired of wasting hours on Reddit outreach. Is there a safe tool?".to_string(),
body: "Tired of wasting hours on Reddit outreach. Is there a safe tool?"
.to_string(),
author: "founder1".to_string(),
created_utc: 1200,
num_comments: 5,
Expand Down Expand Up @@ -770,7 +792,9 @@ mod tests {
"certifier_1",
);

let ranked = OpportunityWorker::discover_opportunities_with_ontology(&threads, &product, &ontology, 1500);
let ranked = OpportunityWorker::discover_opportunities_with_ontology(
&threads, &product, &ontology, 1500,
);

// t_spam must be completely filtered out by HighRiskViolation preflight check
assert_eq!(ranked.len(), 1);
Expand All @@ -782,7 +806,9 @@ mod tests {

// Test drafted reply uses the certified angle
let draft = OpportunityWorker::draft_reply(&ranked[0], &product).expect("draft");
assert!(draft.draft_text.contains("building an open-source local triage tool"));
assert!(draft
.draft_text
.contains("building an open-source local triage tool"));
assert_eq!(draft.review_status, ReviewStatus::Approved);
}
}
9 changes: 8 additions & 1 deletion src/agents/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ impl MasterOrchestrator {
status: "pending_human_approval".to_string(),
steps_completed,
total_steps,
context_summary: "Workflow paused at cryptographic action approval gate.".to_string(),
context_summary: "Workflow paused at cryptographic action approval gate."
.to_string(),
execution_log: context.execution_log,
result: serde_json::json!({
"paused_at_step": step.step_id,
Expand Down Expand Up @@ -151,6 +152,12 @@ impl MasterOrchestrator {
}
}

impl Default for MasterOrchestrator {
fn default() -> Self {
Self::new()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading
Loading