chore(simplify): remove unnecessary comment and avoid double-serialization in event API

- Remove narrating comment in run_manifest.rs (code is self-explanatory)
- Optimize api_event_envelope_from_store: reuse payload's existing
  serde_json::Value instead of serialize-then-deserialize round-trip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-04-10 11:47:15 -04:00
parent 76089bd8aa
commit 7fc133a2b1
No known key found for this signature in database
2 changed files with 13 additions and 12 deletions

View file

@ -97,9 +97,6 @@ pub(crate) fn prepare_manifest_with_mode(
)?;
if let Some(goal) = manifest.goal.as_ref() {
let run = settings.run.get_or_insert_with(RunLayer::default);
// The CLI has already resolved any goal-file reads into
// `manifest.goal.text`, so the server side always stores the
// final text inline.
run.goal = Some(RunGoalLayer::Inline(InterpString::parse(&goal.text)));
}

View file

@ -2495,15 +2495,19 @@ fn octet_stream_response(bytes: Bytes) -> Response {
#[allow(clippy::result_large_err)]
fn api_event_envelope_from_store(event: &EventEnvelope) -> Result<ApiEventEnvelope, Response> {
serde_json::to_value(event)
.and_then(serde_json::from_value)
.map_err(|err| {
ApiError::new(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Failed to serialize stored event: {err}"),
)
.into_response()
})
// The payload is already a serde_json::Value; merge `seq` into it
// instead of serializing the whole envelope and re-parsing.
let mut obj = event.payload.as_value().clone();
if let serde_json::Value::Object(ref mut map) = obj {
map.insert("seq".into(), serde_json::Value::from(event.seq));
}
serde_json::from_value(obj).map_err(|err| {
ApiError::new(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Failed to deserialize stored event: {err}"),
)
.into_response()
})
}
fn clear_live_run_state(run: &mut ManagedRun) {