Skip to content

test(lineage): realign three tests with the #5525 and #5530 contracts - #5809

Merged
Sinity merged 1 commit into
masterfrom
fix/lineage-normalization-tests
Sep 29, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/lineage-normalization-tests

Conversation

@Sinity

@Sinity Sinity commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Summary

Realigns three tests in tests/unit/storage/test_lineage_normalization.py that fail on master (polylogue-ezvw3). Each one encodes a contract that a named PR changed deliberately. No production code changes.

Problem

At master 1beb2e5 (AgentCTL job 2441), these fail:

  • test_prefix_sharing_child_provider_usage_keeps_its_own_reported_totals (line 352). The child's total_tokens-only event (272 000) stores NULL input, cached and output totals, but the test expects 0. feat: stabilize source replay and add OTel GenAI import #5530 (904b2f8) replaced _payload_int with _payload_optional_int in _provider_usage_event_row, so an unreported lane now stays NULL.
  • test_child_before_parent_reextracts_provider_usage_tail (line 1730). The child rollup reads 0 instead of 130. The test put an all-zero cumulative tick after the child's 160/30/25 cumulative. feat: stabilize source replay and add OTel GenAI import #5530 also changed _provider_usage_row_has_lane_totals from "any non-zero" to "any present", and added test_explicit_zero_cumulative_supersedes_prior_positive. An explicit zero cumulative is now a measurement, and the latest one wins.
  • test_late_parent_resolution_invalidates_child_derived_products (line 873). The child is non-valid right after the test seeds a fresh profile. fix(storage): Publish profiles from captured input demand #5525 (ca25740) added trigger-captured session_profile_demand, and _classify_partition_with_demand reports a demanded session as stale until publication consumes the demand. The test's seed never consumed it.

None of the suspects named on the bead (#5803, #5792, #5764, #5691) is the cause. #5803's PR body already lists these three as pre-existing failures.

Solution

  • Prefix-sharing test: the total_tokens-only row now expects NULL input, cached and output totals. The docstring cites feat: stabilize source replay and add OTel GenAI import #5530. The rollup assertion (130/25/30) is unchanged, which proves the NULL row does not displace the latest lane totals.
  • Child-before-parent test: the same measured-zero tick, unchanged, now comes before the child's latest cumulative. The rollup stays exactly 130/25/30 before and after the parent arrives. The re-extraction assertion keeps both cy rows, including the tick's request_id, in their new order. A stale comment about the evidence predicate is corrected.
  • Late-parent test: _seed_fresh_session_products deletes the session's session_profile_demand row, as publish_prepared_session_insight_partition does. The docstring now says the retained-row assertion carries the anti-vacuity, because re-captured demand alone would also mark the child stale.

Schema classification: none. No production file changes, so nothing enters the derived-identity closure.

Verification

  • agentctl job start polylogue pytest_focused --workspace /realm/worktrees/polylogue-mh-lineage -- tests/unit/storage/test_lineage_normalization.py → job 2573: devtools test: PASSED exit=0 (105 passed of 105, head 2d1d0a4).
  • agentctl job start polylogue verify_quick --workspace /realm/worktrees/polylogue-mh-lineage → job 2584: verify: PASSED exit=0 (head 2d1d0a4).

Self-review

  • Contract, not bug. For each failure I found the commit that changed the behavior and checked that it was intended. feat: stabilize source replay and add OTel GenAI import #5530's summary says "distinguish absent usage from explicit zero", and it added a test asserting that a zero cumulative supersedes a prior positive one. fix(storage): Publish profiles from captured input demand #5525 added the demand table, its triggers and the demand-aware classifier on purpose. No assertion was loosened. Every expected value is still exact.
  • Anti-vacuity. Test 1 would fail if re-extraction kept the c1 row, dropped a cy row, or rebased the child against the parent. Test 2's NULL expectation fails if absent lanes are coerced to 0 again. Test 3's retained-row assertion fails if _reextract_prefix_tail_db stops deleting profiles.
  • Siblings. _seed_fresh_session_products has one caller. No other test in this file seeds profiles or reads partition status.
  • Public boundary. Test-only diff with synthetic fixtures.

Residuals

  • Under feat: stabilize source replay and add OTel GenAI import #5530, a zero cumulative that follows a positive one within a session sets the rollup to 0. That is the declared contract. Whether a real provider emits such a reset, and whether billing should then take the maximum, is a product question this PR does not reopen.

polylogue-ezvw3

🤖 Generated with Claude Code

https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg

Three lineage-normalization tests encoded contracts that later PRs changed
deliberately:

- #5530 stores an unreported usage lane as NULL, not 0, so the
  total_tokens-only event keeps NULL input/cached/output totals.
- #5530 treats an explicit zero cumulative as a measurement that
  supersedes an earlier positive one, so the measured-zero tick now
  precedes the child's latest cumulative; the rollup stays 130/25/30.
- #5525 makes a session with pending profile demand stale, so the fresh
  profile seed consumes the demand as publication does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015pdKaZWyGe6Ngvsz468dzg
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@Sinity
Sinity enabled auto-merge (squash) September 29, 2026 08:21
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-29T08:24:13.120508Z 2d1d0a4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity merged commit 4e5b769 into master Sep 29, 2026
2 of 3 checks passed
@Sinity
Sinity deleted the fix/lineage-normalization-tests branch September 29, 2026 08:24
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.

1 participant