Skip to content

Commit b86839d

Browse files
committed
post-merge
1 parent c4b918c commit b86839d

15 files changed

Lines changed: 156 additions & 664 deletions

File tree

Cargo.lock

Lines changed: 135 additions & 480 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pattern_cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ path = "src/main.rs"
1515
default = ["oauth", "discord"]
1616
oauth = ["pattern-core/oauth"]
1717
discord = ["pattern-discord"]
18-
legacy-convert = ["pattern-surreal-compat"]
18+
legacy-convert = ["dep:pattern-surreal-compat"]
1919

2020
[dependencies]
2121
# Workspace dependencies

crates/pattern_cli/src/commands/agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ pub async fn add_rule(
190190
agent_name: &str,
191191
rule_type: &str,
192192
tool_name: &str,
193-
_params: Option<&str>,
194-
_conditions: Option<&str>,
195-
_priority: u8,
193+
params: Option<&str>,
194+
conditions: Option<&str>,
195+
priority: u8,
196196
) -> Result<()> {
197197
let output = Output::new();
198198
let config = crate::helpers::load_config().await?;

crates/pattern_cli/src/commands/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! These commands manage OAuth tokens for AI model providers. This is separate
44
//! from ATProto authentication (see atproto.rs for Bluesky auth).
55
6-
use miette::Result;
6+
use miette::{IntoDiagnostic, Result};
77
use owo_colors::OwoColorize;
88
use pattern_auth::ProviderOAuthToken;
99
use pattern_core::config::PatternConfig;
@@ -28,7 +28,7 @@ pub async fn login(provider: &str, config: &PatternConfig) -> Result<()> {
2828
output.info("Supported providers:", "anthropic");
2929
return Ok(());
3030
}
31-
}
31+
};
3232

3333
output.section(&format!("OAuth Login: {}", provider.bright_cyan()));
3434

crates/pattern_cli/src/commands/debug.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ use crate::output::Output;
2323
pub async fn search_conversations(
2424
agent_name: &str,
2525
query: Option<&str>,
26-
_role: Option<&str>,
27-
_start_time: Option<&str>,
28-
_end_time: Option<&str>,
26+
role: Option<&str>,
27+
start_time: Option<&str>,
28+
end_time: Option<&str>,
2929
limit: usize,
3030
) -> Result<()> {
3131
let output = Output::new();

crates/pattern_cli/src/commands/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub async fn import(
246246
file_path: PathBuf,
247247
rename_to: Option<String>,
248248
preserve_ids: bool,
249-
_config: &PatternConfig,
249+
config: &PatternConfig,
250250
) -> Result<()> {
251251
let output = Output::new();
252252
let db = get_db(config).await?;

crates/pattern_cli/src/commands/group.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub async fn add_member(
8686
group_name: &str,
8787
agent_name: &str,
8888
role: &str,
89-
_capabilities: Option<&str>,
89+
capabilities: Option<&str>,
9090
config: &PatternConfig,
9191
) -> Result<()> {
9292
let output = Output::new();

crates/pattern_core/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ proc-macro2-diagnostics = "0.10"
123123
miette = { workspace = true, features = ["fancy"] }
124124

125125
[features]
126-
default = ["surreal-embedded", "embed-cloud", "file-watch"]
126+
default = [ "embed-cloud", "file-watch"]
127127
nd = [] # Enable neurodivergent features when pattern-nd is ready
128128
export = ["zstd"] # Agent export/import with compression
129129
oauth = ["reqwest-middleware", "http"] # OAuth authentication support
130130
file-watch = [] # File watching for data sources (notify always included)
131131

132132
# Database backends
133-
surreal-embedded = []
134-
surreal-remote = []
135133

136134
# Embedding backends
137135
embed-candle = [

crates/pattern_core/src/agent/mod.rs

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -391,119 +391,3 @@ pub enum ActionPriority {
391391
/// Critical priority - requires immediate attention
392392
Critical,
393393
}
394-
395-
use ferroid::{Base32SnowExt, SnowflakeGeneratorAsyncTokioExt, SnowflakeMastodonId};
396-
use std::fmt;
397-
use std::sync::OnceLock;
398-
399-
/// Wrapper type for Snowflake IDs with proper serde support
400-
#[repr(transparent)]
401-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
402-
pub struct SnowflakePosition(pub SnowflakeMastodonId);
403-
404-
impl SnowflakePosition {
405-
/// Create a new snowflake position
406-
pub fn new(id: SnowflakeMastodonId) -> Self {
407-
Self(id)
408-
}
409-
}
410-
411-
impl fmt::Display for SnowflakePosition {
412-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
413-
// Use the efficient base32 encoding via Display
414-
write!(f, "{}", self.0)
415-
}
416-
}
417-
418-
impl FromStr for SnowflakePosition {
419-
type Err = String;
420-
421-
fn from_str(s: &str) -> core::result::Result<Self, Self::Err> {
422-
// Try parsing as base32 first
423-
if let Ok(id) = SnowflakeMastodonId::decode(s) {
424-
return Ok(Self(id));
425-
}
426-
427-
// Fall back to parsing as raw u64
428-
s.parse::<u64>()
429-
.map(|raw| Self(SnowflakeMastodonId::from_raw(raw)))
430-
.map_err(|e| format!("Failed to parse snowflake as base32 or u64: {}", e))
431-
}
432-
}
433-
434-
impl Serialize for SnowflakePosition {
435-
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
436-
where
437-
S: serde::Serializer,
438-
{
439-
// Serialize as string using Display
440-
serializer.serialize_str(&self.to_string())
441-
}
442-
}
443-
444-
impl<'de> Deserialize<'de> for SnowflakePosition {
445-
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
446-
where
447-
D: serde::Deserializer<'de>,
448-
{
449-
// Deserialize from string and parse
450-
let s = String::deserialize(deserializer)?;
451-
s.parse::<Self>().map_err(serde::de::Error::custom)
452-
}
453-
}
454-
455-
/// Type alias for the Snowflake generator we're using
456-
type SnowflakeGen = ferroid::AtomicSnowflakeGenerator<SnowflakeMastodonId, ferroid::MonotonicClock>;
457-
458-
/// Global ID generator for message positions using Snowflake IDs
459-
/// This provides distributed, monotonic IDs that work across processes
460-
static MESSAGE_POSITION_GENERATOR: OnceLock<SnowflakeGen> = OnceLock::new();
461-
462-
pub fn get_position_generator() -> &'static SnowflakeGen {
463-
MESSAGE_POSITION_GENERATOR.get_or_init(|| {
464-
// Use machine ID 0 for now - in production this would be configurable
465-
let clock = ferroid::MonotonicClock::with_epoch(ferroid::TWITTER_EPOCH);
466-
ferroid::AtomicSnowflakeGenerator::new(0, clock)
467-
})
468-
}
469-
470-
/// Get the next message position synchronously
471-
///
472-
/// This is designed for use in synchronous contexts like Default impls.
473-
/// In practice, we don't generate messages fast enough to hit the sequence
474-
/// limit (65536/ms), so Pending should rarely happen in production.
475-
///
476-
/// When the sequence is exhausted (e.g., in parallel tests), this will block
477-
/// briefly until the next millisecond boundary to get a fresh sequence.
478-
pub fn get_next_message_position_sync() -> SnowflakePosition {
479-
use ferroid::IdGenStatus;
480-
481-
let generator = get_position_generator();
482-
483-
loop {
484-
match generator.next_id() {
485-
IdGenStatus::Ready { id } => return SnowflakePosition::new(id),
486-
IdGenStatus::Pending { yield_for } => {
487-
// If yield_for is 0, we're at the sequence limit but still in the same millisecond.
488-
// Wait at least 1ms to roll over to the next millisecond and reset the sequence.
489-
let wait_ms = yield_for.max(1) as u64;
490-
std::thread::sleep(std::time::Duration::from_millis(wait_ms));
491-
// Loop will retry after the wait
492-
}
493-
}
494-
}
495-
}
496-
497-
/// Get the next message position as a Snowflake ID (async version)
498-
pub async fn get_next_message_position() -> SnowflakePosition {
499-
let id = get_position_generator()
500-
.try_next_id_async()
501-
.await
502-
.expect("for now we are assuming this succeeds");
503-
SnowflakePosition::new(id)
504-
}
505-
506-
/// Get the next message position as a String (for database storage)
507-
pub async fn get_next_message_position_string() -> String {
508-
get_next_message_position().await.to_string()
509-
}

crates/pattern_core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod agent;
88
pub mod config;
99
pub mod context;
1010
pub mod coordination;
11-
//pub mod data_source;
11+
pub mod data_source;
1212
pub mod db;
1313
pub mod embeddings;
1414
pub mod error;

0 commit comments

Comments
 (0)