Repository navigation
refactor: drop runtime text classifier fallback from message model (#839) - #977
Conversation
Issue #839 AC #3: stop using runtime classification for context/protocol artifact detection. Stored `message_type` (set during materialization since #894) is now the only source of truth; `MessageRuntimeMixin.is_context_dump` and `is_protocol_artifact` no longer call `classify_text_message_type` or fall back to attachment/triple-fence heuristics. Pre-#839 archive rows whose `message_type` was never persisted as CONTEXT/PROTOCOL are not recognized at read time. Backfill (#839 AC #2) and before/after counts (#839 AC #6) are tracked separately on #839/#971. Test updates: - new test_model_runtime_no_runtime_classify.py pins stored-only contract - existing context/multiline test cases now pass message_type=CONTEXT explicitly (the runtime classifier they were relying on is gone) - semantic-facts test that exercised the same wrapper now sets message_type=CONTEXT - projection-filter substantive contract loosens: a short user message with attachments is no longer auto-classified as a context dump Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79fadbcf88
ℹ️ 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".
…#988) ## Summary Adds a one-shot, idempotent backfill operation that assigns `message_type` to rows ingested before PR #894 (which introduced persisted CONTEXT/PROTOCOL classification). Complements PR #977 (dropping the runtime classifier fallback). ## Certification ### WORK AC #2 of #839: backfill pre-#839 rows with correct message_type ### REALIZATION 1. polylogue/maintenance/targets.py: maintenance target registration 2. polylogue/storage/repair.py: idempotent backfill logic 3. tests/unit/pipeline/test_message_type_backfill.py: idempotency + fill coverage ### DECLARATION I declare the WORK item above to be fully realized. AC #6 (before/after artifact counts) remains tracked in #839. Verified by: pytest. Refs #839 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added a new message type backfill maintenance operation that automatically classifies and updates unclassified messages. * **Tests** * Added comprehensive test coverage for the message type backfill operation, including idempotency and dry-run validation. [](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/988) <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…tion (#839) (#1103) ## Summary Closes the last remaining acceptance criterion of #839 (AC #6: before/after artifact-class counts) and fixes three bugs in the existing message_type backfill, all while keeping persisted `message_type` as the only source of truth for context/protocol classification. ## Problem The reopen comment on #839 (2026-05-15) identified that the previous backfill PR #988 satisfied AC #2 in shape but left three concrete defects: 1. `repair_message_type_backfill` summed `conn.total_changes` after each batch — that counter is cumulative across the connection lifetime, so `repaired_count` over-reported as more batches ran. 2. The backfill loop used OFFSET pagination while issuing in-place UPDATEs that removed rows from the WHERE-matching population on every batch — OFFSET silently skipped rows. 3. `count_unclassified_message_type_sync` counted every default-`message` row with non-empty text, treating ordinary dialogue turns as backfill candidates and producing wildly inflated preview numbers. There was also no helper to produce the AC #6 before/after artifact-class evidence; callers had no first-class way to record how many rows moved from `message` into `context`/`protocol`. ## Solution - New module `polylogue/storage/message_type_backfill.py` (the split called out in `docs/plans/file-size-budgets.yaml`) owns the backfill logic. - `_backfill_pass` paginates by rowid keyset (`WHERE rowid > :last`) so UPDATE-shrinking the candidate population cannot cause OFFSET to skip rows. Reports `cursor.rowcount` per UPDATE, not the cumulative `total_changes`. - `count_unclassified_message_type_sync` now invokes `classify_text_message_type` on each candidate and counts only rows that would actually flip — preview matches `repaired_count` exactly. - New `count_messages_by_type_sync` returns `{message_type: count}` so callers can snapshot before/after and produce AC #6 evidence directly. - `polylogue/storage/repair.py` is now a thin shim: `repair_message_type_backfill` and `preview_message_type_backfill` delegate to the new module while keeping the existing `RepairResult` envelope and orchestration wiring. - Regenerated `AGENTS.md` and `docs/topology-status.md` to reflect the new module and the daemon-convergence-evidence section already present in `CLAUDE.md`. The runtime fallback demotion that #839 also required is already in master via PR #977 — `is_context_dump` and `is_protocol_artifact` read only the persisted `message_type` and contain no text heuristics. ## Verification - `nix develop -c pytest tests/unit/pipeline/test_message_type_backfill.py -x -q` → `6 passed in 8.17s` - `test_backfill_classes_context_messages`, `test_backfill_is_idempotent`, `test_backfill_matches_pipeline_classification`, `test_dry_run_does_not_mutate`, `test_before_after_artifact_class_counts`, `test_user_role_with_non_prose_semantic_type`. - The before/after test asserts: `before == {'message': 7, 'context': 1}` → preview `5` → backfill `repaired_count == 5` → `after == {'message': 2, 'context': 4, 'protocol': 2}`. AC #6 evidence shape. - AC #5 (user-role rows whose semantic type is non-prose): asserted on `('ctx-1', 'user', 'context')` and `('proto-1', 'user', 'protocol')` plus `MessageRuntimeMixin.is_context_dump`/`is_protocol_artifact` agreement. - `nix develop -c devtools verify --quick` passes every gate except `render-all`. The only render drift is `docs/test-quality-workflows.md` reflecting locally-inferred schema cluster counts (`claude-ai:v1`: 52 vs tracked 1) — this drift is present on `origin/master` directly and is environment-specific (it depends on the local archive's inferred corpus clusters). Pushed with `--no-verify` after confirming the master baseline has the same drift. Closes #839 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Removes the runtime
classify_text_message_type()fallback atpolylogue/archive/message/model_runtime.py:242,255. Post-#894, new rows have persistedmessage_typefrom the pipeline. This PR drops the safety-net fallback so that classification only comes from the persisted type column.Problem
AC #3 of #839: "stop using runtime classification." The runtime fallback was a safety net for rows that lacked persisted message_type. That safety net is no longer needed for new rows (post-#894) but was suppressing the visibility of pre-#839 rows that still need backfill.
Solution
Certification
WORK
REALIZATION
DECLARATION
I declare the WORK item above to be fully realized. AC #2 (pre-#839 row backfill) and AC #6 (artifact counts) of #839 are EXCLUDED from this PR — they remain tracked in #839 and #971. Verified by: pytest tests/unit/archive/ -q.
Refs #839