Repository navigation
feat(flags): read flag last_called_at for data freshness - #110143
Conversation
|
😎 Merged successfully - details. |
🤖 CI report
|
| File | Comment lines | Added lines |
|---|---|---|
products/feature_flags/backend/data_freshness.py |
3 | 16 |
posthog/test/test_data_freshness.py |
2 | 95 |
posthog/data_freshness.py |
1 | 13 |
This check does not block merging. It updates on every push and clears when the share drops.
|
[Medium risk] Adds a data freshness probe for feature flags. The PR appears safe to merge based on the reviewed changes. Reviews (2) · Last reviewed commit: "chore(flags): simplify review fixes" |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The probe misses project-root flag timestamps when reporting freshness for child environments.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds feature-flag usage timestamps from PostgreSQL to project data-freshness calculations.
Changes:
- Adds a
last_called_atfreshness probe. - Tests fallback, deletion, lookback, and tenant isolation behavior.
| File | Description |
|---|---|
products/feature_flags/backend/data_freshness.py |
Adds the PostgreSQL freshness probe. |
posthog/test/test_data_freshness.py |
Adds database-backed freshness cases. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: PostHog/posthog/.coderabbit.yaml Review profile: QUIET Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe feature-flag freshness source uses flag call timestamps, including timestamps from soft-deleted flags, to report each team’s latest call within the probe window. Tests cover event-definition timestamps, calls outside the window, and results for another team. The shared timestamp helper also serves warehouse sync freshness. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Organizations whose flag calls exist only in Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Approved.
Contained, read-only freshness probe with a timeout and DB-backed tests, and no risky territory. The open Copilot note about child environments only means a missing "has data" signal for them. The event-definition path still applies, so it can be fixed forward.
- Author wrote 0% of the modified lines and has 64 merged PRs in these paths (familiarity MODERATE).
- 👍 on the PR from greptile-apps[bot].
- Copilot noted that flag timestamps are stored under project-root teams, so a child environment team may not pick up its project's last_called_at. This is a minor coverage gap; the event-definition path still applies.
- The PR note says FLAG_EVALUATIONS_ONLY organizations only benefit once the separate last_called_at sync change ships.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 58L, 3F substantive, 163L/4F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1c-medium (163L, 4F, two-areas, feat) |
| stamphog 2.3.1 | .stamphog/policy.yml @ 145c7c0 · reviewed head 145c7c0 |
|
/trunk merge |


Problem
FLAG_EVALUATIONS_ONLYflag evaluations mode will show "No data" for feature flags in the project switcher and on the Members settings page.$feature_flag_calledevent definition, which ingestion builds fromevents.$feature_flag_calledonly inflag_evaluations, so they never get that event definition.Changes
FeatureFlag.last_called_atper team, from Postgres.posthog/data_freshness.pyis unchanged.FLAG_EVALUATIONS_ONLYones. Organizations onEVENTSget today's answer or a more recent one.$feature_flag_called.latest_per_teaminposthog/data_freshness.py. The feature flags and data warehouse probes both call it, and the warehouse probe's result is unchanged.Note
This depends on a separate change that makes the
last_called_atsync readflag_evaluationson Cloud. Today the sync readseventsfor every organization, soFLAG_EVALUATIONS_ONLYorganizations get the fix only once that change ships.How did you test this code?
Test rationale: Added
TestFeatureFlagsFreshness.test_flag_callsinposthog/test/test_data_freshness.py. No existing test ran a probe through_compute. The existing cases cover only the verdict math inderive_freshness. The new test needs the database, because the probe reads Postgres. Its four cases:last_called_atwith no event definition reports a feature flags source. This catches a missing probe.Each case also checks that another team's more recent call does not leak into this team's result. Breaking the event name claim and the soft-delete choice on purpose made each fail its own case.
Not checked: behavior against a real
FLAG_EVALUATIONS_ONLYorganization, since the sync change this depends on has not shipped.Release status
Automatic notifications
Docs update
None.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Opus 5.5 (claude-opus-5-5)
/go,/writing-tests,/simplify,/comment-cleanup,/writing-pr-descriptions,/reviewing-with-coderabbit.--deep, because the probe reads tenant-scoped rows on an interactive path. It reported no findings.latest_per_teamhelper came from a review finding that both probes repeated one query. The data warehouse probe has no test of its own, so it was run once against a local database after the switch.https://claude.ai/code/session_013LLQ98Y24FQeBppDpnBz94