Repository navigation
design: D164 batched converging profile refresh and indexed neighborhood gather - #690
Conversation
…nd analysis Bound converging profile refresh and neighborhood clustering below the 1,800 s hosted task ceiling across any corpus size: - chunk EntityProfileRefresher.refresh_many into 64-entity prepare->embed->commit cycles with batched locks and evidence loads; - rewrite _GATHER_NEIGHBORHOOD to use existing GIN trigram/phonetic indexes on aliases, restore matching partial salience indexes on observations/relations, and batch neighborhood attestation across up to 64 lemmas / 256 entities; - chain overflow slices through the existing unlaned PipelineStage.REFRESH_PROFILE stage with frozen target sets, O(1) continuation payloads, readiness tracking, and automatic D159 forget scrubbing. Co-Authored-By: Gemini 4 Neon <noreply@google.com>
…n SQL proofs Apply YAGNI revision to D164: - Remove ledger continuation (§3: REFRESH_PROFILE handler, slice budgets, inline slice 0, frozen entity_ids payloads, on_complete_follow_up, readiness/D159 changes, caller changes, mixed-version rollout) across all six corpus files; callers, stages, payloads, and component versions stay identical to main. - Retain §1 (64-entity chunk-committed refresh) and §2 (GIN-indexed batched gather, matching *_v2 salience indexes, batched attestation) and renumber sections cleanly. - Add §4 Residual bound (~1,000 queries, ~8-11 s local / ~17-21 s WAN on the measured shape; ~360k-400k touched-lemma 0%-changed / ~120k 100%-changed single-task ceiling at 1,800 s) with ledger continuation recorded as a follow-up outside D164 and its adoption trigger; keep the measured-shape query-count and 10 ms-RTT timing acceptance test. - Tighten SQL proofs with verbatim quotes of _GATHER_NEIGHBORHOOD, p9_16_0037 salience indexes, and _SELECT_SALIENT_FACTS, covering float4/float8/numeric threshold equivalence, pg_trgm.similarity_threshold session pinning, NULL/empty/short lemmas, and the phonetic branch. Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Design review, round 1 (independent Claude reviewer; GPT-6.2 sol unavailable until 2026-12-02)VERDICT: CHANGES_REQUESTED The gather row-set proof (float4 Blocking
Non-blocking
|
- Preserve fail-closed clearing in refresh_many by preparing all pending
targets in 64-entity batched transactions before any provider call
(continuing remaining chunks on lock timeout before raising), then
embedding, revalidating, and committing per dense 64-text batch with
byte-identical batches and call_key; update mid-embed and add
optimistic-exhaustion and lock-timeout tests.
- Replace FOR SHARE SKIP LOCKED in auto_merge_enabled=False with waiting
ORDER BY entity_id FOR UPDATE on surviving U_ok entities so concurrent
_BUMP_MENTION_COUNT row locks do not introduce new deferrals; defer only
on failed :obs: try-locks and add a test.
- Preserve _SELECT_ENTITY_LEMMAS SQL collation order, re-normalise each
row via normalized_lemma, return one NeighborhoodReport per input slot,
and add a non-ASCII test.
- Pass exact Python-built pre-sorted text[] lock keys ({dep}:obs:{member}
and {dep}:cluster:{lemma}) to batched advisory lock statements.
- Explicitly accept the chunk-wide 15 s statement_timeout on
_LOCK_KEYS_BATCH with D99/D157 57014 translation.
- Cite D153's resumable concurrent-index procedure for the hash-partitioned
observations/relations *_v2 salience indexes, drop the three reader-less
p9_16_0037 legacy indexes in the same migration after *_v2 validation
(D160/D161), state the linear single-task bound as an explicit non-goal,
and move ledger continuation to plan/proposals/.
- Tighten the frozen replay acceptance gate to name the Full-v45 conv-26
store + CI fixture, key recorded vectors by input_hash, and require >= 1
embed batch, >= 1 merge or split, >= 1 queued review, and >= 1 deferral.
- Drop extra 64-chunking of _load_salient_facts_many in clustering (one
call over deduplicated U_ok) and document/accept batch review-queue
rollback scope on exceptions (retries + uuid5 review IDs converge).
Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Design review, round 2 (independent Claude reviewer)VERDICT: CHANGES_REQUESTED. Eight of the nine round-1 findings are resolved (fail-closed prepare-all, waiting
|
- Correct observations and relations migration from partitioned to plain tables (pg_class.relkind='r'; p0_02_0004:171-205,290-318, verified in p9_46_0067 storage inventory): build the three *_v2 salience indexes via plain CREATE INDEX CONCURRENTLY inside autocommit_block() with --sql refusal, D161 lock_timeout + bounded 55P03 retry, exact definition verification, invalid own-named rebuild via DROP INDEX CONCURRENTLY, and foreign name-collision refusal; drop legacy p9_16_0037 indexes via DROP INDEX CONCURRENTLY IF EXISTS (zero ACCESS EXCLUSIVE locks); remove partitioned wording across all corpus docs and add relkind='r', resume, and no-ACCESS-EXCLUSIVE acceptance checks. - Specify _commit_batch_if_current edge cases matching _commit_if_current (profile_refresher.py:196-224): skip rows already current at commit with updated=False, return written IDs via UPDATE ... RETURNING entity_id and raise RuntimeError on any mismatch, use RETURNING entity_id on _CLEAR_PROFILE_MANY for exact updated reporting, and add acceptance checks. - Sync modelled WAN time (~17-20 s, ~90-105x) and 0%-changed single-task lemma ceiling (~375,000-420,000) in plan/proposals/ledger_continued_profile_convergence.md with design.md. Co-Authored-By: Gemini 4 Neon <noreply@google.com>
…ted transactions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq
Design review, round 3 (independent Claude reviewer): APPROVEAll round-2 findings are resolved:
The one non-blocking nit is fixed in 91b307f. The online-migration test now uses short, individually committed reads and writes instead of a long-held GPT-6.2 sol max re-review is planned once the Codex usage limit resets (2026-12-02). The implementation PR follows this design. |
Why
Hosted ingestion of a 253-chunk document (302 claims) into a Project with 1,364 active entities stalled on
converging profile refresh (profile refresh + neighborhood re-clustering):
adjudicate_supersessionwas cut off at the 1,800 s Cloud Run / Cloud Tasks ceiling on all three attempts anddead-lettered. Run once next to the database it succeeded, but needed 893 s.
label_relationthat follows it uses the sameConvergingProfileRefresher.refresh_for_factsand also exceeded 1,800 s.
Measured on the live database host (read-only, local socket):
_GATHER_NEIGHBORHOODaliases; the trigram/phonetic GIN indexes are bypassed)_locked_profile_stateper entity_load_salient_facts_manyrefresh_manyalso prepares every target before it embeds or commits any, so a cut-off attempt keeps nothing.In this run no profile actually changed: all the time went to re-verifying current profiles.
What D164 decides (design only, no code)
A killed attempt keeps completed chunks; a retry makes no embedding calls for them. Fail-closed clearing is kept.
aliasesGIN indexes(row-set equivalence proven in the analysis). Partial salience indexes match
_SELECT_SALIENT_FACTSagain, addedonline. Each entity is attested once per batch instead of ~27 times, with the same lock order.
in the same lemma order. With auto-merge on, a batch stops at the first mutation and re-gathers. Acceptance
requires a frozen-store replay with zero diffs.
continuation of converging refresh is a recorded follow-up with explicit triggers, not built now (YAGNI).
Files:
plan/designs/bounded_profile_convergence_design.md,plan/analysis/bounded_profile_convergence_analysis.md,the D164 entry in
decisions.md, and reconciled pointers in the entity identity and registries designs and inplan/README.md.Process
(new stage handler, readiness and forget changes, five caller changes) as unneeded machinery.
independent Claude reviewer runs the loop now. A GPT-6.2 sol re-review is planned when available.
Contributor agreement
Signing on behalf of a legal entity (leave blank if accepting individually):
🤖 Generated with Claude Code
https://claude.ai/code/session_01VYytLf2PUQ2RVpEZYENzsq