Repository navigation
perf(experience): reuse FTS projection admission and narrow recurrence reads - #2846
Conversation
hidb4ai
left a comment
There was a problem hiding this comment.
Validation note: the current harness-validation / Acceptance (sqlite) check and aggregate CI result are failing. The uploaded acceptance reports identify AgentSetupTimeoutError: Agent setup timed out after 360.0 seconds, before the business scenarios ran; this is not evidence of a regression in the changed search or recurrence code. Please resolve the harness setup failure and rerun acceptance before merging. See https://github.com/oceanbase/powercontext/actions/runs/45776011633/job/139767673418.
No reproducible correctness defect was found in the reviewed changes. There are no schema changes or new HTTP/MCP endpoints, but the exported RecurrenceRepository gains the callable verdicts_for_target interface.
Brings in oceanbase#2859/oceanbase#2846 and the Harbor shared-download CI fix (oceanbase#2827) so the next acceptance run exercises the updated install path. Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
Which issue or RFC does this PR close?
N/A (performance improvement on Experience search and recurrence read paths; no schema or public API changes).
Rationale for this change
Two read-heavy paths in the built-in Experience pipeline performed avoidable repeated work:
search_approved_artifact_rows/experience_search_hits): Even after the database query had already checked lexical admission against the storedsearchable_textprojection,experience_search_hitsre-ranadmits_fts_text(including full text analysis/tokenization) on every returned Experience row during decoding.RelationalRecurrenceLedger/RecurrenceRepository):record_windoweagerly loaded all active Experience heads for a scope whenever any unlinkedTaskOutcomeappeared, even if the outcome had no unrecorded failure items with available evidence (e.g., passing outcomes or replayed windows)._revision_proposalscanned and decoded everypc_recurrence_observationrow in the scope in Python to filter one(artifact_ref, cue_key)verdict bucket, and re-fetched the target artifact revision viaartifacts.latestafter already loading it viaartifacts.get.What changes are included in this PR?
src/powercontext/builtin/persistence/experience_index.py):projection_admittedcolumn to the bounded finalSELECTinsearch_approved_artifact_rows(with the SQLiterejectedsentinelUNION ALLcolumn list updated to match):family == "experience"), setsprojection_admittedviaEXISTSverifyingpc_artifact_heads.searchable_text = pc_artifact_fts.searchable_textfor the exact(scope_id, family, artifact_id, revision)so drifted FTS rows still fall back to full decoding validation.family == "experience"), setsprojection_admitted = 1whenrequired > 1(both fast probe and full-query fallback) and evaluates exactoceanbase_fts_coverage_sql >= :requiredon the bounded candidate rows whenrequired == 1.projection_admitted = 0) unchanged.experience_search_hitsto skip redundantadmits_fts_text(...)re-analysis whenrow.get("projection_admitted")is truthy.src/powercontext/builtin/persistence/recurrence.py,src/powercontext/builtin/runtime/recurrence.py):RecurrenceRepository.verdicts_for_target, which filters one(artifact_ref, signature_key)bucket using existing_bucket_conditions(revision index + signature hash + plaintext) andevent != 'selected', ordered by(task_outcome_position, observation_id).RelationalRecurrenceLedger.record_windowto return early when noTaskOutcomeis present and lazily loadscope_heads()at most once per window only when an unlinked outcome actually reaches an unrecorded failure item with available evidence._revision_proposalto checkrepair_surfacebefore callingartifacts.latest(..., known=target)and to read bucket verdicts throughverdicts_for_targetinstead of scanning all scope observations.release/upgrade-support.json):schema_review.persistence_sha256and appended the read-only query rationale. No database schema, table layout, index, migration resource, frozen revision checksum, or persisted encoding is changed.tests/builtin/persistence/test_experience_index.py: verifies drifted SQLitepc_artifact_ftsrows cannot bypass lexical admission.tests/builtin/persistence/test_recurrence_repository.py: coversverdicts_for_targetbucket filtering,selectedexclusion, journal ordering, and unnormalized key rejection.tests/builtin/runtime/test_recurrence_ledger.py: verifies passing unlinked windows and replayed windows skippc_artifact_heads/pc_artifactsreads.Are there any user-facing changes?
No user-facing API, configuration, documentation, or persistence format changes. Existing search admission semantics and recurrence ledger behavior are preserved.
How was this change tested?
ruff check,ruff format --check,ty check) passed on all modified files.180 passed, 1 skipped.origin/masterb0f5eadeavs this PR078f7c2d8, 2 interleaved rounds):POST /v1/scopes/{scope_id}/artifacts/experience/search(40 bilingual Experiences,limit=8):71.2 ms -> 22.7 ms(-68.1%)76.8 ms -> 23.7 ms(-69.1%)RecurrenceLedger.record_window(150 active Experience heads, 600 historical observations):25.1 ms -> 1.58 ms(-93.7%, SQL statements5 -> 0)54.9 ms -> 28.1 ms(-48.9%, SQL statements21 -> 16)83.8 ms -> 53.9 ms(-35.8%; mean99.9 ms -> 56.8 ms,-43.1%)AI usage statement
AI coding assistant (Antigravity / Gemini) was used to help review the diff, refine the SQL/runtime changes, add targeted regression tests, and run local SQLite benchmarks.