Skip to content

test(backend): anchor the belief-band test to the clock it is measured against - #13501

Closed
aryanorastar wants to merge 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/belief-band-test-clock
Closed

aryanorastar wants to merge 1 commit into
BasedHardware:mainfrom
aryanorastar:fix/belief-band-test-clock

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

test_memory_item_to_memorydb_attaches_belief_view_only_when_flag_on now anchors captured_at to the real clock instead of a fixed date.

Why

The test was a time bomb, and it went off at 2026-09-11 12:00:00 UTC.

It pinned captured_at to 2026-08-12T12:00Z − 30 days = 2026-07-13T12:00Z with half_life_days=30, then asserted the band reads fading. But the band is not computed against that pinned date — memory_item_to_memorydb calls public_belief_overlay(item, now=datetime.now(timezone.utc)) (canonical_memory_adapter.py:410) and takes no now a test can supply. So elapsed time grows every day the suite is not run:

captured_at   : 2026-07-13 12:00 UTC
half_life_days: 30
currency      : 0.5 ** (days_elapsed / 30)
fading needs  : currency >= 0.25   ->   days_elapsed <= 60
60 days after : 2026-09-11 12:00:00 UTC

At exactly two half-lives the currency is 0.25 and the band is still fading. One second later it is history, and the assertion fails — permanently, on every run from then on. Measured on this branch at 14:52 UTC today: 60.120 days elapsed, currency 0.249311, band history.

Nothing is wrong with the band logic or the read path. Both are correct; the test was measuring them against a clock it could not hold still.

Why 45 days

45 days is one and a half half-lives — currency 0.354, mid-band. 30 days would sit exactly on the current/fading boundary (currency 0.5, and current requires strictly greater), making the result depend on sub-second timing between constructing the fixture and reading the clock.

Verification

  • The full file passes: 11 passed, including the previously failing test.
  • Mutation-checked in both directions rather than trusting a green run: raising FADING_BAND_MIN to 0.4 (so 0.354 falls into history) fails the test; restoring it passes. The assertion still catches a real band regression.

Impact

This one test reddens Backend Unit Tests on every PR that merges current main — it is currently failing on #12409 (shard 3/4) and #11183 (shard 4/4), neither of which touches memory code.

Failure-Class: none

Review in cubic

…d against

The test pinned captured_at to 2026-07-13T12:00Z with a 30-day half-life and
asserted the band reads `fading`, but memory_item_to_memorydb computes the band
via public_belief_overlay(item, now=datetime.now(timezone.utc)) and takes no
`now` a test can pin. Elapsed time therefore grew every day the suite did not
run, and crossing two half-lives at 2026-09-11T12:00:00Z flipped the band to
`history` and failed the assertion for good.

Neither the band logic nor the read path is wrong. The test was measuring them
against a clock it could not hold still, so captured_at is now relative to that
same clock.

45 days rather than 30: one and a half half-lives puts currency at 0.354,
mid-band. 30 days lands exactly on the current/fading boundary, where `current`
requires strictly greater than 0.5, so the outcome would turn on sub-second
timing between building the fixture and reading the clock.

Mutation-checked: raising FADING_BAND_MIN to 0.4 fails the test, restoring it
passes, so the assertion still catches a real band regression.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for this — the diagnosis is excellent and the write-up is exactly the kind of analysis we like to see: the time bomb was real (the fixture pinned captured_at to 2026-07-13T12:00Z while public_belief_overlay measures the band against datetime.now(timezone.utc) with no injectable clock, so the fading assertion was guaranteed to flip to history at two half-lives), and the mutation check showing the assertion still catches real band regressions was a nice touch.

Unfortunately this landed independently while the PR was open: #13506 (merged as b5d425e, "test(backend): keep memory belief-view half-life fixture clock-relative") anchors the same test in backend/tests/unit/test_memories_archive_and_read_contracts.py to the wall clock. Because both changes rewrite the same fixture lines, this branch now conflicts with main, and re-submitting would just reproduce what's already landed — so I'm closing this as superseded rather than asking you to rebase over an identical fix.

For the record, your 45-day mid-band anchor (currency ~0.354, comfortably between the current and fading thresholds) is marginally more robust than the landed 30-day boundary anchor, but the difference isn't worth a conflict cycle. If you're looking for a follow-up, the same clock-anchoring audit would be worth running over the other belief tests (e.g. backend/tests/unit/test_belief_model.py, test_belief_evidence.py, test_belief_backfill.py) — if any fixed calendar dates remain there, a PR pointing that out would be welcome.

Closing with full credit for a correct root-cause analysis. Thanks again!


Automated maintainer feedback on behalf of the Omi maintainers.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added superseded Superseded by a newer change on main backend Backend Task (python) labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hey @aryanorastar 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) superseded Superseded by a newer change on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants