MCPcopy Create free account
hub / github.com/AI45Lab/Code / gen_session_data

Function gen_session_data

core/tests/test_persisted_schema_roundtrip.rs:498–542  ·  view source on GitHub ↗

The largest persisted root type, and the carrier of the 3.3.0 identity fields (tenant/principal/template/correlation). Exercises a nested `PermissionPolicy` (itself holding the persisted untagged `PermissionRule`), the `#[serde(alias = "todos")]` `tasks` field, and the `#[serde(skip)]` `hook_engine` (safe: skipped in both directions).

(rng: &mut Rng)

Source from the content-addressed store, hash-verified

496/// the `#[serde(alias = "todos")]` `tasks` field, and the `#[serde(skip)]`
497/// `hook_engine` (safe: skipped in both directions).
498fn gen_session_data(rng: &mut Rng) -> SessionData {
499 let state = match rng.below(5) {
500 0 => SessionState::Unknown,
501 1 => SessionState::Active,
502 2 => SessionState::Paused,
503 3 => SessionState::Completed,
504 _ => SessionState::Error,
505 };
506 let config = SessionConfig {
507 name: rng.string(),
508 workspace: rng.string(),
509 system_prompt: rng.opt_string(),
510 permission_policy: if rng.boolean() {
511 Some(gen_permission_policy(rng))
512 } else {
513 None
514 },
515 ..Default::default()
516 };
517 SessionData {
518 id: rng.string(),
519 config,
520 state,
521 messages: (0..rng.below(3)).map(|_| gen_message(rng)).collect(),
522 context_usage: ContextUsage::default(),
523 total_usage: gen_token_usage(rng),
524 total_cost: rng.f64_finite(),
525 model_name: rng.opt_string(),
526 cost_records: Vec::new(),
527 tool_names: rng.string_vec(3),
528 thinking_enabled: rng.boolean(),
529 thinking_budget: rng.opt_usize(),
530 created_at: rng.u64_small() as i64,
531 updated_at: rng.u64_small() as i64,
532 llm_config: None,
533 tasks: (0..rng.below(3))
534 .map(|i| Task::new(format!("t{i}"), rng.string()))
535 .collect(),
536 parent_id: rng.opt_string(),
537 tenant_id: rng.opt_string(),
538 principal: rng.opt_string(),
539 agent_template_id: rng.opt_string(),
540 correlation_id: rng.opt_string(),
541 }
542}
543
544// ─────────────────────────────────────────────────────────────────────
545// Property helpers.

Calls 11

gen_permission_policyFunction · 0.85
gen_messageFunction · 0.85
gen_token_usageFunction · 0.85
belowMethod · 0.80
stringMethod · 0.80
opt_stringMethod · 0.80
booleanMethod · 0.80
f64_finiteMethod · 0.80
string_vecMethod · 0.80
opt_usizeMethod · 0.80
u64_smallMethod · 0.80

Tested by

no test coverage detected