Skip to content

perf(daemon): drain convergence and retention backlogs by work - #5692

Merged
Sinity merged 5 commits into
masterfrom
claude/perf-drains
Sep 28, 2026
Merged

Sinity merged 5 commits into
masterfrom
claude/perf-drains

Conversation

@Sinity

@Sinity Sinity commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Convergence-debt and raw-retention backlogs now drain by work, not by tick. A subject-independent stage runs once per backlog instead of once per row. Debt left by a cold build waits for promotion and is then released immediately.

Problem (evidence)

Numbers come from devtools bench fresh-build (#5678). Each run cold-builds a sealed 144-file (276 MiB) private sample of Claude Code, Codex and Gemini sources through polylogued run --cold-build-index on a shared host (load 18-35). Only aggregate numbers are quoted. Wall times move with host load; writer holds, stage timers and CPU seconds move less.

After intake finished, derived convergence never became terminal on master. The generic drain retried at most 100 debt rows per 60 s tick, and raw retention retried 25 rows per pass. Stages whose verdict ignores the subject (delegation_work_evidence, raw_authority_verdict_cache, fts_readiness_binding) ran once for every one of the 1,008 debt rows. The drain also ran during the cold build against the empty active generation, pushing rows into backoff before promotion.

Solution

  • _drain_convergence_debt_backlog loops pages within a 45 s budget. Rows owned by other loops are excluded from the page query.
  • ConvergenceStage.subject_independent: the drain runs one representative, and on success clears the stage's rows recorded up to that point.
  • raw_authority_verdict_cache loops its batches while they make progress (10 s pass). Raw-retention retry loops until the backlog stops shrinking (30 s budget, 64 backlog paths per writer admission).
  • The drain skips while a cold-build generation is active. settle_cold_build releases deferred debt backoff after promotion.
  • An inherited failure is fixed forward: test_convergence_debt_summary_rejects_unknown_status wrote its corrupt row through the writer, which now validates statuses, so the test corrupts the row with UPDATE instead.

Verification

  • devtools test tests/unit/daemon/test_convergence_debt_drain.py tests/unit/daemon/test_convergence_debt.py tests/unit/daemon/test_convergence_stages.py tests/unit/daemon/test_convergence_debt_alert.py plus three test_live_batch_support.py raw-retention ids: all passed except the inherited status test. After the fix, that test's rerun passed.
  • Benchmark: debt went from 1,008 at promotion to 0 at 907 s on the first run with this change. On the combined branch it reached 0 and the build became terminal and qualified at 436 s, with the derived phase taking 322 s after promotion.

Residuals

  • batch.py, cursor.py and watcher.py are IN the derived schema-identity closure. The change must land before the fresh build starts.
  • Per-session derivations (session_profile, session_usage_rollup) still publish in bursts of about 64 per pass. They now dominate the time from promotion to terminal.

🤖 Generated with Claude Code

https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 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
📝 Code Review ✅ Completed 2026-09-27T23:47:03.849165Z f68e1d1 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3bfb3a8e5

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/daemon/cli.py Resolved
Comment thread polylogue/sources/live/watcher.py Resolved
Comment thread polylogue/daemon/cli.py Resolved
Comment thread polylogue/sources/live/cursor.py Resolved
Review findings on the backlog drains:
- an archive-wide stage clear keeps rows recorded in the millisecond its
  run started (strict cutoff);
- a deferred-debt release whose write never ran raises instead of
  reporting zero rows released;
- deferred debt is released when a cold build settles, promoted or
  discarded;
- raw-retention passes page 64 backlog paths per writer admission, so one
  pass cannot hold the writer across thousands of snapshots;
- the source-family cache keys on every POLYLOGUE_*, XDG_* and HOME value;
- the daemon reads the cold-build registry through its intake seam, not
  from polylogue.sources (layering ratchet).

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

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d1736c761

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/daemon/cli.py Resolved
Comment thread polylogue/sources/live/cursor.py Resolved
A stage settled by one archive-wide clear no longer also clears its rows
per subject (which ignored the run-start cutoff and deleted rows
re-recorded after the run began). A clear that could not be written is
reported as degraded and leaves the rows for the next pass. The
source-family cache key includes the selected config files' revisions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
@Sinity
Sinity merged commit 7c297f5 into master Sep 28, 2026
3 checks passed
@Sinity
Sinity deleted the claude/perf-drains branch September 28, 2026 00:04
Sinity added a commit that referenced this pull request Sep 28, 2026
…ent routes

The periodic retry drains through _drain_convergence_debt_backlog (#5692),
so patching the single-page helper let the real drain run. Status is served
by the daemon (#5550); with none running it reports unavailable rather than
materialization counts, which the find/analyze/readiness surfaces still
compute.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4
Sinity added a commit that referenced this pull request Sep 28, 2026
…ent routes

The periodic retry drains through _drain_convergence_debt_backlog (#5692),
so patching the single-page helper let the real drain run. Status is served
by the daemon (#5550); with none running it reports unavailable rather than
materialization counts, which the find/analyze/readiness surfaces still
compute.

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