Skip to content

fix(search): document search_text tool-body coverage gap - #2740

Merged
Sinity merged 1 commit into
masterfrom
fix/search-text-write-tool-coverage
Jul 12, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/search-text-write-tool-coverage

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Documents the FTS search_text coverage boundary discovered in polylogue-013x: blocks.search_text excludes tool_input.$.content (Write file bodies) and $.old_string/$.new_string (Edit bodies), so a distinctive string an agent wrote or edited into a file is invisible to FTS with no diagnostic explaining why.

Problem

blocks.search_text (polylogue/storage/sqlite/archive_tiers/index.py) is a generated column that concatenates text, tool_name, and tool_input.$.command/$.file_path/$.path. It does not include tool_input.$.content or $.old_string/$.new_string. An operator searching for a string they know an agent authored into a file gets zero hits with no explanation, and docs/search.md never stated this boundary — the two defects the bead was filed for.

Solution

Chose option B (document + workaround) from the bead's design over option A (extend the generated column):

  • Extending search_text to cover $.content is a derived-tier schema change (polylogue/storage/sqlite/archive_tiers/index.py DDL + polylogue ops reset --index && polylogued run). The bead's own design explicitly requires a live-archive FTS index size probe as decision evidence before doing that (Write bodies can be large enough to meaningfully bloat the index), which isn't available from an isolated worktree, and the repo's derived-tier schema regime says such bumps should be batched, not done as an isolated silent schema change.
  • docs/search.md gains a new "Searchable Content Coverage" section: a table enumerating exactly which block/tool_input fields feed search_text (including confirming thinking/reasoning block content and tool_result output are searchable today), what's excluded (Write's $.content, Edit's $.old_string/$.new_string, and any other unindexed tool_input key), and a raw-SQL json_extract/LIKE workaround query.
  • The "Empty Result Diagnostics" checklist gets a new step pointing at this boundary.

tests/unit/storage/test_search_text_write_tool_coverage.py pins three things:

  1. The live search_text DDL expression (extracted via regex from index.py) matches the documented matrix — a drift check that fails if a future change adds/removes a json_extract path without updating the docs.
  2. A distinctive token placed only in a Write/Edit tool body is genuinely unreachable via messages_fts MATCH (proves the gap is real, not just documented).
  3. The documented raw-SQL workaround query actually finds it.

Verification

  • devtools test tests/unit/storage/test_search_text_write_tool_coverage.py → 4 passed in 5.34s
  • mypy --strict tests/unit/storage/test_search_text_write_tool_coverage.py → Success: no issues found in 1 source file
  • ruff check / ruff format --check on the touched .py file → clean
  • python3 devtools/verify_docs_drift.py → zero unhandled drift across the reference-docs sweep
  • git push pre-push gate (devtools verify --quick: ruff format/check, mypy, render all, topology/layering/closure-matrix, schema roundtrip, manifests, ci-workflows, doc-commands, test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly) → all green, exit_code: 0

Note: per operator instruction, the heavy devtools test/devtools verify --all suite was not run broadly — only the focused new test file plus the pre-push quick gate. GitHub CI is expected to be blocked by an unrelated account billing lock.

Ref polylogue-013x

Problem: blocks.search_text (the generated column FTS5 indexes) only
concatenates text, tool_name, and tool_input.$.command/$.file_path/$.path.
It excludes tool_input.$.content (Write file bodies) and $.old_string/
$.new_string (Edit bodies), so a distinctive string an agent wrote or
edited into a file returns zero FTS hits with no diagnostic explaining
why. docs/search.md never stated this boundary.

Solution: adds a "Searchable Content Coverage" matrix to docs/search.md
enumerating exactly which block/tool_input fields feed search_text, plus
a raw-SQL json_extract/LIKE workaround for the excluded Write/Edit
bodies, and a pointer from the Empty Result Diagnostics checklist.
Chose documentation (option B from the bead design) over extending the
generated column (option A): extending search_text needs a live-archive
FTS index size probe plus a derived-tier index rebuild
(polylogue ops reset --index && polylogued run), which is out of scope
for an isolated doc-boundary fix and shouldn't be done as a silent
schema bump per the derived-tier schema regime.

tests/unit/storage/test_search_text_write_tool_coverage.py pins three
things: the live search_text DDL expression matches the documented
matrix (drift check), a Write/Edit tool body token is genuinely
unreachable via FTS MATCH, and the documented raw-SQL workaround finds
it.

Verification:
- devtools test tests/unit/storage/test_search_text_write_tool_coverage.py -> 4 passed
- mypy --strict tests/unit/storage/test_search_text_write_tool_coverage.py -> Success: no issues found
- ruff check / ruff format --check on the touched .py file -> clean
- python3 devtools/verify_docs_drift.py -> zero unhandled drift

Ref polylogue-013x

Co-Authored-By: Claude <[email protected]>
@gitguardian

gitguardian Bot commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
34761467 Triggered Generic High Entropy Secret 98a8114 tests/unit/storage/test_search_text_write_tool_coverage.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@coderabbitai

coderabbitai Bot commented Jul 12, 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: 32 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

Run ID: 9a20fc28-f23b-4aff-91a5-d2f9a93207a6

📥 Commits

Reviewing files that changed from the base of the PR and between d819423 and 98a8114.

📒 Files selected for processing (2)
  • docs/search.md
  • tests/unit/storage/test_search_text_write_tool_coverage.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/search-text-write-tool-coverage

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.

@Sinity
Sinity merged commit b14c3a4 into master Jul 12, 2026
2 of 13 checks passed
@Sinity
Sinity deleted the fix/search-text-write-tool-coverage branch July 12, 2026 05:28

@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: 98a81141d5

ℹ️ 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 docs/search.md Resolved
Sinity added a commit that referenced this pull request Jul 12, 2026
## Summary

Correct the search-text coverage guide after adversarial review:
Write/Edit bodies remain excluded from FTS, but the documented
action-evidence query route searches raw tool input without a direct-SQL
detour.

## Problem

Merged PR #2740 incorrectly stated that no query-DSL field could search
Write/Edit bodies. Its claimed DDL-to-doc and workaround tests checked
independent fragments rather than the documented matrix and fenced SQL
themselves.

## Solution

- Document action text predicates as the unindexed, portable route for
Write/Edit body lookup; retain the JSON SQL probe for direct index
inspection.
- Clarify the FTS versus action-evidence boundary and fully qualify the
Edit input keys.
- Add a documentation-derived contract test that compares every matrix
entry with the live generated column, compiles and executes the
documented action predicates against real Write/Edit blocks, and
executes the fenced SQL from the docs.

## Verification

- env POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest nix
develop --command devtools test
tests/unit/pipeline/test_search_text_coverage_contract.py — 2 passed.
- nix develop --command devtools verify --quick — passed all format,
lint, mypy, render, topology, layering, schema, and policy checks.
- Pre-push quick gate — passed; its mypy phase was delayed by concurrent
fanout load but completed successfully.

## Anti-vacuity

The new test invokes the production query compiler and ArchiveStore
lowering path against stored Write/Edit tool_input. Removing tool_input
from action text lowering makes the DSL assertion fail. It also parses
and executes the SQL fence from docs, and derives every documented
Yes/No matrix value from the live search_text DDL, so changes to either
contract artifact fail the test.

## Adversarial review notes

Iteration 1 found two real gaps in the already-merged #2740 closure: the
hidden DSL route and a vacuous docs-to-DDL/workaround test. This PR
fixes both; no prior review comments apply to this branch.

## Acceptance criteria

- Satisfied: searchable-content matrix matches live DDL through a
documentation-derived test.
- Satisfied: Option B is explicit: Write/Edit bodies stay out of FTS and
have an action-evidence route plus a direct SQL inspection path.
- Not applicable: Option A size probe and index rebuild, because this PR
retains Option B.

Ref polylogue-013x

---------

Co-authored-by: Claude <[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.

  • 57.F111 / P2: fixed-already at the checked revision: docs/search.md:1133-1136 now explicitly documents the action text predicate over raw tool_input, including Write content and Edit old/new strings. The executable DSL examples at docs/search.md:1139-1140 precede the optional SQL alternative, so the workaround is no longer hidden.

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