Skip to content

test(storage): give raw-authority-ledger codex fixtures real message text - #3572

Merged
Sinity merged 2 commits into
masterfrom
feature/tests/fix-raw-authority-ledger-fixture-content
Aug 2, 2026
Merged

test(storage): give raw-authority-ledger codex fixtures real message text#3572
Sinity merged 2 commits into
masterfrom
feature/tests/fix-raw-authority-ledger-fixture-content

Conversation

@Sinity

@Sinity Sinity commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes 10 failing tests in tests/unit/storage/test_raw_authority_ledger.py (confirmed failing on origin/master in a fresh worktree checkout, not testmon-cache noise). All 10 share one root cause and one fix: the test file's _write_codex_raw fixture helper defaulted to text="", which a recently-merged, intentional production behavior change now refuses at parse time. Fixing the fixture default (one line) restores all 10.

Problem

_write_codex_raw's default text="" predates PR #3497 (fix(sources): require positive conversational evidence for session creation, merged 2026-08-01, closing polylogue-9ykn/polylogue-6mpy). That PR added require_positive_conversational_evidence()/message_carries_authored_content(): a session is only materialized when at least one message carries real text or a content block. It's a deliberate, well-evidenced fix — the live archive had 5,257/23,496 (22.4%) phantom zero-message sessions, and the PR body documents the reconciliation query-by-query.

Every one of the 10 failing tests writes a raw codex artifact via _write_codex_raw without an explicit text=, so its sole message has empty text and gets silently refused ("no messages, no positive conversational evidence") instead of materializing a session. That collapses each test's repair/census/replay/blocker outcome down to "nothing materialized", breaking assertions on repaired_count, plan status (RawReplayPlanStatus.TERMINAL expected, REJECTED_STALE observed), census plan/post-plan counts, and application-receipt contents — none of which are actually about the content-evidence gate; they're about raw-authority census/plan/replay/blocker bookkeeping.

Solution

Per-test investigation (git log/git blame/git show on polylogue/storage/raw_authority.py + polylogue/sources/dispatch.py, plus the PR #3497 body) confirmed all 10 failures are the same drift, not independent behavior changes:

  • test_parsed_timestamp_without_exact_application_receipt_fails_closed
  • test_two_successive_quiescent_censuses_are_required_for_fixed_point
  • test_stale_blocker_resolution_replans_current_evidence_and_resumes
  • test_application_receipt_requires_exact_application_authority[accepted_raw_id / session_id / accepted_content_hash]
  • test_census_ledger_conserves_unselected_plan_and_application_receipt
  • test_frontier_classifies_dangling_head_session_as_corrupt
  • test_frontier_classifies_head_session_raw_mismatch_as_corrupt
  • test_ineligible_quarantined_raw_gets_a_terminal_actuator_not_refine_quarantine

Verdict for all 10: test-update, not code-fix. PR #3497's gate is correct and intentional; production code is untouched. _write_codex_raw's default text is changed from "" to "authored content" so the fixture always produces a materializable session, matching the new behavior. No test in the file relied on empty-text semantics on purpose (grep -n 'text=""' on the file returns nothing).

While investigating, found the same class of break in a sibling synthetic-corpus generator, out of scope for this bead (different files, confirmed pre-existing on origin/master independent of this fix — reproduced identically with this diff stashed out): devtools/raw_authority_scale_proof.py's synthetic codex-session generator hits the same gate, breaking 5 tests in tests/unit/devtools/test_raw_authority_scale_proof.py and 1 integration test (tests/integration/test_raw_authority_daemon_health_proof.py::test_real_daemon_drains_backlog_while_staying_probeable, which times out because the synthetic backlog can never drain). Filed as polylogue-h7y0j.

Verification

devtools test tests/unit/storage/test_raw_authority_ledger.py
  -> 41 passed (2 more tests exist on rebased master than at investigation time; all pass)

devtools test -k raw_materialization
  -> 118 passed

devtools test -k raw_authority
  -> 88 passed, 6 failed — all 6 confirmed pre-existing/unrelated (different files:
     test_raw_authority_scale_proof.py, test_raw_authority_daemon_health_proof.py;
     reproduced identically with this branch's diff stashed out; tracked as polylogue-h7y0j)

devtools verify --quick
  -> exit 0 (also ran automatically via the pre-push hook)

Ref polylogue-k2grh


Co-authored-by: Claude noreply@anthropic.com

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 03a4e48c-e324-49ae-b574-f8a84a72d377

📥 Commits

Reviewing files that changed from the base of the PR and between 50b2aa1 and 38bc8e7.

📒 Files selected for processing (2)
  • .beads/issues.jsonl
  • tests/unit/storage/test_raw_authority_ledger.py

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.

Sinity and others added 2 commits August 2, 2026 17:16
…text

Problem: 10 tests in tests/unit/storage/test_raw_authority_ledger.py
failed on origin/master (confirmed in a fresh worktree, not testmon-cache
noise) -- e.g. test_parsed_timestamp_without_exact_application_receipt_fails_closed
asserted RawReplayPlanStatus.TERMINAL but got REJECTED_STALE;
test_two_successive_quiescent_censuses_are_required_for_fixed_point
asserted repaired_count == 1 but got 0.

Root cause (verified via git log/git show, not guessed): PR #3497
(fix(sources): require positive conversational evidence for session
creation, closing polylogue-9ykn/polylogue-6mpy, merged 2026-08-01)
intentionally added require_positive_conversational_evidence() so a
session is only materialized when at least one message carries real
text or a content block -- a deliberate, well-documented correctness
fix for a live-archive defect (22.4% of sessions were phantom
zero-message rows). The ledger test file's `_write_codex_raw` helper
predates that gate and defaulted `text=""`, so every one of its
raw-authority fixtures now gets refused at parse time ("no messages,
no positive conversational evidence") instead of materializing a
session -- collapsing repair/census/replay outcomes the tests assert
on (repaired_count, plan status, census plan/post-plan counts,
application-receipt contents) down to the "nothing materialized" case.

These 10 tests exercise raw-authority census/plan/replay/blocker
mechanics, not the content-evidence gate itself, so the fix is the test
fixture, not production code: give `_write_codex_raw` a non-empty
default `text` so its raw writes always produce a materializable
session again, matching the new intentional behavior. No production
code changed.

Also filed polylogue-h7y0j for a sibling break in the same class found
while investigating (devtools/raw_authority_scale_proof.py's synthetic
codex-session generator hits the same gate) -- confirmed pre-existing
on origin/master and out of scope here (different files, not part of
this bead), reproduced independently with this fix stashed out.

Verification:
  devtools test tests/unit/storage/test_raw_authority_ledger.py -> 39 passed
  devtools test -k raw_materialization -> 118 passed
  devtools test -k raw_authority -> 88 passed, 6 pre-existing failures
    (all in test_raw_authority_scale_proof.py / test_raw_authority_daemon_health_proof.py,
    confirmed unrelated: reproduced identically with this commit's diff
    stashed out; tracked as polylogue-h7y0j)
  devtools verify --quick -> exit 0

Ref polylogue-k2grh

Co-Authored-By: Claude <noreply@anthropic.com>
Ref polylogue-k2grh

Co-Authored-By: Claude <noreply@anthropic.com>
@Sinity
Sinity force-pushed the feature/tests/fix-raw-authority-ledger-fixture-content branch from a4b7f78 to 38bc8e7 Compare August 2, 2026 15:20
@Sinity
Sinity merged commit 4832e4c into master Aug 2, 2026
3 checks passed
@Sinity
Sinity deleted the feature/tests/fix-raw-authority-ledger-fixture-content branch August 2, 2026 15:22
Sinity added a commit that referenced this pull request Aug 2, 2026
Sinity added a commit that referenced this pull request Aug 19, 2026
…gbm-quiet, 7qw4) (#4006)

## Summary

Retires the four mechanical rows of the WS-B known-red/false-green
ledger
(`.agent/campaigns/2026-08-overhaul/ws-b-suite-health.md`): uxrim,
bwo2l,
vqt48, and 7qw4 were all already satisfied on master before this branch
was
cut; the one row that needed real work was polylogue-ndgbm's quiet
component (Codex query-cardinality oracle's fixture never emitted a
`message`-shaped record, so the parser's admission gate refused every
payload and the module fixture errored at setup), which this PR fixes
and
whose two associated xfail markers it removes.

## Problem

The ledger recorded five findings as known-red or false-green test debt,
each with a RECIPE and file:line anchors, dispatched here as a themed
sweep.

## Solution

- **uxrim** (`tests/unit/api/test_facade_contracts.py:4789`): the recipe
  asked to extend the `frozen_clock_modules` marker to also cover
  `revision_governance`. Already done — commit 8ed4f91 (PR #3595,
  2026-08-03) landed exactly that extension. No diff needed.
- **7qw4** (`tests/unit/storage/test_store_ops.py`): the recipe asked to
rewrite the test to call the production `aggregate_message_stats` async
  fn and delete a test-local shadow reimplementation. Already done —
commits from PR #3729 (call the repository path) and PR #3813 (assert on
public `origins`) landed this; no shadow function remains in the file.
No
  diff needed.
- **bwo2l + vqt48** (`tests/unit/cli/test_archive_maintenance_cli.py`,
  `tests/unit/sources/test_live_watcher.py`,
`tests/unit/sources/test_live_batch_support.py`): the recipe asked to
give
  refused codex fixtures real conversational content. Already done — the
9ykn positive-evidence-gate fixes landed across several prior PRs
(visible
  in `git log --grep`: #3555, #3572, #3600, #3642, #3841). All 138 + 259
  tests pass.
- **ndgbm quiet component** (`tests/infra/query_manifest_oracle.py`,
`tests/unit/cli/test_query_composition_laws.py`): the actual fix in this
  PR. `QueryCardinalitySession.wire_records()` emitted only
  `function_call`/`function_call_output` response_items — zero
  `message`-shaped records — so `codex.is_supported_session_stream()`
  (`has_message` never set) refused every payload before ingest and the
  module-scoped fixture errored at setup before either test could run.
Added one planted user/assistant message-pair response_item per session
(same wire shape landed for the bwo2l/vqt48 fixtures), which admits the
stream; action-identity assertions are unaffected because they only
count
  tool rows.

  Removing the two xfail markers this unblocks surfaced two further
pre-existing issues that had never been reachable before (the tests
always
  errored at setup), fixed in the same commit:
- The naive-duplicate-id-join mutation test's hand-rolled `actions` view
    predates the production view's `result_state` CASE projection
    (polylogue-cuxz.5, `archive_tiers/index.py:1040`) and crashed with
`sqlite3.OperationalError: no such column: a.result_state` instead of
producing the comparably-wrong row count the test actually asserts on.
    Added the same CASE projection to the test's naive view.
- `find ... then delete --yes --all` has no non-daemon route — it
refuses
outright when the daemon does not answer the `/prepare` call. Added a
daemon-delete stand-in patch on `_submit_daemon_mutation`, mirroring the
    existing pattern in

`test_verb_cardinality.py::TestDeleteCardinalityLargeNonMocked._daemon_delete_route`
    (does the real delete through `ArchiveStore`, just skips the daemon
    process).
  - `_copy_archive`'s plain `shutil.copytree` left the durable bootstrap
    marker bound to the *original* archive root path
(`durable_identity_digest`), so the first write-mode
`ArchiveStore.open_existing`
    at the copied path raised `DurableChangeTrainError: fresh durable
bootstrap marker durable identity mismatch`. Re-bind the marker after
copy, mirroring
`tests/infra/workload_artifacts.py::clone_seeded_archive`.

**ndgbm residual (not closed by this PR):** the bead also names a
second,
separate symptom — the 64-seed process-pool death only reproduces beside
a
saturated 10-worker gate (confirmed load-only: quiet re-run
20260818T231534Z
was green in 43s). That's a load-robustness question the dispatch prompt
asked to coordinate with WS-A's e98k cgroup-mmap-budget findings. I
could not
type this as a `partial` disposition in the machine-readable pr-scope
carrier below: the validator requires a **pre-existing Beads dependency
edge** (`blocks`/`discovered-from`/`relates-to`/`supersedes`) between
ndgbm
and its named successor before it will accept the disposition, and no
such
edge exists between polylogue-ndgbm and polylogue-e98k today. Per the
lane
contract I do not invoke `bd` from a worktree, so I did not create that
link. **Coordinator action needed:** link `polylogue-ndgbm` →
`polylogue-e98k` (or a dedicated new successor) via `bd dep add` (or
equivalent) before ndgbm can be typed `partial` in a carrier; until then
the
bead should stay open with its residual noted in its own notes (already
present).

## Verification

- `devtools test tests/unit/api/test_facade_contracts.py -k
raw_artifacts_read_source_tier` → 1 passed (uxrim, unchanged/confirmed)
- `devtools test tests/unit/cli/test_archive_maintenance_cli.py` → 138
passed (bwo2l, unchanged/confirmed)
- `devtools test tests/unit/sources/test_live_watcher.py
tests/unit/sources/test_live_batch_support.py` → 259 passed (vqt48,
unchanged/confirmed)
- `devtools test tests/unit/storage/test_store_ops.py -k
aggregate_message_stats` → 1 passed (7qw4, unchanged/confirmed);
mutation red-check locally re-applied AG1 (role-swap on the unfiltered
`role_row` query) and AG2 (`words_approx = 0`) against
`polylogue/storage/sqlite/queries/stats.py`, both now fail (`assert 1 ==
2`, `assert 0 == 9`), reverted before commit — no diff shipped for this
row
- `devtools test tests/unit/cli/test_query_composition_laws.py` → 2
passed, 0 xfail (ndgbm quiet component: red→green; both `-p no:testmon`
and cached runs confirmed)
- `devtools verify --quick` → exit 0 (format + lint + mypy + `render all
--check`; no `out of sync` in output)

All four rows were verified in the context that was failing: each
command
above is the exact standalone-context command named in the dispatch
recipe,
run directly (not nested inside a broader suite run).

## Bead disposition matrix

| Bead | Disposition | Evidence | Notes |
| --- | --- | --- | --- |
| polylogue-uxrim | SATISFIED | test pass + commit 8ed4f91 | already
fixed on master, PR #3595 |
| polylogue-bwo2l | SATISFIED | test pass (138/138) | already fixed on
master |
| polylogue-vqt48 | SATISFIED | test pass (259/259) | already fixed on
master |
| polylogue-7qw4 | SATISFIED | test pass + mutation red-check | already
fixed on master (PR #3729, #3813) |
| polylogue-ndgbm | PARTIAL | test pass (2/2, no xfail) + diff | quiet
component fixed this PR; load-only pool-death residual stays open on the
bead — **not represented in the typed carrier below** (see Solution
section: needs a coordinator-created Beads link to type as `partial`) |

<!-- polylogue-pr-scope:v2
{
  "assigned_beads": [
    "polylogue-uxrim",
    "polylogue-bwo2l",
    "polylogue-vqt48",
    "polylogue-7qw4"
  ],
  "dispositions": [
    {
      "bead_id": "polylogue-uxrim",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "test",
"ref":
"tests/unit/api/test_facade_contracts.py::test_archive_tiers_api_raw_artifacts_read_source_tier"
        },
        {
          "kind": "commit",
          "ref": "8ed4f9101813aa142bc915e9c70ef439b86a100d"
        }
      ],
      "successors": []
    },
    {
      "bead_id": "polylogue-bwo2l",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "test",
          "ref": "tests/unit/cli/test_archive_maintenance_cli.py"
        }
      ],
      "successors": []
    },
    {
      "bead_id": "polylogue-vqt48",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "test",
          "ref": "tests/unit/sources/test_live_watcher.py"
        },
        {
          "kind": "test",
          "ref": "tests/unit/sources/test_live_batch_support.py"
        }
      ],
      "successors": []
    },
    {
      "bead_id": "polylogue-7qw4",
      "disposition": "satisfied",
      "evidence": [
        {
          "kind": "test",
"ref":
"tests/unit/storage/test_store_ops.py::test_aggregate_message_stats_reports_public_contract"
        }
      ],
      "successors": []
    }
  ],
  "mutated_beads": [],
"scope_digest":
"e397dd57058877a651382c5cf8f681b4cffabc7aae67e285f7192b2c62c787ad",
  "scope_kind": "bead",
  "version": 2
}
-->

Ref polylogue-uxrim, polylogue-bwo2l, polylogue-vqt48, polylogue-ndgbm,
polylogue-7qw4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01HWcPJJJvuF25CqVwTFgSQC

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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