You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Performance] Batch reauthorize persisted post-Ask evidence without N+1 queries #358
Reading a post with many persisted Ask exchanges currently reauthorizes each exchange serially. Correctness and fail-closed behavior are preserved, but database round-trips grow linearly with exchange count and can make the post detail visibly slower.
Current authority boundary
Keep current tenant ABAC, publication eligibility, and each exchange's persisted knowledge cutoff.
If any citation for an exchange is no longer visible, withhold that exchange exactly as today.
Do not reuse stale authorization or expose hidden citation labels, counts, project links, or prose.
Do not replace the canonical Project-history API or TEPP adapter.
Required implementation
Add a bounded repository function that accepts all persisted exchange citation sets and cutoffs for one post.
Validate citation UUIDs before SQL.
Fetch the authorized citation/project evidence in one bounded query or a fixed small number of queries.
Partition the result back to each exchange deterministically.
Preserve current response ordering and fail-closed removal semantics.
Add a maximum exchange/citation budget and explicit truncation or typed failure rather than an unbounded IN list.
Record query-count and latency evidence in docs/product-technical-gap-baseline.md.
TDD acceptance
1, 10, and maximum supported exchange histories produce identical authorized responses to the current implementation;
a hidden citation removes only the affected exchange and leaks no title, count, project key, or answer text;
mixed knowledge cutoffs cannot admit evidence newer than each exchange's own cutoff;
query count remains bounded independently of exchange count;
real PostgreSQL integration, tenant isolation, statement/branch coverage, docstrings, and full API regressions pass;
no feature or Buyer evidence surface is removed.
Origin
Tracked from the exact-head review of PR #342. The current implementation remains correct; this issue owns the bounded performance improvement so the security repair is not diluted by an unrelated query refactor.
Implementation exists in stacked PR #401 and was reconciled through #402 and #406, with the documented bounded-query and real-PostgreSQL evidence. Those merges target non-main stack branches; protected main exact head ef6f5a5 does not contain their merge commits. Keeping this issue open until the stack reaches protected main and the main-bound exact-head checks revalidate the acceptance contract.
Protected main at 7403a452 does not contain the project-history Ask reauthorization path that produced this N+1 issue: backend/app/ask_project_history.py, account/post Ask sessions, per-exchange knowledge cutoffs, and the serial reauthorization loop are absent. The earlier implementation exists only in non-default stacked merges #401/#402/#406 and cannot transfer protected delivery evidence. PR #631 records ADR 0136 as a broader missing current-main product contract and requires bounded batch reauthorization before that UI is introduced. Closing this obsolete symptom ticket prevents implementing an optimizer for an unshipped path; a current-main ADR 0136 slice must carry its own query-count and tenant-isolation acceptance.
Activity
seonghobae commentedon Aug 22, 2026
Implementation exists in stacked PR #401 and was reconciled through #402 and #406, with the documented bounded-query and real-PostgreSQL evidence. Those merges target non-main stack branches; protected main exact head ef6f5a5 does not contain their merge commits. Keeping this issue open until the stack reaches protected main and the main-bound exact-head checks revalidate the acceptance contract.
perf(ask): batch per-turn reauthorization instead of N+1 queries (#358)
seonghobae commentedon Aug 25, 2026
Protected
mainat7403a452does not contain the project-history Ask reauthorization path that produced this N+1 issue:backend/app/ask_project_history.py, account/post Ask sessions, per-exchange knowledge cutoffs, and the serial reauthorization loop are absent. The earlier implementation exists only in non-default stacked merges #401/#402/#406 and cannot transfer protected delivery evidence. PR #631 records ADR 0136 as a broader missing current-main product contract and requires bounded batch reauthorization before that UI is introduced. Closing this obsolete symptom ticket prevents implementing an optimizer for an unshipped path; a current-main ADR 0136 slice must carry its own query-count and tenant-isolation acceptance.