Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(api,cli): report search truncation on create and push - #331

Open
Anga205 wants to merge 1 commit into
razorpay:masterfrom
Anga205:Anga205/search-truncated-flag
Open

Anga205 wants to merge 1 commit into
razorpay:masterfrom
Anga205:Anga205/search-truncated-flag

Conversation

@Anga205

@Anga205 Anga205 commented Dec 3, 2026

Copy link
Copy Markdown

What and why

Refs #201 this is the short-term fix discussed there, (not the chunked-indexing redesign)

A version's search_text is capped at 256 KiB (maxSearchTextBytes in api/internal/repo/postgres/search_text.go). Text past the cut is silently unsearchable: create/push report success, and an agent using the CLI or MCP has no way to know. The reporter supplied the SQL reproduction; the word-boundary cut and the help-text documentation were already merged upstream in 04b721a. The remaining work, as narrowed in the issue discussion, was to surface the cut to the author.

This change:

  1. searchTextTruncated returns the text and a truncated flag from the same extraction pass, so the flag cannot drift from what is indexed. Exactly at the limit, it scans the remainder for a visible word, ignoring hidden elements.
  2. repo.Version.SearchTruncated carries the flag from document create and from the live-version seal path (version push).
  3. Create and version responses expose search_truncated (omitempty); Swagger docs regenerated.
  4. CLI prints a one-line warning on docs create and docs push and keeps the field under --json. MCP inherits the field through the existing response payload.
  5. skills/slashdocs/SKILL.md documents the warning and the JSON field.

Scope: what this does NOT fix

  • The PostgreSQL 16,383-position cap for quoted phrases and the 256-positions-per-lexeme rule are still silent. Fixing them needs chunked indexing (new table + migration), which the issue discussion explicitly left as a bigger design call. Both limits were already documented in skills/slashdocs/SKILL.md before this PR.
  • The flag is computed and returned at create/push time; it is not persisted, so a client that loses the response cannot query it later.
  • No browser-UI warning for live editor sessions. The seal path computes the flag so the API can carry it, but the web app does not surface one yet.
  • search_truncated is omitempty: absent means false.
  • MCP tool descriptions were not updated to advertise the field; it is present in the JSON result.

Attribution

  • Issue Content search silently fails past ~16k words (exact phrases) and 256 KiB (any word) #201 by @sairam0424 contains the reproduction and the suggested short-term fix (search_truncated hint + CLI warning).
  • The Dec 2 comment by @RealAdhi narrowed the remaining work to exactly this shape and explicitly deferred chunked indexing. The field name and scope follow that suggestion verbatim.
  • The word-boundary cut and help docs were already merged upstream in 04b721a; this PR builds on them and does not re-implement them.
  • Response-field and CLI-warning patterns copy the existing default_grant /
    permission_warning and note handling. Tests follow the structure of
    existing tests in the same files.

How it was tested

  • go build ./..., go vet, golangci-lint run on changed packages: clean.
  • go test -p 1 ./... -count=1: all 22 packages pass. Serial invocation avoids the testcontainers port exhaustion tracked in Tests leave a PostgreSQL container running per package when the testcontainers reaper does not run #304.
  • New tests: TestSearchTextTruncated, TestCreateDocumentReportsSearchTruncation, TestCreateVersionReportsSearchTruncation, TestCreateWarnsWhenSearchIsTruncated, TestPushWarnsWhenSearchIsTruncated.
  • make swagger produces no diff; gofmt -l and prettier --check clean.
  • npm test: 1323/1325 pass. The two failures are in auth-state.test.tsx and format-date.test.ts, both untouched by this PR and failing on master too (timing/locale flakes).

Checklist

  • Branch from current master, single focused commit
  • Tests added for repo, server and CLI paths
  • Docs updated (SKILL.md + generated Swagger)
  • make format, make test, make lint run locally
  • No version/tag changes

@Anga205
Anga205 force-pushed the Anga205/search-truncated-flag branch from 155b9c4 to 6856285 Compare December 4, 2026 16:39
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