Skip to content

test(viewer): session-ledger distill compiler proptest surface (WBS-6.2 #462) - #478

Closed
KooshaPari wants to merge 5 commits into
mainfrom
fix/viewer-mock-data-properties-20260809
Closed

test(viewer): session-ledger distill compiler proptest surface (WBS-6.2 #462)#478
KooshaPari wants to merge 5 commits into
mainfrom
fix/viewer-mock-data-properties-20260809

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Aug 10, 2026

Copy link
Copy Markdown
Owner

User description

Summary

Adds crates/sl-viewer/tests/properties_session_ledger_distill.rs with 9 proptest properties pinning session_ledger::distill::compile and compile_and_store (WBS-6.2 #462) — the deterministic compilation pipeline that turns a Session into a ContinuationBundle + episodic memories.

compile (6 properties)

  • Bundle source_id equals session.id.
  • Always injectable (carries Acceptance slice) — load-bearing contract for resume.
  • Always emits one slice for every documented kind (Acceptance / Intent / Context / Contract / Provenance / Worklog) — even for empty sessions.
  • total_token_estimate() equals the sum of per-slice token_estimate values.
  • Deterministic across calls.
  • Worklog slice body deserializes to a WorklogProjection whose message_count equals session.messages.len().

compile_and_store (3 properties)

  • Returns an injectable bundle with the input source_id.
  • Writes exactly 3 episodic memories (intent / contract / context) to the memory store.
  • Deterministic across fresh stores.

Validation

  • cargo test -p sl-viewer --test properties_session_ledger_distill --features "desktop parquet" --locked — 9 passed
  • cargo fmt --all --check — clean

WBS / TRACEABILITY

WBS-6.2 evidence list and TRACEABILITY.json gain crates/sl-viewer/tests/properties_session_ledger_distill.rs. CHANGELOG Unreleased documents the new surface.


CodeAnt-AI Description

Add property-test coverage for viewer loading states and session-ledger recovery, export, validation, and compilation behavior

What Changed

  • Verify viewer skeleton layouts have the documented variants, default selection, stable labels, and bounded row counts
  • Verify unfinished session detection identifies awaiting responses, interrupted execution, missing completion markers, and finished sessions while preserving session details and concise summaries
  • Verify OKF documents and exports preserve source and corpus details, validate cleanly, produce expected entities, and avoid duplicate identifiers
  • Verify session compilation always produces deterministic, injectable bundles with all required slices and exactly three stored episodic memories
  • Record the new property-test evidence in the changelog, traceability records, and WBS documentation

Impact

✅ Fewer undetected lost-work sessions
✅ Valid OKF exports for downstream consumers
✅ Reliable session resume bundles
✅ Stable viewer loading behavior

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

SessionLedger Bot added 5 commits August 9, 2026 19:37
)

Adds crates/sl-viewer/tests/properties_viewer_async_states.rs with
7 proptest properties pinning the async_states SSOT:

* SkeletonLayout::default() is Bundles.
* SkeletonLayout exposes exactly three variants
  (Bundles, ListDetail, StreamFeed).
* Every variant's Debug label is non-empty, single-line, and
  matches one of the documented names.
* SkeletonLayout::default() matches the first arm in the match
  block in ContentSkeleton.
* list_rows.clamp(3, 6) lands in [3, 6] for every input.
* The clamp is monotonic non-decreasing.
* The clamp has the documented fixed points (0/2 -> 3, 6/MAX -> 6).

Updates WBS-6.2 evidence list, TRACEABILITY.json, and CHANGELOG.
…(WBS-6.2 #459)

Adds crates/sl-viewer/tests/properties_session_ledger_okf.rs with
12 proptest properties pinning the session-ledger OKF SSOT:

* OkfDocument::new(b, c) always produces okf = "1.0".
* OkfDocument::new(b, c) propagates bundle.source_id into
  source_id and provenance.source_id.
* OkfDocument::new(b, c) propagates c into provenance.corpus.
* OkfDocument::new(b, c) starts with empty entities, relations,
  tags.
* validate_okf_document reports exactly one unsupported_version
  error per non-"1.0" okf (with offending version in message).
* validate_okf_document reports exactly one source_id_mismatch
  error per provenance/source mismatch.
* Duplicate entity ids each surface a duplicate_entity_id error.
* Dangling relation source / target surface their respective
  errors.
* Every OkfValidationError carries non-empty field / code /
  message.

First property test to exercise session_ledger (the core domain
crate) from sl-viewer's test harness, pivoting the bounded lane
beyond the viewer-only surface.

Updates WBS-6.2 evidence list, TRACEABILITY.json, and CHANGELOG.
…6.2 #460)

Adds crates/sl-viewer/tests/properties_session_ledger_worklog.rs
with 11 proptest properties pinning the session-ledger worklog
projector (crash-recovery / lost-work pipeline):

* Empty sessions project None.
* Final Role::User turn -> AwaitingAssistantResponse.
* Final Role::Tool / Role::Subagent -> InterruptedExecution.
* Final assistant turn with one of the 9 documented completion
  markers (complete / completed / done / [completed] /
  <completed> / status: complete / status: completed /
  task complete / task completed) projects None.
* Final assistant turn without any marker projects as
  MissingCompletionMarker.
* UnfinishedWorkItem carries the originating session id, corpus,
  and message_count.
* summary never exceeds 241 chars and is single-line.
* project_unfinished_work returns one item per unfinished
  session in input order and is deterministic.
* WorklogProjection::from_session carries message_count and
  matches detect_unfinished exactly.

Updates WBS-6.2 evidence list, TRACEABILITY.json, and CHANGELOG.
…-6.2 #461)

Adds crates/sl-viewer/tests/properties_session_ledger_export.rs with
8 proptest properties pinning session_ledger::export_to_okf
(the OKF v1 export pipeline entry point):

* export_to_okf always produces okf = "1.0" and propagates
  bundle.source_id into source_id + provenance.source_id.
* export_to_okf propagates the corpus arg into provenance.corpus.
* Empty bundles yield zero entities / relations / tags.
* Every exported document passes validate_okf_document.
* export_to_okf is deterministic across calls.
* Intent bundles emit exactly one goal entity (label = goal),
  one acceptance entity per acceptance signal, one constraint
  entity per constraint.
* Context bundles emit exactly one resource entity when cwd is
  present.
* Acceptance bundles emit exactly one gate entity with
  label = "resume-gate" and properties.ready = true /
  scope_sized = true.
* The exporter never produces duplicate entity ids across
  mixed intent / context / acceptance / contract bundles.

Updates WBS-6.2 evidence list, TRACEABILITY.json, and CHANGELOG.
#462)

Adds crates/sl-viewer/tests/properties_session_ledger_distill.rs
with 9 proptest properties pinning session_ledger::distill::compile
and compile_and_store:

* compile(session) always produces a bundle whose source_id
  equals session.id.
* compile(session) always produces an injectable bundle
  (carries an Acceptance slice) — the load-bearing contract
  for resume.
* compile(session) always emits one slice for every documented
  kind (Acceptance / Intent / Context / Contract / Provenance /
  Worklog) — even when the session is empty.
* compile(session) always returns a bundle whose
  total_token_estimate() equals the sum of per-slice
  token_estimate values.
* compile(session) is deterministic across calls.
* The Worklog slice body deserializes to a WorklogProjection
  whose message_count equals session.messages.len().
* compile_and_store returns an injectable bundle with the
  input source_id.
* compile_and_store writes exactly 3 episodic memories
  (intent / contract / context) to the memory store.
* compile_and_store is deterministic across fresh stores.

Updates WBS-6.2 evidence list, TRACEABILITY.json, and CHANGELOG.
Copilot AI lite review requested due to automatic review settings August 10, 2026 03:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KooshaPari, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 20 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e860e88b-c91f-4fc4-8cb6-18ea15caa0c1

📥 Commits

Reviewing files that changed from the base of the PR and between 8f34223 and 22d1ea3.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • crates/sl-viewer/tests/properties_session_ledger_distill.rs
  • crates/sl-viewer/tests/properties_session_ledger_export.rs
  • crates/sl-viewer/tests/properties_session_ledger_okf.rs
  • crates/sl-viewer/tests/properties_session_ledger_worklog.rs
  • crates/sl-viewer/tests/properties_viewer_async_states.rs
  • docs/ops/TRACEABILITY.json
  • docs/ops/WBS.md

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.

@codeant-ai

codeant-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 22d1ea3 Aug 10, 2026 · 03:36 03:38

@codeant-ai

codeant-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Aug 10, 2026
Comment on lines +183 to +184
prop_assert_eq!(out_a.bundle, out_b.bundle);
prop_assert_eq!(out_a.memories.len(), out_b.memories.len());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This test claims that the complete DistillOutput is deterministic but compares only the number of memories, not their IDs, keys, or kinds. A regression that changes the persisted memory metadata or writes different facts while preserving the count would pass. Compare the complete memories values, and verify the stored contents if those are part of the contract. [incomplete implementation]

Severity Level: Major ⚠️
- ⚠️ Distill determinism property misses changed memory IDs or keys.
- ⚠️ ETL memory metadata regressions can pass CI undetected.
- ⚠️ Episodic persistence contents are not compared by this property.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/sl-viewer/tests/properties_session_ledger_distill.rs
**Line:** 183:184
**Comment:**
	*Incomplete Implementation: This test claims that the complete `DistillOutput` is deterministic but compares only the number of memories, not their IDs, keys, or kinds. A regression that changes the persisted memory metadata or writes different facts while preserving the count would pass. Compare the complete `memories` values, and verify the stored contents if those are part of the contract.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +260 to +265
let errors = validate_okf_document(&document);
prop_assert!(!errors.is_empty());
for err in &errors {
prop_assert!(!err.field.is_empty(), "error has empty field");
prop_assert!(!err.code.is_empty(), "error has empty code");
prop_assert!(!err.message.is_empty(), "error has empty message");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The fixture comment says it forces every error class, but the assertions only check that some errors exist and that their fields are non-empty. A validator regression that drops unsupported_version, source_id_mismatch, or duplicate_entity_id would still pass. Assert that each expected error code and field is present. [incomplete implementation]

Severity Level: Major ⚠️
- ⚠️ OKF validation coverage can silently lose error classes.
- ⚠️ Export diagnostics may omit version or provenance failures.
- ⚠️ Downstream callers receive incomplete validation feedback.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/sl-viewer/tests/properties_session_ledger_okf.rs
**Line:** 260:265
**Comment:**
	*Incomplete Implementation: The fixture comment says it forces every error class, but the assertions only check that some errors exist and that their fields are non-empty. A validator regression that drops `unsupported_version`, `source_id_mismatch`, or `duplicate_entity_id` would still pass. Assert that each expected error code and field is present.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +100 to +108
body in "[a-zA-Z0-9 .,!?]{1,40}",
) {
let mut session = Session::new("a", Corpus::Forge);
session.messages = vec![
Message::new(Role::User, "do it"),
Message::new(Role::Assistant, body),
];
let item = detect_unfinished(&session).expect("missing marker is unfinished");
prop_assert_eq!(item.reason, UnfinishedReason::MissingCompletionMarker);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The generated body may equal a completion marker such as complete, completed, or done. In that case detect_unfinished correctly returns None, so the unconditional expect panics and the property fails for valid generated input. Exclude the completion-marker set from this strategy or assert the result conditionally. [logic error]

Severity Level: Major ⚠️
- ❌ Worklog property test panics for valid completion content.
- ⚠️ Proptest runs can fail nondeterministically based on generated examples.
- ⚠️ CI validation of unfinished-work behavior becomes unreliable.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/sl-viewer/tests/properties_session_ledger_worklog.rs
**Line:** 100:108
**Comment:**
	*Logic Error: The generated `body` may equal a completion marker such as `complete`, `completed`, or `done`. In that case `detect_unfinished` correctly returns `None`, so the unconditional `expect` panics and the property fails for valid generated input. Exclude the completion-marker set from this strategy or assert the result conditionally.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment on lines +76 to +78
fn list_rows_clamp_in_range(input in any::<usize>()) {
let clamped = input.clamp(3, 6);
prop_assert!((3..=6).contains(&clamped), "clamp produced {clamped} for input {input}");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This property exercises usize::clamp directly rather than ContentSkeleton, even though the documented contract concerns the component's rendered row count. The component could stop clamping list_rows, apply the clamp only for some layouts, or use a different value and all these assertions would still pass. Render or otherwise exercise ContentSkeleton with the generated input and inspect its rows. [incomplete implementation]

Severity Level: Major ⚠️
- ⚠️ Component row-count regressions can pass property tests.
- ⚠️ Loading skeleton layouts may render too few or too many rows.
- ⚠️ Bundle, search, feed, and replay loading surfaces share this component.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** crates/sl-viewer/tests/properties_viewer_async_states.rs
**Line:** 76:78
**Comment:**
	*Incomplete Implementation: This property exercises `usize::clamp` directly rather than `ContentSkeleton`, even though the documented contract concerns the component's rendered row count. The component could stop clamping `list_rows`, apply the clamp only for some layouts, or use a different value and all these assertions would still pass. Render or otherwise exercise `ContentSkeleton` with the generated input and inspect its rows.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@KooshaPari KooshaPari closed this Aug 10, 2026
@KooshaPari
KooshaPari deleted the fix/viewer-mock-data-properties-20260809 branch August 10, 2026 04:20
@KooshaPari
KooshaPari restored the fix/viewer-mock-data-properties-20260809 branch August 10, 2026 04:20
@KooshaPari
KooshaPari deleted the fix/viewer-mock-data-properties-20260809 branch August 10, 2026 04:27
prop_assert!(name.is_ascii(), "variant {name:?} is not ASCII");
seen.insert(name);
}
prop_assert_eq!(seen.len(), 3, "variant count drifted");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: skeleton_layout_has_three_variants does not verify the total variant count

The test iterates over 3 hardcoded variants and asserts seen.len() == 3, which is trivially true. A 4th SkeletonLayout variant could be added and this test would still pass because it never enumerates all variants. Consider adding a compile-time check or documenting that ContentSkeleton's exhaustive match is the real guard.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

let first = match () {
() => SkeletonLayout::Bundles, // mirrors the first match arm in ContentSkeleton
};
prop_assert_eq!(SkeletonLayout::default(), first);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: skeleton_layout_default_is_first_arm is redundant

This test duplicates skeleton_layout_default_is_bundles (line 24). Both assert SkeletonLayout::default() == SkeletonLayout::Bundles. The match () { () => ... } single-arm block is a convoluted tautology that adds no coverage.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

// meaningful; final role is whatever the strategy picks.
let role = if i == n - 1 { final_role } else if i % 2 == 0 { Role::User } else { Role::Assistant };
let content = match role {
Role::Assistant => "complete".to_string(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Hardcoded "complete" for Role::Assistant masks unfinished-detection coverage

In worklog_projection_matches_detect, Role::Assistant always produces body "complete", which is a completion marker. This means detect_unfinished returns None for final_role = Role::Assistant, so the Some branch at line 229 is never exercised for that role despite role_choice() including it. The test appears to cover all roles but silently skips the Some path for Assistant.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
crates/sl-viewer/tests/properties_viewer_async_states.rs 45 skeleton_layout_has_three_variants does not verify total variant count
crates/sl-viewer/tests/properties_session_ledger_worklog.rs 219 Hardcoded completion marker for Role::Assistant masks unfinished-detection coverage

SUGGESTION

File Line Issue
crates/sl-viewer/tests/properties_viewer_async_states.rs 71 skeleton_layout_default_is_first_arm is redundant with skeleton_layout_default_is_bundles
Files Reviewed (7 files)
  • crates/sl-viewer/tests/properties_viewer_async_states.rs - 2 issues
  • crates/sl-viewer/tests/properties_session_ledger_worklog.rs - 1 issue
  • crates/sl-viewer/tests/properties_session_ledger_distill.rs
  • crates/sl-viewer/tests/properties_session_ledger_export.rs
  • crates/sl-viewer/tests/properties_session_ledger_okf.rs
  • docs/ops/TRACEABILITY.json
  • docs/ops/WBS.md

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash · Input: 90.6K · Output: 24.9K · Cached: 1.4M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants