Skip to content

test: Assert structured event tokens instead of retired prose - #5107

Merged
Sinity merged 1 commit into
masterfrom
fix/structured-event-assertions
Sep 14, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/structured-event-assertions

Conversation

@Sinity

@Sinity Sinity commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

Two tests grepped for prose sentences that the structured-logging wave
deleted. Both now assert the stable event token and its declared fields.

Which merged PR moved the ground

PRs #5072 (5eb270707, "Convert the remaining daemon modules to structured
events") and #5073 (ab850e0b7, "Carry the correlation context into the
derivation kernel") retired prose logging in these modules.
polylogue/logging.py:400 emit() writes structured records to its own
sinks and never touches stdlib logging, so caplog.text is empty by
construction -- these were failing on an assertion that can no longer be true,
not on behaviour.

  • daemon/convergence_stages.py:308 now emits daemon.stage.check_failed
    (reason="probe_failed_assuming_work"), and the execute path reports through
    span.degraded("materialization_failed"), whose terminal event is
    daemon.stage.execute.degraded.
  • daemon/lifecycle.py:287 now emits daemon.lifecycle.signal_received
    (signal_name=SIGTERM).

CLAUDE.md is explicit: "Do not enforce natural-language wording".

Solution

  • test_convergence_stage_reports_probe_and_materialization_failures_as_pending_work:
    drop caplog, use polylogue.logging.capture(), and assert the exact
    (stage, outcome, reason, error_type) tuple for each of the two events.
  • test_sigterm_read_only_daemon_records_forensics reads the daemon
    subprocess's own stream, which may render console or JSON. It now selects
    the line carrying daemon.lifecycle.signal_received and asserts it names
    SIGTERM. The "Current thread" faulthandler assertion is unchanged.

Both assertions are on tokens and fields, which are the storage form; the
human sentence was always a rendering concern.

Verification

devtools test tests/unit/insights/test_delegation_work_evidence_materializer.py
     (receipt 20260914T163857Z-focused-test-3135387-125edb44)  -> green
devtools test tests/integration/test_daemon_resilience.py
     (receipt 20260914T165038Z-focused-test-3220954-2ff3e795)
  -> 7 passed / 7 collected, including
     test_sigterm_read_only_daemon_records_forensics
devtools verify --quick  -> exit 0, 15/15 gates

Anti-vacuity

Test Mutation that makes it red
convergence stage, probe half make check's except return False, or drop the emit
convergence stage, execute half swallow the materialization exception into a success; the degraded/materialization_failed terminal event disappears
SIGTERM forensics drop the emit from install_signal_handlers (no line carries the token), or drop faulthandler.dump_traceback (no stack dump)

Residuals

Test-only change. The integration test still depends on the daemon's
configured renderer emitting the token in either format; it does not pin which
format, deliberately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

PRs #5072 (5eb2707) and #5073 (ab850e0) converted these modules to
structured events. polylogue/logging.py:400 emit() writes to its own
sinks and never touches stdlib logging, so caplog.text is empty by
construction -- both tests were failing on an assertion that can no
longer be true, not on behaviour.

Assert the stable tokens and their declared fields instead, per
CLAUDE.md ('Do not enforce natural-language wording'):

- convergence_stages.py:308 emits daemon.stage.check_failed
  (probe_failed_assuming_work); the execute path reports through
  span.degraded, terminal event daemon.stage.execute.degraded. Use
  polylogue.logging.capture() and pin (stage, outcome, reason,
  error_type) for both.
- lifecycle.py:287 emits daemon.lifecycle.signal_received. The
  integration test reads the daemon subprocess's own stream, so select
  the line carrying the token and assert it names SIGTERM, without
  pinning console or JSON rendering. The faulthandler assertion is
  unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
@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.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 3b29c5e5-f1b6-4c13-ab54-cbbd4ad08195

📥 Commits

Reviewing files that changed from the base of the PR and between 513c887 and ee737cc.

📒 Files selected for processing (2)
  • tests/integration/test_daemon_resilience.py
  • tests/unit/insights/test_delegation_work_evidence_materializer.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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 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-14T17:00:25.539173Z ee737cc 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 086460a into master Sep 14, 2026
3 checks passed
@Sinity
Sinity deleted the fix/structured-event-assertions branch September 14, 2026 17:07
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