Skip to content

fix(csa-session): preserve user result schema in result.toml pipeline#308

Merged
RyderFreeman4Logos merged 4 commits intomainfrom
fix/issue-307-result-schema
Mar 3, 2026
Merged

fix(csa-session): preserve user result schema in result.toml pipeline#308
RyderFreeman4Logos merged 4 commits intomainfrom
fix/issue-307-result-schema

Conversation

@RyderFreeman4Logos
Copy link
Owner

@RyderFreeman4Logos RyderFreeman4Logos commented Mar 3, 2026

Summary

  • preserve user-authored result schema when runtime persists session result
  • snapshot conflicting/non-runtime result content to stable sidecar output/user-result.toml
  • prevent stale runtime keys (events_count, artifacts) from leaking across saves
  • keep sidecar as first-write snapshot only, and fail fast when sidecar path exists but is not a file
  • add regression tests for repeated saves, stale field clearing, and sidecar path validation

Validation

  • just fmt
  • just clippy
  • cargo test -p csa-session test_save_result_preserves_custom_schema_with_sidecar_snapshot
  • cargo test -p csa-session test_save_result_does_not_overwrite_existing_sidecar_snapshot
  • cargo test -p csa-session test_save_result_errors_when_sidecar_path_is_not_file
  • cargo test -p csa-session test_save_result_clears_stale_optional_runtime_fields
  • cargo nextest run -p csa-session --all-features
  • just test-e2e
  • just test

Fixes #307

@RyderFreeman4Logos
Copy link
Owner Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a20b242853

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

match key {
"status" | "summary" | "tool" | "started_at" | "completed_at" => value.is_str(),
"exit_code" | "events_count" => value.is_integer(),
"artifacts" => value.is_array(),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate artifact entry schema before skipping sidecar snapshot

value_matches_runtime_schema treats artifacts as runtime-compatible whenever the value is any array, so malformed/custom artifact payloads (for example artifacts = [1, 2] or tables without path) are classified as non-custom and save_result_in skips output/user-result.toml snapshotting before overwrite. Since SessionResult artifact deserialization only accepts string paths or SessionArtifact objects, this path silently drops user-authored non-runtime result content that this change is intended to preserve.

Useful? React with 👍 / 👎.

@RyderFreeman4Logos
Copy link
Owner Author

Addressed Codex P2 in commit 3b28c7a: artifacts schema validation now checks per-entry shape before deciding whether to skip user-result sidecar snapshot; added regression test for malformed artifacts arrays.

@RyderFreeman4Logos
Copy link
Owner Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b28c7a902

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +735 to +736
if has_custom_schema {
let Some(contents) = existing_contents.as_deref() else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain sidecar artifact across subsequent saves

save_result_in only adds output/user-result.toml to artifacts inside the if has_custom_schema branch. For sessions whose original custom schema is entirely conflicting keys (for example only [tool]), the first save snapshots to sidecar and removes those conflicting keys, so later saves no longer satisfy has_custom_schema; then the runtime merge removes artifacts and replaces it with the caller-provided list, which drops the sidecar reference. This makes downstream consumers that rely on result.toml artifacts (rather than scanning output/) lose visibility of the preserved user snapshot even though the file still exists.

Useful? React with 👍 / 👎.

@RyderFreeman4Logos
Copy link
Owner Author

Addressed follow-up P2 in commit 6c6771c: if output/user-result.toml exists, save_result_in now always keeps its artifact entry so later saves cannot drop visibility.

@RyderFreeman4Logos
Copy link
Owner Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@RyderFreeman4Logos RyderFreeman4Logos merged commit cfd403e into main Mar 3, 2026
6 checks passed
@RyderFreeman4Logos RyderFreeman4Logos deleted the fix/issue-307-result-schema branch March 3, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csa run result.toml cannot carry custom sa schema (overwritten to minimal fields)

1 participant