Skip to content

refactor: drop runtime text classifier fallback from message model (#839) - #977

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/drop-runtime-message-classify
May 9, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/drop-runtime-message-classify

Conversation

@Sinity

@Sinity Sinity commented May 9, 2026

Copy link
Copy Markdown
Owner

Summary

Removes the runtime classify_text_message_type() fallback at polylogue/archive/message/model_runtime.py:242,255. Post-#894, new rows have persisted message_type from 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

  • Return sentinel (UNKNOWN) when message lacks persisted type, instead of calling the runtime classifier
  • Test covers: persisted type used, missing persisted type returns UNKNOWN, classify_text_message_type NOT called at runtime

Certification

WORK

  1. Stop using runtime classification at model_runtime.py:242,255 (AC The gmd CLI monolith is blocking richer render surfaces #3 of fix(archive): store context and protocol artifacts semantically, not via projection fallbacks #839)

REALIZATION

  1. polylogue/archive/message/model_runtime.py: dropped fallback; test: tests/unit/archive/test_model_runtime_no_runtime_classify.py

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

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]>
Copilot AI review requested due to automatic review settings May 9, 2026 11:01
@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 28 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 85fe9e74-0242-42c4-8f4c-c1caf226f38d

📥 Commits

Reviewing files that changed from the base of the PR and between 32cef74 and 79fadbc.

📒 Files selected for processing (4)
  • polylogue/archive/message/model_runtime.py
  • tests/unit/archive/test_model_runtime_no_runtime_classify.py
  • tests/unit/core/test_conversation_semantics.py
  • tests/unit/core/test_semantic_facts.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/drop-runtime-message-classify

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 and usage tips.

@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: 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".

@Sinity
Sinity merged commit 2287b23 into master May 9, 2026
8 of 14 checks passed
@Sinity
Sinity deleted the feature/refactor/drop-runtime-message-classify branch May 9, 2026 11:11
@Sinity
Sinity removed the request for review from Copilot May 9, 2026 11:23
Sinity added a commit that referenced this pull request May 9, 2026
…#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.

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/988)

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sinity added a commit that referenced this pull request May 16, 2026
…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]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 58.F013 / P1: refuted at the checked revision: AGENTS.md:192-194 rejects compatibility fallbacks and remedies that retain prior archive state in fresh v1. Reintroducing text fallback specifically for pre-839 persisted rows contradicts that rule rather than repairing a supported fresh-format input.

Only the rows listed above are dispositioned. Held findings remain open.

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