feat(subscriptions): ground AI reports in saved context - #91787
Draft
vdekrijger wants to merge 13 commits into
Draft
feat(subscriptions): ground AI reports in saved context#91787vdekrijger wants to merge 13 commits into
vdekrijger wants to merge 13 commits into
Conversation
This was referenced Aug 31, 2026
Contributor
🤖 CI report
|
vdekrijger
force-pushed
the
codex/ai-subscription-contexts-stack-v1
branch
from
August 31, 2026 16:19
eb7358a to
275ce18
Compare
vdekrijger
force-pushed
the
codex/ai-subscription-context-execution-v1
branch
from
August 31, 2026 16:19
78016f1 to
9a6188d
Compare
vdekrijger
force-pushed
the
codex/ai-subscription-context-execution-v1
branch
2 times, most recently
from
September 1, 2026 13:01
97058bc to
8a32ee0
Compare
Contributor
🦔 PostHog Review reviewed this pull requestFound 2 must fix, 6 should fix, 3 consider. Published 11 findings (view the review). Resolved comments: 2 already settled, 2 left for you |
Contributor
|
PostHog Review alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏 |
vdekrijger
force-pushed
the
codex/ai-subscription-context-execution-v1
branch
from
September 8, 2026 16:47
8a32ee0 to
8730b54
Compare
created_by is nullable, so select_related() joins it as a LEFT OUTER JOIN and
PostgreSQL rejects an unscoped FOR UPDATE that reaches it. Every AI subscription
delivery failed with NotSupportedError before report generation started.
Lock only the subscription row with of=("self",), matching the existing pattern
in the recording rasterizer. Add a real-database test for the resolver, which
the rest of the delivery suite mocks out.
Generated-By: PostHog Desktop
Task-Id: 11780ac9-ccc8-44fc-91d2-32b7b582a523
The last-delivery cutoff lookup swallows database errors and degrades to the cadence window. It now runs inside the resolver's transaction, where an un-rolled-back statement error aborts every later query in the block — including the creator's access check — so the delivery failed instead of falling back. Read the row inside a savepoint so the error rolls back to it and the caller's transaction stays usable. Add a test that drives a real statement error through the lookup and asserts the resolver still completes. Generated-By: PostHog Desktop Task-Id: 11780ac9-ccc8-44fc-91d2-32b7b582a523
A dashboard whose tiles all failed reported "failed", and one truncated tile made the whole dashboard "truncated", but a mix of succeeded and failed tiles fell through to "success". The degradation rollup reads only the dashboard-level status, so losing most of a dashboard's evidence to query timeouts left the report tagged healthy. Treat any tile short of a clean success as incomplete evidence, which is what the dashboard-level "truncated" already reports for tiles dropped to fit the character budget. All-failed still reports "failed". Generated-By: PostHog Desktop Task-Id: 11780ac9-ccc8-44fc-91d2-32b7b582a523
The sanitizer cuts content to the character budget with no marker and returns a plain string, so the cut was invisible: the status check only looked for the formatter's per-cell marker, and nothing downstream could still detect it. A single oversized standalone insight was stored with status "success" while its table reached the model stopping mid-row. Sanitize uncapped, then bound the content here so an over-budget result carries the truncation marker and the truncated status. Generated-By: PostHog Desktop Task-Id: 11780ac9-ccc8-44fc-91d2-32b7b582a523
The planner may answer with zero queries only when computed context already covers the prompt. That gate tested the context block for emptiness, but a failed context still fills the block with unavailability markers, so a report whose every context failed could ship with no query data at all while its synthesis input said no supplemental queries were needed. Thread the existing has_successful_evidence signal down to the gate so an empty plan is refused unless at least one context produced a result. Generated-By: PostHog Desktop Task-Id: 11780ac9-ccc8-44fc-91d2-32b7b582a523
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AI reports cannot use saved dashboard or insight context yet, so the report harness still relies on prompt inference.
This execution layer depends on #91428. #91788 adds the UI.
Changes
Before:
flowchart LR Prompt[Prompt] --> Harness{{Report harness}} Harness --> Project[Project data] Project --> Delivery[Report delivery] class Prompt,Delivery phYellow class Harness phBlue class Project phGray classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff; classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000; classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;After:
flowchart LR Prompt[Prompt] --> Harness{{Report harness}} Context[Saved context] --> Resolve[Bounded query execution] Resolve --> Harness Harness --> Delivery[Report delivery] class Prompt,Delivery phYellow class Harness phBlue class Context,Resolve phGray classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff; classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000; classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;How did you test this code?
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
No public docs update. The feature remains unavailable until the final stack layer enables its UI.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
/writing-dataclasses,/writing-tests,/qa-team,/running-ci-preflight,/writing-pr-descriptions, and/stacking-prs.