Skip to content

agent-trace: Add SCE metadata to generated payloads#46

Open
ivke995 wants to merge 2 commits into
mainfrom
feat/agent-trace-sce-metadata
Open

agent-trace: Add SCE metadata to generated payloads#46
ivke995 wants to merge 2 commits into
mainfrom
feat/agent-trace-sce-metadata

Conversation

@ivke995
Copy link
Copy Markdown
Contributor

@ivke995 ivke995 commented May 20, 2026

Emit implementation-owned metadata.sce.version from the compiled CLI package version when building Agent Trace payloads. Update golden fixtures and tests to assert the metadata is present and schema-valid, and document the persisted payload contract.

Summary by CodeRabbit

  • New Features
    • Agent trace records now include metadata with SCE version information for improved tracking and compatibility verification.
  • Tests
    • Test helpers validate that emitted traces contain a non-empty SCE metadata version.
  • Chores
    • Updated trace golden fixtures to include the new SCE metadata version field.

Review Change Stack

Emit implementation-owned metadata.sce.version from the compiled CLI package version when building Agent Trace payloads. Update golden fixtures and tests to assert the metadata is present and schema-valid, and document the persisted payload contract.

Plan: agent-trace-sce-metadata

Tasks: T01, T02, T03

Co-authored-by: SCE <sce@crocoder.dev>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

📝 Walkthrough

Walkthrough

Adds SCE metadata to agent traces: defines a version constant and metadata types, embeds a defaulted metadata field in AgentTrace, populates it in build_agent_trace, updates tests to assert the metadata is present, and updates golden fixtures.

Changes

SCE Trace Metadata Versioning

Layer / File(s) Summary
Metadata type definitions and version constant
cli/src/services/agent_trace.rs
SCE_METADATA_VERSION is derived from crate version and AgentTraceMetadata and AgentTraceSceMetadata are defined as JSON-serializable types with snake_case naming.
AgentTrace struct integration
cli/src/services/agent_trace.rs
AgentTrace struct gains a new metadata: AgentTraceMetadata field with default deserialization behavior.
Populate metadata during trace construction
cli/src/services/agent_trace.rs
build_agent_trace function is updated to populate the metadata field in the emitted AgentTrace output.
Test assertions for metadata
cli/src/services/agent_trace/tests.rs
Tests extract metadata.sce.version from serialized JSON and assert it is present and non-empty.
Golden trace fixture updates
cli/src/services/agent_trace/fixtures/**/golden.json
All seven golden fixture files (average_age_reconstruction, file_rename_reconstruction, hello_world_reconstruction, mixed_change_reconstruction, poem_edit_reconstruction, poem_write_reconstruction, text_file_lifecycle_reconstruction) are updated to include metadata.sce.version: "0.2.0".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding SCE metadata to agent trace payloads, which aligns with all code modifications introducing metadata structures and updating fixtures.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/agent-trace-sce-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ivke995 ivke995 marked this pull request as ready for review May 20, 2026 12:14
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cli/src/services/agent_trace/tests.rs (1)

1-7: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reorder imports to match repository Rust grouping.

Third-party crates (serde_json) must be grouped before local crate:: and super:: imports, per the coding guideline.

♻️ Proposed fix
-use super::{
-    build_agent_trace, validate_agent_trace_value, AgentTraceMetadataInput, AgentTraceVcsType,
-    LineRange, AGENT_TRACE_VERSION, SCE_METADATA_VERSION,
-};
-use crate::services::patch::{combine_patches, parse_patch, ParsedPatch};
 use serde_json::{json, Value};
+
+use crate::services::patch::{combine_patches, parse_patch, ParsedPatch};
+use super::{
+    build_agent_trace, validate_agent_trace_value, AgentTraceMetadataInput, AgentTraceVcsType,
+    LineRange, AGENT_TRACE_VERSION, SCE_METADATA_VERSION,
+};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/services/agent_trace/tests.rs` around lines 1 - 7, Reorder the use
statements so third-party crates come first: move serde_json::{json, Value}
above the local imports; then list crate::services::patch items
(combine_patches, parse_patch, ParsedPatch) followed by the super:: items
(build_agent_trace, validate_agent_trace_value, AgentTraceMetadataInput,
AgentTraceVcsType, LineRange, AGENT_TRACE_VERSION, SCE_METADATA_VERSION) to
match the repository Rust import grouping conventions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@cli/src/services/agent_trace/tests.rs`:
- Around line 1-7: Reorder the use statements so third-party crates come first:
move serde_json::{json, Value} above the local imports; then list
crate::services::patch items (combine_patches, parse_patch, ParsedPatch)
followed by the super:: items (build_agent_trace, validate_agent_trace_value,
AgentTraceMetadataInput, AgentTraceVcsType, LineRange, AGENT_TRACE_VERSION,
SCE_METADATA_VERSION) to match the repository Rust import grouping conventions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a049642c-e8b9-41db-9ab1-9fb105429e78

📥 Commits

Reviewing files that changed from the base of the PR and between 5506feb and a319e50.

⛔ Files ignored due to path filters (7)
  • context/context-map.md is excluded by !context/**/*.md
  • context/glossary.md is excluded by !context/**/*.md
  • context/overview.md is excluded by !context/**/*.md
  • context/plans/agent-trace-sce-metadata.md is excluded by !context/**/*.md
  • context/sce/agent-trace-db.md is excluded by !context/**/*.md
  • context/sce/agent-trace-hooks-command-routing.md is excluded by !context/**/*.md
  • context/sce/agent-trace-minimal-generator.md is excluded by !context/**/*.md
📒 Files selected for processing (9)
  • cli/src/services/agent_trace.rs
  • cli/src/services/agent_trace/fixtures/average_age_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/file_rename_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/hello_world_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/mixed_change_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/poem_edit_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/poem_write_reconstruction/golden.json
  • cli/src/services/agent_trace/fixtures/text_file_lifecycle_reconstruction/golden.json
  • cli/src/services/agent_trace/tests.rs

Comment thread cli/src/services/agent_trace/tests.rs Outdated
@ivke995 ivke995 requested a review from stefanskoricdev May 20, 2026 13:51
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cli/src/services/agent_trace/tests.rs (1)

1-7: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Reorder imports to follow repository Rust grouping rules.

Move third-party imports (serde_json) above local crate/module imports, keeping groups in the required order.

As per coding guidelines, "**/*.rs: Group Rust imports in this order: standard library, third-party crates, then crate::... imports."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cli/src/services/agent_trace/tests.rs` around lines 1 - 7, The import block
in tests.rs is misordered; move the third-party import serde_json (json, Value)
above local crate/module imports so imports follow the repo rule (standard
library, third-party, then crate), preserving the existing items
(build_agent_trace, validate_agent_trace_value, AgentTraceMetadataInput,
AgentTraceVcsType, LineRange, AGENT_TRACE_VERSION, combine_patches, parse_patch,
ParsedPatch) and ensure a blank line separates the groups.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@cli/src/services/agent_trace/tests.rs`:
- Around line 1-7: The import block in tests.rs is misordered; move the
third-party import serde_json (json, Value) above local crate/module imports so
imports follow the repo rule (standard library, third-party, then crate),
preserving the existing items (build_agent_trace, validate_agent_trace_value,
AgentTraceMetadataInput, AgentTraceVcsType, LineRange, AGENT_TRACE_VERSION,
combine_patches, parse_patch, ParsedPatch) and ensure a blank line separates the
groups.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6950ce63-6c00-4eb3-bda3-0e35a36054bd

📥 Commits

Reviewing files that changed from the base of the PR and between a319e50 and f92d3f6.

📒 Files selected for processing (1)
  • cli/src/services/agent_trace/tests.rs

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.

2 participants