Skip to content

fix(storage): stop title_source=unknown from defeating the structural label - #3421

Merged
Sinity merged 4 commits into
masterfrom
feature/fix/cijx4-structural-label-title-provenance
Jul 31, 2026
Merged

fix(storage): stop title_source=unknown from defeating the structural label#3421
Sinity merged 4 commits into
masterfrom
feature/fix/cijx4-structural-label-title-provenance

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the one concrete production bug found while auditing
polylogue-cijx.4 ("Repo identity, path normalization and readable labels
are ONE batch"): the session structural-label projection (decision 3 of
that bead) was wired into the summary read path but never actually fired,
because the "does this session have a real title" check only asked
whether sessions.title was non-blank — not whether it came from a real
source.

Problem

polylogue-cijx.4 decisions 1-3 (repo identity keyed on the normalized
remote, repo-relative paths, and a read-time structural-label projection)
turned out to already be substantially landed on master before this
lane started — they shipped as part of PR #3390's larger diff (commit
5e23e6abf, "index v46 wire-evidence batch"), with real test coverage
(tests/unit/archive/test_repo_identity.py,
tests/unit/insights/test_session_label.py).

Auditing that existing implementation against a read-only copy of the
live archive (/realm/db/polylogue/index.db) found the label was dead in
production: _summary_from_row in
storage/sqlite/archive_tiers/archive.py treated any non-blank
sessions.title as a genuine provider title. But Claude Code's parser
(sources/parsers/claude/code_parser.py, out of this lane's write scope —
owned by the polylogue-pbuh lane) initializes title to the raw composed
session id (a bare UUID, or "<uuid>:agent-<hash>" for a subagent) and
only promotes title_source off UNKNOWN when a real signal (human
message, agent-name, ai-title, custom-title) is found. So a
title_source='unknown' row still carries a non-blank title — exactly
the raw-id echo the bead's motivating text complains about
("agent-ad682bc849a1cd0f0 - 27f - 499m — worse than the UUID it
replaces").

Measured live, read-only: 7,501 of 15,401 root sessions (48.7%) carry
title_source='unknown'. The structural-label fallback never fired for
any of them.

Solution

_summary_from_row now only treats a non-blank sessions.title as a
real title when title_source is origin, heuristic, or user.
unknown (and the label's own prior path output, for rebuild
idempotency) fall through to session_structural_label_for_session.

Modules touched: polylogue/storage/sqlite/archive_tiers/archive.py
(the fix), tests/unit/storage/test_title_source_queryable.py (new
regression test reproducing the exact Claude Code raw-id-fallback shape),
.beads/issues.jsonl (AC disposition + a new follow-up bead).

AC4 of polylogue-cijx.4 (default result unit = top-level session) is
explicitly NOT addressed here
— investigated and found to require a
separate, higher-blast-radius change (Lark DSL grammar wiring for a
root: field, which currently doesn't exist on any query surface despite
the underlying Session.is_root/parent_session_id plumbing already
being correct, plus a default-behavior decision affecting every
unfiltered find/list()/MCP query call). Split out as
polylogue-oqib rather than folded into this diff. Full AC1-5
disposition recorded as a comment on polylogue-cijx.4.

Not a polylogue-pbuh overlap: pbuh's typed ai-title/agent-name/
pr-link sidecar-record work is a different, complementary fix (making
title_source legitimately origin more often) — this PR fixes the read
path's consumption of title_source, regardless of how it got there.

Verification

devtools test tests/unit/storage/test_title_source_queryable.py tests/unit/insights/test_session_label.py tests/unit/archive/test_repo_identity.py
# 29 passed in ~19s
devtools test tests/unit/archive/ tests/unit/cli/ tests/unit/mcp/ tests/unit/api/ -k title
# 21 passed
devtools verify --quick
# 19 steps, exit 0 (ruff format/check, mypy --strict, render all --check, topology/layering/closure-matrix, schema policy/roundtrip)

Live collision-rate re-measurement (AC5 of polylogue-cijx.4), read-only
against /realm/db/polylogue/index.db (15,401 root sessions), after this
fix:

  • Among sessions with resolved file-touch evidence (a dominant
    repo-relative path — the population the bead's original 3.5%/max-10
    baseline was measured against): 3.28% collision (78/2,377), max group
    37
    .
  • Raw collision across all 13,219 title-less sessions: 76.46%, but that
    figure is dominated by a 5,233-session cluster of genuinely
    evidence-free (zero-message, no repo, no file touch) sessions
    collapsing to the honest label "0 msgs" — not a labeling defect. Full
    numbers and a note about whether 5,233 zero-message root sessions is
    itself a data-quality question are on the polylogue-cijx.4 comment.

Not run: the full non-quick devtools verify --all (testmon wasn't
seeded on this worktree; ran the exact touched-file selection instead per
repo convention).

Ref polylogue-cijx.4

Sinity added 2 commits July 31, 2026 06:39
… label

Problem: polylogue-cijx.4 decision 3 wired session_structural_label_for_
session into ArchiveStore._summary_from_row, but the "is this a real
title" check only asked whether sessions.title was non-blank. Claude
Code's parser initializes title to the raw composed session id (a bare
UUID, or "<uuid>:agent-<hash>" for a subagent) and only promotes
title_source off UNKNOWN when a real signal is found. So a title_source=
'unknown' row still carries a non-blank title, and the pre-blank-only
check accepted it as a "provider title" -- the exact raw-id echo decision
3 was supposed to replace. Measured live (/realm/db/polylogue, read-only):
7,501 of 15,401 root sessions (48.7%) carry title_source='unknown', which
made the structural-label fallback dead code for all of them.

What changed: _summary_from_row now only treats a non-blank title as
real when title_source is 'origin', 'heuristic', or 'user'; 'unknown'
(and the label's own prior 'path' output, for idempotency) fall through
to the structural label.

Verification: devtools test tests/unit/storage/test_title_source_
queryable.py tests/unit/insights/test_session_label.py tests/unit/
archive/test_repo_identity.py -- 29 passed. devtools verify --quick --
19 steps, exit 0. Live re-measure after the fix (read-only against
/realm/db/polylogue/index.db): among root sessions with resolved
file-touch evidence (a dominant repo-relative path -- the population the
bead's original 3.5%/max-10 baseline was measured against), collision
rate is 3.28% (78/2377), max group size 37. The much larger raw
collision figure across ALL title-less sessions (76.46%, dominated by a
5,233-session "0 msgs" cluster) reflects genuinely evidence-free stub/
empty sessions, not a labeling defect -- reported in full on
polylogue-cijx.4.

Ref polylogue-cijx.4
polylogue-cijx.4's decisions 1-3 (repo identity, repo-relative paths,
structural label projection) were already substantially landed on
master before this lane started (PR #3390 fallout); this lane's own
contribution is the archive.py title-provenance fix in eb5f904 plus
the live AC5 collision measurement, both recorded as a comment on
polylogue-cijx.4.

Decision 4 (default result unit = top-level session) needs a separate,
higher-blast-radius change (DSL grammar + CLI default-behavior audit
across every query surface) -- split out as polylogue-oqib rather than
attempted inside this lane's diff.

Ref polylogue-cijx.4
@coderabbitai

coderabbitai Bot commented Jul 31, 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: 26 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: 4ecda121-45e3-476f-bd0b-b6423951a654

📥 Commits

Reviewing files that changed from the base of the PR and between d2402c1 and d24fab4.

📒 Files selected for processing (2)
  • polylogue/storage/sqlite/archive_tiers/archive.py
  • tests/unit/storage/test_title_source_queryable.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 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: 05941dc319

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

# dead code for all of them. ``title_source='path'`` is the structural
# label's own prior output; treating it as "not a real title" keeps this
# idempotent on rebuild instead of freezing a stale message count.
has_real_title = bool(raw_title and raw_title.strip()) and raw_title_source in {"origin", "heuristic", "user"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve provider titles without stamped provenance

When a stored title has no title_source, this whitelist now treats it as synthetic. That is normal production data for several origins: polylogue/sources/parsers/chatgpt.py:1101-1106, for example, copies the provider's conversation title into ParsedSession without setting title_source, and the ChatGPT assembly does not add it. Consequently read_summary and list_summaries replace genuine ChatGPT titles with structural labels such as "1 msgs", propagating through CLI/MCP/API summary surfaces. Restrict the fallback to title_source='unknown', or stamp every affected parser before enforcing this whitelist.

Useful? React with 👍 / 👎.

@Sinity
Sinity merged commit fb980cb into master Jul 31, 2026
1 of 3 checks passed
@Sinity
Sinity deleted the feature/fix/cijx4-structural-label-title-provenance branch July 31, 2026 08:21
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