Skip to content
Closed
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
10 changes: 0 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,9 @@ unsafe_code = "forbid"

[lints.clippy]
all = "deny"

[[bench]]
name = "lifecycle_deletion_repairs"
harness = false

[[bench]]
name = "claims_nplus1"
harness = false

[[bench]]
name = "store_review_evidence_nplus1"
harness = false

[[bench]]
name = "validate_evidence"
harness = false
98 changes: 0 additions & 98 deletions benches/store_review_evidence_nplus1.rs

This file was deleted.

81 changes: 0 additions & 81 deletions benches/validate_evidence.rs

This file was deleted.

6 changes: 0 additions & 6 deletions plugins/openclaw/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,9 @@ export async function runZkr(

child.stdout.on("data", (chunk: Buffer) => capture(output.stdout, chunk));
child.stderr.on("data", (chunk: Buffer) => capture(output.stderr, chunk));
child.stdin.on("error", () => {
// Ignore EPIPE errors which occur when the child process closes its stdin before we finish writing
});
child.on("error", () => {
fail(false);
});
child.stdin.on("error", () => {
// Ignore EPIPE errors if the process closes stdin early
});
child.on("close", (code) => {
if (settled) return;
clearTimeout(timeout);
Expand Down
12 changes: 2 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ fn run() -> Result<Option<serde_json::Value>, Box<dyn std::error::Error>> {
return Err("usage: zkr --db PATH COMMAND (use --help)".into());
}
let mut database = MemoryDb::open(&arguments[1])?;
let value = dispatch_command(&mut database, arguments[2].as_str())?;
Ok(Some(value))
}

fn dispatch_command(
database: &mut MemoryDb,
command: &str,
) -> Result<serde_json::Value, Box<dyn std::error::Error>> {
let value = match command {
let value = match arguments[2].as_str() {
"remember" => {
let request = read_json::<RememberRequest>()?;
serde_json::to_value(database.remember_with_locator(request.memory, request.locator)?)?
Expand Down Expand Up @@ -93,7 +85,7 @@ fn dispatch_command(
"apply" => serde_json::to_value(database.apply(read_json::<ApplyInput>()?)?)?,
command => return Err(format!("unknown command {command:?}").into()),
};
Ok(value)
Ok(Some(value))
}

fn read_json<T: DeserializeOwned>() -> Result<T, Box<dyn std::error::Error>> {
Expand Down
33 changes: 0 additions & 33 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,37 +481,4 @@ mod tests {
_ => panic!("Expected EmptyText error for evidence id"),
}
}

#[test]
fn test_validate_text_valid() {
assert_eq!(validate_text("test_field", "valid text"), Ok(()));
assert_eq!(validate_text("test_field", " leading whitespace"), Ok(()));
assert_eq!(validate_text("test_field", "trailing whitespace "), Ok(()));
assert_eq!(validate_text("test_field", " both "), Ok(()));
assert_eq!(validate_text("test_field", "a"), Ok(()));
}

#[test]
fn test_validate_text_invalid() {
assert_eq!(
validate_text("test_field", ""),
Err(ValidationError::EmptyText("test_field"))
);
assert_eq!(
validate_text("test_field", " "),
Err(ValidationError::EmptyText("test_field"))
);
assert_eq!(
validate_text("test_field", "\t"),
Err(ValidationError::EmptyText("test_field"))
);
assert_eq!(
validate_text("test_field", "\n"),
Err(ValidationError::EmptyText("test_field"))
);
assert_eq!(
validate_text("test_field", " \t\n "),
Err(ValidationError::EmptyText("test_field"))
);
}
}
13 changes: 0 additions & 13 deletions src/personality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2095,17 +2095,4 @@ mod tests {
.unwrap();
assert_eq!(augmented, "Base prompt.");
}

#[test]
fn search_personality_propagates_db_error() {
let tmp = tempfile::tempdir().unwrap();
let db = MemoryDb::open(tmp.path().join("personality.db")).unwrap();
// Use an empty TenantId, which makes db.search fail validation
let tenant_id = TenantId("".into());
let person_id = PersonId("p1".into());
let personality = Personality::new(db, tenant_id, person_id);

let result = personality.search_personality("query", 5);
assert!(result.is_err());
}
}
62 changes: 24 additions & 38 deletions src/store/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,20 +450,6 @@ fn apply_evidence(
Ok(())
}

struct StoredClaim {
subject: String,
predicate: String,
value: String,
kind: String,
valid_from: Timestamp,
recorded_from: Timestamp,
valid_until: Option<Timestamp>,
recorded_until: Option<Timestamp>,
status: String,
tier: String,
processing_state: String,
}

fn apply_claim(transaction: &Transaction<'_>, record: &Claim, applied_at: Timestamp) -> Result<()> {
assert_legal_state(&record.tier, &record.status, &record.processing_state)
.map_err(|error| Error::Invalid(error.to_string()))?;
Expand All @@ -476,19 +462,19 @@ fn apply_claim(transaction: &Transaction<'_>, record: &Claim, applied_at: Timest
"SELECT subject, predicate, value, kind, valid_from, recorded_from, valid_until, recorded_until, status, tier, processing_state FROM claims WHERE id = ?1 AND tenant_id = ?2 AND person_id = ?3",
params![record.id.0, record.tenant_id.0, record.person_id.0],
|row| {
Ok(StoredClaim {
subject: row.get::<_, String>(0)?,
predicate: row.get::<_, String>(1)?,
value: row.get::<_, String>(2)?,
kind: row.get::<_, String>(3)?,
valid_from: row.get::<_, Timestamp>(4)?,
recorded_from: row.get::<_, Timestamp>(5)?,
valid_until: row.get::<_, Option<Timestamp>>(6)?,
recorded_until: row.get::<_, Option<Timestamp>>(7)?,
status: row.get::<_, String>(8)?,
tier: row.get::<_, String>(9)?,
processing_state: row.get::<_, String>(10)?,
})
Ok((
row.get::<_, String>(0)?,
row.get::<_, String>(1)?,
row.get::<_, String>(2)?,
row.get::<_, String>(3)?,
row.get::<_, Timestamp>(4)?,
row.get::<_, Timestamp>(5)?,
row.get::<_, Option<Timestamp>>(6)?,
row.get::<_, Option<Timestamp>>(7)?,
row.get::<_, String>(8)?,
row.get::<_, String>(9)?,
row.get::<_, String>(10)?,
))
},
)
.optional()?;
Expand All @@ -499,23 +485,23 @@ fn apply_claim(transaction: &Transaction<'_>, record: &Claim, applied_at: Timest
).map_err(claim_interval_error)?;
return Ok(());
};
if stored.subject != record.subject
|| stored.predicate != record.predicate
|| stored.value != record.value
|| stored.kind != kind
|| stored.valid_from != record.valid_time.from
|| stored.recorded_from != record.recorded_time.from
if stored.0 != record.subject
|| stored.1 != record.predicate
|| stored.2 != record.value
|| stored.3 != kind
|| stored.4 != record.valid_time.from
|| stored.5 != record.recorded_time.from
{
return Err(Error::Invalid(format!(
"applied claim {} conflicts with the stored claim payload",
record.id.0
)));
}
if stored.valid_until == record.valid_time.until
&& stored.recorded_until == record.recorded_time.until
&& stored.status == status
&& stored.tier == tier
&& stored.processing_state == processing_state
if stored.6 == record.valid_time.until
&& stored.7 == record.recorded_time.until
&& stored.8 == status
&& stored.9 == tier
&& stored.10 == processing_state
{
return Ok(());
}
Expand Down
Loading
Loading