Skip to content

fix(posthog-ai): convert remaining schema references to generated column tables - #84280

Merged
trunk-io[bot] merged 8 commits into
masterfrom
posthog/generate-schema-docs-sweep
Sep 2, 2026
Merged

trunk-io[bot] merged 8 commits into
masterfrom
posthog/generate-schema-docs-sweep

Conversation

@sampennington

Copy link
Copy Markdown
Contributor

Problem

Stacked on #84279, which added the schema_columns() generator and converted one reference. The remaining models-* references still hand-write their column tables, so they keep advertising Django-model columns the executor rejects — the same failure #84279 fixed for insights, still live for surveys, actions, flags, recordings, and the rest.

Changes

  • Converts the remaining 24 models-* references to .md.j2 templates rendering their column tables via schema_columns() — every hunk is the same shape: delete a stale hand-written table, add one template call. Prose, notes, and the two-column nested-JSON tables are preserved; only four-column schema tables are generated.
  • Fixes two SQL examples projecting columns HogQL does not expose (system.surveys.description/archived, system.early_access_features.deleted).
  • Adds a regression test that renders every models-*.md.j2 template (failing if a referenced table leaves the catalog) and rejects any hand-written four-column schema row — the pattern that caused the drift.

How did you test this code?

  • The new render test passes locally (no database needed): all 45 referenced tables resolve in the catalog and render, and no template hand-writes a schema row.
  • Generated tables cannot disagree with the executor by construction — both read the same collector.
  • ruff check/format clean.
  • Not checked: a full build_skills run against a live stack (CI's skill-build job covers it).

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude (PostHog Desktop cloud task), directed to split PR #84081 into a reviewable stack; this is the mechanical bulk layer, kept separate so the generator in #84279 can be reviewed on its own. Column-description corrections these docs now inherit are in #84278. No customer data or session material reached the diff or this description.


Created with PostHog Desktop

@sampennington sampennington self-assigned this Aug 18, 2026
@sampennington
sampennington force-pushed the posthog/generate-schema-docs-from-catalog branch from c58ea51 to 6e3ccd3 Compare August 19, 2026 09:54
@sampennington
sampennington force-pushed the posthog/generate-schema-docs-sweep branch from f5477f7 to 62b7ac4 Compare August 19, 2026 09:54
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Playwright — all passed

All tests passed.

View test results →

✅ Backend coverage — all changed backend lines covered

🧪 Backend test coverage

Patch coverage — changed backend lines (products + core): ████████████████████ 100.0% (6 / 6)

All changed backend lines are covered ✅

Per-product line coverage (touched products)
Product Coverage Lines
platform_features ██░░░░░░░░░░░░░░░░░░ 12.1% 7 / 58
warehouse_sources_queue ██████░░░░░░░░░░░░░░ 29.4% 91 / 309
demo ███████████░░░░░░░░░ 56.9% 1,518 / 2,666
autoresearch ████████████░░░░░░░░ 62.5% 5 / 8
data_tools █████████████░░░░░░░ 66.2% 90 / 136
ai_gateway ███████████████░░░░░ 75.0% 9 / 12
batch_exports ████████████████░░░░ 79.8% 19,692 / 24,683
apm █████████████████░░░ 83.3% 1,234 / 1,481
signals █████████████████░░░ 84.6% 33,343 / 39,421
cdp █████████████████░░░ 85.2% 4,310 / 5,056
wizard █████████████████░░░ 86.7% 1,090 / 1,257
data_modeling █████████████████░░░ 86.7% 9,654 / 11,133
notebooks ██████████████████░░ 87.7% 11,209 / 12,777
product_tours ██████████████████░░ 87.9% 1,303 / 1,482
data_warehouse ██████████████████░░ 88.6% 12,793 / 14,436
engineering_analytics ██████████████████░░ 89.0% 7,707 / 8,656
cohorts ██████████████████░░ 89.1% 7,369 / 8,275
business_knowledge ██████████████████░░ 89.1% 4,440 / 4,984
dashboards ██████████████████░░ 89.6% 6,811 / 7,602
tasks ██████████████████░░ 90.0% 63,220 / 70,248
streamlit_apps ██████████████████░░ 90.2% 2,500 / 2,773
exports ██████████████████░░ 90.5% 8,717 / 9,637
links ██████████████████░░ 90.6% 183 / 202
managed_warehouse ██████████████████░░ 90.8% 8,734 / 9,618
visual_review ██████████████████░░ 90.9% 6,880 / 7,567
alerts ██████████████████░░ 91.0% 5,208 / 5,722
conversations ██████████████████░░ 91.0% 20,916 / 22,978
canvas ██████████████████░░ 91.0% 4,919 / 5,403
mcp_analytics ██████████████████░░ 91.2% 4,374 / 4,795
error_tracking ██████████████████░░ 91.5% 12,679 / 13,860
notifications ██████████████████░░ 92.2% 1,101 / 1,194
early_access_features ███████████████████░ 92.5% 1,323 / 1,430
managed_migrations ███████████████████░ 92.6% 1,556 / 1,681
slack_app ███████████████████░ 92.8% 12,354 / 13,315
stamphog ███████████████████░ 92.9% 5,775 / 6,216
web_analytics ███████████████████░ 93.1% 18,601 / 19,970
surveys ███████████████████░ 93.2% 6,043 / 6,486
context_layer ███████████████████░ 93.3% 2,594 / 2,779
reminders ███████████████████░ 93.4% 468 / 501
mcp_store ███████████████████░ 93.5% 7,639 / 8,174
posthog_ai ███████████████████░ 93.5% 1,372 / 1,468
marketing_analytics ███████████████████░ 93.5% 17,326 / 18,530
ai_observability ███████████████████░ 93.7% 17,988 / 19,194
approvals ███████████████████░ 93.7% 3,492 / 3,725
billing_alerts ███████████████████░ 93.9% 2,078 / 2,212
workflows ███████████████████░ 94.1% 11,045 / 11,742
legal_documents ███████████████████░ 94.1% 1,970 / 2,093
review_hog ███████████████████░ 94.3% 9,982 / 10,583
endpoints ███████████████████░ 94.4% 8,866 / 9,396
tracing ███████████████████░ 94.4% 2,683 / 2,842
access_control ███████████████████░ 94.9% 5,828 / 6,139
customer_analytics ███████████████████░ 95.0% 17,775 / 18,713
annotations ███████████████████░ 95.2% 795 / 835
product_analytics ███████████████████░ 95.3% 19,295 / 20,255
replay_vision ███████████████████░ 95.4% 26,087 / 27,356
experiments ███████████████████░ 95.5% 29,271 / 30,660
actions ███████████████████░ 95.5% 706 / 739
skills ███████████████████░ 95.6% 5,403 / 5,651
messaging ███████████████████░ 95.8% 3,646 / 3,805
logs ███████████████████░ 95.9% 13,523 / 14,105
growth ███████████████████░ 95.9% 7,644 / 7,969
feature_flags ███████████████████░ 96.1% 19,596 / 20,392
revenue_analytics ███████████████████░ 96.3% 1,841 / 1,911
user_interviews ███████████████████░ 96.5% 2,639 / 2,735
warehouse_sources ███████████████████░ 97.2% 406,097 / 417,906
data_quality ███████████████████░ 97.5% 4,103 / 4,209
analytics_platform ████████████████████ 98.1% 2,286 / 2,330
metrics ████████████████████ 98.4% 3,528 / 3,587
data_catalog ████████████████████ 98.4% 3,235 / 3,289
pulse ████████████████████ 98.4% 2,017 / 2,049
live_debugger ████████████████████ 99.2% 613 / 618
field_notes ████████████████████ 99.4% 158 / 159

Report-only. Patch coverage = changed backend lines covered vs origin/master. Sorted lowest first.
Known gaps: lines covered only by Temporal tests show as uncovered; core line numbers may drift if master changed the same file.

@sampennington
sampennington force-pushed the posthog/generate-schema-docs-from-catalog branch from 6e3ccd3 to b1f12f7 Compare August 27, 2026 10:35
@sampennington
sampennington force-pushed the posthog/generate-schema-docs-sweep branch from 62b7ac4 to ca29a7c Compare August 27, 2026 10:38
@trunk-io

trunk-io Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@sampennington
sampennington force-pushed the posthog/generate-schema-docs-sweep branch from ca29a7c to 46b4b6b Compare September 1, 2026 13:54
@sampennington
sampennington marked this pull request as ready for review September 1, 2026 13:59
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 1, 2026 13:59
@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
products/posthog_ai/skills/querying-posthog-data/references/models-surveys.md.j2:10
**Unsupported survey columns remain**

When the skill uses this reference, the hand-written `response_sampling_*` row advertises fields absent from the `system.surveys` HogQL catalog, causing generated queries that use these fields to be rejected. The new regression test also misses this row because its column-name pattern excludes `*`.

```suggestion

```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(posthog-ai): correct reference prose..." | Re-trigger Greptile

@sampennington sampennington left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 sp-ship · 🚫 Blockers

Generated schema content regresses queryable survey, recording, and usage-metric contracts. Correct the catalog metadata and remove the remaining wildcard row before this sweep ships.

@skoob13 skoob13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you for doing it!

Base automatically changed from posthog/generate-schema-docs-from-catalog to master September 1, 2026 16:37
@trunk-io

trunk-io Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

…umn tables

Converts the remaining models-* references to .md.j2 templates rendering
their column tables via schema_columns(), and fixes SQL examples that
project columns HogQL does not expose (system.surveys.description/archived,
system.early_access_features.deleted).

Adds a regression test that renders every models-*.md.j2 template (failing
the build if a referenced table leaves the catalog) and rejects any
hand-written four-column schema row, which is how the drift arose. The
two-column field|description tables describing nested JSON stay hand-written
deliberately - they document structure inside JSON columns, which the
catalog cannot know.

Prose sections (Important Notes, JSON shapes, query patterns) are preserved
unchanged; only the four-column schema tables are generated.

Generated-By: PostHog Desktop
Task-Id: 6bef1783-fd5e-4096-8828-1fd26ec9e69e
Four notes verified wrong against the models during the schema audit:

- session recordings: `deleted IS NOT TRUE` is a Postgres-boolean idiom;
  the HogQL column is an integer 0/1 expression, NULL for older rows.
- playlists: `deleted = false` likewise; the column is 0/1.
- customer analytics: the role keys on accounts.properties are retired
  leftovers (RETIRED_ROLE_KEYS), not a mirror of active assignments;
  dropped the example querying them.
- support tickets: assignments are queryable via support_tickets.assignee,
  contrary to the "not exposed" note.

Generated-By: PostHog Desktop
Task-Id: 6bef1783-fd5e-4096-8828-1fd26ec9e69e
Generated-By: PostHog Desktop
Task-Id: 545b83da-fd0e-4270-91a9-0faef0d62eaf
@sampennington
sampennington force-pushed the posthog/generate-schema-docs-sweep branch from f139867 to 89d9b2b Compare September 2, 2026 06:08
Apply the formatter's required line wrapping after the conflict resolution.

Generated-By: PostHog Desktop
Task-Id: 2adecc1d-c349-45a0-9a14-9ff117904ee4
Set the partial refresh Delta commit timestamp after the completed snapshot so time-travel assertions do not depend on write timing.

Generated-By: PostHog Desktop
Task-Id: 43fbaa16-eb37-417f-b013-1ea5d07235fe
@trunk-io
trunk-io Bot merged commit f0b45c9 into master Sep 2, 2026
245 checks passed
@trunk-io
trunk-io Bot deleted the posthog/generate-schema-docs-sweep branch September 2, 2026 10:31
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-02 10:52 UTC Run
prod-us ✅ Deployed 2026-09-03 08:35 UTC Run
prod-eu ✅ Deployed 2026-09-03 08:36 UTC Run

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.

2 participants